diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..d48bed8d --- /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/com/pahimar/ee3/EquivalentExchange3.java b/src/main/java/com/pahimar/ee3/EquivalentExchange3.java index 4169c643..ff4f4f0f 100644 --- a/src/main/java/com/pahimar/ee3/EquivalentExchange3.java +++ b/src/main/java/com/pahimar/ee3/EquivalentExchange3.java @@ -1,5 +1,7 @@ package com.pahimar.ee3; +import java.io.File; + import com.pahimar.ee3.api.exchange.IEnergyValueRegistry; import com.pahimar.ee3.array.AlchemyArrayRegistry; import com.pahimar.ee3.blacklist.BlacklistRegistry; @@ -23,7 +25,6 @@ import com.pahimar.ee3.util.FluidHelper; import com.pahimar.ee3.util.LogHelper; import com.pahimar.ee3.util.SerializationHelper; import com.pahimar.ee3.util.TileEntityDataHelper; - import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; @@ -35,33 +36,37 @@ import cpw.mods.fml.common.registry.GameRegistry; import moze_intel.projecte.api.ProjectEAPI; import moze_intel.projecte.api.proxy.IEMCProxy; -import java.io.File; - -@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, certificateFingerprint = Reference.FINGERPRINT, version = Reference.MOD_VERSION, dependencies = Reference.DEPENDENCIES, guiFactory = Reference.GUI_FACTORY_CLASS) -public class EquivalentExchange3 -{ +@Mod( + modid = Reference.MOD_ID, + name = Reference.MOD_NAME, + certificateFingerprint = Reference.FINGERPRINT, + version = Reference.MOD_VERSION, + dependencies = Reference.DEPENDENCIES, + guiFactory = Reference.GUI_FACTORY_CLASS +) +public class EquivalentExchange3 { @Instance(Reference.MOD_ID) public static EquivalentExchange3 instance; - @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) + @SidedProxy( + clientSide = Reference.CLIENT_PROXY_CLASS, + serverSide = Reference.SERVER_PROXY_CLASS + ) public static IProxy proxy; public static IEnergyValueRegistry REGISTRY; @EventHandler public void invalidFingerprint(FMLFingerprintViolationEvent event) { - if (Reference.FINGERPRINT.equals("@FINGERPRINT@")) { LogHelper.info(Messages.NO_FINGERPRINT_MESSAGE); - } - else { + } else { LogHelper.warn(Messages.INVALID_FINGERPRINT_MESSAGE); } } @EventHandler public void onServerStarting(FMLServerStartingEvent event) { - Files.updateFileReferences(); SerializationHelper.initModDataDirectories(); @@ -70,7 +75,6 @@ public class EquivalentExchange3 @EventHandler public void preInit(FMLPreInitializationEvent event) { - if (Loader.isModLoaded("ProjectE")) { IEMCProxy proxy = ProjectEAPI.getEMCProxy(); REGISTRY = new EMCRegistry(proxy); @@ -99,7 +103,6 @@ public class EquivalentExchange3 @EventHandler public void init(FMLInitializationEvent event) { - // Register the GUI Handler NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); @@ -123,12 +126,15 @@ public class EquivalentExchange3 GameRegistry.registerFuelHandler(new FuelHandler()); // Register the Waila data provider - FMLInterModComms.sendMessage("Waila", "register", "com.pahimar.ee3.waila.WailaDataProvider.callbackRegister"); + FMLInterModComms.sendMessage( + "Waila", + "register", + "com.pahimar.ee3.waila.WailaDataProvider.callbackRegister" + ); } @EventHandler public void postInit(FMLPostInitializationEvent event) { - Abilities.init(); // Initialize our test files @@ -138,7 +144,6 @@ public class EquivalentExchange3 @EventHandler public void onServerStopping(FMLServerStoppingEvent event) { - WorldEventHandler.hasInitilialized = false; EnergyValueRegistry.INSTANCE.save(); PlayerKnowledgeRegistry.INSTANCE.saveAll(); @@ -147,7 +152,6 @@ public class EquivalentExchange3 @EventHandler public void handleMissingMappingEvent(FMLMissingMappingsEvent event) { - for (FMLMissingMappingsEvent.MissingMapping mapping : event.get()) { if (mapping.type == GameRegistry.Type.ITEM) { if (mapping.name.equals("EE3:alchemicalTome")) { @@ -157,18 +161,15 @@ public class EquivalentExchange3 } } - public IEnergyValueRegistry getEnergyValueRegistry() - { + public IEnergyValueRegistry getEnergyValueRegistry() { return REGISTRY; } - public RecipeRegistry getRecipeRegistry() - { + public RecipeRegistry getRecipeRegistry() { return RecipeRegistry.INSTANCE; } - public AludelRecipeManager getAludelRecipeManager() - { + public AludelRecipeManager getAludelRecipeManager() { return AludelRecipeManager.getInstance(); } @@ -176,8 +177,7 @@ public class EquivalentExchange3 return BlacklistRegistry.INSTANCE; } - public AlchemyArrayRegistry getAlchemyArrayRegistry() - { + public AlchemyArrayRegistry getAlchemyArrayRegistry() { return AlchemyArrayRegistry.getInstance(); } @@ -185,13 +185,11 @@ public class EquivalentExchange3 return PlayerKnowledgeRegistry.INSTANCE; } - public TileEntityDataHelper getTileEntityDataHelper() - { + public TileEntityDataHelper getTileEntityDataHelper() { return TileEntityDataHelper.getInstance(); } - public void runEnergyValueTestSuite(File file) - { + public void runEnergyValueTestSuite(File file) { runEnergyValueTestSuite(file, false); } diff --git a/src/main/java/com/pahimar/ee3/api/array/AlchemyArray.java b/src/main/java/com/pahimar/ee3/api/array/AlchemyArray.java index e6e711bd..4d85778d 100644 --- a/src/main/java/com/pahimar/ee3/api/array/AlchemyArray.java +++ b/src/main/java/com/pahimar/ee3/api/array/AlchemyArray.java @@ -11,114 +11,88 @@ import net.minecraft.world.Explosion; import net.minecraft.world.World; // TODO Switch bare Strings to String constants -public class AlchemyArray implements Comparable -{ +public class AlchemyArray implements Comparable { private ResourceLocation texture; private String unlocalizedName; private String className; private int lightLevel; private int chalkPerBlockCost; - private AlchemyArray() - { + private AlchemyArray() {} - } - - public AlchemyArray(ResourceLocation texture, String unlocalizedName) - { + public AlchemyArray(ResourceLocation texture, String unlocalizedName) { this.texture = texture; this.unlocalizedName = unlocalizedName; this.chalkPerBlockCost = 1; this.lightLevel = 0; } - public ResourceLocation getTexture() - { + public ResourceLocation getTexture() { return texture; } - public void setTexture(ResourceLocation texture) - { + public void setTexture(ResourceLocation texture) { this.texture = texture; } - public String getUnlocalizedName() - { + public String getUnlocalizedName() { return unlocalizedName; } - public void setUnlocalizedName(String unlocalizedName) - { + public void setUnlocalizedName(String unlocalizedName) { this.unlocalizedName = unlocalizedName; } - public String getDisplayName() - { + public String getDisplayName() { return StatCollector.translateToLocal(unlocalizedName); } - public int getChalkCostPerBlock() - { + public int getChalkCostPerBlock() { return chalkPerBlockCost; } - public void setChalkPerBlockCost(int chalkPerBlockCost) - { + public void setChalkPerBlockCost(int chalkPerBlockCost) { this.chalkPerBlockCost = Math.abs(chalkPerBlockCost); } - public int getLightLevel() - { + public int getLightLevel() { return lightLevel; } - public String getClassName() - { + public String getClassName() { return className; } - public void readFromNBT(NBTTagCompound nbtTagCompound) - { - if (nbtTagCompound != null) - { - if (nbtTagCompound.hasKey("textureDomain") && nbtTagCompound.hasKey("texturePath")) - { - this.texture = new ResourceLocation(nbtTagCompound.getString("textureDomain"), nbtTagCompound.getString("texturePath")); - } - else - { + public void readFromNBT(NBTTagCompound nbtTagCompound) { + if (nbtTagCompound != null) { + if (nbtTagCompound.hasKey("textureDomain") + && nbtTagCompound.hasKey("texturePath")) { + this.texture = new ResourceLocation( + nbtTagCompound.getString("textureDomain"), + nbtTagCompound.getString("texturePath") + ); + } else { this.texture = new ResourceLocation(""); } - if (nbtTagCompound.hasKey("unlocalizedName")) - { + if (nbtTagCompound.hasKey("unlocalizedName")) { this.unlocalizedName = nbtTagCompound.getString("unlocalizedName"); - } - else - { + } else { this.unlocalizedName = ""; } - if (nbtTagCompound.hasKey("className")) - { + if (nbtTagCompound.hasKey("className")) { this.className = nbtTagCompound.getString("className"); - } - else - { + } else { this.className = ""; } - if (nbtTagCompound.hasKey("lightLevel")) - { + if (nbtTagCompound.hasKey("lightLevel")) { this.lightLevel = nbtTagCompound.getInteger("lightLevel"); - } - else - { + } else { this.lightLevel = 0; } - } - else - { + } else { this.texture = new ResourceLocation(""); this.unlocalizedName = ""; this.className = ""; @@ -126,8 +100,7 @@ public class AlchemyArray implements Comparable } } - public void writeToNBT(NBTTagCompound nbtTagCompound) - { + public void writeToNBT(NBTTagCompound nbtTagCompound) { nbtTagCompound.setString("textureDomain", texture.getResourceDomain()); nbtTagCompound.setString("texturePath", texture.getResourcePath()); nbtTagCompound.setString("unlocalizedName", unlocalizedName); @@ -135,58 +108,102 @@ public class AlchemyArray implements Comparable nbtTagCompound.setInteger("lightLevel", lightLevel); } - public static AlchemyArray readArrayFromNBT(NBTTagCompound nbtTagCompound) - { + public static AlchemyArray readArrayFromNBT(NBTTagCompound nbtTagCompound) { AlchemyArray alchemyArray = new AlchemyArray(); alchemyArray.readFromNBT(nbtTagCompound); return alchemyArray; } - public void onArrayPlacedBy(World world, int eventX, int eventY, int eventZ, int arrayX, int arrayY, int arrayZ, EntityLivingBase entityLiving, ItemStack itemStack) - { + public void onArrayPlacedBy( + World world, + int eventX, + int eventY, + int eventZ, + int arrayX, + int arrayY, + int arrayZ, + EntityLivingBase entityLiving, + ItemStack itemStack + ) {} - } + public void onArrayActivated( + World world, + int eventX, + int eventY, + int eventZ, + int arrayX, + int arrayY, + int arrayZ, + EntityPlayer entityPlayer, + int sideHit, + float hitX, + float hitY, + float hitZ + ) {} - public void onArrayActivated(World world, int eventX, int eventY, int eventZ, int arrayX, int arrayY, int arrayZ, EntityPlayer entityPlayer, int sideHit, float hitX, float hitY, float hitZ) - { + public void onArrayClicked( + World world, + int eventX, + int eventY, + int eventZ, + int arrayX, + int arrayY, + int arrayZ, + EntityPlayer entityPlayer + ) {} - } + public void onArrayDestroyedByExplosion( + World world, + int eventX, + int eventY, + int eventZ, + int arrayX, + int arrayY, + int arrayZ, + Explosion explosion + ) {} - public void onArrayClicked(World world, int eventX, int eventY, int eventZ, int arrayX, int arrayY, int arrayZ, EntityPlayer entityPlayer) - { + public void onArrayDestroyedByPlayer( + World world, + int eventX, + int eventY, + int eventZ, + int arrayX, + int arrayY, + int arrayZ, + int metaData + ) {} - } + public void onEntityCollidedWithArray( + World world, + int eventX, + int eventY, + int eventZ, + int arrayX, + int arrayY, + int arrayZ, + Entity entity + ) {} - public void onArrayDestroyedByExplosion(World world, int eventX, int eventY, int eventZ, int arrayX, int arrayY, int arrayZ, Explosion explosion) - { + public void onArrayFallenUpon( + World world, + int eventX, + int eventY, + int eventZ, + int arrayX, + int arrayY, + int arrayZ, + Entity entity, + float fallDistance + ) {} - } - - public void onArrayDestroyedByPlayer(World world, int eventX, int eventY, int eventZ, int arrayX, int arrayY, int arrayZ, int metaData) - { - - } - - public void onEntityCollidedWithArray(World world, int eventX, int eventY, int eventZ, int arrayX, int arrayY, int arrayZ, Entity entity) - { - - } - - public void onArrayFallenUpon(World world, int eventX, int eventY, int eventZ, int arrayX, int arrayY, int arrayZ, Entity entity, float fallDistance) - { - - } - - public void onUpdate(World world, int arrayX, int arrayY, int arrayZ, int tickCount) - { + public void onUpdate(World world, int arrayX, int arrayY, int arrayZ, int tickCount) { } @Override - public boolean equals(Object object) - { - if (object instanceof AlchemyArray) - { + public boolean equals(Object object) { + if (object instanceof AlchemyArray) { return this.compareTo((AlchemyArray) object) == 0; } @@ -194,22 +211,23 @@ public class AlchemyArray implements Comparable } @Override - public int compareTo(AlchemyArray alchemyArray) - { - if (this.texture.getResourceDomain().equalsIgnoreCase(alchemyArray.getTexture().getResourceDomain())) - { - if (this.texture.getResourcePath().equalsIgnoreCase(alchemyArray.getTexture().getResourcePath())) - { + public int compareTo(AlchemyArray alchemyArray) { + if (this.texture.getResourceDomain().equalsIgnoreCase( + alchemyArray.getTexture().getResourceDomain() + )) { + if (this.texture.getResourcePath().equalsIgnoreCase( + alchemyArray.getTexture().getResourcePath() + )) { return 0; + } else { + return this.texture.getResourcePath().compareToIgnoreCase( + alchemyArray.getTexture().getResourcePath() + ); } - else - { - return this.texture.getResourcePath().compareToIgnoreCase(alchemyArray.getTexture().getResourcePath()); - } - } - else - { - return this.texture.getResourceDomain().compareToIgnoreCase(alchemyArray.getTexture().getResourceDomain()); + } else { + return this.texture.getResourceDomain().compareToIgnoreCase( + alchemyArray.getTexture().getResourceDomain() + ); } } } diff --git a/src/main/java/com/pahimar/ee3/api/array/AlchemyArrayRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/array/AlchemyArrayRegistryProxy.java index adab61a2..3d2108ef 100644 --- a/src/main/java/com/pahimar/ee3/api/array/AlchemyArrayRegistryProxy.java +++ b/src/main/java/com/pahimar/ee3/api/array/AlchemyArrayRegistryProxy.java @@ -1,48 +1,41 @@ package com.pahimar.ee3.api.array; +import java.util.SortedSet; + import com.pahimar.ee3.EquivalentExchange3; import cpw.mods.fml.common.Mod; -import java.util.SortedSet; - -public class AlchemyArrayRegistryProxy -{ +public class AlchemyArrayRegistryProxy { @Mod.Instance("EE3") private static Object ee3Mod; - public static boolean registerAlchemyArray(AlchemyArray alchemyArray) - { + public static boolean registerAlchemyArray(AlchemyArray alchemyArray) { init(); - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getAlchemyArrayRegistry().registerAlchemyArray(alchemyArray); + if (ee3Mod != null) { + return EE3Wrapper.ee3mod.getAlchemyArrayRegistry().registerAlchemyArray( + alchemyArray + ); } return false; } - public static SortedSet getRegisteredAlchemyArrays() - { + public static SortedSet getRegisteredAlchemyArrays() { init(); - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getAlchemyArrayRegistry().getRegisteredAlchemyArrays(); + if (ee3Mod != null) { + return EE3Wrapper.ee3mod.getAlchemyArrayRegistry().getRegisteredAlchemyArrays( + ); } return null; } - private static class EE3Wrapper - { - private static EquivalentExchange3 ee3mod; - } + private static class EE3Wrapper { private static EquivalentExchange3 ee3mod; } - private static void init() - { - if (ee3Mod != null) - { + private static void init() { + if (ee3Mod != null) { EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod; } } diff --git a/src/main/java/com/pahimar/ee3/api/array/ICustomAlchemyArrayRender.java b/src/main/java/com/pahimar/ee3/api/array/ICustomAlchemyArrayRender.java index e5586ed9..aaf02dc8 100644 --- a/src/main/java/com/pahimar/ee3/api/array/ICustomAlchemyArrayRender.java +++ b/src/main/java/com/pahimar/ee3/api/array/ICustomAlchemyArrayRender.java @@ -5,8 +5,16 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public interface ICustomAlchemyArrayRender -{ +public interface ICustomAlchemyArrayRender { @SideOnly(Side.CLIENT) - public abstract void doCustomRendering(TileEntity tileEntity, double x, double y, double z, int arraySize, ForgeDirection orientation, ForgeDirection rotation, float tick); + public abstract void doCustomRendering( + TileEntity tileEntity, + double x, + double y, + double z, + int arraySize, + ForgeDirection orientation, + ForgeDirection rotation, + float tick + ); } diff --git a/src/main/java/com/pahimar/ee3/api/array/package-info.java b/src/main/java/com/pahimar/ee3/api/array/package-info.java index bbf831ae..56164148 100644 --- a/src/main/java/com/pahimar/ee3/api/array/package-info.java +++ b/src/main/java/com/pahimar/ee3/api/array/package-info.java @@ -1,3 +1,4 @@ -@API(owner = "EE3", apiVersion = "@API_VERSION@", provides = "EE3-API|array") package com.pahimar.ee3.api.array; +@API(owner = "EE3", apiVersion = "@API_VERSION@", provides = "EE3-API|array") +package com.pahimar.ee3.api.array; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/src/main/java/com/pahimar/ee3/api/blacklist/BlacklistRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/blacklist/BlacklistRegistryProxy.java index 4f58635b..775d4ad5 100644 --- a/src/main/java/com/pahimar/ee3/api/blacklist/BlacklistRegistryProxy.java +++ b/src/main/java/com/pahimar/ee3/api/blacklist/BlacklistRegistryProxy.java @@ -1,13 +1,12 @@ package com.pahimar.ee3.api.blacklist; +import java.util.Set; + import com.pahimar.ee3.EquivalentExchange3; import com.pahimar.ee3.exchange.WrappedStack; import cpw.mods.fml.common.Mod; -import java.util.Set; - public class BlacklistRegistryProxy { - /** * TODO Finis JavaDoc * @@ -33,14 +32,12 @@ public class BlacklistRegistryProxy { * @return */ public static Set getBlacklist(Blacklist blacklist) { - init(); if (ee3Mod != null) { if (blacklist == Blacklist.KNOWLEDGE) { return EE3Wrapper.ee3mod.getBlacklistRegistry().getKnowledgeBlacklist(); - } - else if (blacklist == Blacklist.EXCHANGE) { + } else if (blacklist == Blacklist.EXCHANGE) { return EE3Wrapper.ee3mod.getBlacklistRegistry().getExchangeBlacklist(); } } @@ -55,7 +52,6 @@ public class BlacklistRegistryProxy { * @return */ public static boolean isLearnable(Object object) { - init(); if (ee3Mod != null) { @@ -72,7 +68,6 @@ public class BlacklistRegistryProxy { * @return */ public static boolean isExchangeable(Object object) { - init(); if (ee3Mod != null) { @@ -125,7 +120,6 @@ public class BlacklistRegistryProxy { * @param blacklist */ public static void addToBlacklist(Object object, Blacklist blacklist) { - init(); if (ee3Mod != null) { @@ -140,30 +134,25 @@ public class BlacklistRegistryProxy { * @param blacklist */ public static void removeFromBlacklist(Object object, Blacklist blacklist) { - init(); if (ee3Mod != null) { - EE3Wrapper.ee3mod.getBlacklistRegistry().removeFromBlacklist(object, blacklist); + EE3Wrapper.ee3mod.getBlacklistRegistry().removeFromBlacklist( + object, blacklist + ); } } @Mod.Instance("EE3") private static Object ee3Mod; - private static class EE3Wrapper { - private static EquivalentExchange3 ee3mod; - } + private static class EE3Wrapper { private static EquivalentExchange3 ee3mod; } private static void init() { - if (ee3Mod != null) { BlacklistRegistryProxy.EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod; } } - public enum Blacklist { - KNOWLEDGE, - EXCHANGE - } + public enum Blacklist { KNOWLEDGE, EXCHANGE } } diff --git a/src/main/java/com/pahimar/ee3/api/blacklist/package-info.java b/src/main/java/com/pahimar/ee3/api/blacklist/package-info.java index 59b5fbd0..edeb3663 100644 --- a/src/main/java/com/pahimar/ee3/api/blacklist/package-info.java +++ b/src/main/java/com/pahimar/ee3/api/blacklist/package-info.java @@ -1,3 +1,4 @@ -@API(owner = "EE3", apiVersion = "@API_VERSION@", provides = "EE3-API|blacklist") package com.pahimar.ee3.api.blacklist; +@API(owner = "EE3", apiVersion = "@API_VERSION@", provides = "EE3-API|blacklist") +package com.pahimar.ee3.api.blacklist; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/src/main/java/com/pahimar/ee3/api/event/AbilityEvent.java b/src/main/java/com/pahimar/ee3/api/event/AbilityEvent.java index 3ad3d382..eaf385e0 100644 --- a/src/main/java/com/pahimar/ee3/api/event/AbilityEvent.java +++ b/src/main/java/com/pahimar/ee3/api/event/AbilityEvent.java @@ -7,7 +7,6 @@ import cpw.mods.fml.common.eventhandler.Event; */ @Deprecated public class AbilityEvent extends Event { - public final Object object; /** @@ -17,52 +16,48 @@ public class AbilityEvent extends Event { public AbilityEvent(Object object) { this.object = object; } + @Override - public boolean isCancelable() - { + public boolean isCancelable() { return true; } /** - * @deprecated See {@link com.pahimar.ee3.api.event.BlacklistEvent.KnowledgeWhitelistEvent} + * @deprecated See {@link + * com.pahimar.ee3.api.event.BlacklistEvent.KnowledgeWhitelistEvent} */ - public static class SetLearnableEvent extends AbilityEvent - { - public SetLearnableEvent(Object object) - { + public static class SetLearnableEvent extends AbilityEvent { + public SetLearnableEvent(Object object) { super(object); } } /** - * @deprecated See {@link com.pahimar.ee3.api.event.BlacklistEvent.KnowledgeBlacklistEvent} + * @deprecated See {@link + * com.pahimar.ee3.api.event.BlacklistEvent.KnowledgeBlacklistEvent} */ - public static class SetNotLearnableEvent extends AbilityEvent - { - public SetNotLearnableEvent(Object object) - { + public static class SetNotLearnableEvent extends AbilityEvent { + public SetNotLearnableEvent(Object object) { super(object); } } /** - * @deprecated See {@link com.pahimar.ee3.api.event.BlacklistEvent.ExchangeWhitelistEvent} + * @deprecated See {@link + * com.pahimar.ee3.api.event.BlacklistEvent.ExchangeWhitelistEvent} */ - public static class SetRecoverableEvent extends AbilityEvent - { - public SetRecoverableEvent(Object object) - { + public static class SetRecoverableEvent extends AbilityEvent { + public SetRecoverableEvent(Object object) { super(object); } } /** - * @deprecated See {@link com.pahimar.ee3.api.event.BlacklistEvent.ExchangeBlacklistEvent} + * @deprecated See {@link + * com.pahimar.ee3.api.event.BlacklistEvent.ExchangeBlacklistEvent} */ - public static class SetNotRecoverableEvent extends AbilityEvent - { - public SetNotRecoverableEvent(Object object) - { + public static class SetNotRecoverableEvent extends AbilityEvent { + public SetNotRecoverableEvent(Object object) { super(object); } } diff --git a/src/main/java/com/pahimar/ee3/api/event/BlacklistEvent.java b/src/main/java/com/pahimar/ee3/api/event/BlacklistEvent.java index fb0f1251..33868445 100644 --- a/src/main/java/com/pahimar/ee3/api/event/BlacklistEvent.java +++ b/src/main/java/com/pahimar/ee3/api/event/BlacklistEvent.java @@ -3,7 +3,6 @@ package com.pahimar.ee3.api.event; import cpw.mods.fml.common.eventhandler.Event; public class BlacklistEvent extends Event { - public final Object object; public BlacklistEvent(Object object) { @@ -16,28 +15,24 @@ public class BlacklistEvent extends Event { } public static class KnowledgeBlacklistEvent extends BlacklistEvent { - public KnowledgeBlacklistEvent(Object object) { super(object); } } public static class KnowledgeWhitelistEvent extends BlacklistEvent { - public KnowledgeWhitelistEvent(Object object) { super(object); } } public static class ExchangeBlacklistEvent extends BlacklistEvent { - public ExchangeBlacklistEvent(Object object) { super(object); } } public static class ExchangeWhitelistEvent extends BlacklistEvent { - public ExchangeWhitelistEvent(Object object) { super(object); } diff --git a/src/main/java/com/pahimar/ee3/api/event/EnergyValueEvent.java b/src/main/java/com/pahimar/ee3/api/event/EnergyValueEvent.java index 36b183e8..98db8084 100644 --- a/src/main/java/com/pahimar/ee3/api/event/EnergyValueEvent.java +++ b/src/main/java/com/pahimar/ee3/api/event/EnergyValueEvent.java @@ -5,12 +5,10 @@ import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; import cpw.mods.fml.common.eventhandler.Event; public class EnergyValueEvent extends Event { - public final Object object; public final EnergyValueRegistryProxy.Phase phase; public EnergyValueEvent(Object object, EnergyValueRegistryProxy.Phase phase) { - this.object = object; this.phase = phase; } @@ -21,19 +19,22 @@ public class EnergyValueEvent extends Event { } public static class SetEnergyValueEvent extends EnergyValueEvent { - public final EnergyValue newEnergyValue; - public SetEnergyValueEvent(Object object, EnergyValue newEnergyValue, EnergyValueRegistryProxy.Phase phase) { - + public SetEnergyValueEvent( + Object object, + EnergyValue newEnergyValue, + EnergyValueRegistryProxy.Phase phase + ) { super(object, phase); this.newEnergyValue = newEnergyValue; } } public static class RemoveEnergyValueEvent extends EnergyValueEvent { - - public RemoveEnergyValueEvent(Object object, EnergyValueRegistryProxy.Phase phase) { + public RemoveEnergyValueEvent( + Object object, EnergyValueRegistryProxy.Phase phase + ) { super(object, phase); } } diff --git a/src/main/java/com/pahimar/ee3/api/event/EntityTransmutationEvent.java b/src/main/java/com/pahimar/ee3/api/event/EntityTransmutationEvent.java index d04d333c..bb775d8a 100644 --- a/src/main/java/com/pahimar/ee3/api/event/EntityTransmutationEvent.java +++ b/src/main/java/com/pahimar/ee3/api/event/EntityTransmutationEvent.java @@ -3,19 +3,16 @@ package com.pahimar.ee3.api.event; import net.minecraft.entity.Entity; import net.minecraftforge.event.entity.EntityEvent; -public class EntityTransmutationEvent extends EntityEvent -{ +public class EntityTransmutationEvent extends EntityEvent { public final Entity newEntity; - public EntityTransmutationEvent(Entity originalEntity, Entity newEntity) - { + public EntityTransmutationEvent(Entity originalEntity, Entity newEntity) { super(originalEntity); this.newEntity = newEntity; } @Override - public boolean isCancelable() - { + public boolean isCancelable() { return true; } } diff --git a/src/main/java/com/pahimar/ee3/api/event/PlayerKnowledgeEvent.java b/src/main/java/com/pahimar/ee3/api/event/PlayerKnowledgeEvent.java index b947ed06..6f851fc9 100644 --- a/src/main/java/com/pahimar/ee3/api/event/PlayerKnowledgeEvent.java +++ b/src/main/java/com/pahimar/ee3/api/event/PlayerKnowledgeEvent.java @@ -1,74 +1,63 @@ package com.pahimar.ee3.api.event; +import java.util.UUID; + import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import java.util.UUID; - -public class PlayerKnowledgeEvent extends Event -{ +public class PlayerKnowledgeEvent extends Event { public final UUID playerUUID; - private PlayerKnowledgeEvent(EntityPlayer entityPlayer) - { + private PlayerKnowledgeEvent(EntityPlayer entityPlayer) { this(entityPlayer.getUniqueID()); } - private PlayerKnowledgeEvent(UUID playerUUID) - { + private PlayerKnowledgeEvent(UUID playerUUID) { this.playerUUID = playerUUID; } @Override - public boolean isCancelable() - { + public boolean isCancelable() { return true; } - public static class PlayerLearnKnowledgeEvent extends PlayerKnowledgeEvent - { + public static class PlayerLearnKnowledgeEvent extends PlayerKnowledgeEvent { public final ItemStack itemStack; - public PlayerLearnKnowledgeEvent(EntityPlayer entityPlayer, ItemStack itemStack) - { + public PlayerLearnKnowledgeEvent(EntityPlayer entityPlayer, ItemStack itemStack) { super(entityPlayer); this.itemStack = itemStack; } - public PlayerLearnKnowledgeEvent(UUID playerUUID, ItemStack itemStack) - { + public PlayerLearnKnowledgeEvent(UUID playerUUID, ItemStack itemStack) { super(playerUUID); this.itemStack = itemStack; } } - public static class PlayerForgetKnowledgeEvent extends PlayerKnowledgeEvent - { + public static class PlayerForgetKnowledgeEvent extends PlayerKnowledgeEvent { public final ItemStack itemStack; - public PlayerForgetKnowledgeEvent(EntityPlayer entityPlayer, ItemStack itemStack) - { + public PlayerForgetKnowledgeEvent( + EntityPlayer entityPlayer, ItemStack itemStack + ) { super(entityPlayer); this.itemStack = itemStack; } - public PlayerForgetKnowledgeEvent(UUID playerUUID, ItemStack itemStack) - { + public PlayerForgetKnowledgeEvent(UUID playerUUID, ItemStack itemStack) { super(playerUUID); this.itemStack = itemStack; } } - public static class PlayerForgetAllKnowledgeEvent extends PlayerKnowledgeEvent - { - public PlayerForgetAllKnowledgeEvent(EntityPlayer entityPlayer) - { + public static class PlayerForgetAllKnowledgeEvent extends PlayerKnowledgeEvent { + public PlayerForgetAllKnowledgeEvent(EntityPlayer entityPlayer) { super(entityPlayer); } - public PlayerForgetAllKnowledgeEvent(UUID playerUUID) - { + public PlayerForgetAllKnowledgeEvent(UUID playerUUID) { super(playerUUID); } } diff --git a/src/main/java/com/pahimar/ee3/api/event/TabletTransmutationEvent.java b/src/main/java/com/pahimar/ee3/api/event/TabletTransmutationEvent.java index ca02395a..a27e0c62 100644 --- a/src/main/java/com/pahimar/ee3/api/event/TabletTransmutationEvent.java +++ b/src/main/java/com/pahimar/ee3/api/event/TabletTransmutationEvent.java @@ -4,16 +4,16 @@ import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -public class TabletTransmutationEvent extends Event -{ +public class TabletTransmutationEvent extends Event { public final EntityPlayer entityPlayer; public final int x; public final int y; public final int z; public final ItemStack itemStack; - public TabletTransmutationEvent(EntityPlayer entityPlayer, int x, int y, int z, ItemStack itemStack) - { + public TabletTransmutationEvent( + EntityPlayer entityPlayer, int x, int y, int z, ItemStack itemStack + ) { this.entityPlayer = entityPlayer; this.x = x; this.y = y; @@ -22,8 +22,7 @@ public class TabletTransmutationEvent extends Event } @Override - public boolean isCancelable() - { + public boolean isCancelable() { return true; } } diff --git a/src/main/java/com/pahimar/ee3/api/event/TemplateKnowledgeEvent.java b/src/main/java/com/pahimar/ee3/api/event/TemplateKnowledgeEvent.java index f1b609ef..b29c6bf8 100644 --- a/src/main/java/com/pahimar/ee3/api/event/TemplateKnowledgeEvent.java +++ b/src/main/java/com/pahimar/ee3/api/event/TemplateKnowledgeEvent.java @@ -3,38 +3,29 @@ package com.pahimar.ee3.api.event; import cpw.mods.fml.common.eventhandler.Event; import net.minecraft.item.ItemStack; -public class TemplateKnowledgeEvent extends Event -{ +public class TemplateKnowledgeEvent extends Event { @Override - public boolean isCancelable() - { + public boolean isCancelable() { return true; } - public static class TemplateLearnKnowledgeEvent extends TemplateKnowledgeEvent - { + public static class TemplateLearnKnowledgeEvent extends TemplateKnowledgeEvent { public final ItemStack itemStack; - public TemplateLearnKnowledgeEvent(ItemStack itemStack) - { + public TemplateLearnKnowledgeEvent(ItemStack itemStack) { this.itemStack = itemStack; } } - public static class TemplateForgetKnowledgeEvent extends TemplateKnowledgeEvent - { + public static class TemplateForgetKnowledgeEvent extends TemplateKnowledgeEvent { public final ItemStack itemStack; - public TemplateForgetKnowledgeEvent(ItemStack itemStack) - { + public TemplateForgetKnowledgeEvent(ItemStack itemStack) { this.itemStack = itemStack; } } - public static class TemplateForgetAllKnowledgeEvent extends TemplateKnowledgeEvent - { - public TemplateForgetAllKnowledgeEvent() - { - } + public static class TemplateForgetAllKnowledgeEvent extends TemplateKnowledgeEvent { + public TemplateForgetAllKnowledgeEvent() {} } } diff --git a/src/main/java/com/pahimar/ee3/api/event/WorldTransmutationEvent.java b/src/main/java/com/pahimar/ee3/api/event/WorldTransmutationEvent.java index 2ef58911..b4cea7c7 100644 --- a/src/main/java/com/pahimar/ee3/api/event/WorldTransmutationEvent.java +++ b/src/main/java/com/pahimar/ee3/api/event/WorldTransmutationEvent.java @@ -7,14 +7,21 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.event.world.BlockEvent; -public class WorldTransmutationEvent extends BlockEvent -{ +public class WorldTransmutationEvent extends BlockEvent { public final ForgeDirection sideHit; public final EntityPlayer player; public final ItemStack heldItemStack; - public WorldTransmutationEvent(int x, int y, int z, World world, Block block, int blockMetaData, ForgeDirection sideHit, EntityPlayer entityLiving) - { + public WorldTransmutationEvent( + int x, + int y, + int z, + World world, + Block block, + int blockMetaData, + ForgeDirection sideHit, + EntityPlayer entityLiving + ) { super(x, y, z, world, block, blockMetaData); this.sideHit = sideHit; this.player = entityLiving; @@ -22,8 +29,7 @@ public class WorldTransmutationEvent extends BlockEvent } @Override - public boolean isCancelable() - { + public boolean isCancelable() { return true; } } diff --git a/src/main/java/com/pahimar/ee3/api/event/package-info.java b/src/main/java/com/pahimar/ee3/api/event/package-info.java index 3e79a038..69606540 100644 --- a/src/main/java/com/pahimar/ee3/api/event/package-info.java +++ b/src/main/java/com/pahimar/ee3/api/event/package-info.java @@ -1,3 +1,4 @@ -@API(owner = "EE3", apiVersion = "@API_VERSION@", provides = "EE3-API|event") package com.pahimar.ee3.api.event; +@API(owner = "EE3", apiVersion = "@API_VERSION@", provides = "EE3-API|event") +package com.pahimar.ee3.api.event; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/src/main/java/com/pahimar/ee3/api/exchange/EnergyValue.java b/src/main/java/com/pahimar/ee3/api/exchange/EnergyValue.java index 7662cce0..5b47c074 100644 --- a/src/main/java/com/pahimar/ee3/api/exchange/EnergyValue.java +++ b/src/main/java/com/pahimar/ee3/api/exchange/EnergyValue.java @@ -1,19 +1,18 @@ package com.pahimar.ee3.api.exchange; +import java.math.BigDecimal; +import java.text.DecimalFormat; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; -import java.math.BigDecimal; -import java.text.DecimalFormat; - public final class EnergyValue implements Comparable { - - private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("###,###,###,###,###.###"); + private static final DecimalFormat DECIMAL_FORMAT + = new DecimalFormat("###,###,###,###,###.###"); private float energyValue; - public EnergyValue() - { + public EnergyValue() { this(0); } @@ -41,11 +40,9 @@ public final class EnergyValue implements Comparable { @Override public int compareTo(EnergyValue energyValue) { - if (energyValue != null) { return Float.compare(this.energyValue, energyValue.getValue()); - } - else { + } else { return -1; } } @@ -56,21 +53,18 @@ public final class EnergyValue implements Comparable { } public void readFromNBT(NBTTagCompound nbtTagCompound) { - if (nbtTagCompound.hasKey("energyValue")) { this.energyValue = nbtTagCompound.getFloat("energyValue"); } } public static NBTTagCompound writeEnergyValueToNBT(EnergyValue energyValue) { - NBTTagCompound nbtTagCompound = new NBTTagCompound(); energyValue.writeToNBT(nbtTagCompound); return nbtTagCompound; } public static EnergyValue loadEnergyValueFromNBT(NBTTagCompound nbtTagCompound) { - if (nbtTagCompound.hasKey("energyValue")) { float energyValue = nbtTagCompound.getFloat("energyValue"); return new EnergyValue(energyValue); @@ -80,11 +74,13 @@ public final class EnergyValue implements Comparable { } public static EnergyValue factor(EnergyValue energyValue, Number factor) { - if ((Float.compare(factor.floatValue(), 0f) != 0) && (energyValue != null)) { - return new EnergyValue(new BigDecimal(energyValue.getValue() * 1f / factor.floatValue()).setScale(3, BigDecimal.ROUND_HALF_EVEN).floatValue()); - } - else { + return new EnergyValue( + new BigDecimal(energyValue.getValue() * 1f / factor.floatValue()) + .setScale(3, BigDecimal.ROUND_HALF_EVEN) + .floatValue() + ); + } else { return null; } } diff --git a/src/main/java/com/pahimar/ee3/api/exchange/EnergyValueMappingsTester.java b/src/main/java/com/pahimar/ee3/api/exchange/EnergyValueMappingsTester.java index e6ce772b..d33d8615 100644 --- a/src/main/java/com/pahimar/ee3/api/exchange/EnergyValueMappingsTester.java +++ b/src/main/java/com/pahimar/ee3/api/exchange/EnergyValueMappingsTester.java @@ -1,23 +1,19 @@ package com.pahimar.ee3.api.exchange; +import java.io.File; + import com.pahimar.ee3.EquivalentExchange3; import cpw.mods.fml.common.Mod; -import java.io.File; - -public class EnergyValueMappingsTester -{ - public static void runTest(File file) - { +public class EnergyValueMappingsTester { + public static void runTest(File file) { runTest(file, false); } - public static void runTest(File file, boolean strict) - { + public static void runTest(File file, boolean strict) { init(); - if (ee3Mod != null) - { + if (ee3Mod != null) { EE3Wrapper.ee3mod.runEnergyValueTestSuite(file, strict); } } @@ -25,15 +21,10 @@ public class EnergyValueMappingsTester @Mod.Instance("EE3") private static Object ee3Mod; - private static class EE3Wrapper - { - private static EquivalentExchange3 ee3mod; - } + private static class EE3Wrapper { private static EquivalentExchange3 ee3mod; } - private static void init() - { - if (ee3Mod != null) - { + private static void init() { + if (ee3Mod != null) { EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod; } } diff --git a/src/main/java/com/pahimar/ee3/api/exchange/EnergyValueRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/exchange/EnergyValueRegistryProxy.java index 6c2f7573..ed47e3de 100644 --- a/src/main/java/com/pahimar/ee3/api/exchange/EnergyValueRegistryProxy.java +++ b/src/main/java/com/pahimar/ee3/api/exchange/EnergyValueRegistryProxy.java @@ -1,16 +1,15 @@ package com.pahimar.ee3.api.exchange; -import com.pahimar.ee3.EquivalentExchange3; -import com.pahimar.ee3.exchange.WrappedStack; -import cpw.mods.fml.common.Mod; - import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; -public final class EnergyValueRegistryProxy { +import com.pahimar.ee3.EquivalentExchange3; +import com.pahimar.ee3.exchange.WrappedStack; +import cpw.mods.fml.common.Mod; +public final class EnergyValueRegistryProxy { @Mod.Instance("EE3") private static Object ee3Mod; @@ -34,17 +33,17 @@ public final class EnergyValueRegistryProxy { return null; } - public static boolean hasEnergyValue(Object object) - { + public static boolean hasEnergyValue(Object object) { return hasEnergyValue(object, false); } public static boolean hasEnergyValue(Object object, boolean strict) { - init(); if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getEnergyValueRegistry().hasEnergyValue(object, strict); + return EE3Wrapper.ee3mod.getEnergyValueRegistry().hasEnergyValue( + object, strict + ); } return false; @@ -55,11 +54,12 @@ public final class EnergyValueRegistryProxy { } public static EnergyValue getEnergyValue(Object object, boolean strict) { - init(); if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getEnergyValueRegistry().getEnergyValue(object, strict); + return EE3Wrapper.ee3mod.getEnergyValueRegistry().getEnergyValue( + object, strict + ); } return null; @@ -70,11 +70,12 @@ public final class EnergyValueRegistryProxy { } public static EnergyValue getEnergyValueForStack(Object object, boolean strict) { - init(); if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getEnergyValueRegistry().getEnergyValueForStack(object, strict); + return EE3Wrapper.ee3mod.getEnergyValueRegistry().getEnergyValueForStack( + object, strict + ); } return null; @@ -87,11 +88,12 @@ public final class EnergyValueRegistryProxy { @Deprecated public static List getStacksInRange(EnergyValue start, EnergyValue finish) { - init(); if (ee3Mod != null) { - return new ArrayList<>(EE3Wrapper.ee3mod.getEnergyValueRegistry().getStacksInRange(start, finish)); + return new ArrayList<>( + EE3Wrapper.ee3mod.getEnergyValueRegistry().getStacksInRange(start, finish) + ); } return Collections.EMPTY_LIST; @@ -137,7 +139,8 @@ public final class EnergyValueRegistryProxy { * @param energyValue */ @Deprecated - public static void addPreCalculationEnergyValue(Object object, EnergyValue energyValue) { + public static void + addPreCalculationEnergyValue(Object object, EnergyValue energyValue) { setEnergyValue(object, energyValue, Phase.PRE_CALCULATION); } @@ -159,7 +162,8 @@ public final class EnergyValueRegistryProxy { * @param energyValue */ @Deprecated - public static void addPostAssignedEnergyValue(Object object, EnergyValue energyValue) { + public static void + addPostAssignedEnergyValue(Object object, EnergyValue energyValue) { setEnergyValue(object, energyValue); } @@ -181,7 +185,8 @@ public final class EnergyValueRegistryProxy { * @param energyValue */ @Deprecated - public static void addPostCalculationEnergyValue(Object object, EnergyValue energyValue) { + public static void + addPostCalculationEnergyValue(Object object, EnergyValue energyValue) { setEnergyValue(object, energyValue); } @@ -194,25 +199,23 @@ public final class EnergyValueRegistryProxy { } public static void setEnergyValue(Object object, Number energyValue, Phase phase) { - setEnergyValue(object, new EnergyValue(energyValue), phase); } - public static void setEnergyValue(Object object, EnergyValue energyValue, Phase phase) { - + public static void + setEnergyValue(Object object, EnergyValue energyValue, Phase phase) { init(); if (ee3Mod != null) { - EE3Wrapper.ee3mod.getEnergyValueRegistry().setEnergyValue(object, energyValue, phase); + EE3Wrapper.ee3mod.getEnergyValueRegistry().setEnergyValue( + object, energyValue, phase + ); } } - private static class EE3Wrapper { - private static EquivalentExchange3 ee3mod; - } + private static class EE3Wrapper { private static EquivalentExchange3 ee3mod; } private static void init() { - if (ee3Mod != null) { EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod; } diff --git a/src/main/java/com/pahimar/ee3/api/exchange/IEnergyValueProvider.java b/src/main/java/com/pahimar/ee3/api/exchange/IEnergyValueProvider.java index d1d047b1..15d15e22 100644 --- a/src/main/java/com/pahimar/ee3/api/exchange/IEnergyValueProvider.java +++ b/src/main/java/com/pahimar/ee3/api/exchange/IEnergyValueProvider.java @@ -3,6 +3,5 @@ package com.pahimar.ee3.api.exchange; import net.minecraft.item.ItemStack; public interface IEnergyValueProvider { - EnergyValue getEnergyValue(ItemStack itemStack); } diff --git a/src/main/java/com/pahimar/ee3/api/exchange/IEnergyValueRegistry.java b/src/main/java/com/pahimar/ee3/api/exchange/IEnergyValueRegistry.java index 38866911..8a8bc6f2 100644 --- a/src/main/java/com/pahimar/ee3/api/exchange/IEnergyValueRegistry.java +++ b/src/main/java/com/pahimar/ee3/api/exchange/IEnergyValueRegistry.java @@ -3,11 +3,9 @@ package com.pahimar.ee3.api.exchange; import java.util.Set; import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy.Phase; - import net.minecraft.item.ItemStack; public interface IEnergyValueRegistry { - boolean hasEnergyValue(Object object, boolean strict); EnergyValue getEnergyValue(Object object, boolean strict); @@ -17,5 +15,4 @@ public interface IEnergyValueRegistry { Set getStacksInRange(EnergyValue start, EnergyValue finish); void setEnergyValue(Object object, EnergyValue energyValue, Phase phase); - } diff --git a/src/main/java/com/pahimar/ee3/api/exchange/ITransmutationContainer.java b/src/main/java/com/pahimar/ee3/api/exchange/ITransmutationContainer.java index b01a3887..b94f42ef 100644 --- a/src/main/java/com/pahimar/ee3/api/exchange/ITransmutationContainer.java +++ b/src/main/java/com/pahimar/ee3/api/exchange/ITransmutationContainer.java @@ -3,12 +3,10 @@ package com.pahimar.ee3.api.exchange; import java.util.Set; import com.pahimar.ee3.knowledge.PlayerKnowledge; - import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; public interface ITransmutationContainer extends IInventory { - int getXCoord(); int getYCoord(); @@ -24,5 +22,4 @@ public interface ITransmutationContainer extends IInventory { void updateEnergyValueFromInventory(); void handlePlayerKnowledgeUpdate(PlayerKnowledge playerKnowledge); - } diff --git a/src/main/java/com/pahimar/ee3/api/exchange/RecipeRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/exchange/RecipeRegistryProxy.java index 077ec8a4..2bf7807a 100644 --- a/src/main/java/com/pahimar/ee3/api/exchange/RecipeRegistryProxy.java +++ b/src/main/java/com/pahimar/ee3/api/exchange/RecipeRegistryProxy.java @@ -8,7 +8,6 @@ import java.util.List; */ @Deprecated public final class RecipeRegistryProxy { - /** * * @deprecated @@ -18,7 +17,9 @@ public final class RecipeRegistryProxy { */ @Deprecated public static void addRecipe(Object recipeOutput, List recipeInputList) { - com.pahimar.ee3.api.recipe.RecipeRegistryProxy.addRecipe(recipeOutput, recipeInputList); + com.pahimar.ee3.api.recipe.RecipeRegistryProxy.addRecipe( + recipeOutput, recipeInputList + ); } /** diff --git a/src/main/java/com/pahimar/ee3/api/exchange/package-info.java b/src/main/java/com/pahimar/ee3/api/exchange/package-info.java index 109de40e..62934eba 100644 --- a/src/main/java/com/pahimar/ee3/api/exchange/package-info.java +++ b/src/main/java/com/pahimar/ee3/api/exchange/package-info.java @@ -1,3 +1,4 @@ -@API(owner = "EE3", apiVersion = "@API_VERSION@", provides = "EE3-API|exchange") package com.pahimar.ee3.api.exchange; +@API(owner = "EE3", apiVersion = "@API_VERSION@", provides = "EE3-API|exchange") +package com.pahimar.ee3.api.exchange; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/src/main/java/com/pahimar/ee3/api/knowledge/AbilityRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/knowledge/AbilityRegistryProxy.java index f4d34f7b..d7560b9d 100644 --- a/src/main/java/com/pahimar/ee3/api/knowledge/AbilityRegistryProxy.java +++ b/src/main/java/com/pahimar/ee3/api/knowledge/AbilityRegistryProxy.java @@ -4,7 +4,6 @@ import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; @Deprecated public final class AbilityRegistryProxy { - /** * @deprecated See {@link BlacklistRegistryProxy#isLearnable(Object)} */ @@ -61,9 +60,5 @@ public final class AbilityRegistryProxy { // NOOP } - public enum Abilities { - NOT_LEARNABLE, - NOT_RECOVERABLE, - ALL - } + public enum Abilities { NOT_LEARNABLE, NOT_RECOVERABLE, ALL } } diff --git a/src/main/java/com/pahimar/ee3/api/knowledge/PlayerKnowledgeRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/knowledge/PlayerKnowledgeRegistryProxy.java index 58159d98..64fc1dd4 100644 --- a/src/main/java/com/pahimar/ee3/api/knowledge/PlayerKnowledgeRegistryProxy.java +++ b/src/main/java/com/pahimar/ee3/api/knowledge/PlayerKnowledgeRegistryProxy.java @@ -1,16 +1,15 @@ package com.pahimar.ee3.api.knowledge; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; + import com.pahimar.ee3.EquivalentExchange3; import cpw.mods.fml.common.Mod; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import java.util.Collection; -import java.util.Collections; -import java.util.Set; - public class PlayerKnowledgeRegistryProxy { - /** * TODO Finish JavaDoc * @@ -19,11 +18,12 @@ public class PlayerKnowledgeRegistryProxy { * @return */ public static boolean doesPlayerKnow(EntityPlayer entityPlayer, Object object) { - init(); if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().doesPlayerKnow(entityPlayer, object); + return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().doesPlayerKnow( + entityPlayer, object + ); } return false; @@ -37,11 +37,12 @@ public class PlayerKnowledgeRegistryProxy { * @return */ public static boolean doesPlayerKnow(String playerName, Object object) { - init(); if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().doesPlayerKnow(playerName, object); + return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().doesPlayerKnow( + playerName, object + ); } return false; @@ -55,11 +56,12 @@ public class PlayerKnowledgeRegistryProxy { * @return */ public static boolean canPlayerLearn(EntityPlayer entityPlayer, Object object) { - init(); if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().canPlayerLearn(entityPlayer, object); + return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().canPlayerLearn( + entityPlayer, object + ); } return false; @@ -73,11 +75,12 @@ public class PlayerKnowledgeRegistryProxy { * @return */ public static boolean canPlayerLearn(String playerName, Object object) { - init(); if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().canPlayerLearn(playerName, object); + return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().canPlayerLearn( + playerName, object + ); } return false; @@ -90,11 +93,12 @@ public class PlayerKnowledgeRegistryProxy { * @return */ public static Set getKnownItemStacks(EntityPlayer entityPlayer) { - init(); if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().getKnownItemStacks(entityPlayer); + return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().getKnownItemStacks( + entityPlayer + ); } return Collections.EMPTY_SET; @@ -107,11 +111,12 @@ public class PlayerKnowledgeRegistryProxy { * @return */ public static Set getKnownItemStacks(String playerName) { - init(); if (ee3Mod != null) { - return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().getKnownItemStacks(playerName); + return EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().getKnownItemStacks( + playerName + ); } return Collections.EMPTY_SET; @@ -124,11 +129,12 @@ public class PlayerKnowledgeRegistryProxy { * @param object */ public static void teachPlayer(EntityPlayer entityPlayer, Object object) { - init(); if (ee3Mod != null) { - EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().teachPlayer(entityPlayer, object); + EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().teachPlayer( + entityPlayer, object + ); } } @@ -139,11 +145,12 @@ public class PlayerKnowledgeRegistryProxy { * @param object */ public static void teachPlayer(String playerName, Object object) { - init(); if (ee3Mod != null) { - EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().teachPlayer(playerName, object); + EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().teachPlayer( + playerName, object + ); } } @@ -154,11 +161,12 @@ public class PlayerKnowledgeRegistryProxy { * @param objects */ public static void teachPlayer(EntityPlayer entityPlayer, Collection objects) { - init(); if (ee3Mod != null) { - EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().teachPlayer(entityPlayer, objects); + EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().teachPlayer( + entityPlayer, objects + ); } } @@ -169,11 +177,12 @@ public class PlayerKnowledgeRegistryProxy { * @param objects */ public static void teachPlayer(String playerName, Collection objects) { - init(); if (ee3Mod != null) { - EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().teachPlayer(playerName, objects); + EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().teachPlayer( + playerName, objects + ); } } @@ -184,11 +193,12 @@ public class PlayerKnowledgeRegistryProxy { * @param object */ public static void makePlayerForget(EntityPlayer entityPlayer, Object object) { - init(); if (ee3Mod != null) { - EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForget(entityPlayer, object); + EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForget( + entityPlayer, object + ); } } @@ -199,11 +209,12 @@ public class PlayerKnowledgeRegistryProxy { * @param object */ public static void makePlayerForget(String playerName, Object object) { - init(); if (ee3Mod != null) { - EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForget(playerName, object); + EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForget( + playerName, object + ); } } @@ -213,12 +224,14 @@ public class PlayerKnowledgeRegistryProxy { * @param entityPlayer * @param objects */ - public static void makePlayerForget(EntityPlayer entityPlayer, Collection objects) { - + public static void + makePlayerForget(EntityPlayer entityPlayer, Collection objects) { init(); if (ee3Mod != null) { - EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForget(entityPlayer, objects); + EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForget( + entityPlayer, objects + ); } } @@ -229,11 +242,12 @@ public class PlayerKnowledgeRegistryProxy { * @param objects */ public static void makePlayerForget(String playerName, Collection objects) { - init(); if (ee3Mod != null) { - EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForget(playerName, objects); + EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForget( + playerName, objects + ); } } @@ -243,11 +257,12 @@ public class PlayerKnowledgeRegistryProxy { * @param entityPlayer */ public static void makePlayerForgetAll(EntityPlayer entityPlayer) { - init(); if (ee3Mod != null) { - EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForgetAll(entityPlayer); + EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForgetAll( + entityPlayer + ); } } @@ -257,23 +272,20 @@ public class PlayerKnowledgeRegistryProxy { * @param playerName */ public static void makePlayerForgetAll(String playerName) { - init(); if (ee3Mod != null) { - EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForgetAll(playerName); + EE3Wrapper.ee3mod.getPlayerKnowledgeRegistry().makePlayerForgetAll(playerName + ); } } @Mod.Instance("EE3") private static Object ee3Mod; - private static class EE3Wrapper { - private static EquivalentExchange3 ee3mod; - } + private static class EE3Wrapper { private static EquivalentExchange3 ee3mod; } private static void init() { - if (ee3Mod != null) { PlayerKnowledgeRegistryProxy.EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod; } diff --git a/src/main/java/com/pahimar/ee3/api/knowledge/TransmutationKnowledgeRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/knowledge/TransmutationKnowledgeRegistryProxy.java index 95a2e393..b2db05a1 100644 --- a/src/main/java/com/pahimar/ee3/api/knowledge/TransmutationKnowledgeRegistryProxy.java +++ b/src/main/java/com/pahimar/ee3/api/knowledge/TransmutationKnowledgeRegistryProxy.java @@ -1,19 +1,18 @@ package com.pahimar.ee3.api.knowledge; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - import java.util.Collections; import java.util.Set; import java.util.UUID; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + /** * @deprecated as of API 0.4.0; use {@link PlayerKnowledgeRegistryProxy} instead * @see PlayerKnowledgeRegistryProxy */ @Deprecated public class TransmutationKnowledgeRegistryProxy { - @Deprecated public static boolean doesPlayerKnow(EntityPlayer entityPlayer, ItemStack itemStack) { return PlayerKnowledgeRegistryProxy.doesPlayerKnow(entityPlayer, itemStack); @@ -45,22 +44,28 @@ public class TransmutationKnowledgeRegistryProxy { } @Deprecated - public static Set getPlayerKnownTransmutationsFilteredStartsWith(EntityPlayer entityPlayer, String filterString) { + public static Set getPlayerKnownTransmutationsFilteredStartsWith( + EntityPlayer entityPlayer, String filterString + ) { return PlayerKnowledgeRegistryProxy.getKnownItemStacks(entityPlayer); } @Deprecated - public static Set getPlayerKnownTransmutationsFilteredStartsWith(UUID playerUUID, String filterString) { + public static Set + getPlayerKnownTransmutationsFilteredStartsWith(UUID playerUUID, String filterString) { return Collections.EMPTY_SET; } @Deprecated - public static Set getPlayerKnownTransmutationsFilteredContains(EntityPlayer entityPlayer, String filterString) { + public static Set getPlayerKnownTransmutationsFilteredContains( + EntityPlayer entityPlayer, String filterString + ) { return PlayerKnowledgeRegistryProxy.getKnownItemStacks(entityPlayer); } @Deprecated - public static Set getPlayerKnownTransmutationsFilteredContains(UUID playerUUID, String filterString) { + public static Set + getPlayerKnownTransmutationsFilteredContains(UUID playerUUID, String filterString) { return Collections.EMPTY_SET; } @@ -105,12 +110,14 @@ public class TransmutationKnowledgeRegistryProxy { } @Deprecated - public static Set getTemplateKnownTransmutationsFilteredStartsWith(String filterString) { + public static Set + getTemplateKnownTransmutationsFilteredStartsWith(String filterString) { return Collections.EMPTY_SET; } @Deprecated - public static Set getTemplateKnownTransmutationsFilteredContains(String filterString) { + public static Set + getTemplateKnownTransmutationsFilteredContains(String filterString) { return Collections.EMPTY_SET; } diff --git a/src/main/java/com/pahimar/ee3/api/knowledge/package-info.java b/src/main/java/com/pahimar/ee3/api/knowledge/package-info.java index 259ded8e..483b4fe2 100644 --- a/src/main/java/com/pahimar/ee3/api/knowledge/package-info.java +++ b/src/main/java/com/pahimar/ee3/api/knowledge/package-info.java @@ -1,3 +1,4 @@ -@API(owner = "EE3", apiVersion = "@API_VERSION@", provides = "EE3-API|knowledge") package com.pahimar.ee3.api.knowledge; +@API(owner = "EE3", apiVersion = "@API_VERSION@", provides = "EE3-API|knowledge") +package com.pahimar.ee3.api.knowledge; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/src/main/java/com/pahimar/ee3/api/package-info.java b/src/main/java/com/pahimar/ee3/api/package-info.java index 8025d45f..55547c57 100644 --- a/src/main/java/com/pahimar/ee3/api/package-info.java +++ b/src/main/java/com/pahimar/ee3/api/package-info.java @@ -1,3 +1,4 @@ -@API(owner = "EE3", apiVersion = "@API_VERSION@", provides = "EE3-API|core") package com.pahimar.ee3.api; +@API(owner = "EE3", apiVersion = "@API_VERSION@", provides = "EE3-API|core") +package com.pahimar.ee3.api; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/src/main/java/com/pahimar/ee3/api/recipe/AludelRecipeProxy.java b/src/main/java/com/pahimar/ee3/api/recipe/AludelRecipeProxy.java index 3349b4ca..a51ac72b 100644 --- a/src/main/java/com/pahimar/ee3/api/recipe/AludelRecipeProxy.java +++ b/src/main/java/com/pahimar/ee3/api/recipe/AludelRecipeProxy.java @@ -4,44 +4,40 @@ import com.pahimar.ee3.EquivalentExchange3; import cpw.mods.fml.common.Mod; import net.minecraft.item.ItemStack; -// TODO Clean this up and make it more nice for modders. Consider this very volatile for the time being -public class AludelRecipeProxy -{ +// TODO Clean this up and make it more nice for modders. Consider this very volatile for +// the time being +public class AludelRecipeProxy { @Mod.Instance("EE3") private static Object ee3Mod; - public void addRecipe(ItemStack recipeOutput, ItemStack recipeInputStack, ItemStack recipeInputDust) - { + public void addRecipe( + ItemStack recipeOutput, ItemStack recipeInputStack, ItemStack recipeInputDust + ) { init(); - if (ee3Mod != null) - { - EE3Wrapper.ee3mod.getAludelRecipeManager().addRecipe(recipeOutput, recipeInputStack, recipeInputDust); + if (ee3Mod != null) { + EE3Wrapper.ee3mod.getAludelRecipeManager().addRecipe( + recipeOutput, recipeInputStack, recipeInputDust + ); } } - public ItemStack getResult(ItemStack recipeInputStack, ItemStack recipeInputDust) - { + public ItemStack getResult(ItemStack recipeInputStack, ItemStack recipeInputDust) { init(); - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getAludelRecipeManager().getResult(recipeInputStack, recipeInputDust); + if (ee3Mod != null) { + return EE3Wrapper.ee3mod.getAludelRecipeManager().getResult( + recipeInputStack, recipeInputDust + ); } return null; } + private static class EE3Wrapper { private static EquivalentExchange3 ee3mod; } - private static class EE3Wrapper - { - private static EquivalentExchange3 ee3mod; - } - - private static void init() - { - if (ee3Mod != null) - { + private static void init() { + if (ee3Mod != null) { EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod; } } diff --git a/src/main/java/com/pahimar/ee3/api/recipe/RecipeRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/recipe/RecipeRegistryProxy.java index b757f56d..27e47057 100644 --- a/src/main/java/com/pahimar/ee3/api/recipe/RecipeRegistryProxy.java +++ b/src/main/java/com/pahimar/ee3/api/recipe/RecipeRegistryProxy.java @@ -1,29 +1,33 @@ package com.pahimar.ee3.api.recipe; -import com.pahimar.ee3.EquivalentExchange3; -import cpw.mods.fml.common.Mod; - import java.util.Arrays; import java.util.List; -public final class RecipeRegistryProxy { +import com.pahimar.ee3.EquivalentExchange3; +import cpw.mods.fml.common.Mod; - public static void addRecipe(Object recipeOutput, Object ... recipeInputs) { // TODO 1.9, List -> Collection +public final class RecipeRegistryProxy { + public static void addRecipe( + Object recipeOutput, Object... recipeInputs + ) { // TODO 1.9, List -> Collection addRecipe(recipeOutput, Arrays.asList(recipeInputs)); } - public static void addRecipe(Object recipeOutput, List recipeInputList) { // TODO 1.9, List -> Collection + public static void addRecipe( + Object recipeOutput, List recipeInputList + ) { // TODO 1.9, List -> Collection init(); // NOOP if EquivalentExchange3 is not present if (ee3Mod != null) { - EE3Wrapper.ee3mod.getRecipeRegistry().addRecipe(recipeOutput, recipeInputList); + EE3Wrapper.ee3mod.getRecipeRegistry().addRecipe( + recipeOutput, recipeInputList + ); } } public static void dumpRecipeRegistryToLog() { - init(); // NOOP if EquivalentExchange3 is not present @@ -35,12 +39,9 @@ public final class RecipeRegistryProxy { @Mod.Instance("EE3") private static Object ee3Mod; - private static class EE3Wrapper { - private static EquivalentExchange3 ee3mod; - } + private static class EE3Wrapper { private static EquivalentExchange3 ee3mod; } private static void init() { - if (ee3Mod != null) { EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod; } diff --git a/src/main/java/com/pahimar/ee3/api/recipe/package-info.java b/src/main/java/com/pahimar/ee3/api/recipe/package-info.java index 5329382e..338eaa9b 100644 --- a/src/main/java/com/pahimar/ee3/api/recipe/package-info.java +++ b/src/main/java/com/pahimar/ee3/api/recipe/package-info.java @@ -1,3 +1,4 @@ -@API(owner = "EE3", apiVersion = "@API_VERSION@", provides = "EE3-API|recipe") package com.pahimar.ee3.api.recipe; +@API(owner = "EE3", apiVersion = "@API_VERSION@", provides = "EE3-API|recipe") +package com.pahimar.ee3.api.recipe; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/src/main/java/com/pahimar/ee3/api/util/TileEntityDataProxy.java b/src/main/java/com/pahimar/ee3/api/util/TileEntityDataProxy.java index 1b94cf40..d02e51e1 100644 --- a/src/main/java/com/pahimar/ee3/api/util/TileEntityDataProxy.java +++ b/src/main/java/com/pahimar/ee3/api/util/TileEntityDataProxy.java @@ -1,98 +1,94 @@ package com.pahimar.ee3.api.util; +import java.util.UUID; + import com.pahimar.ee3.EquivalentExchange3; import cpw.mods.fml.common.Mod; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.UUID; - -public class TileEntityDataProxy -{ +public class TileEntityDataProxy { @Mod.Instance("EE3") private static Object ee3Mod; - public static Class getTileEntityClass(World world, int xCoord, int yCoord, int zCoord) - { + public static Class + getTileEntityClass(World world, int xCoord, int yCoord, int zCoord) { init(); - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getTileEntityDataHelper().getTileEntityClass(world, xCoord, yCoord, zCoord); + if (ee3Mod != null) { + return EE3Wrapper.ee3mod.getTileEntityDataHelper().getTileEntityClass( + world, xCoord, yCoord, zCoord + ); } return null; } - public static ForgeDirection getOrientation(World world, int xCoord, int yCoord, int zCoord) - { + public static ForgeDirection + getOrientation(World world, int xCoord, int yCoord, int zCoord) { init(); - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getTileEntityDataHelper().getOrientation(world, xCoord, yCoord, zCoord); + if (ee3Mod != null) { + return EE3Wrapper.ee3mod.getTileEntityDataHelper().getOrientation( + world, xCoord, yCoord, zCoord + ); } return null; } - public static short getState(World world, int xCoord, int yCoord, int zCoord) - { + public static short getState(World world, int xCoord, int yCoord, int zCoord) { init(); - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getTileEntityDataHelper().getState(world, xCoord, yCoord, zCoord); + if (ee3Mod != null) { + return EE3Wrapper.ee3mod.getTileEntityDataHelper().getState( + world, xCoord, yCoord, zCoord + ); } return Short.MIN_VALUE; } - public static String getCustomName(World world, int xCoord, int yCoord, int zCoord) - { + public static String getCustomName(World world, int xCoord, int yCoord, int zCoord) { init(); - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getTileEntityDataHelper().getCustomName(world, xCoord, yCoord, zCoord); + if (ee3Mod != null) { + return EE3Wrapper.ee3mod.getTileEntityDataHelper().getCustomName( + world, xCoord, yCoord, zCoord + ); } return null; } - public static UUID getOwnerUUID(World world, int xCoord, int yCoord, int zCoord) - { + public static UUID getOwnerUUID(World world, int xCoord, int yCoord, int zCoord) { init(); - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getTileEntityDataHelper().getOwnerUUID(world, xCoord, yCoord, zCoord); + if (ee3Mod != null) { + return EE3Wrapper.ee3mod.getTileEntityDataHelper().getOwnerUUID( + world, xCoord, yCoord, zCoord + ); } return null; } - public static String getOwnerName(World world, int xCoord, int yCoord, int zCoord) - { + public static String getOwnerName(World world, int xCoord, int yCoord, int zCoord) { init(); - if (ee3Mod != null) - { - return EE3Wrapper.ee3mod.getTileEntityDataHelper().getOwnerName(world, xCoord, yCoord, zCoord); + if (ee3Mod != null) { + return EE3Wrapper.ee3mod.getTileEntityDataHelper().getOwnerName( + world, xCoord, yCoord, zCoord + ); } return null; } - private static class EE3Wrapper - { - private static EquivalentExchange3 ee3mod; - } + private static class EE3Wrapper { private static EquivalentExchange3 ee3mod; } - private static void init() - { - if (ee3Mod != null) - { + private static void init() { + if (ee3Mod != null) { EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod; } } diff --git a/src/main/java/com/pahimar/ee3/api/util/package-info.java b/src/main/java/com/pahimar/ee3/api/util/package-info.java index ec96fb40..40c125f3 100644 --- a/src/main/java/com/pahimar/ee3/api/util/package-info.java +++ b/src/main/java/com/pahimar/ee3/api/util/package-info.java @@ -1,3 +1,4 @@ -@API(owner = "EE3", apiVersion = "@API_VERSION@", provides = "EE3-API|util") package com.pahimar.ee3.api.util; +@API(owner = "EE3", apiVersion = "@API_VERSION@", provides = "EE3-API|util") +package com.pahimar.ee3.api.util; import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/src/main/java/com/pahimar/ee3/array/AlchemyArrayEE.java b/src/main/java/com/pahimar/ee3/array/AlchemyArrayEE.java index 7ea8a597..0f15d0db 100644 --- a/src/main/java/com/pahimar/ee3/array/AlchemyArrayEE.java +++ b/src/main/java/com/pahimar/ee3/array/AlchemyArrayEE.java @@ -3,10 +3,8 @@ package com.pahimar.ee3.array; import com.pahimar.ee3.api.array.AlchemyArray; import net.minecraft.util.ResourceLocation; -public abstract class AlchemyArrayEE extends AlchemyArray -{ - public AlchemyArrayEE(ResourceLocation texture, String unlocalizedName) - { +public abstract class AlchemyArrayEE extends AlchemyArray { + public AlchemyArrayEE(ResourceLocation texture, String unlocalizedName) { super(texture, unlocalizedName); } } diff --git a/src/main/java/com/pahimar/ee3/array/AlchemyArrayRegistry.java b/src/main/java/com/pahimar/ee3/array/AlchemyArrayRegistry.java index dbef679f..56f4ecfa 100644 --- a/src/main/java/com/pahimar/ee3/array/AlchemyArrayRegistry.java +++ b/src/main/java/com/pahimar/ee3/array/AlchemyArrayRegistry.java @@ -1,5 +1,8 @@ package com.pahimar.ee3.array; +import java.util.SortedSet; +import java.util.TreeSet; + import com.google.common.collect.ImmutableSortedSet; import com.pahimar.ee3.api.array.AlchemyArray; import com.pahimar.ee3.util.LoaderHelper; @@ -8,23 +11,16 @@ import cpw.mods.fml.common.Loader; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; -import java.util.SortedSet; -import java.util.TreeSet; - -public class AlchemyArrayRegistry -{ - public static final Marker ALCHEMY_ARRAY_MARKER = MarkerManager.getMarker("EE3_ALCHEMY_ARRAY", LogHelper.MOD_MARKER); +public class AlchemyArrayRegistry { + public static final Marker ALCHEMY_ARRAY_MARKER + = MarkerManager.getMarker("EE3_ALCHEMY_ARRAY", LogHelper.MOD_MARKER); private static AlchemyArrayRegistry alchemyArrayRegistry = null; private SortedSet registeredAlchemyArrays; - private AlchemyArrayRegistry() - { - } + private AlchemyArrayRegistry() {} - public static AlchemyArrayRegistry getInstance() - { - if (alchemyArrayRegistry == null) - { + public static AlchemyArrayRegistry getInstance() { + if (alchemyArrayRegistry == null) { alchemyArrayRegistry = new AlchemyArrayRegistry(); alchemyArrayRegistry.init(); } @@ -32,20 +28,16 @@ public class AlchemyArrayRegistry return alchemyArrayRegistry; } - private void init() - { + private void init() { registeredAlchemyArrays = new TreeSet(); } - public AlchemyArray getAlchemyArray(int index) - { - if (registeredAlchemyArrays != null) - { + public AlchemyArray getAlchemyArray(int index) { + if (registeredAlchemyArrays != null) { AlchemyArray[] alchemyArrays = new AlchemyArray[0]; alchemyArrays = registeredAlchemyArrays.toArray(alchemyArrays); - if (index < alchemyArrays.length) - { + if (index < alchemyArrays.length) { return alchemyArrays[index]; } } @@ -53,16 +45,19 @@ public class AlchemyArrayRegistry return null; } - public SortedSet getRegisteredAlchemyArrays() - { + public SortedSet getRegisteredAlchemyArrays() { return ImmutableSortedSet.copyOf(registeredAlchemyArrays); } - public boolean registerAlchemyArray(AlchemyArray alchemyArray) - { - if (!registeredAlchemyArrays.contains(alchemyArray)) - { - LogHelper.trace(ALCHEMY_ARRAY_MARKER, "[{}]: Mod with ID '{}' added alchemy array {}", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), alchemyArray); + public boolean registerAlchemyArray(AlchemyArray alchemyArray) { + if (!registeredAlchemyArrays.contains(alchemyArray)) { + LogHelper.trace( + ALCHEMY_ARRAY_MARKER, + "[{}]: Mod with ID '{}' added alchemy array {}", + LoaderHelper.getLoaderState(), + Loader.instance().activeModContainer().getModId(), + alchemyArray + ); return registeredAlchemyArrays.add(alchemyArray); } diff --git a/src/main/java/com/pahimar/ee3/array/AlchemyArrayTransmutation.java b/src/main/java/com/pahimar/ee3/array/AlchemyArrayTransmutation.java index 8173814d..ddba7a1f 100644 --- a/src/main/java/com/pahimar/ee3/array/AlchemyArrayTransmutation.java +++ b/src/main/java/com/pahimar/ee3/array/AlchemyArrayTransmutation.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.array; +import java.util.Random; + import com.pahimar.ee3.init.ModBlocks; import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.reference.Particles; @@ -21,60 +23,145 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Random; - -public class AlchemyArrayTransmutation extends AlchemyArrayEE implements IInventory -{ +public class AlchemyArrayTransmutation extends AlchemyArrayEE implements IInventory { private ItemStack[] inventory = new ItemStack[25]; - public AlchemyArrayTransmutation() - { - super(Textures.AlchemyArray.TRANSMUTATION_ALCHEMY_ARRAY, Names.AlchemyArrays.TRANSMUTATION_ALCHEMY_ARRAY); + public AlchemyArrayTransmutation() { + super( + Textures.AlchemyArray.TRANSMUTATION_ALCHEMY_ARRAY, + Names.AlchemyArrays.TRANSMUTATION_ALCHEMY_ARRAY + ); } @Override - public void onEntityCollidedWithArray(World world, int eventX, int eventY, int eventZ, int arrayX, int arrayY, int arrayZ, Entity entity) - { + public void onEntityCollidedWithArray( + World world, + int eventX, + int eventY, + int eventZ, + int arrayX, + int arrayY, + int arrayZ, + Entity entity + ) { LogHelper.info(entity); } @Override - public void onArrayActivated(World world, int eventX, int eventY, int eventZ, int arrayX, int arrayY, int arrayZ, EntityPlayer entityPlayer, int sideHit, float hitX, float hitY, float hitZ) - { + public void onArrayActivated( + World world, + int eventX, + int eventY, + int eventZ, + int arrayX, + int arrayY, + int arrayZ, + EntityPlayer entityPlayer, + int sideHit, + float hitX, + float hitY, + float hitZ + ) { // TODO Come back to this later to resolve inventory issues // if (!entityPlayer.isSneaking()) // { - // entityPlayer.openGui(EquivalentExchange3.instance, GUIs.TRANSMUTATION_ARRAY.ordinal(), world, arrayX, arrayY, arrayZ); + // entityPlayer.openGui(EquivalentExchange3.instance, + // GUIs.TRANSMUTATION_ARRAY.ordinal(), world, arrayX, arrayY, arrayZ); // return; // } - if (!world.isRemote && entityPlayer.isSneaking()) - { + if (!world.isRemote && entityPlayer.isSneaking()) { boolean successFlag = false; - if (world.getTileEntity(arrayX, arrayY, arrayZ) instanceof TileEntityAlchemyArray) - { - TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(arrayX, arrayY, arrayZ); + if (world.getTileEntity(arrayX, arrayY, arrayZ) + instanceof TileEntityAlchemyArray) { + TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray + ) world.getTileEntity(arrayX, arrayY, arrayZ); // First, see if we can make a Transmutation Tablet - if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.UP && tileEntityAlchemyArray.getSize() == 2 && areBlocksValidForTransmutationTablet(world, arrayX, arrayY, arrayZ)) - { - world.setBlock(arrayX - 1, arrayY - 1, arrayZ - 1, ModBlocks.ashInfusedStoneSlab, 1, 3); - world.setBlock(arrayX, arrayY - 1, arrayZ - 1, ModBlocks.ashInfusedStoneSlab, 2, 3); - world.setBlock(arrayX + 1, arrayY - 1, arrayZ - 1, ModBlocks.ashInfusedStoneSlab, 3, 3); + if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.UP + && tileEntityAlchemyArray.getSize() == 2 + && areBlocksValidForTransmutationTablet( + world, arrayX, arrayY, arrayZ + )) { + world.setBlock( + arrayX - 1, + arrayY - 1, + arrayZ - 1, + ModBlocks.ashInfusedStoneSlab, + 1, + 3 + ); + world.setBlock( + arrayX, + arrayY - 1, + arrayZ - 1, + ModBlocks.ashInfusedStoneSlab, + 2, + 3 + ); + world.setBlock( + arrayX + 1, + arrayY - 1, + arrayZ - 1, + ModBlocks.ashInfusedStoneSlab, + 3, + 3 + ); - world.setBlock(arrayX - 1, arrayY - 1, arrayZ, ModBlocks.ashInfusedStoneSlab, 4, 3); - world.setBlock(arrayX, arrayY - 1, arrayZ, ModBlocks.transmutationTablet, 0, 3); - world.setBlock(arrayX + 1, arrayY - 1, arrayZ, ModBlocks.ashInfusedStoneSlab, 5, 3); + world.setBlock( + arrayX - 1, + arrayY - 1, + arrayZ, + ModBlocks.ashInfusedStoneSlab, + 4, + 3 + ); + world.setBlock( + arrayX, arrayY - 1, arrayZ, ModBlocks.transmutationTablet, 0, 3 + ); + world.setBlock( + arrayX + 1, + arrayY - 1, + arrayZ, + ModBlocks.ashInfusedStoneSlab, + 5, + 3 + ); - world.setBlock(arrayX - 1, arrayY - 1, arrayZ + 1, ModBlocks.ashInfusedStoneSlab, 6, 3); - world.setBlock(arrayX, arrayY - 1, arrayZ + 1, ModBlocks.ashInfusedStoneSlab, 7, 3); - world.setBlock(arrayX + 1, arrayY - 1, arrayZ + 1, ModBlocks.ashInfusedStoneSlab, 8, 3); + world.setBlock( + arrayX - 1, + arrayY - 1, + arrayZ + 1, + ModBlocks.ashInfusedStoneSlab, + 6, + 3 + ); + world.setBlock( + arrayX, + arrayY - 1, + arrayZ + 1, + ModBlocks.ashInfusedStoneSlab, + 7, + 3 + ); + world.setBlock( + arrayX + 1, + arrayY - 1, + arrayZ + 1, + ModBlocks.ashInfusedStoneSlab, + 8, + 3 + ); - if (world.getTileEntity(arrayX, arrayY - 1, arrayZ) instanceof TileEntityTransmutationTablet) - { - ((TileEntityTransmutationTablet) world.getTileEntity(arrayX, arrayY - 1, arrayZ)).setOrientation(tileEntityAlchemyArray.getOrientation()); - ((TileEntityTransmutationTablet) world.getTileEntity(arrayX, arrayY - 1, arrayZ)).setRotation(tileEntityAlchemyArray.getRotation()); + if (world.getTileEntity(arrayX, arrayY - 1, arrayZ) + instanceof TileEntityTransmutationTablet) { + ((TileEntityTransmutationTablet + ) world.getTileEntity(arrayX, arrayY - 1, arrayZ)) + .setOrientation(tileEntityAlchemyArray.getOrientation()); + ((TileEntityTransmutationTablet + ) world.getTileEntity(arrayX, arrayY - 1, arrayZ)) + .setRotation(tileEntityAlchemyArray.getRotation()); } ejectInventory(world, arrayX, arrayY, arrayZ); @@ -82,31 +169,56 @@ public class AlchemyArrayTransmutation extends AlchemyArrayEE implements IInvent successFlag = true; } - if (successFlag) - { - CommonSoundHelper.playSoundAtLocation(world.provider.dimensionId, arrayX, arrayY, arrayZ, Sounds.TRANSMUTE, 1f, 1f); + if (successFlag) { + CommonSoundHelper.playSoundAtLocation( + world.provider.dimensionId, + arrayX, + arrayY, + arrayZ, + Sounds.TRANSMUTE, + 1f, + 1f + ); - if (tileEntityAlchemyArray.getSize() == 1) - { - CommonParticleHelper.spawnParticleAtLocation(Particles.LARGE_SMOKE, world.provider.dimensionId, arrayX + 0.5d, arrayY, arrayZ + 0.5d, 0d, 0.1d, 0d); - } - else if (tileEntityAlchemyArray.getSize() == 2) - { - for (int i = -1; i <= 1; i++) - { - for (int j = -1; j <= 1; j++) - { - CommonParticleHelper.spawnParticleAtLocation(Particles.LARGE_SMOKE, world.provider.dimensionId, arrayX + i + 0.5d, arrayY, arrayZ + j + 0.5d, 0d, 0.1d, 0d); + if (tileEntityAlchemyArray.getSize() == 1) { + CommonParticleHelper.spawnParticleAtLocation( + Particles.LARGE_SMOKE, + world.provider.dimensionId, + arrayX + 0.5d, + arrayY, + arrayZ + 0.5d, + 0d, + 0.1d, + 0d + ); + } else if (tileEntityAlchemyArray.getSize() == 2) { + for (int i = -1; i <= 1; i++) { + for (int j = -1; j <= 1; j++) { + CommonParticleHelper.spawnParticleAtLocation( + Particles.LARGE_SMOKE, + world.provider.dimensionId, + arrayX + i + 0.5d, + arrayY, + arrayZ + j + 0.5d, + 0d, + 0.1d, + 0d + ); } } - } - else if (tileEntityAlchemyArray.getSize() == 3) - { - for (int i = -2; i <= 2; i++) - { - for (int j = -2; j <= 2; j++) - { - CommonParticleHelper.spawnParticleAtLocation(Particles.LARGE_SMOKE, world.provider.dimensionId, arrayX + i + 0.5d, arrayY, arrayZ + j + 0.5d, 0d, 0.1d, 0d); + } else if (tileEntityAlchemyArray.getSize() == 3) { + for (int i = -2; i <= 2; i++) { + for (int j = -2; j <= 2; j++) { + CommonParticleHelper.spawnParticleAtLocation( + Particles.LARGE_SMOKE, + world.provider.dimensionId, + arrayX + i + 0.5d, + arrayY, + arrayZ + j + 0.5d, + 0d, + 0.1d, + 0d + ); } } } @@ -115,16 +227,15 @@ public class AlchemyArrayTransmutation extends AlchemyArrayEE implements IInvent } } - private boolean areBlocksValidForTransmutationTablet(World world, int arrayX, int arrayY, int arrayZ) - { + private boolean areBlocksValidForTransmutationTablet( + World world, int arrayX, int arrayY, int arrayZ + ) { boolean areBlocksValid = true; - for (int i = -1; i <= 1; i++) - { - for (int j = -1; j <= 1; j++) - { - if (world.getBlock(arrayX + i, arrayY - 1, arrayZ + j) != ModBlocks.ashInfusedStone) - { + for (int i = -1; i <= 1; i++) { + for (int j = -1; j <= 1; j++) { + if (world.getBlock(arrayX + i, arrayY - 1, arrayZ + j) + != ModBlocks.ashInfusedStone) { areBlocksValid = false; } } @@ -134,16 +245,13 @@ public class AlchemyArrayTransmutation extends AlchemyArrayEE implements IInvent } @Override - public int getSizeInventory() - { + public int getSizeInventory() { return inventory.length; } @Override - public ItemStack getStackInSlot(int slotIndex) - { - if (slotIndex < getSizeInventory()) - { + public ItemStack getStackInSlot(int slotIndex) { + if (slotIndex < getSizeInventory()) { return inventory[slotIndex]; } @@ -151,20 +259,14 @@ public class AlchemyArrayTransmutation extends AlchemyArrayEE implements IInvent } @Override - public ItemStack decrStackSize(int slotIndex, int decrementAmount) - { + public ItemStack decrStackSize(int slotIndex, int decrementAmount) { ItemStack itemStack = getStackInSlot(slotIndex); - if (itemStack != null) - { - if (itemStack.stackSize <= decrementAmount) - { + if (itemStack != null) { + if (itemStack.stackSize <= decrementAmount) { setInventorySlotContents(slotIndex, null); - } - else - { + } else { itemStack = itemStack.splitStack(decrementAmount); - if (itemStack.stackSize == 0) - { + if (itemStack.stackSize == 0) { setInventorySlotContents(slotIndex, null); } } @@ -174,76 +276,62 @@ public class AlchemyArrayTransmutation extends AlchemyArrayEE implements IInvent } @Override - public ItemStack getStackInSlotOnClosing(int slotIndex) - { + public ItemStack getStackInSlotOnClosing(int slotIndex) { ItemStack itemStack = getStackInSlot(slotIndex); - if (itemStack != null) - { + if (itemStack != null) { setInventorySlotContents(slotIndex, null); } return itemStack; } @Override - public void setInventorySlotContents(int slotIndex, ItemStack itemStack) - { - if (slotIndex < getSizeInventory()) - { + public void setInventorySlotContents(int slotIndex, ItemStack itemStack) { + if (slotIndex < getSizeInventory()) { inventory[slotIndex] = itemStack; - if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) - { + if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) { itemStack.stackSize = getInventoryStackLimit(); } } } @Override - public String getInventoryName() - { + public String getInventoryName() { return Names.AlchemyArrays.TRANSMUTATION_ALCHEMY_ARRAY; } @Override - public boolean hasCustomInventoryName() - { + public boolean hasCustomInventoryName() { return false; } @Override - public int getInventoryStackLimit() - { + public int getInventoryStackLimit() { return 1; } @Override - public void markDirty() - { + public void markDirty() { // NOOP } @Override - public boolean isUseableByPlayer(EntityPlayer entityPlayer) - { + public boolean isUseableByPlayer(EntityPlayer entityPlayer) { return true; } @Override - public void openInventory() - { + public void openInventory() { // NOOP } @Override - public void closeInventory() - { + public void closeInventory() { // NOOP } @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) - { - if (slotIndex < getSizeInventory()) - { + public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { + if (slotIndex < getSizeInventory()) { return itemStack.getItem() instanceof ItemBlock; } @@ -251,35 +339,29 @@ public class AlchemyArrayTransmutation extends AlchemyArrayEE implements IInvent } @Override - public void readFromNBT(NBTTagCompound nbtTagCompound) - { + public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = nbtTagCompound.getTagList(Names.NBT.ITEMS, 10); inventory = new ItemStack[this.getSizeInventory()]; - for (int i = 0; i < tagList.tagCount(); ++i) - { + for (int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slotIndex = tagCompound.getByte("Slot"); - if (slotIndex >= 0 && slotIndex < inventory.length) - { + if (slotIndex >= 0 && slotIndex < inventory.length) { inventory[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); } } } @Override - public void writeToNBT(NBTTagCompound nbtTagCompound) - { + public void writeToNBT(NBTTagCompound nbtTagCompound) { super.writeToNBT(nbtTagCompound); // Write the ItemStacks in the inventory to NBT NBTTagList tagList = new NBTTagList(); - for (int currentIndex = 0; currentIndex < getSizeInventory(); ++currentIndex) - { - if (getStackInSlot(currentIndex) != null) - { + for (int currentIndex = 0; currentIndex < getSizeInventory(); ++currentIndex) { + if (getStackInSlot(currentIndex) != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte) currentIndex); getStackInSlot(currentIndex).writeToNBT(tagCompound); @@ -289,25 +371,24 @@ public class AlchemyArrayTransmutation extends AlchemyArrayEE implements IInvent nbtTagCompound.setTag(Names.NBT.ITEMS, tagList); } - protected void ejectInventory(World world, int x, int y, int z) - { - for (int i = 0; i < getSizeInventory(); i++) - { + protected void ejectInventory(World world, int x, int y, int z) { + for (int i = 0; i < getSizeInventory(); i++) { ItemStack itemStack = getStackInSlot(i); - if (itemStack != null && itemStack.stackSize > 0) - { + if (itemStack != null && itemStack.stackSize > 0) { Random rand = new Random(); float dX = rand.nextFloat() * 0.8F + 0.1F; float dY = rand.nextFloat() * 0.8F + 0.1F; float dZ = rand.nextFloat() * 0.8F + 0.1F; - EntityItem entityItem = new EntityItem(world, x + dX, y + dY, z + dZ, itemStack.copy()); + EntityItem entityItem + = new EntityItem(world, x + dX, y + dY, z + dZ, itemStack.copy()); - if (itemStack.hasTagCompound()) - { - entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy()); + if (itemStack.hasTagCompound()) { + entityItem.getEntityItem().setTagCompound( + (NBTTagCompound) itemStack.getTagCompound().copy() + ); } float factor = 0.05F; diff --git a/src/main/java/com/pahimar/ee3/blacklist/BlacklistRegistry.java b/src/main/java/com/pahimar/ee3/blacklist/BlacklistRegistry.java index 3dc7001d..6fb596fb 100644 --- a/src/main/java/com/pahimar/ee3/blacklist/BlacklistRegistry.java +++ b/src/main/java/com/pahimar/ee3/blacklist/BlacklistRegistry.java @@ -1,5 +1,15 @@ package com.pahimar.ee3.blacklist; +import static com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy.Blacklist; +import static com.pahimar.ee3.api.event.BlacklistEvent.*; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; + import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; import com.pahimar.ee3.exchange.OreStack; import com.pahimar.ee3.exchange.WrappedStack; @@ -13,28 +23,24 @@ import net.minecraftforge.common.MinecraftForge; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; -import java.io.File; -import java.util.Collection; -import java.util.Collections; -import java.util.Set; -import java.util.TreeSet; -import java.util.stream.Collectors; - -import static com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy.Blacklist; -import static com.pahimar.ee3.api.event.BlacklistEvent.*; - // TODO Logging public class BlacklistRegistry { - public static final BlacklistRegistry INSTANCE = new BlacklistRegistry(); - private static final Marker BLACKLIST_MARKER = MarkerManager.getMarker("EE3_BLACKLIST", LogHelper.MOD_MARKER); - private static final Marker KNOWLEDGE_MARKER = MarkerManager.getMarker("EE3_KNOWLEDGE", BLACKLIST_MARKER); - private static final Marker KNOWLEDGE_BLACKLIST_MARKER = MarkerManager.getMarker("EE3_KNOWLEDGE_BLACKLIST", KNOWLEDGE_MARKER); - private static final Marker KNOWLEDGE_WHITELIST_MARKER = MarkerManager.getMarker("EE3_KNOWLEDGE_WHITELIST", KNOWLEDGE_MARKER); - private static final Marker EXCHANGE_MARKER = MarkerManager.getMarker("EE3_EXCHANGE", BLACKLIST_MARKER); - private static final Marker EXCHANGE_BLACKLIST_MARKER = MarkerManager.getMarker("EE3_EXCHANGE_BLACKLIST", EXCHANGE_MARKER); - private static final Marker EXCHANGE_WHITELIST_MARKER = MarkerManager.getMarker("EE3_EXCHANGE_WHITELIST", EXCHANGE_MARKER); + private static final Marker BLACKLIST_MARKER + = MarkerManager.getMarker("EE3_BLACKLIST", LogHelper.MOD_MARKER); + private static final Marker KNOWLEDGE_MARKER + = MarkerManager.getMarker("EE3_KNOWLEDGE", BLACKLIST_MARKER); + private static final Marker KNOWLEDGE_BLACKLIST_MARKER + = MarkerManager.getMarker("EE3_KNOWLEDGE_BLACKLIST", KNOWLEDGE_MARKER); + private static final Marker KNOWLEDGE_WHITELIST_MARKER + = MarkerManager.getMarker("EE3_KNOWLEDGE_WHITELIST", KNOWLEDGE_MARKER); + private static final Marker EXCHANGE_MARKER + = MarkerManager.getMarker("EE3_EXCHANGE", BLACKLIST_MARKER); + private static final Marker EXCHANGE_BLACKLIST_MARKER + = MarkerManager.getMarker("EE3_EXCHANGE_BLACKLIST", EXCHANGE_MARKER); + private static final Marker EXCHANGE_WHITELIST_MARKER + = MarkerManager.getMarker("EE3_EXCHANGE_WHITELIST", EXCHANGE_MARKER); private final Set knowledgeBlacklist, exchangeBlacklist; public static File knowledgeBlacklistFile, exchangeBlacklistFile; @@ -44,7 +50,6 @@ public class BlacklistRegistry { * TODO Finish JavaDoc */ private BlacklistRegistry() { - knowledgeBlacklist = new TreeSet<>(); exchangeBlacklist = new TreeSet<>(); shouldSave = true; @@ -75,24 +80,22 @@ public class BlacklistRegistry { * @return */ public boolean isLearnable(Object object) { - if (WrappedStack.canBeWrapped(object)) { - WrappedStack wrappedObject = WrappedStack.wrap(object, 1); if (object instanceof ItemStack && ((ItemStack) object).isItemDamaged()) { return false; - } - else { + } else { if (EnergyValueRegistryProxy.hasEnergyValue(wrappedObject)) { - if (knowledgeBlacklist.contains(wrappedObject)) { return false; - } - else if (object instanceof ItemStack){ - Collection oreNames = OreDictionaryHelper.getOreNames((ItemStack) object); + } else if (object instanceof ItemStack) { + Collection oreNames + = OreDictionaryHelper.getOreNames((ItemStack) object); for (String oreName : oreNames) { - if (knowledgeBlacklist.contains(WrappedStack.wrap(new OreStack(oreName)))) { + if (knowledgeBlacklist.contains( + WrappedStack.wrap(new OreStack(oreName)) + )) { return false; } } @@ -113,20 +116,19 @@ public class BlacklistRegistry { * @return */ public boolean isExchangeable(Object object) { - if (WrappedStack.canBeWrapped(object)) { - WrappedStack wrappedObject = WrappedStack.wrap(object, 1); if (EnergyValueRegistryProxy.hasEnergyValue(wrappedObject)) { - if (exchangeBlacklist.contains(wrappedObject)) { return false; - } - else if (object instanceof ItemStack){ - Collection oreNames = OreDictionaryHelper.getOreNames((ItemStack) object); + } else if (object instanceof ItemStack) { + Collection oreNames + = OreDictionaryHelper.getOreNames((ItemStack) object); for (String oreName : oreNames) { - if (exchangeBlacklist.contains(WrappedStack.wrap(new OreStack(oreName)))) { + if (exchangeBlacklist.contains( + WrappedStack.wrap(new OreStack(oreName)) + )) { return false; } } @@ -146,21 +148,34 @@ public class BlacklistRegistry { * @param blacklist */ public void addToBlacklist(Object object, Blacklist blacklist) { - if (WrappedStack.canBeWrapped(object)) { - WrappedStack wrappedStack = WrappedStack.wrap(object, 1); if (blacklist == Blacklist.KNOWLEDGE) { - if (wrappedStack != null && !MinecraftForge.EVENT_BUS.post(new KnowledgeBlacklistEvent(object))) { - LogHelper.trace(KNOWLEDGE_BLACKLIST_MARKER, "[{}] Mod with ID '{}' added object {} to the player knowledge blacklist", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack); + if (wrappedStack != null + && !MinecraftForge.EVENT_BUS.post(new KnowledgeBlacklistEvent(object) + )) { + LogHelper.trace( + KNOWLEDGE_BLACKLIST_MARKER, + "[{}] Mod with ID '{}' added object {} to the player knowledge blacklist", + LoaderHelper.getLoaderState(), + Loader.instance().activeModContainer().getModId(), + wrappedStack + ); knowledgeBlacklist.add(WrappedStack.wrap(object, 1)); save(blacklist); } - } - else if (blacklist == Blacklist.EXCHANGE) { - if (wrappedStack != null && !MinecraftForge.EVENT_BUS.post(new ExchangeBlacklistEvent(object))) { - LogHelper.trace(EXCHANGE_BLACKLIST_MARKER, "[{}] Mod with ID '{}' added object {} to the exchange blacklist", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack); + } else if (blacklist == Blacklist.EXCHANGE) { + if (wrappedStack != null + && !MinecraftForge.EVENT_BUS.post(new ExchangeBlacklistEvent(object) + )) { + LogHelper.trace( + EXCHANGE_BLACKLIST_MARKER, + "[{}] Mod with ID '{}' added object {} to the exchange blacklist", + LoaderHelper.getLoaderState(), + Loader.instance().activeModContainer().getModId(), + wrappedStack + ); exchangeBlacklist.add(WrappedStack.wrap(object, 1)); save(blacklist); } @@ -175,21 +190,34 @@ public class BlacklistRegistry { * @param blacklist */ public void removeFromBlacklist(Object object, Blacklist blacklist) { - if (WrappedStack.canBeWrapped(object)) { - WrappedStack wrappedStack = WrappedStack.wrap(object, 1); if (blacklist == Blacklist.KNOWLEDGE) { - if (wrappedStack != null && !MinecraftForge.EVENT_BUS.post(new KnowledgeWhitelistEvent(object))) { - LogHelper.trace(KNOWLEDGE_WHITELIST_MARKER, "[{}] Mod with ID '{}' removed object {} from the player knowledge blacklist", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack); + if (wrappedStack != null + && !MinecraftForge.EVENT_BUS.post(new KnowledgeWhitelistEvent(object) + )) { + LogHelper.trace( + KNOWLEDGE_WHITELIST_MARKER, + "[{}] Mod with ID '{}' removed object {} from the player knowledge blacklist", + LoaderHelper.getLoaderState(), + Loader.instance().activeModContainer().getModId(), + wrappedStack + ); knowledgeBlacklist.remove(wrappedStack); save(blacklist); } - } - else if (blacklist == Blacklist.EXCHANGE) { - if (wrappedStack != null && !MinecraftForge.EVENT_BUS.post(new ExchangeWhitelistEvent(object))) { - LogHelper.trace(EXCHANGE_WHITELIST_MARKER, "[{}] Mod with ID '{}' removed object {} from the exchange blacklist", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedStack); + } else if (blacklist == Blacklist.EXCHANGE) { + if (wrappedStack != null + && !MinecraftForge.EVENT_BUS.post(new ExchangeWhitelistEvent(object) + )) { + LogHelper.trace( + EXCHANGE_WHITELIST_MARKER, + "[{}] Mod with ID '{}' removed object {} from the exchange blacklist", + LoaderHelper.getLoaderState(), + Loader.instance().activeModContainer().getModId(), + wrappedStack + ); exchangeBlacklist.remove(wrappedStack); save(blacklist); } @@ -210,17 +238,22 @@ public class BlacklistRegistry { * TODO Finish JavaDoc */ public void load() { - if (knowledgeBlacklistFile != null) { - Set knowledgeBlacklistSet = SerializationHelper.readSetFromFile(knowledgeBlacklistFile); + Set knowledgeBlacklistSet + = SerializationHelper.readSetFromFile(knowledgeBlacklistFile); knowledgeBlacklist.clear(); - knowledgeBlacklist.addAll(knowledgeBlacklistSet.stream().filter(wrappedStack -> wrappedStack != null).collect(Collectors.toList())); + knowledgeBlacklist.addAll(knowledgeBlacklistSet.stream() + .filter(wrappedStack -> wrappedStack != null) + .collect(Collectors.toList())); } if (exchangeBlacklistFile != null) { - Set exchangeBlacklistSet = SerializationHelper.readSetFromFile(exchangeBlacklistFile); + Set exchangeBlacklistSet + = SerializationHelper.readSetFromFile(exchangeBlacklistFile); exchangeBlacklist.clear(); - exchangeBlacklist.addAll(exchangeBlacklistSet.stream().filter(wrappedStack -> wrappedStack != null).collect(Collectors.toList())); + exchangeBlacklist.addAll(exchangeBlacklistSet.stream() + .filter(wrappedStack -> wrappedStack != null) + .collect(Collectors.toList())); } } @@ -231,20 +264,29 @@ public class BlacklistRegistry { * @param blacklist */ public void load(Set blacklistSet, Blacklist blacklist) { - if (blacklist != null && blacklistSet != null) { - setShouldSave(false); if (blacklist == Blacklist.KNOWLEDGE) { - LogHelper.info("Received {} player knowledge blacklist entries from server", blacklistSet.size()); + LogHelper.info( + "Received {} player knowledge blacklist entries from server", + blacklistSet.size() + ); knowledgeBlacklist.clear(); - knowledgeBlacklist.addAll(blacklistSet.stream().filter(wrappedStack -> wrappedStack != null).collect(Collectors.toList())); - } - else if (blacklist == Blacklist.EXCHANGE) { - LogHelper.info("Received {} exchange blacklist entries from server", blacklistSet.size()); + knowledgeBlacklist.addAll( + blacklistSet.stream() + .filter(wrappedStack -> wrappedStack != null) + .collect(Collectors.toList()) + ); + } else if (blacklist == Blacklist.EXCHANGE) { + LogHelper.info( + "Received {} exchange blacklist entries from server", + blacklistSet.size() + ); exchangeBlacklist.clear(); - exchangeBlacklist.addAll(blacklistSet.stream().filter(wrappedStack -> wrappedStack != null).collect(Collectors.toList())); + exchangeBlacklist.addAll(blacklistSet.stream() + .filter(wrappedStack -> wrappedStack != null) + .collect(Collectors.toList())); } } } @@ -255,13 +297,17 @@ public class BlacklistRegistry { * @param blacklist */ public void save(Blacklist blacklist) { - if (shouldSave) { if (blacklist == Blacklist.KNOWLEDGE && knowledgeBlacklistFile != null) { - SerializationHelper.writeJsonFile(knowledgeBlacklistFile, SerializationHelper.GSON.toJson(knowledgeBlacklist)); - } - else if (blacklist == Blacklist.EXCHANGE && exchangeBlacklistFile != null) { - SerializationHelper.writeJsonFile(exchangeBlacklistFile, SerializationHelper.GSON.toJson(exchangeBlacklist)); + SerializationHelper.writeJsonFile( + knowledgeBlacklistFile, + SerializationHelper.GSON.toJson(knowledgeBlacklist) + ); + } else if (blacklist == Blacklist.EXCHANGE && exchangeBlacklistFile != null) { + SerializationHelper.writeJsonFile( + exchangeBlacklistFile, + SerializationHelper.GSON.toJson(exchangeBlacklist) + ); } } } @@ -270,11 +316,20 @@ public class BlacklistRegistry { * TODO Finish JavaDoc */ public void saveAll() { - - if (shouldSave && knowledgeBlacklistFile != null && exchangeBlacklistFile != null) { - LogHelper.trace(BLACKLIST_MARKER, "Saving all blacklists to disk", exchangeBlacklistFile.getAbsolutePath()); - SerializationHelper.writeJsonFile(knowledgeBlacklistFile, SerializationHelper.GSON.toJson(knowledgeBlacklist)); - SerializationHelper.writeJsonFile(exchangeBlacklistFile, SerializationHelper.GSON.toJson(exchangeBlacklist)); + if (shouldSave && knowledgeBlacklistFile != null + && exchangeBlacklistFile != null) { + LogHelper.trace( + BLACKLIST_MARKER, + "Saving all blacklists to disk", + exchangeBlacklistFile.getAbsolutePath() + ); + SerializationHelper.writeJsonFile( + knowledgeBlacklistFile, + SerializationHelper.GSON.toJson(knowledgeBlacklist) + ); + SerializationHelper.writeJsonFile( + exchangeBlacklistFile, SerializationHelper.GSON.toJson(exchangeBlacklist) + ); } } } diff --git a/src/main/java/com/pahimar/ee3/block/BlockAlchemicalChest.java b/src/main/java/com/pahimar/ee3/block/BlockAlchemicalChest.java index cd3883a9..ea299bf7 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockAlchemicalChest.java +++ b/src/main/java/com/pahimar/ee3/block/BlockAlchemicalChest.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.block; +import java.util.List; + import com.pahimar.ee3.EquivalentExchange3; import com.pahimar.ee3.reference.GUIs; import com.pahimar.ee3.reference.Names; @@ -19,12 +21,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.List; - -public class BlockAlchemicalChest extends BlockTileEntityEE -{ - public BlockAlchemicalChest() - { +public class BlockAlchemicalChest extends BlockTileEntityEE { + public BlockAlchemicalChest() { super(Material.wood); this.setHardness(2.5f); this.setBlockName(Names.Blocks.ALCHEMICAL_CHEST); @@ -32,18 +30,12 @@ public class BlockAlchemicalChest extends BlockTileEntityEE } @Override - public TileEntity createNewTileEntity(World world, int metaData) - { - if (metaData == 0) - { + public TileEntity createNewTileEntity(World world, int metaData) { + if (metaData == 0) { return new TileEntityAlchemicalChestSmall(); - } - else if (metaData == 1) - { + } else if (metaData == 1) { return new TileEntityAlchemicalChestMedium(); - } - else if (metaData == 2) - { + } else if (metaData == 2) { return new TileEntityAlchemicalChestLarge(); } @@ -51,41 +43,51 @@ public class BlockAlchemicalChest extends BlockTileEntityEE } @Override - public int damageDropped(int metaData) - { + public int damageDropped(int metaData) { return metaData; } @Override - public boolean renderAsNormalBlock() - { + public boolean renderAsNormalBlock() { return false; } @Override - public boolean isOpaqueCube() - { + public boolean isOpaqueCube() { return false; } @Override - public int getRenderType() - { + public int getRenderType() { return RenderIds.alchemicalChest; } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) - { - if ((player.isSneaking() && player.getCurrentEquippedItem() != null) || world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) - { + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer player, + int par6, + float par7, + float par8, + float par9 + ) { + if ((player.isSneaking() && player.getCurrentEquippedItem() != null) + || world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) { return true; - } - else - { - if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityAlchemicalChest) - { - player.openGui(EquivalentExchange3.instance, GUIs.ALCHEMICAL_CHEST.ordinal(), world, x, y, z); + } else { + if (!world.isRemote + && world.getTileEntity(x, y, z) instanceof TileEntityAlchemicalChest) { + player.openGui( + EquivalentExchange3.instance, + GUIs.ALCHEMICAL_CHEST.ordinal(), + world, + x, + y, + z + ); } return true; @@ -94,10 +96,8 @@ public class BlockAlchemicalChest extends BlockTileEntityEE @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) - { - for (int meta = 0; meta < 3; meta++) - { + public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) { + for (int meta = 0; meta < 3; meta++) { list.add(new ItemStack(item, 1, meta)); } } diff --git a/src/main/java/com/pahimar/ee3/block/BlockAlchemicalFuel.java b/src/main/java/com/pahimar/ee3/block/BlockAlchemicalFuel.java index 2da3d164..f70aa2c0 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockAlchemicalFuel.java +++ b/src/main/java/com/pahimar/ee3/block/BlockAlchemicalFuel.java @@ -1,5 +1,8 @@ package com.pahimar.ee3.block; +import java.util.List; +import java.util.Random; + import com.pahimar.ee3.reference.Names; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -11,16 +14,11 @@ import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraftforge.common.util.ForgeDirection; -import java.util.List; -import java.util.Random; - -public class BlockAlchemicalFuel extends BlockEE -{ +public class BlockAlchemicalFuel extends BlockEE { @SideOnly(Side.CLIENT) private IIcon[] blockTop, blockSide; - public BlockAlchemicalFuel() - { + public BlockAlchemicalFuel() { super(); this.setBlockName(Names.Blocks.ALCHEMICAL_FUEL); this.setHardness(5.0f); @@ -28,53 +26,54 @@ public class BlockAlchemicalFuel extends BlockEE } @Override - public Item getItemDropped(int par1, Random random, int par2) - { + public Item getItemDropped(int par1, Random random, int par2) { return Item.getItemFromBlock(this); } @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) - { - for (int meta = 0; meta < Names.Items.ALCHEMICAL_FUEL_SUBTYPES.length; meta++) - { + public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) { + for (int meta = 0; meta < Names.Items.ALCHEMICAL_FUEL_SUBTYPES.length; meta++) { list.add(new ItemStack(item, 1, meta)); } } @Override - public int damageDropped(int metaData) - { + public int damageDropped(int metaData) { return metaData; } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) - { + public void registerBlockIcons(IIconRegister iconRegister) { this.blockTop = new IIcon[Names.Items.ALCHEMICAL_FUEL_SUBTYPES.length]; this.blockSide = new IIcon[Names.Items.ALCHEMICAL_FUEL_SUBTYPES.length]; - for (int i = 0; i < Names.Items.ALCHEMICAL_FUEL_SUBTYPES.length; i++) - { - blockTop[i] = iconRegister.registerIcon(String.format("%s.%s_top", getUnwrappedUnlocalizedName(this.getUnlocalizedName()), Names.Items.ALCHEMICAL_FUEL_SUBTYPES[i])); - blockSide[i] = iconRegister.registerIcon(String.format("%s.%s_side", getUnwrappedUnlocalizedName(this.getUnlocalizedName()), Names.Items.ALCHEMICAL_FUEL_SUBTYPES[i])); + for (int i = 0; i < Names.Items.ALCHEMICAL_FUEL_SUBTYPES.length; i++) { + blockTop[i] = iconRegister.registerIcon(String.format( + "%s.%s_top", + getUnwrappedUnlocalizedName(this.getUnlocalizedName()), + Names.Items.ALCHEMICAL_FUEL_SUBTYPES[i] + )); + blockSide[i] = iconRegister.registerIcon(String.format( + "%s.%s_side", + getUnwrappedUnlocalizedName(this.getUnlocalizedName()), + Names.Items.ALCHEMICAL_FUEL_SUBTYPES[i] + )); } } @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metaData) - { - metaData = MathHelper.clamp_int(metaData, 0, Names.Items.ALCHEMICAL_FUEL_SUBTYPES.length - 1); + public IIcon getIcon(int side, int metaData) { + metaData = MathHelper.clamp_int( + metaData, 0, Names.Items.ALCHEMICAL_FUEL_SUBTYPES.length - 1 + ); - if (ForgeDirection.getOrientation(side) == ForgeDirection.UP || ForgeDirection.getOrientation(side) == ForgeDirection.DOWN) - { + if (ForgeDirection.getOrientation(side) == ForgeDirection.UP + || ForgeDirection.getOrientation(side) == ForgeDirection.DOWN) { return blockTop[metaData]; - } - else - { + } else { return blockSide[metaData]; } } diff --git a/src/main/java/com/pahimar/ee3/block/BlockAlchemyArray.java b/src/main/java/com/pahimar/ee3/block/BlockAlchemyArray.java index c706221d..6a0316f6 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockAlchemyArray.java +++ b/src/main/java/com/pahimar/ee3/block/BlockAlchemyArray.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.block; +import java.util.Random; + import com.pahimar.ee3.api.array.AlchemyArray; import com.pahimar.ee3.array.AlchemyArrayRegistry; import com.pahimar.ee3.reference.Names; @@ -25,41 +27,33 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Random; - -public class BlockAlchemyArray extends BlockTileEntityEE -{ - public BlockAlchemyArray() - { +public class BlockAlchemyArray extends BlockTileEntityEE { + public BlockAlchemyArray() { super(Material.circuits); this.setCreativeTab(null); this.setBlockName(Names.Blocks.ALCHEMY_ARRAY); } @Override - public boolean renderAsNormalBlock() - { + public boolean renderAsNormalBlock() { return false; } @Override - public boolean isOpaqueCube() - { + public boolean isOpaqueCube() { return false; } @Override - public int getRenderType() - { + public int getRenderType() { return RenderIds.alchemyArray; } @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) - { - TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(x, y, z); + public int getLightValue(IBlockAccess world, int x, int y, int z) { + if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) { + TileEntityAlchemyArray tileEntityAlchemyArray + = (TileEntityAlchemyArray) world.getTileEntity(x, y, z); return tileEntityAlchemyArray.getLightLevel(); } @@ -68,56 +62,46 @@ public class BlockAlchemyArray extends BlockTileEntityEE } @Override - public Item getItemDropped(int par1, Random random, int par2) - { + public Item getItemDropped(int par1, Random random, int par2) { return null; } @Override - public void setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z) - { - if (iBlockAccess.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) - { - TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) iBlockAccess.getTileEntity(x, y, z); + public void + setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z) { + if (iBlockAccess.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) { + TileEntityAlchemyArray tileEntityAlchemyArray + = (TileEntityAlchemyArray) iBlockAccess.getTileEntity(x, y, z); - switch (tileEntityAlchemyArray.getOrientation()) - { - case DOWN: - { + switch (tileEntityAlchemyArray.getOrientation()) { + case DOWN: { this.setBlockBounds(0f, 1f, 0f, 1f, 1 - 0.0625f, 1f); break; } - case UP: - { + case UP: { this.setBlockBounds(0f, 0f, 0f, 1f, 0.0625f, 1f); break; } - case NORTH: - { + case NORTH: { this.setBlockBounds(0f, 0f, 1 - 0.0625f, 1f, 1f, 1f); break; } - case SOUTH: - { + case SOUTH: { this.setBlockBounds(0f, 0f, 0f, 1f, 1f, 0.0625f); break; } - case EAST: - { + case EAST: { this.setBlockBounds(0f, 0f, 0f, 0.0625f, 1f, 1f); break; } - case WEST: - { + case WEST: { this.setBlockBounds(1f, 0f, 0f, 1 - 0.0625f, 1f, 1f); break; } - case UNKNOWN: - { + case UNKNOWN: { break; } - default: - { + default: { this.setBlockBounds(0f, 0f, 0f, 1f, 0.0625f, 1f); } } @@ -125,50 +109,55 @@ public class BlockAlchemyArray extends BlockTileEntityEE } @Override - public boolean canPlaceBlockAt(World world, int x, int y, int z) - { - return world.getBlock(x, y, z).isReplaceable(world, x, y, z) && (world.isSideSolid(x - 1, y, z, ForgeDirection.EAST) || - world.isSideSolid(x + 1, y, z, ForgeDirection.WEST) || - world.isSideSolid(x, y, z - 1, ForgeDirection.SOUTH) || - world.isSideSolid(x, y, z + 1, ForgeDirection.NORTH) || - world.isSideSolid(x, y - 1, z, ForgeDirection.UP) || - world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)); + public boolean canPlaceBlockAt(World world, int x, int y, int z) { + return world.getBlock(x, y, z).isReplaceable(world, x, y, z) + && (world.isSideSolid(x - 1, y, z, ForgeDirection.EAST) + || world.isSideSolid(x + 1, y, z, ForgeDirection.WEST) + || world.isSideSolid(x, y, z - 1, ForgeDirection.SOUTH) + || world.isSideSolid(x, y, z + 1, ForgeDirection.NORTH) + || world.isSideSolid(x, y - 1, z, ForgeDirection.UP) + || world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)); } @Override - public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int sideHit) - { + public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int sideHit) { ForgeDirection side = ForgeDirection.getOrientation(sideHit); - return world.getBlock(x, y, z).isReplaceable(world, x, y, z) && ((side == ForgeDirection.DOWN && world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) || - (side == ForgeDirection.UP && world.isSideSolid(x, y - 1, z, ForgeDirection.UP)) || - (side == ForgeDirection.NORTH && world.isSideSolid(x, y, z + 1, ForgeDirection.NORTH)) || - (side == ForgeDirection.SOUTH && world.isSideSolid(x, y, z - 1, ForgeDirection.SOUTH)) || - (side == ForgeDirection.WEST && world.isSideSolid(x + 1, y, z, ForgeDirection.WEST)) || - (side == ForgeDirection.EAST && world.isSideSolid(x - 1, y, z, ForgeDirection.EAST))); + return world.getBlock(x, y, z).isReplaceable(world, x, y, z) + && ((side == ForgeDirection.DOWN + && world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) + || (side == ForgeDirection.UP + && world.isSideSolid(x, y - 1, z, ForgeDirection.UP)) + || (side == ForgeDirection.NORTH + && world.isSideSolid(x, y, z + 1, ForgeDirection.NORTH)) + || (side == ForgeDirection.SOUTH + && world.isSideSolid(x, y, z - 1, ForgeDirection.SOUTH)) + || (side == ForgeDirection.WEST + && world.isSideSolid(x + 1, y, z, ForgeDirection.WEST)) + || (side == ForgeDirection.EAST + && world.isSideSolid(x - 1, y, z, ForgeDirection.EAST))); } @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) - { + public boolean + isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { return false; } @Override - public boolean isReplaceable(IBlockAccess world, int x, int y, int z) - { + public boolean isReplaceable(IBlockAccess world, int x, int y, int z) { return true; } @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) - { - TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(x, y, z); + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + if (!world.isRemote + && world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) { + TileEntityAlchemyArray tileEntityAlchemyArray + = (TileEntityAlchemyArray) world.getTileEntity(x, y, z); boolean invalidateAlchemyArray = false; - if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.UP && !world.isSideSolid(x, y - 1, z, ForgeDirection.UP, true)) - { + if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.UP + && !world.isSideSolid(x, y - 1, z, ForgeDirection.UP, true)) { invalidateAlchemyArray = true; } else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.DOWN && !world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN, true)) @@ -192,8 +181,7 @@ public class BlockAlchemyArray extends BlockTileEntityEE invalidateAlchemyArray = true; } - if (invalidateAlchemyArray) - { + if (invalidateAlchemyArray) { tileEntityAlchemyArray.invalidate(); world.setBlockToAir(x, y, z); } @@ -201,95 +189,137 @@ public class BlockAlchemyArray extends BlockTileEntityEE } @Override - public int onBlockPlaced(World world, int x, int y, int z, int sideHit, float hitX, float hitY, float hitZ, int metaData) - { + public int onBlockPlaced( + World world, + int x, + int y, + int z, + int sideHit, + float hitX, + float hitY, + float hitZ, + int metaData + ) { return sideHit; } @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) - { - if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray && entityLiving instanceof EntityPlayer) - { - NBTTagCompound customEntityData = EntityHelper.getCustomEntityData(entityLiving); + public void onBlockPlacedBy( + World world, + int x, + int y, + int z, + EntityLivingBase entityLiving, + ItemStack itemStack + ) { + if (!world.isRemote + && world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray + && entityLiving instanceof EntityPlayer) { + NBTTagCompound customEntityData + = EntityHelper.getCustomEntityData(entityLiving); ChalkSettings chalkSettings = new ChalkSettings(); chalkSettings.readFromNBT(customEntityData); - AlchemyArray alchemyArray = AlchemyArrayRegistry.getInstance().getAlchemyArray(chalkSettings.getIndex()); + AlchemyArray alchemyArray + = AlchemyArrayRegistry.getInstance().getAlchemyArray( + chalkSettings.getIndex() + ); - if (alchemyArray != null) - { + if (alchemyArray != null) { // Set adjusted rotation - int facing = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z), 3); - ((TileEntityEE) world.getTileEntity(x, y, z)).setOrientation(world.getBlockMetadata(x, y, z)); - ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).setRotation(chalkSettings.getRotation(), facing); - ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).setAlchemyArray(alchemyArray, chalkSettings.getSize()); - CommonSoundHelper.playSoundAtPlayer((EntityPlayer) entityLiving, Sounds.Chalk.getRandomChalkSound(), 1f, 1f); + int facing = MathHelper.floor_double( + entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D + ) + & 3; + world.setBlockMetadataWithNotify( + x, y, z, world.getBlockMetadata(x, y, z), 3 + ); + ((TileEntityEE) world.getTileEntity(x, y, z)) + .setOrientation(world.getBlockMetadata(x, y, z)); + ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)) + .setRotation(chalkSettings.getRotation(), facing); + ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)) + .setAlchemyArray(alchemyArray, chalkSettings.getSize()); + CommonSoundHelper.playSoundAtPlayer( + (EntityPlayer) entityLiving, + Sounds.Chalk.getRandomChalkSound(), + 1f, + 1f + ); - ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).onBlockPlacedBy(world, x, y, z, entityLiving, itemStack); + ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)) + .onBlockPlacedBy(world, x, y, z, entityLiving, itemStack); } } } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int sideHit, float hitX, float hitY, float hitZ) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) - { - ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).onBlockActivated(world, x, y, z, entityPlayer, sideHit, hitX, hitY, hitZ); + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer entityPlayer, + int sideHit, + float hitX, + float hitY, + float hitZ + ) { + if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) { + ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)) + .onBlockActivated( + world, x, y, z, entityPlayer, sideHit, hitX, hitY, hitZ + ); } return false; } @Override - public void onBlockClicked(World world, int x, int y, int z, EntityPlayer entityPlayer) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) - { - ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).onBlockClicked(world, x, y, z, entityPlayer); + public void + onBlockClicked(World world, int x, int y, int z, EntityPlayer entityPlayer) { + if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) { + ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)) + .onBlockClicked(world, x, y, z, entityPlayer); } } @Override - public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) - { - ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).onBlockDestroyedByExplosion(world, x, y, z, explosion); + public void + onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) { + if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) { + ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)) + .onBlockDestroyedByExplosion(world, x, y, z, explosion); } } @Override - public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int metaData) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) - { - ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).onBlockDestroyedByPlayer(world, x, y, z, metaData); + public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int metaData) { + if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) { + ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)) + .onBlockDestroyedByPlayer(world, x, y, z, metaData); } } @Override - public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) - { - ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).onEntityCollidedWithBlock(world, x, y, z, entity); + public void + onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { + if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) { + ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)) + .onEntityCollidedWithBlock(world, x, y, z, entity); } } @Override - public void onFallenUpon(World world, int x, int y, int z, Entity entity, float fallDistance) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) - { - ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).onFallenUpon(world, x, y, z, entity, fallDistance); + public void + onFallenUpon(World world, int x, int y, int z, Entity entity, float fallDistance) { + if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) { + ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)) + .onFallenUpon(world, x, y, z, entity, fallDistance); } } @Override - public TileEntity createNewTileEntity(World world, int metaData) - { + public TileEntity createNewTileEntity(World world, int metaData) { return new TileEntityAlchemyArray(); } } diff --git a/src/main/java/com/pahimar/ee3/block/BlockAludel.java b/src/main/java/com/pahimar/ee3/block/BlockAludel.java index 244f6a89..783a244c 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockAludel.java +++ b/src/main/java/com/pahimar/ee3/block/BlockAludel.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.block; +import java.util.Random; + import com.pahimar.ee3.EquivalentExchange3; import com.pahimar.ee3.init.ModBlocks; import com.pahimar.ee3.reference.GUIs; @@ -19,12 +21,8 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Random; - -public class BlockAludel extends BlockTileEntityEE -{ - public BlockAludel() - { +public class BlockAludel extends BlockTileEntityEE { + public BlockAludel() { super(Material.anvil); this.setHardness(5.0f); this.setBlockName(Names.Blocks.ALUDEL); @@ -32,93 +30,165 @@ public class BlockAludel extends BlockTileEntityEE } @Override - public TileEntity createNewTileEntity(World world, int metaData) - { + public TileEntity createNewTileEntity(World world, int metaData) { return new TileEntityAludel(); } @Override - public boolean renderAsNormalBlock() - { + public boolean renderAsNormalBlock() { return false; } @Override - public int getRenderType() - { + public int getRenderType() { return RenderIds.aludel; } @Override - public boolean isOpaqueCube() - { + public boolean isOpaqueCube() { return false; } @Override - public void randomDisplayTick(World world, int x, int y, int z, Random random) - { + public void randomDisplayTick(World world, int x, int y, int z, Random random) { TileEntity tile = world.getTileEntity(x, y, z); - if (tile instanceof TileEntityAludel) - { - if (((TileEntityAludel) tile).getState() == 1) - { - switch (((TileEntityAludel) tile).getOrientation()) - { + if (tile instanceof TileEntityAludel) { + if (((TileEntityAludel) tile).getState() == 1) { + switch (((TileEntityAludel) tile).getOrientation()) { case NORTH: - world.spawnParticle(Particles.FLAME, (double) x + 0.5F, (double) y + 0.33F, (double) z + 0.175F, 0.0D, 0.0D, 0.0D); + world.spawnParticle( + Particles.FLAME, + (double) x + 0.5F, + (double) y + 0.33F, + (double) z + 0.175F, + 0.0D, + 0.0D, + 0.0D + ); break; case SOUTH: - world.spawnParticle(Particles.FLAME, (double) x + 0.5F, (double) y + 0.33F, (double) z + 0.825F, 0.0D, 0.0D, 0.0D); + world.spawnParticle( + Particles.FLAME, + (double) x + 0.5F, + (double) y + 0.33F, + (double) z + 0.825F, + 0.0D, + 0.0D, + 0.0D + ); break; case WEST: - world.spawnParticle(Particles.FLAME, (double) x + 0.175F, (double) y + 0.33F, (double) z + 0.5F, 0.0D, 0.0D, 0.0D); + world.spawnParticle( + Particles.FLAME, + (double) x + 0.175F, + (double) y + 0.33F, + (double) z + 0.5F, + 0.0D, + 0.0D, + 0.0D + ); break; case EAST: - world.spawnParticle(Particles.FLAME, (double) x + 0.825F, (double) y + 0.33F, (double) z + 0.5F, 0.0D, 0.0D, 0.0D); + world.spawnParticle( + Particles.FLAME, + (double) x + 0.825F, + (double) y + 0.33F, + (double) z + 0.5F, + 0.0D, + 0.0D, + 0.0D + ); break; default: break; } - world.spawnParticle(Particles.NORMAL_SMOKE, (double) x + 0.5F, (double) y + 0.7F, (double) z + 0.0F, 0.0D, 0.05D, 0.0D); - world.spawnParticle(Particles.NORMAL_SMOKE, (double) x + 0.5F, (double) y + 0.7F, (double) z + 1.0F, 0.0D, 0.05D, 0.0D); - world.spawnParticle(Particles.NORMAL_SMOKE, (double) x + 0.0F, (double) y + 0.7F, (double) z + 0.5F, 0.0D, 0.05D, 0.0D); - world.spawnParticle(Particles.NORMAL_SMOKE, (double) x + 1.0F, (double) y + 0.7F, (double) z + 0.5F, 0.0D, 0.05D, 0.0D); + world.spawnParticle( + Particles.NORMAL_SMOKE, + (double) x + 0.5F, + (double) y + 0.7F, + (double) z + 0.0F, + 0.0D, + 0.05D, + 0.0D + ); + world.spawnParticle( + Particles.NORMAL_SMOKE, + (double) x + 0.5F, + (double) y + 0.7F, + (double) z + 1.0F, + 0.0D, + 0.05D, + 0.0D + ); + world.spawnParticle( + Particles.NORMAL_SMOKE, + (double) x + 0.0F, + (double) y + 0.7F, + (double) z + 0.5F, + 0.0D, + 0.05D, + 0.0D + ); + world.spawnParticle( + Particles.NORMAL_SMOKE, + (double) x + 1.0F, + (double) y + 0.7F, + (double) z + 0.5F, + 0.0D, + 0.05D, + 0.0D + ); } } } @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - TileEntityAludel tileEntityAludel = (TileEntityAludel) world.getTileEntity(x, y, z); - tileEntityAludel.hasGlassBell = world.getTileEntity(x, y + 1, z) instanceof TileEntityGlassBell; + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + TileEntityAludel tileEntityAludel + = (TileEntityAludel) world.getTileEntity(x, y, z); + tileEntityAludel.hasGlassBell + = world.getTileEntity(x, y + 1, z) instanceof TileEntityGlassBell; super.onNeighborBlockChange(world, x, y, z, block); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int faceHit, float par7, float par8, float par9) - { - if (player.isSneaking()) - { + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer player, + int faceHit, + float par7, + float par8, + float par9 + ) { + if (player.isSneaking()) { return false; - } - else - { - if (!world.isRemote) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityAludel && world.getTileEntity(x, y + 1, z) instanceof TileEntityGlassBell) - { - player.openGui(EquivalentExchange3.instance, GUIs.ALUDEL.ordinal(), world, x, y, z); + } else { + if (!world.isRemote) { + if (world.getTileEntity(x, y, z) instanceof TileEntityAludel + && world.getTileEntity(x, y + 1, z) instanceof TileEntityGlassBell) { + player.openGui( + EquivalentExchange3.instance, + GUIs.ALUDEL.ordinal(), + world, + x, + y, + z + ); } } - if (world.getTileEntity(x, y, z) instanceof TileEntityAludel && ModBlocks.glassBell.canPlaceBlockAt(world, x, y + 1, z) && faceHit == ForgeDirection.UP.ordinal()) - { - if (player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemBlock && ((ItemBlock) player.getHeldItem().getItem()).field_150939_a == ModBlocks.glassBell) - { + if (world.getTileEntity(x, y, z) instanceof TileEntityAludel + && ModBlocks.glassBell.canPlaceBlockAt(world, x, y + 1, z) + && faceHit == ForgeDirection.UP.ordinal()) { + if (player.getHeldItem() != null + && player.getHeldItem().getItem() instanceof ItemBlock + && ((ItemBlock) player.getHeldItem().getItem()).field_150939_a + == ModBlocks.glassBell) { return false; } } @@ -128,12 +198,9 @@ public class BlockAludel extends BlockTileEntityEE } @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityAludel) - { - if (((TileEntityAludel) world.getTileEntity(x, y, z)).getState() == 1) - { + public int getLightValue(IBlockAccess world, int x, int y, int z) { + if (world.getTileEntity(x, y, z) instanceof TileEntityAludel) { + if (((TileEntityAludel) world.getTileEntity(x, y, z)).getState() == 1) { return 15; } } @@ -142,12 +209,11 @@ public class BlockAludel extends BlockTileEntityEE } @Override - public void breakBlock(World world, int x, int y, int z, Block block, int meta) - { - if (world.getTileEntity(x, y + 1, z) instanceof TileEntityGlassBell) - { + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + if (world.getTileEntity(x, y + 1, z) instanceof TileEntityGlassBell) { world.markBlockForUpdate(x, y + 1, z); - // NAME UPDATE - this.worldObj.updateAllLightTypes(this.xCoord, this.yCoord, this.zCoord); + // NAME UPDATE - this.worldObj.updateAllLightTypes(this.xCoord, this.yCoord, + // this.zCoord); world.func_147451_t(x, y + 1, z); } @@ -155,25 +221,37 @@ public class BlockAludel extends BlockTileEntityEE } @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) - { + public void onBlockPlacedBy( + World world, + int x, + int y, + int z, + EntityLivingBase entityLiving, + ItemStack itemStack + ) { super.onBlockPlacedBy(world, x, y, z, entityLiving, itemStack); - if (world.getTileEntity(x, y + 1, z) instanceof TileEntityGlassBell) - { - TileEntityGlassBell tileEntityGlassBell = (TileEntityGlassBell) world.getTileEntity(x, y + 1, z); + if (world.getTileEntity(x, y + 1, z) instanceof TileEntityGlassBell) { + TileEntityGlassBell tileEntityGlassBell + = (TileEntityGlassBell) world.getTileEntity(x, y + 1, z); tileEntityGlassBell.setOrientation(ForgeDirection.UP); - if (world.getTileEntity(x, y, z) instanceof TileEntityAludel) - { - TileEntityAludel tileEntityAludel = (TileEntityAludel) world.getTileEntity(x, y, z); + if (world.getTileEntity(x, y, z) instanceof TileEntityAludel) { + TileEntityAludel tileEntityAludel + = (TileEntityAludel) world.getTileEntity(x, y, z); - ItemStack itemStackGlassBell = tileEntityGlassBell.getStackInSlot(TileEntityGlassBell.DISPLAY_SLOT_INVENTORY_INDEX); + ItemStack itemStackGlassBell = tileEntityGlassBell.getStackInSlot( + TileEntityGlassBell.DISPLAY_SLOT_INVENTORY_INDEX + ); - tileEntityGlassBell.setInventorySlotContents(TileEntityGlassBell.DISPLAY_SLOT_INVENTORY_INDEX, null); + tileEntityGlassBell.setInventorySlotContents( + TileEntityGlassBell.DISPLAY_SLOT_INVENTORY_INDEX, null + ); - tileEntityAludel.setInventorySlotContents(TileEntityAludel.INPUT_INVENTORY_INDEX, itemStackGlassBell); + tileEntityAludel.setInventorySlotContents( + TileEntityAludel.INPUT_INVENTORY_INDEX, itemStackGlassBell + ); tileEntityAludel.hasGlassBell = true; } diff --git a/src/main/java/com/pahimar/ee3/block/BlockAshInfusedStone.java b/src/main/java/com/pahimar/ee3/block/BlockAshInfusedStone.java index a90d8171..d1265557 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockAshInfusedStone.java +++ b/src/main/java/com/pahimar/ee3/block/BlockAshInfusedStone.java @@ -3,10 +3,8 @@ package com.pahimar.ee3.block; import com.pahimar.ee3.reference.Names; import net.minecraft.block.material.Material; -public class BlockAshInfusedStone extends BlockEE -{ - public BlockAshInfusedStone() - { +public class BlockAshInfusedStone extends BlockEE { + public BlockAshInfusedStone() { super(Material.rock); this.setBlockName(Names.Blocks.ASH_INFUSED_STONE); this.setHardness(1.5f); diff --git a/src/main/java/com/pahimar/ee3/block/BlockAshInfusedStoneSlab.java b/src/main/java/com/pahimar/ee3/block/BlockAshInfusedStoneSlab.java index 0c18548a..d200f653 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockAshInfusedStoneSlab.java +++ b/src/main/java/com/pahimar/ee3/block/BlockAshInfusedStoneSlab.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.block; +import java.util.List; + import com.pahimar.ee3.creativetab.CreativeTab; import com.pahimar.ee3.init.ModBlocks; import com.pahimar.ee3.reference.Names; @@ -19,15 +21,12 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.List; - -public class BlockAshInfusedStoneSlab extends BlockSlab -{ +public class BlockAshInfusedStoneSlab extends BlockSlab { @SideOnly(Side.CLIENT) - protected IIcon blockIcon, sideVariant1, sideVariant2, topVariant1, topVariant2, topVariant3, topVariant4; + protected IIcon blockIcon, sideVariant1, sideVariant2, topVariant1, topVariant2, + topVariant3, topVariant4; - public BlockAshInfusedStoneSlab() - { + public BlockAshInfusedStoneSlab() { super(false, Material.rock); this.setCreativeTab(CreativeTab.EE3_TAB); this.setHardness(2.0f); @@ -35,65 +34,72 @@ public class BlockAshInfusedStoneSlab extends BlockSlab } @Override - public void setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z) - { + public void + setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } - - public int getLightOpacity() - { + + public int getLightOpacity() { return 0; } /** - * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the - * mask.) Parameters: World, X, Y, Z, mask, list, colliding entity + * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the + * list if they intersect the mask.) Parameters: World, X, Y, Z, mask, list, colliding + * entity */ - public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axisAlignedBB, List list, Entity entity) - { - if (isAssociatedWithValidTablet(world, x, y, z)) - { + public void addCollisionBoxesToList( + World world, + int x, + int y, + int z, + AxisAlignedBB axisAlignedBB, + List list, + Entity entity + ) { + if (isAssociatedWithValidTablet(world, x, y, z)) { int metaData = world.getBlockMetadata(x, y, z); - if (metaData == 1) - { + if (metaData == 1) { this.setBlockBounds(0.5F, 0.0F, 0.5F, 1.0F, 0.625F, 1.0F); - super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); - } - else if (metaData == 2) - { + super.addCollisionBoxesToList( + world, x, y, z, axisAlignedBB, list, entity + ); + } else if (metaData == 2) { this.setBlockBounds(0.0F, 0.0F, 0.5F, 1.0F, 0.625F, 1.0F); - super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); - } - else if (metaData == 3) - { + super.addCollisionBoxesToList( + world, x, y, z, axisAlignedBB, list, entity + ); + } else if (metaData == 3) { this.setBlockBounds(0.0F, 0.0F, 1.0F, 0.5F, 0.625F, 0.5F); - super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); - } - else if (metaData == 4) - { + super.addCollisionBoxesToList( + world, x, y, z, axisAlignedBB, list, entity + ); + } else if (metaData == 4) { this.setBlockBounds(0.5F, 0.0F, 0.0F, 1.0F, 0.625F, 1.0F); - super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); - } - else if (metaData == 5) - { + super.addCollisionBoxesToList( + world, x, y, z, axisAlignedBB, list, entity + ); + } else if (metaData == 5) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.5F, 0.625F, 1.0F); - super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); - } - else if (metaData == 6) - { + super.addCollisionBoxesToList( + world, x, y, z, axisAlignedBB, list, entity + ); + } else if (metaData == 6) { this.setBlockBounds(0.5F, 0.0F, 0.0F, 1.0F, 0.625F, 0.5F); - super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); - } - else if (metaData == 7) - { + super.addCollisionBoxesToList( + world, x, y, z, axisAlignedBB, list, entity + ); + } else if (metaData == 7) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.625F, 0.5F); - super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); - } - else if (metaData == 8) - { + super.addCollisionBoxesToList( + world, x, y, z, axisAlignedBB, list, entity + ); + } else if (metaData == 8) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.5F, 0.625F, 0.5F); - super.addCollisionBoxesToList(world, x, y, z, axisAlignedBB, list, entity); + super.addCollisionBoxesToList( + world, x, y, z, axisAlignedBB, list, entity + ); } } @@ -102,54 +108,58 @@ public class BlockAshInfusedStoneSlab extends BlockSlab } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int sideHit, float hitX, float hitY, float hitZ) - { + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer entityPlayer, + int sideHit, + float hitX, + float hitY, + float hitZ + ) { int metaData = world.getBlockMetadata(x, y, z); int shiftedX = x; int shiftedZ = z; - if (metaData != 0) - { - if (metaData == 1) - { + if (metaData != 0) { + if (metaData == 1) { shiftedX++; shiftedZ++; - } - else if (metaData == 2) - { + } else if (metaData == 2) { shiftedZ++; - } - else if (metaData == 3) - { + } else if (metaData == 3) { shiftedX--; shiftedZ++; - } - else if (metaData == 4) - { + } else if (metaData == 4) { shiftedX++; - } - else if (metaData == 5) - { + } else if (metaData == 5) { shiftedX--; - } - else if (metaData == 6) - { + } else if (metaData == 6) { shiftedX++; shiftedZ--; - } - else if (metaData == 7) - { + } else if (metaData == 7) { shiftedZ--; - } - else if (metaData == 8) - { + } else if (metaData == 8) { shiftedX--; shiftedZ--; } - if (world.getTileEntity(shiftedX, y, shiftedZ) instanceof TileEntityTransmutationTablet) - { - world.getBlock(shiftedX, y, shiftedZ).onBlockActivated(world, shiftedX, y, shiftedZ, entityPlayer, sideHit, hitX, hitY, hitZ); + if (world.getTileEntity(shiftedX, y, shiftedZ) + instanceof TileEntityTransmutationTablet) { + world.getBlock(shiftedX, y, shiftedZ) + .onBlockActivated( + world, + shiftedX, + y, + shiftedZ, + entityPlayer, + sideHit, + hitX, + hitY, + hitZ + ); return true; } } @@ -159,59 +169,63 @@ public class BlockAshInfusedStoneSlab extends BlockSlab @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) - { - blockIcon = iconRegister.registerIcon(String.format("%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName()))); - sideVariant1 = iconRegister.registerIcon(String.format("%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName()) + "_side1")); - sideVariant2 = iconRegister.registerIcon(String.format("%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName()) + "_side2")); - topVariant1 = iconRegister.registerIcon(String.format("%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName()) + "_top1")); - topVariant2 = iconRegister.registerIcon(String.format("%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName()) + "_top2")); - topVariant3 = iconRegister.registerIcon(String.format("%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName()) + "_top3")); - topVariant4 = iconRegister.registerIcon(String.format("%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName()) + "_top4")); + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon( + String.format("%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName())) + ); + sideVariant1 = iconRegister.registerIcon(String.format( + "%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName()) + "_side1" + )); + sideVariant2 = iconRegister.registerIcon(String.format( + "%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName()) + "_side2" + )); + topVariant1 = iconRegister.registerIcon(String.format( + "%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName()) + "_top1" + )); + topVariant2 = iconRegister.registerIcon(String.format( + "%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName()) + "_top2" + )); + topVariant3 = iconRegister.registerIcon(String.format( + "%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName()) + "_top3" + )); + topVariant4 = iconRegister.registerIcon(String.format( + "%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName()) + "_top4" + )); } @Override - public String getUnlocalizedName() - { - return String.format("tile.%s%s", Textures.RESOURCE_PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + public String getUnlocalizedName() { + return String.format( + "tile.%s%s", + Textures.RESOURCE_PREFIX, + getUnwrappedUnlocalizedName(super.getUnlocalizedName()) + ); } - protected String getUnwrappedUnlocalizedName(String unlocalizedName) - { + protected String getUnwrappedUnlocalizedName(String unlocalizedName) { return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); } @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { + public IIcon getIcon(int side, int meta) { ForgeDirection forgeDirection = ForgeDirection.getOrientation(side); - if (forgeDirection == ForgeDirection.SOUTH || forgeDirection == ForgeDirection.NORTH || forgeDirection == ForgeDirection.EAST || forgeDirection == ForgeDirection.WEST) - { - if (meta == 1 || meta == 3 || meta == 6 || meta == 8) - { + if (forgeDirection == ForgeDirection.SOUTH + || forgeDirection == ForgeDirection.NORTH + || forgeDirection == ForgeDirection.EAST + || forgeDirection == ForgeDirection.WEST) { + if (meta == 1 || meta == 3 || meta == 6 || meta == 8) { return this.sideVariant1; - } - else - { + } else { return this.sideVariant2; } - } - else if (forgeDirection == ForgeDirection.UP) - { - if (meta == 1) - { + } else if (forgeDirection == ForgeDirection.UP) { + if (meta == 1) { return this.topVariant1; - } - else if (meta == 3) - { + } else if (meta == 3) { return this.topVariant4; - } - else if (meta == 6) - { + } else if (meta == 6) { return this.topVariant2; - } - else if (meta == 8) - { + } else if (meta == 8) { return this.topVariant3; } } @@ -220,59 +234,41 @@ public class BlockAshInfusedStoneSlab extends BlockSlab } @Override - public String func_150002_b(int meta) - { + public String func_150002_b(int meta) { return getUnlocalizedName(); } - private boolean isAssociatedWithValidTablet(World world, int x, int y, int z) - { + private boolean isAssociatedWithValidTablet(World world, int x, int y, int z) { int metaData = world.getBlockMetadata(x, y, z); - if (metaData != 0) - { + if (metaData != 0) { int shiftedX = x; int shiftedZ = z; - if (metaData == 1) - { + if (metaData == 1) { shiftedX++; shiftedZ++; - } - else if (metaData == 2) - { + } else if (metaData == 2) { shiftedZ++; - } - else if (metaData == 3) - { + } else if (metaData == 3) { shiftedX--; shiftedZ++; - } - else if (metaData == 4) - { + } else if (metaData == 4) { shiftedX++; - } - else if (metaData == 5) - { + } else if (metaData == 5) { shiftedZ--; - } - else if (metaData == 6) - { + } else if (metaData == 6) { shiftedX++; shiftedZ--; - } - else if (metaData == 7) - { + } else if (metaData == 7) { shiftedZ--; - } - else if (metaData == 8) - { + } else if (metaData == 8) { shiftedX--; shiftedZ--; } - if (world.getTileEntity(shiftedX, y, shiftedZ) instanceof TileEntityTransmutationTablet) - { + if (world.getTileEntity(shiftedX, y, shiftedZ) + instanceof TileEntityTransmutationTablet) { return true; } } @@ -282,14 +278,12 @@ public class BlockAshInfusedStoneSlab extends BlockSlab @Override @SideOnly(Side.CLIENT) - public Item getItem(World world, int x, int y, int z) - { + public Item getItem(World world, int x, int y, int z) { return Item.getItemFromBlock(ModBlocks.ashInfusedStoneSlab); } @Override - public int getDamageValue(World world, int x, int y, int z) - { + public int getDamageValue(World world, int x, int y, int z) { return 0; } } diff --git a/src/main/java/com/pahimar/ee3/block/BlockCalcinator.java b/src/main/java/com/pahimar/ee3/block/BlockCalcinator.java index 57a9610e..def6b9df 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockCalcinator.java +++ b/src/main/java/com/pahimar/ee3/block/BlockCalcinator.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.block; +import java.util.Random; + import com.pahimar.ee3.EquivalentExchange3; import com.pahimar.ee3.reference.GUIs; import com.pahimar.ee3.reference.Names; @@ -12,12 +14,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import java.util.Random; - -public class BlockCalcinator extends BlockTileEntityEE -{ - public BlockCalcinator() - { +public class BlockCalcinator extends BlockTileEntityEE { + public BlockCalcinator() { super(Material.rock); this.setHardness(2.0f); this.setBlockName(Names.Blocks.CALCINATOR); @@ -25,56 +23,76 @@ public class BlockCalcinator extends BlockTileEntityEE } @Override - public TileEntity createNewTileEntity(World world, int metaData) - { + public TileEntity createNewTileEntity(World world, int metaData) { return new TileEntityCalcinator(); } @Override - public boolean renderAsNormalBlock() - { + public boolean renderAsNormalBlock() { return false; } @Override - public int getRenderType() - { + public int getRenderType() { return RenderIds.calcinator; } @Override - public boolean isOpaqueCube() - { + public boolean isOpaqueCube() { return false; } @Override - public void randomDisplayTick(World world, int x, int y, int z, Random random) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityCalcinator) - { - if (((TileEntityCalcinator) world.getTileEntity(x, y, z)).getState() == 1) - { - world.spawnParticle(Particles.NORMAL_SMOKE, (double) x + 0.5F, (double) y + 0.4F, (double) ((z + 0.5F) + (random.nextFloat() * 0.5F - 0.3F)), 0.0D, 0.0D, 0.0D); - world.spawnParticle(Particles.FLAME, (double) x + 0.5F, (double) y + 0.4F, (double) z + 0.5F, 0.0D, 0.0D, 0.0D); + public void randomDisplayTick(World world, int x, int y, int z, Random random) { + if (world.getTileEntity(x, y, z) instanceof TileEntityCalcinator) { + if (((TileEntityCalcinator) world.getTileEntity(x, y, z)).getState() == 1) { + world.spawnParticle( + Particles.NORMAL_SMOKE, + (double) x + 0.5F, + (double) y + 0.4F, + (double) ((z + 0.5F) + (random.nextFloat() * 0.5F - 0.3F)), + 0.0D, + 0.0D, + 0.0D + ); + world.spawnParticle( + Particles.FLAME, + (double) x + 0.5F, + (double) y + 0.4F, + (double) z + 0.5F, + 0.0D, + 0.0D, + 0.0D + ); } } } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) - { - if (player.isSneaking()) - { + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer player, + int par6, + float par7, + float par8, + float par9 + ) { + if (player.isSneaking()) { return false; - } - else - { - if (!world.isRemote) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityCalcinator) - { - player.openGui(EquivalentExchange3.instance, GUIs.CALCINATOR.ordinal(), world, x, y, z); + } else { + if (!world.isRemote) { + if (world.getTileEntity(x, y, z) instanceof TileEntityCalcinator) { + player.openGui( + EquivalentExchange3.instance, + GUIs.CALCINATOR.ordinal(), + world, + x, + y, + z + ); } } @@ -83,10 +101,9 @@ public class BlockCalcinator extends BlockTileEntityEE } @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) - { - if ((world.getTileEntity(x, y, z) instanceof TileEntityCalcinator) && (((TileEntityCalcinator) world.getTileEntity(x, y, z)).getState() == 1)) - { + public int getLightValue(IBlockAccess world, int x, int y, int z) { + if ((world.getTileEntity(x, y, z) instanceof TileEntityCalcinator) + && (((TileEntityCalcinator) world.getTileEntity(x, y, z)).getState() == 1)) { return 15; } diff --git a/src/main/java/com/pahimar/ee3/block/BlockChalk.java b/src/main/java/com/pahimar/ee3/block/BlockChalk.java index eefbe540..3baa65c1 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockChalk.java +++ b/src/main/java/com/pahimar/ee3/block/BlockChalk.java @@ -1,16 +1,14 @@ package com.pahimar.ee3.block; +import java.util.Random; + import com.pahimar.ee3.init.ModItems; import com.pahimar.ee3.reference.Names; import net.minecraft.block.material.Material; import net.minecraft.item.Item; -import java.util.Random; - -public class BlockChalk extends BlockEE -{ - public BlockChalk() - { +public class BlockChalk extends BlockEE { + public BlockChalk() { super(Material.clay); this.setBlockName(Names.Items.CHALK); this.setHardness(0.6f); @@ -18,14 +16,12 @@ public class BlockChalk extends BlockEE } @Override - public Item getItemDropped(int par1, Random random, int par2) - { + public Item getItemDropped(int par1, Random random, int par2) { return ModItems.chalk; } @Override - public int quantityDropped(Random random) - { + public int quantityDropped(Random random) { return (random.nextInt(4) + 1); } } diff --git a/src/main/java/com/pahimar/ee3/block/BlockDummyArray.java b/src/main/java/com/pahimar/ee3/block/BlockDummyArray.java index 31f1e8fb..2b0bb731 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockDummyArray.java +++ b/src/main/java/com/pahimar/ee3/block/BlockDummyArray.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.block; +import java.util.Random; + import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.reference.RenderIds; import com.pahimar.ee3.tileentity.TileEntityAlchemyArray; @@ -18,41 +20,33 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Random; - -public class BlockDummyArray extends BlockTileEntityEE -{ - public BlockDummyArray() - { +public class BlockDummyArray extends BlockTileEntityEE { + public BlockDummyArray() { super(Material.circuits); setCreativeTab(null); this.setBlockName(Names.Blocks.DUMMY_ARRAY); } @Override - public boolean isOpaqueCube() - { + public boolean isOpaqueCube() { return false; } @Override - public boolean renderAsNormalBlock() - { + public boolean renderAsNormalBlock() { return false; } @Override - public int getRenderType() - { + public int getRenderType() { return RenderIds.dummyArray; } @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) - { - TileEntityDummyArray tileEntityDummyArray = (TileEntityDummyArray) world.getTileEntity(x, y, z); + public int getLightValue(IBlockAccess world, int x, int y, int z) { + if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) { + TileEntityDummyArray tileEntityDummyArray + = (TileEntityDummyArray) world.getTileEntity(x, y, z); return tileEntityDummyArray.getLightLevel(); } @@ -61,64 +55,106 @@ public class BlockDummyArray extends BlockTileEntityEE } @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) - { + public boolean + isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { return false; } @Override - public boolean isReplaceable(IBlockAccess world, int x, int y, int z) - { + public boolean isReplaceable(IBlockAccess world, int x, int y, int z) { return true; } @Override - public boolean canPlaceBlockAt(World world, int x, int y, int z) - { - return world.getBlock(x, y, z).isReplaceable(world, x, y, z) && (world.isSideSolid(x - 1, y, z, ForgeDirection.EAST) || - world.isSideSolid(x + 1, y, z, ForgeDirection.WEST) || - world.isSideSolid(x, y, z - 1, ForgeDirection.SOUTH) || - world.isSideSolid(x, y, z + 1, ForgeDirection.NORTH) || - world.isSideSolid(x, y - 1, z, ForgeDirection.UP) || - world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)); + public boolean canPlaceBlockAt(World world, int x, int y, int z) { + return world.getBlock(x, y, z).isReplaceable(world, x, y, z) + && (world.isSideSolid(x - 1, y, z, ForgeDirection.EAST) + || world.isSideSolid(x + 1, y, z, ForgeDirection.WEST) + || world.isSideSolid(x, y, z - 1, ForgeDirection.SOUTH) + || world.isSideSolid(x, y, z + 1, ForgeDirection.NORTH) + || world.isSideSolid(x, y - 1, z, ForgeDirection.UP) + || world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)); } @Override - public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int sideHit) - { + public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int sideHit) { ForgeDirection side = ForgeDirection.getOrientation(sideHit); - return world.getBlock(x, y, z).isReplaceable(world, x, y, z) && ((side == ForgeDirection.DOWN && world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) || - (side == ForgeDirection.UP && world.isSideSolid(x, y - 1, z, ForgeDirection.UP)) || - (side == ForgeDirection.NORTH && world.isSideSolid(x, y, z + 1, ForgeDirection.NORTH)) || - (side == ForgeDirection.SOUTH && world.isSideSolid(x, y, z - 1, ForgeDirection.SOUTH)) || - (side == ForgeDirection.WEST && world.isSideSolid(x + 1, y, z, ForgeDirection.WEST)) || - (side == ForgeDirection.EAST && world.isSideSolid(x - 1, y, z, ForgeDirection.EAST))); + return world.getBlock(x, y, z).isReplaceable(world, x, y, z) + && ((side == ForgeDirection.DOWN + && world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) + || (side == ForgeDirection.UP + && world.isSideSolid(x, y - 1, z, ForgeDirection.UP)) + || (side == ForgeDirection.NORTH + && world.isSideSolid(x, y, z + 1, ForgeDirection.NORTH)) + || (side == ForgeDirection.SOUTH + && world.isSideSolid(x, y, z - 1, ForgeDirection.SOUTH)) + || (side == ForgeDirection.WEST + && world.isSideSolid(x + 1, y, z, ForgeDirection.WEST)) + || (side == ForgeDirection.EAST + && world.isSideSolid(x - 1, y, z, ForgeDirection.EAST))); } @Override - public int onBlockPlaced(World world, int x, int y, int z, int sideHit, float hitX, float hitY, float hitZ, int metaData) - { + public int onBlockPlaced( + World world, + int x, + int y, + int z, + int sideHit, + float hitX, + float hitY, + float hitZ, + int metaData + ) { return sideHit; } @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) - { - ((TileEntityEE) world.getTileEntity(x, y, z)).setOrientation(world.getBlockMetadata(x, y, z)); + public void onBlockPlacedBy( + World world, + int x, + int y, + int z, + EntityLivingBase entityLiving, + ItemStack itemStack + ) { + ((TileEntityEE) world.getTileEntity(x, y, z)) + .setOrientation(world.getBlockMetadata(x, y, z)); world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z), 3); } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int sideHit, float hitX, float hitY, float hitZ) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) - { - TileEntityAlchemyArray tileEntityAlchemyArray = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getAssociatedTileEntity(); + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer entityPlayer, + int sideHit, + float hitX, + float hitY, + float hitZ + ) { + if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) { + TileEntityAlchemyArray tileEntityAlchemyArray + = ((TileEntityDummyArray) world.getTileEntity(x, y, z)) + .getAssociatedTileEntity(); - if (tileEntityAlchemyArray != null) - { - tileEntityAlchemyArray.onBlockActivated(world, x, y, z, tileEntityAlchemyArray.xCoord, tileEntityAlchemyArray.yCoord, tileEntityAlchemyArray.zCoord, entityPlayer, sideHit, hitX, hitY, hitZ); + if (tileEntityAlchemyArray != null) { + tileEntityAlchemyArray.onBlockActivated( + world, + x, + y, + z, + tileEntityAlchemyArray.xCoord, + tileEntityAlchemyArray.yCoord, + tileEntityAlchemyArray.zCoord, + entityPlayer, + sideHit, + hitX, + hitY, + hitZ + ); } } @@ -126,91 +162,139 @@ public class BlockDummyArray extends BlockTileEntityEE } @Override - public void onBlockClicked(World world, int x, int y, int z, EntityPlayer entityPlayer) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) - { - TileEntityAlchemyArray tileEntityAlchemyArray = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getAssociatedTileEntity(); + public void + onBlockClicked(World world, int x, int y, int z, EntityPlayer entityPlayer) { + if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) { + TileEntityAlchemyArray tileEntityAlchemyArray + = ((TileEntityDummyArray) world.getTileEntity(x, y, z)) + .getAssociatedTileEntity(); - if (tileEntityAlchemyArray != null) - { - tileEntityAlchemyArray.onBlockClicked(world, x, y, z, tileEntityAlchemyArray.xCoord, tileEntityAlchemyArray.yCoord, tileEntityAlchemyArray.zCoord, entityPlayer); + if (tileEntityAlchemyArray != null) { + tileEntityAlchemyArray.onBlockClicked( + world, + x, + y, + z, + tileEntityAlchemyArray.xCoord, + tileEntityAlchemyArray.yCoord, + tileEntityAlchemyArray.zCoord, + entityPlayer + ); } } } @Override - public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) - { - TileEntityAlchemyArray tileEntityAlchemyArray = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getAssociatedTileEntity(); + public void + onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) { + if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) { + TileEntityAlchemyArray tileEntityAlchemyArray + = ((TileEntityDummyArray) world.getTileEntity(x, y, z)) + .getAssociatedTileEntity(); - if (tileEntityAlchemyArray != null) - { - tileEntityAlchemyArray.onBlockDestroyedByExplosion(world, x, y, z, tileEntityAlchemyArray.xCoord, tileEntityAlchemyArray.yCoord, tileEntityAlchemyArray.zCoord, explosion); + if (tileEntityAlchemyArray != null) { + tileEntityAlchemyArray.onBlockDestroyedByExplosion( + world, + x, + y, + z, + tileEntityAlchemyArray.xCoord, + tileEntityAlchemyArray.yCoord, + tileEntityAlchemyArray.zCoord, + explosion + ); } } } @Override - public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int metaData) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) - { - TileEntityAlchemyArray tileEntityAlchemyArray = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getAssociatedTileEntity(); + public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int metaData) { + if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) { + TileEntityAlchemyArray tileEntityAlchemyArray + = ((TileEntityDummyArray) world.getTileEntity(x, y, z)) + .getAssociatedTileEntity(); - if (tileEntityAlchemyArray != null) - { - tileEntityAlchemyArray.onBlockDestroyedByPlayer(world, x, y, z, tileEntityAlchemyArray.xCoord, tileEntityAlchemyArray.yCoord, tileEntityAlchemyArray.zCoord, metaData); + if (tileEntityAlchemyArray != null) { + tileEntityAlchemyArray.onBlockDestroyedByPlayer( + world, + x, + y, + z, + tileEntityAlchemyArray.xCoord, + tileEntityAlchemyArray.yCoord, + tileEntityAlchemyArray.zCoord, + metaData + ); } } } @Override - public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) - { - TileEntityAlchemyArray tileEntityAlchemyArray = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getAssociatedTileEntity(); + public void + onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { + if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) { + TileEntityAlchemyArray tileEntityAlchemyArray + = ((TileEntityDummyArray) world.getTileEntity(x, y, z)) + .getAssociatedTileEntity(); - if (tileEntityAlchemyArray != null) - { - tileEntityAlchemyArray.onEntityCollidedWithBlock(world, x, y, z, tileEntityAlchemyArray.xCoord, tileEntityAlchemyArray.yCoord, tileEntityAlchemyArray.zCoord, entity); + if (tileEntityAlchemyArray != null) { + tileEntityAlchemyArray.onEntityCollidedWithBlock( + world, + x, + y, + z, + tileEntityAlchemyArray.xCoord, + tileEntityAlchemyArray.yCoord, + tileEntityAlchemyArray.zCoord, + entity + ); } } } @Override - public void onFallenUpon(World world, int x, int y, int z, Entity entity, float fallDistance) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) - { - TileEntityAlchemyArray tileEntityAlchemyArray = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getAssociatedTileEntity(); + public void + onFallenUpon(World world, int x, int y, int z, Entity entity, float fallDistance) { + if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) { + TileEntityAlchemyArray tileEntityAlchemyArray + = ((TileEntityDummyArray) world.getTileEntity(x, y, z)) + .getAssociatedTileEntity(); - if (tileEntityAlchemyArray != null) - { - tileEntityAlchemyArray.onFallenUpon(world, x, y, z, tileEntityAlchemyArray.xCoord, tileEntityAlchemyArray.yCoord, tileEntityAlchemyArray.zCoord, entity, fallDistance); + if (tileEntityAlchemyArray != null) { + tileEntityAlchemyArray.onFallenUpon( + world, + x, + y, + z, + tileEntityAlchemyArray.xCoord, + tileEntityAlchemyArray.yCoord, + tileEntityAlchemyArray.zCoord, + entity, + fallDistance + ); } } } @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) - { - int trueXCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueXCoord(); - int trueYCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueYCoord(); - int trueZCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueZCoord(); + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + if (!world.isRemote + && world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) { + int trueXCoord + = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueXCoord(); + int trueYCoord + = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueYCoord(); + int trueZCoord + = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueZCoord(); - if (world.getTileEntity(trueXCoord, trueYCoord, trueZCoord) instanceof TileEntityAlchemyArray) - { - TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(trueXCoord, trueYCoord, trueZCoord); + if (world.getTileEntity(trueXCoord, trueYCoord, trueZCoord) + instanceof TileEntityAlchemyArray) { + TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray + ) world.getTileEntity(trueXCoord, trueYCoord, trueZCoord); boolean invalidateAlchemyArray = false; - if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.UP && !world.isSideSolid(x, y - 1, z, ForgeDirection.UP, true)) - { + if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.UP + && !world.isSideSolid(x, y - 1, z, ForgeDirection.UP, true)) { invalidateAlchemyArray = true; } else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.DOWN && !world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN, true)) @@ -234,8 +318,7 @@ public class BlockDummyArray extends BlockTileEntityEE invalidateAlchemyArray = true; } - if (invalidateAlchemyArray) - { + if (invalidateAlchemyArray) { world.getTileEntity(x, y, z).invalidate(); tileEntityAlchemyArray.invalidate(); world.setBlockToAir(x, y, z); @@ -246,64 +329,60 @@ public class BlockDummyArray extends BlockTileEntityEE } @Override - public Item getItemDropped(int par1, Random random, int par2) - { + public Item getItemDropped(int par1, Random random, int par2) { return null; } @Override - public void setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z) - { - if (iBlockAccess.getTileEntity(x, y, z) instanceof TileEntityDummyArray) - { - TileEntityDummyArray tileEntityDummyArray = (TileEntityDummyArray) iBlockAccess.getTileEntity(x, y, z); + public void + setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z) { + if (iBlockAccess.getTileEntity(x, y, z) instanceof TileEntityDummyArray) { + TileEntityDummyArray tileEntityDummyArray + = (TileEntityDummyArray) iBlockAccess.getTileEntity(x, y, z); - switch (tileEntityDummyArray.getOrientation()) - { - case DOWN: - { + switch (tileEntityDummyArray.getOrientation()) { + case DOWN: { this.setBlockBounds(0f, 1f, 0f, 1f, 1 - 0.0625f, 1f); break; } - case UP: - { + case UP: { this.setBlockBounds(0f, 0f, 0f, 1f, 0.0625f, 1f); break; } - case NORTH: - { + case NORTH: { this.setBlockBounds(0f, 0f, 1 - 0.0625f, 1f, 1f, 1f); break; } - case SOUTH: - { + case SOUTH: { this.setBlockBounds(0f, 0f, 0f, 1f, 1f, 0.0625f); break; } - case EAST: - { + case EAST: { this.setBlockBounds(0f, 0f, 0f, 0.0625f, 1f, 1f); break; } - case WEST: - { + case WEST: { this.setBlockBounds(1f, 0f, 0f, 1 - 0.0625f, 1f, 1f); break; } - case UNKNOWN: - { + case UNKNOWN: { break; } } } } - public void breakBlock(World world, int x, int y, int z, Block block, int metaData) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) - { + public void breakBlock(World world, int x, int y, int z, Block block, int metaData) { + if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) { TileEntity tileEntity = world.getTileEntity(x, y, z); - super.breakBlock(world, ((TileEntityDummyArray) tileEntity).getTrueXCoord(), ((TileEntityDummyArray) tileEntity).getTrueYCoord(), ((TileEntityDummyArray) tileEntity).getTrueZCoord(), block, metaData); + super.breakBlock( + world, + ((TileEntityDummyArray) tileEntity).getTrueXCoord(), + ((TileEntityDummyArray) tileEntity).getTrueYCoord(), + ((TileEntityDummyArray) tileEntity).getTrueZCoord(), + block, + metaData + ); } super.breakBlock(world, x, y, z, block, metaData); } @@ -315,8 +394,7 @@ public class BlockDummyArray extends BlockTileEntityEE * @param metaData */ @Override - public TileEntity createNewTileEntity(World world, int metaData) - { + public TileEntity createNewTileEntity(World world, int metaData) { return new TileEntityDummyArray(); } } diff --git a/src/main/java/com/pahimar/ee3/block/BlockEE.java b/src/main/java/com/pahimar/ee3/block/BlockEE.java index 30aaa6ab..1275a10c 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockEE.java +++ b/src/main/java/com/pahimar/ee3/block/BlockEE.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.block; +import java.util.Random; + import com.pahimar.ee3.creativetab.CreativeTab; import com.pahimar.ee3.reference.Textures; import com.pahimar.ee3.tileentity.TileEntityEE; @@ -19,75 +21,72 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Random; - -public class BlockEE extends Block -{ - public BlockEE() - { +public class BlockEE extends Block { + public BlockEE() { this(Material.rock); } - public BlockEE(Material material) - { + public BlockEE(Material material) { super(material); this.setCreativeTab(CreativeTab.EE3_TAB); } @Override - public String getUnlocalizedName() - { - return String.format("tile.%s%s", Textures.RESOURCE_PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + public String getUnlocalizedName() { + return String.format( + "tile.%s%s", + Textures.RESOURCE_PREFIX, + getUnwrappedUnlocalizedName(super.getUnlocalizedName()) + ); } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) - { - blockIcon = iconRegister.registerIcon(String.format("%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName()))); + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon( + String.format("%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName())) + ); } - protected String getUnwrappedUnlocalizedName(String unlocalizedName) - { + protected String getUnwrappedUnlocalizedName(String unlocalizedName) { return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); } @Override - public void breakBlock(World world, int x, int y, int z, Block block, int meta) - { + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { dropInventory(world, x, y, z); super.breakBlock(world, x, y, z, block, meta); } @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) - { + public void onBlockPlacedBy( + World world, + int x, + int y, + int z, + EntityLivingBase entityLiving, + ItemStack itemStack + ) { super.onBlockPlacedBy(world, x, y, z, entityLiving, itemStack); - if (world.getTileEntity(x, y, z) instanceof TileEntityEE) - { + if (world.getTileEntity(x, y, z) instanceof TileEntityEE) { int direction = 0; - int facing = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + int facing + = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) + & 3; - if (facing == 0) - { + if (facing == 0) { direction = ForgeDirection.NORTH.ordinal(); - } - else if (facing == 1) - { + } else if (facing == 1) { direction = ForgeDirection.EAST.ordinal(); - } - else if (facing == 2) - { + } else if (facing == 2) { direction = ForgeDirection.SOUTH.ordinal(); - } - else if (facing == 3) - { + } else if (facing == 3) { direction = ForgeDirection.WEST.ordinal(); } - if (itemStack.hasDisplayName()) - { - ((TileEntityEE) world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName()); + if (itemStack.hasDisplayName()) { + ((TileEntityEE) world.getTileEntity(x, y, z)) + .setCustomName(itemStack.getDisplayName()); } ((TileEntityEE) world.getTileEntity(x, y, z)).setOrientation(direction); @@ -95,40 +94,38 @@ public class BlockEE extends Block } @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) - { + public AxisAlignedBB + getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { this.setBlockBoundsBasedOnState(world, x, y, z); return super.getCollisionBoundingBoxFromPool(world, x, y, z); } - protected void dropInventory(World world, int x, int y, int z) - { + protected void dropInventory(World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); - if (!(tileEntity instanceof IInventory)) - { + if (!(tileEntity instanceof IInventory)) { return; } IInventory inventory = (IInventory) tileEntity; - for (int i = 0; i < inventory.getSizeInventory(); i++) - { + for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack itemStack = inventory.getStackInSlot(i); - if (itemStack != null && itemStack.stackSize > 0) - { + if (itemStack != null && itemStack.stackSize > 0) { Random rand = new Random(); float dX = rand.nextFloat() * 0.8F + 0.1F; float dY = rand.nextFloat() * 0.8F + 0.1F; float dZ = rand.nextFloat() * 0.8F + 0.1F; - EntityItem entityItem = new EntityItem(world, x + dX, y + dY, z + dZ, itemStack.copy()); + EntityItem entityItem + = new EntityItem(world, x + dX, y + dY, z + dZ, itemStack.copy()); - if (itemStack.hasTagCompound()) - { - entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy()); + if (itemStack.hasTagCompound()) { + entityItem.getEntityItem().setTagCompound( + (NBTTagCompound) itemStack.getTagCompound().copy() + ); } float factor = 0.05F; diff --git a/src/main/java/com/pahimar/ee3/block/BlockGlassBell.java b/src/main/java/com/pahimar/ee3/block/BlockGlassBell.java index d83cf2f3..c5e4d70d 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockGlassBell.java +++ b/src/main/java/com/pahimar/ee3/block/BlockGlassBell.java @@ -16,45 +16,38 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public class BlockGlassBell extends BlockTileEntityEE -{ - public BlockGlassBell() - { +public class BlockGlassBell extends BlockTileEntityEE { + public BlockGlassBell() { super(Material.glass); this.setHardness(1.0f); this.setBlockName(Names.Blocks.GLASS_BELL); } @Override - public TileEntity createNewTileEntity(World world, int metaData) - { + public TileEntity createNewTileEntity(World world, int metaData) { return new TileEntityGlassBell(); } @Override - public boolean renderAsNormalBlock() - { + public boolean renderAsNormalBlock() { return false; } @Override - public boolean isOpaqueCube() - { + public boolean isOpaqueCube() { return false; } @Override - public int getRenderType() - { + public int getRenderType() { return RenderIds.glassBell; } @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityGlassBell) - { - TileEntityGlassBell tileEntityGlassBell = (TileEntityGlassBell) world.getTileEntity(x, y, z); + public int getLightValue(IBlockAccess world, int x, int y, int z) { + if (world.getTileEntity(x, y, z) instanceof TileEntityGlassBell) { + TileEntityGlassBell tileEntityGlassBell + = (TileEntityGlassBell) world.getTileEntity(x, y, z); return tileEntityGlassBell.getState(); } @@ -63,25 +56,40 @@ public class BlockGlassBell extends BlockTileEntityEE } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) - { - if (player.isSneaking()) - { + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer player, + int par6, + float par7, + float par8, + float par9 + ) { + if (player.isSneaking()) { return false; - } - else - { - if (!world.isRemote) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityGlassBell) - { - if (world.getTileEntity(x, y - 1, z) instanceof TileEntityAludel) - { - player.openGui(EquivalentExchange3.instance, GUIs.ALUDEL.ordinal(), world, x, y - 1, z); - } - else - { - player.openGui(EquivalentExchange3.instance, GUIs.GLASS_BELL.ordinal(), world, x, y, z); + } else { + if (!world.isRemote) { + if (world.getTileEntity(x, y, z) instanceof TileEntityGlassBell) { + if (world.getTileEntity(x, y - 1, z) instanceof TileEntityAludel) { + player.openGui( + EquivalentExchange3.instance, + GUIs.ALUDEL.ordinal(), + world, + x, + y - 1, + z + ); + } else { + player.openGui( + EquivalentExchange3.instance, + GUIs.GLASS_BELL.ordinal(), + world, + x, + y, + z + ); } } } @@ -91,72 +99,79 @@ public class BlockGlassBell extends BlockTileEntityEE } @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) - { - if (itemStack.hasDisplayName()) - { - ((TileEntityEE) world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName()); + public void onBlockPlacedBy( + World world, + int x, + int y, + int z, + EntityLivingBase entityLiving, + ItemStack itemStack + ) { + if (itemStack.hasDisplayName()) { + ((TileEntityEE) world.getTileEntity(x, y, z)) + .setCustomName(itemStack.getDisplayName()); } - if (world.getTileEntity(x, y - 1, z) != null && world.getTileEntity(x, y - 1, z) instanceof TileEntityAludel) - { - ((TileEntityEE) world.getTileEntity(x, y, z)).setOrientation(ForgeDirection.UP); - } - else - { - ((TileEntityEE) world.getTileEntity(x, y, z)).setOrientation(world.getBlockMetadata(x, y, z)); + if (world.getTileEntity(x, y - 1, z) != null + && world.getTileEntity(x, y - 1, z) instanceof TileEntityAludel) { + ((TileEntityEE) world.getTileEntity(x, y, z)) + .setOrientation(ForgeDirection.UP); + } else { + ((TileEntityEE) world.getTileEntity(x, y, z)) + .setOrientation(world.getBlockMetadata(x, y, z)); } world.setBlockMetadataWithNotify(x, y, z, 0, 3); } @Override - public int onBlockPlaced(World world, int x, int y, int z, int sideHit, float hitX, float hitY, float hitZ, int metaData) - { + public int onBlockPlaced( + World world, + int x, + int y, + int z, + int sideHit, + float hitX, + float hitY, + float hitZ, + int metaData + ) { return sideHit; } @Override - public void setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z) - { - if (iBlockAccess.getTileEntity(x, y, z) instanceof TileEntityGlassBell) - { - TileEntityGlassBell tileGlassBell = (TileEntityGlassBell) iBlockAccess.getTileEntity(x, y, z); + public void + setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z) { + if (iBlockAccess.getTileEntity(x, y, z) instanceof TileEntityGlassBell) { + TileEntityGlassBell tileGlassBell + = (TileEntityGlassBell) iBlockAccess.getTileEntity(x, y, z); - switch (tileGlassBell.getOrientation()) - { - case DOWN: - { + switch (tileGlassBell.getOrientation()) { + case DOWN: { this.setBlockBounds(0.125F, 0.33F, 0.125F, 0.875F, 1.0F, 0.875F); break; } - case UP: - { + case UP: { this.setBlockBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.66F, 0.875F); break; } - case NORTH: - { + case NORTH: { this.setBlockBounds(0.125F, 0.125F, 0.33F, 0.875F, 0.875F, 1.0F); break; } - case SOUTH: - { + case SOUTH: { this.setBlockBounds(0.125F, 0.125F, 0.0F, 0.875F, 0.875F, 0.66F); break; } - case EAST: - { + case EAST: { this.setBlockBounds(0.0F, 0.125F, 0.125F, 0.66F, 0.875F, 0.875F); break; } - case WEST: - { + case WEST: { this.setBlockBounds(0.33F, 0.125F, 0.125F, 1.0F, 0.875F, 0.875F); break; } - case UNKNOWN: - { + case UNKNOWN: { break; } } diff --git a/src/main/java/com/pahimar/ee3/block/BlockResearchStation.java b/src/main/java/com/pahimar/ee3/block/BlockResearchStation.java index cd6da1b4..5b37a2d7 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockResearchStation.java +++ b/src/main/java/com/pahimar/ee3/block/BlockResearchStation.java @@ -10,53 +10,58 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class BlockResearchStation extends BlockTileEntityEE -{ - public BlockResearchStation() - { +public class BlockResearchStation extends BlockTileEntityEE { + public BlockResearchStation() { super(Material.rock); this.setHardness(2.0f); this.setBlockName(Names.Blocks.RESEARCH_STATION); } @Override - public TileEntity createNewTileEntity(World world, int metaData) - { + public TileEntity createNewTileEntity(World world, int metaData) { return new TileEntityResearchStation(); } @Override - public boolean renderAsNormalBlock() - { + public boolean renderAsNormalBlock() { return false; } @Override - public boolean isOpaqueCube() - { + public boolean isOpaqueCube() { return false; } @Override - public int getRenderType() - { + public int getRenderType() { return RenderIds.researchStation; } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) - { - if (player.isSneaking()) - { + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer player, + int par6, + float par7, + float par8, + float par9 + ) { + if (player.isSneaking()) { return false; - } - else - { - if (!world.isRemote) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityResearchStation) - { - player.openGui(EquivalentExchange3.instance, GUIs.RESEARCH_STATION.ordinal(), world, x, y, z); + } else { + if (!world.isRemote) { + if (world.getTileEntity(x, y, z) instanceof TileEntityResearchStation) { + player.openGui( + EquivalentExchange3.instance, + GUIs.RESEARCH_STATION.ordinal(), + world, + x, + y, + z + ); } } diff --git a/src/main/java/com/pahimar/ee3/block/BlockTileEntityEE.java b/src/main/java/com/pahimar/ee3/block/BlockTileEntityEE.java index f1dc99b1..b7d64084 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockTileEntityEE.java +++ b/src/main/java/com/pahimar/ee3/block/BlockTileEntityEE.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.block; +import java.util.Random; + import com.pahimar.ee3.creativetab.CreativeTab; import com.pahimar.ee3.reference.Textures; import com.pahimar.ee3.tileentity.TileEntityEE; @@ -20,70 +22,68 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Random; - -public abstract class BlockTileEntityEE extends BlockContainer -{ - protected BlockTileEntityEE(Material material) - { +public abstract class BlockTileEntityEE extends BlockContainer { + protected BlockTileEntityEE(Material material) { super(material); this.setCreativeTab(CreativeTab.EE3_TAB); } @Override - public String getUnlocalizedName() - { - return String.format("tile.%s%s", Textures.RESOURCE_PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + public String getUnlocalizedName() { + return String.format( + "tile.%s%s", + Textures.RESOURCE_PREFIX, + getUnwrappedUnlocalizedName(super.getUnlocalizedName()) + ); } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) - { - blockIcon = iconRegister.registerIcon(String.format("%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName()))); + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon( + String.format("%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName())) + ); } - protected String getUnwrappedUnlocalizedName(String unlocalizedName) - { + protected String getUnwrappedUnlocalizedName(String unlocalizedName) { return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); } @Override - public void breakBlock(World world, int x, int y, int z, Block block, int meta) - { + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { dropInventory(world, x, y, z); super.breakBlock(world, x, y, z, block, meta); } @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) - { + public void onBlockPlacedBy( + World world, + int x, + int y, + int z, + EntityLivingBase entityLiving, + ItemStack itemStack + ) { super.onBlockPlacedBy(world, x, y, z, entityLiving, itemStack); - if (world.getTileEntity(x, y, z) instanceof TileEntityEE) - { + if (world.getTileEntity(x, y, z) instanceof TileEntityEE) { int direction = 0; - int facing = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + int facing + = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) + & 3; - if (facing == 0) - { + if (facing == 0) { direction = ForgeDirection.NORTH.ordinal(); - } - else if (facing == 1) - { + } else if (facing == 1) { direction = ForgeDirection.EAST.ordinal(); - } - else if (facing == 2) - { + } else if (facing == 2) { direction = ForgeDirection.SOUTH.ordinal(); - } - else if (facing == 3) - { + } else if (facing == 3) { direction = ForgeDirection.WEST.ordinal(); } - if (itemStack.hasDisplayName()) - { - ((TileEntityEE) world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName()); + if (itemStack.hasDisplayName()) { + ((TileEntityEE) world.getTileEntity(x, y, z)) + .setCustomName(itemStack.getDisplayName()); } ((TileEntityEE) world.getTileEntity(x, y, z)).setOrientation(direction); @@ -91,40 +91,38 @@ public abstract class BlockTileEntityEE extends BlockContainer } @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) - { + public AxisAlignedBB + getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { this.setBlockBoundsBasedOnState(world, x, y, z); return super.getCollisionBoundingBoxFromPool(world, x, y, z); } - protected void dropInventory(World world, int x, int y, int z) - { + protected void dropInventory(World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); - if (!(tileEntity instanceof IInventory)) - { + if (!(tileEntity instanceof IInventory)) { return; } IInventory inventory = (IInventory) tileEntity; - for (int i = 0; i < inventory.getSizeInventory(); i++) - { + for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack itemStack = inventory.getStackInSlot(i); - if (itemStack != null && itemStack.stackSize > 0) - { + if (itemStack != null && itemStack.stackSize > 0) { Random rand = new Random(); float dX = rand.nextFloat() * 0.8F + 0.1F; float dY = rand.nextFloat() * 0.8F + 0.1F; float dZ = rand.nextFloat() * 0.8F + 0.1F; - EntityItem entityItem = new EntityItem(world, x + dX, y + dY, z + dZ, itemStack.copy()); + EntityItem entityItem + = new EntityItem(world, x + dX, y + dY, z + dZ, itemStack.copy()); - if (itemStack.hasTagCompound()) - { - entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy()); + if (itemStack.hasTagCompound()) { + entityItem.getEntityItem().setTagCompound( + (NBTTagCompound) itemStack.getTagCompound().copy() + ); } float factor = 0.05F; diff --git a/src/main/java/com/pahimar/ee3/block/BlockTransmutationTablet.java b/src/main/java/com/pahimar/ee3/block/BlockTransmutationTablet.java index 081d58a8..27f553b7 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockTransmutationTablet.java +++ b/src/main/java/com/pahimar/ee3/block/BlockTransmutationTablet.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.block; +import java.util.Random; + import com.pahimar.ee3.EquivalentExchange3; import com.pahimar.ee3.init.ModBlocks; import com.pahimar.ee3.reference.GUIs; @@ -13,12 +15,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import java.util.Random; - -public class BlockTransmutationTablet extends BlockTileEntityEE -{ - public BlockTransmutationTablet() - { +public class BlockTransmutationTablet extends BlockTileEntityEE { + public BlockTransmutationTablet() { super(Material.rock); setCreativeTab(null); this.setHardness(2.0f); @@ -26,38 +24,46 @@ public class BlockTransmutationTablet extends BlockTileEntityEE } @Override - public void setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z) - { - if (isStructureValid(iBlockAccess, x, y, z)) - { + public void + setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z) { + if (isStructureValid(iBlockAccess, x, y, z)) { this.setBlockBounds(0f, 0f, 0f, 1f, 0.625f, 1f); - } - else - { + } else { this.setBlockBounds(0f, 0f, 0f, 1f, 0.5f, 1f); } } @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) - { + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { return Item.getItemFromBlock(ModBlocks.ashInfusedStoneSlab); } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int sideHit, float hitX, float hitY, float hitZ) - { - if (entityPlayer.isSneaking()) - { + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer entityPlayer, + int sideHit, + float hitX, + float hitY, + float hitZ + ) { + if (entityPlayer.isSneaking()) { return false; - } - else - { - if (!world.isRemote) - { - if (world.getTileEntity(x, y, z) instanceof TileEntityTransmutationTablet && isStructureValid(world, x, y, z)) - { - entityPlayer.openGui(EquivalentExchange3.instance, GUIs.TRANSMUTATION_TABLET.ordinal(), world, x, y, z); + } else { + if (!world.isRemote) { + if (world.getTileEntity(x, y, z) instanceof TileEntityTransmutationTablet + && isStructureValid(world, x, y, z)) { + entityPlayer.openGui( + EquivalentExchange3.instance, + GUIs.TRANSMUTATION_TABLET.ordinal(), + world, + x, + y, + z + ); } } @@ -66,44 +72,67 @@ public class BlockTransmutationTablet extends BlockTileEntityEE } @Override - public int onBlockPlaced(World world, int x, int y, int z, int sideHit, float hitX, float hitY, float hitZ, int metaData) - { + public int onBlockPlaced( + World world, + int x, + int y, + int z, + int sideHit, + float hitX, + float hitY, + float hitZ, + int metaData + ) { return metaData; } @Override - public TileEntity createNewTileEntity(World world, int metaData) - { + public TileEntity createNewTileEntity(World world, int metaData) { return new TileEntityTransmutationTablet(); } @Override - public boolean renderAsNormalBlock() - { + public boolean renderAsNormalBlock() { return false; } @Override - public boolean isOpaqueCube() - { + public boolean isOpaqueCube() { return false; } @Override - public int getRenderType() - { + public int getRenderType() { return RenderIds.tabletSlab; } - private boolean isStructureValid(IBlockAccess iBlockAcces, int xCoord, int yCoord, int zCoord) - { - return ((iBlockAcces.getBlock(xCoord - 1, yCoord, zCoord - 1) instanceof BlockAshInfusedStoneSlab && iBlockAcces.getBlockMetadata(xCoord - 1, yCoord, zCoord - 1) == 1) && - (iBlockAcces.getBlock(xCoord, yCoord, zCoord - 1) instanceof BlockAshInfusedStoneSlab && iBlockAcces.getBlockMetadata(xCoord, yCoord, zCoord - 1) == 2) && - (iBlockAcces.getBlock(xCoord + 1, yCoord, zCoord - 1) instanceof BlockAshInfusedStoneSlab && iBlockAcces.getBlockMetadata(xCoord + 1, yCoord, zCoord - 1) == 3) && - (iBlockAcces.getBlock(xCoord - 1, yCoord, zCoord) instanceof BlockAshInfusedStoneSlab && iBlockAcces.getBlockMetadata(xCoord - 1, yCoord, zCoord) == 4) && - (iBlockAcces.getBlock(xCoord + 1, yCoord, zCoord) instanceof BlockAshInfusedStoneSlab && iBlockAcces.getBlockMetadata(xCoord + 1, yCoord, zCoord) == 5) && - (iBlockAcces.getBlock(xCoord - 1, yCoord, zCoord + 1) instanceof BlockAshInfusedStoneSlab && iBlockAcces.getBlockMetadata(xCoord - 1, yCoord, zCoord + 1) == 6) && - (iBlockAcces.getBlock(xCoord, yCoord, zCoord + 1) instanceof BlockAshInfusedStoneSlab && iBlockAcces.getBlockMetadata(xCoord, yCoord, zCoord + 1) == 7) && - (iBlockAcces.getBlock(xCoord + 1, yCoord, zCoord + 1) instanceof BlockAshInfusedStoneSlab && iBlockAcces.getBlockMetadata(xCoord + 1, yCoord, zCoord + 1) == 8)); + private boolean + isStructureValid(IBlockAccess iBlockAcces, int xCoord, int yCoord, int zCoord) { + return ( + (iBlockAcces.getBlock(xCoord - 1, yCoord, zCoord - 1) + instanceof BlockAshInfusedStoneSlab + && iBlockAcces.getBlockMetadata(xCoord - 1, yCoord, zCoord - 1) == 1) + && (iBlockAcces.getBlock(xCoord, yCoord, zCoord - 1) + instanceof BlockAshInfusedStoneSlab + && iBlockAcces.getBlockMetadata(xCoord, yCoord, zCoord - 1) == 2) + && (iBlockAcces.getBlock(xCoord + 1, yCoord, zCoord - 1) + instanceof BlockAshInfusedStoneSlab + && iBlockAcces.getBlockMetadata(xCoord + 1, yCoord, zCoord - 1) == 3) + && (iBlockAcces.getBlock(xCoord - 1, yCoord, zCoord) + instanceof BlockAshInfusedStoneSlab + && iBlockAcces.getBlockMetadata(xCoord - 1, yCoord, zCoord) == 4) + && (iBlockAcces.getBlock(xCoord + 1, yCoord, zCoord) + instanceof BlockAshInfusedStoneSlab + && iBlockAcces.getBlockMetadata(xCoord + 1, yCoord, zCoord) == 5) + && (iBlockAcces.getBlock(xCoord - 1, yCoord, zCoord + 1) + instanceof BlockAshInfusedStoneSlab + && iBlockAcces.getBlockMetadata(xCoord - 1, yCoord, zCoord + 1) == 6) + && (iBlockAcces.getBlock(xCoord, yCoord, zCoord + 1) + instanceof BlockAshInfusedStoneSlab + && iBlockAcces.getBlockMetadata(xCoord, yCoord, zCoord + 1) == 7) + && (iBlockAcces.getBlock(xCoord + 1, yCoord, zCoord + 1) + instanceof BlockAshInfusedStoneSlab + && iBlockAcces.getBlockMetadata(xCoord + 1, yCoord, zCoord + 1) == 8) + ); } } diff --git a/src/main/java/com/pahimar/ee3/client/gui/GuiBase.java b/src/main/java/com/pahimar/ee3/client/gui/GuiBase.java index 94e9cac9..f9d9cdfd 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/GuiBase.java +++ b/src/main/java/com/pahimar/ee3/client/gui/GuiBase.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.client.gui; +import java.util.*; + import com.pahimar.ee3.client.gui.component.GuiComponent; import com.pahimar.ee3.client.util.RenderUtils; import com.pahimar.repackage.cofh.lib.util.helpers.StringHelper; @@ -12,14 +14,12 @@ import net.minecraft.inventory.Slot; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -import java.util.*; - @SideOnly(Side.CLIENT) public abstract class GuiBase extends GuiContainer { - @SideOnly(Side.CLIENT) protected ResourceLocation texture; - protected Map guiComponentMap = new TreeMap(); + protected Map guiComponentMap + = new TreeMap(); protected String title; private boolean shouldDrawTitle = true; private String activeGuiComponentId = null; @@ -152,7 +152,8 @@ public abstract class GuiBase extends GuiContainer { } public GuiComponent getTopGuiComponentAt(int positionX, int positionY) { - TreeSet guiComponents = new TreeSet(GuiComponent.zIndexComparator); + TreeSet guiComponents + = new TreeSet(GuiComponent.zIndexComparator); for (GuiComponent guiComponent : getGuiComponents()) { if (guiComponent.intersectsWith(positionX, positionY)) { guiComponents.add(guiComponent); @@ -171,7 +172,8 @@ public abstract class GuiBase extends GuiContainer { } public Collection getGuiComponentsAt(int positionX, int positionY) { - Collection intersectingGuiComponents = new ArrayList(); + Collection intersectingGuiComponents + = new ArrayList(); for (GuiComponent guiComponent : getGuiComponents()) { if (guiComponent.intersectsWith(positionX, positionY)) { @@ -182,8 +184,10 @@ public abstract class GuiBase extends GuiContainer { return intersectingGuiComponents; } - public Collection getGuiComponentsAt(int positionX, int positionY, int zIndex) { - Collection intersectingGuiComponents = new ArrayList(); + public Collection + getGuiComponentsAt(int positionX, int positionY, int zIndex) { + Collection intersectingGuiComponents + = new ArrayList(); for (GuiComponent guiComponent : getGuiComponents()) { if (guiComponent.intersectsWith(positionX, positionY, zIndex)) { @@ -215,7 +219,8 @@ public abstract class GuiBase extends GuiContainer { public void initGui() { super.initGui(); - // A bunch of different impls clear the list of components here - no reason I can discern why at this point + // A bunch of different impls clear the list of components here - no reason I can + // discern why at this point for (GuiComponent guiComponent : getGuiComponents()) { guiComponent.onInit(); @@ -263,12 +268,10 @@ public abstract class GuiBase extends GuiContainer { } @Override - protected void mouseClickMove(int rawMouseX, int rawMouseY, int mouseButton, long duration) { - - } + protected void + mouseClickMove(int rawMouseX, int rawMouseY, int mouseButton, long duration) {} public Slot getSlotAtPosition(int rawMouseX, int rawMouseY) { - Iterator iterator = this.inventorySlots.inventorySlots.iterator(); while (iterator.hasNext()) { Slot slot = (Slot) iterator.next(); @@ -281,14 +284,25 @@ public abstract class GuiBase extends GuiContainer { } public boolean isMouseOverSlot(Slot slot, int rawMouseX, int rawMouseY) { - return this.isMouseOverSlot(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, rawMouseX, rawMouseY); + return this.isMouseOverSlot( + slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, rawMouseX, rawMouseY + ); } - - protected boolean isMouseOverSlot(int slotPositionX, int slotPositionY, int slotWidth, int slotHeight, int rawMouseX, int rawMouseY) { + protected boolean isMouseOverSlot( + int slotPositionX, + int slotPositionY, + int slotWidth, + int slotHeight, + int rawMouseX, + int rawMouseY + ) { rawMouseX -= getGuiPositionX(); rawMouseY -= getGuiPositionX(); - return (rawMouseX >= slotPositionX - 1) && (rawMouseX < slotPositionX + slotWidth + 1) && (rawMouseY >= slotPositionY - 1) && (rawMouseY < slotPositionY + slotHeight + 1); + return (rawMouseX >= slotPositionX - 1) + && (rawMouseX < slotPositionX + slotWidth + 1) + && (rawMouseY >= slotPositionY - 1) + && (rawMouseY < slotPositionY + slotHeight + 1); } @Override @@ -299,7 +313,9 @@ public abstract class GuiBase extends GuiContainer { for (GuiComponent guiComponent : getGuiComponents()) { if (guiComponent.intersectsWith(getAdjustedMouseX(), getAdjustedMouseY())) { - guiComponent.onMouseOver(getAdjustedMouseX(), getAdjustedMouseY(), partialTicks); + guiComponent.onMouseOver( + getAdjustedMouseX(), getAdjustedMouseY(), partialTicks + ); } } } @@ -308,7 +324,14 @@ public abstract class GuiBase extends GuiContainer { protected void drawGuiContainerForegroundLayer(int rawMouseX, int rawMouseY) { // Draw text if (shouldDrawTitle && title != null) { - getFontRenderer().drawString(StringHelper.localize(title), RenderUtils.getCenteredTextOffset(getFontRenderer(), StringHelper.localize(title), getGuiWidth()), 6, 0x404040); + getFontRenderer().drawString( + StringHelper.localize(title), + RenderUtils.getCenteredTextOffset( + getFontRenderer(), StringHelper.localize(title), getGuiWidth() + ), + 6, + 0x404040 + ); } // Draw components @@ -316,14 +339,17 @@ public abstract class GuiBase extends GuiContainer { } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int rawMouseX, int rawMouseY) { + protected void + drawGuiContainerBackgroundLayer(float partialTicks, int rawMouseX, int rawMouseY) { // Draw background GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); if (texture != null) { RenderUtils.bindTexture(texture); int xStart = (getScreenWidth() - getGuiWidth()) / 2; int yStart = (getScreenHeight() - getGuiHeight()) / 2; - this.drawTexturedModalRect(xStart, yStart, 0, 0, getGuiWidth(), getGuiHeight()); + this.drawTexturedModalRect( + xStart, yStart, 0, 0, getGuiWidth(), getGuiHeight() + ); } // Draw components @@ -331,11 +357,11 @@ public abstract class GuiBase extends GuiContainer { GL11.glTranslatef(getGuiPositionX(), getGuiPositionY(), 0.0F); drawComponents(false, rawMouseX, rawMouseY, partialTicks); GL11.glPopMatrix(); - } - protected void drawComponents(boolean drawForeground, int rawMouseX, int rawMouseY, float partialTicks) { - + protected void drawComponents( + boolean drawForeground, int rawMouseX, int rawMouseY, float partialTicks + ) { for (GuiComponent guiComponent : getGuiComponents()) { if (guiComponent.isVisible()) { if (drawForeground) { diff --git a/src/main/java/com/pahimar/ee3/client/gui/GuiFactory.java b/src/main/java/com/pahimar/ee3/client/gui/GuiFactory.java index d38817d6..8169decb 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/GuiFactory.java +++ b/src/main/java/com/pahimar/ee3/client/gui/GuiFactory.java @@ -1,34 +1,27 @@ package com.pahimar.ee3.client.gui; +import java.util.Set; + import cpw.mods.fml.client.IModGuiFactory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; -import java.util.Set; - -public class GuiFactory implements IModGuiFactory -{ +public class GuiFactory implements IModGuiFactory { @Override - public void initialize(Minecraft minecraft) - { - - } + public void initialize(Minecraft minecraft) {} @Override - public Class mainConfigGuiClass() - { + public Class mainConfigGuiClass() { return ModGuiConfig.class; } @Override - public Set runtimeGuiCategories() - { + public Set runtimeGuiCategories() { return null; } @Override - public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) - { + public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { return null; } } diff --git a/src/main/java/com/pahimar/ee3/client/gui/ModGuiConfig.java b/src/main/java/com/pahimar/ee3/client/gui/ModGuiConfig.java index 9c7c99c0..d8f4a56e 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/ModGuiConfig.java +++ b/src/main/java/com/pahimar/ee3/client/gui/ModGuiConfig.java @@ -7,10 +7,18 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.config.ConfigElement; import net.minecraftforge.common.config.Configuration; -public class ModGuiConfig extends GuiConfig -{ - public ModGuiConfig(GuiScreen guiScreen) - { - super(guiScreen, new ConfigElement(ConfigurationHandler.configuration.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), Reference.MOD_ID, false, false, GuiConfig.getAbridgedConfigPath(ConfigurationHandler.configuration.toString())); +public class ModGuiConfig extends GuiConfig { + public ModGuiConfig(GuiScreen guiScreen) { + super( + guiScreen, + new ConfigElement(ConfigurationHandler.configuration.getCategory( + Configuration.CATEGORY_GENERAL + )) + .getChildElements(), + Reference.MOD_ID, + false, + false, + GuiConfig.getAbridgedConfigPath(ConfigurationHandler.configuration.toString()) + ); } } diff --git a/src/main/java/com/pahimar/ee3/client/gui/component/GuiComponent.java b/src/main/java/com/pahimar/ee3/client/gui/component/GuiComponent.java index c1aae127..a23736c6 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/component/GuiComponent.java +++ b/src/main/java/com/pahimar/ee3/client/gui/component/GuiComponent.java @@ -1,59 +1,63 @@ package com.pahimar.ee3.client.gui.component; +import java.util.Comparator; + import com.pahimar.ee3.client.gui.GuiBase; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.util.ResourceLocation; -import java.util.Comparator; - public abstract class GuiComponent implements Comparable { - - public static Comparator orderingComparator = new Comparator() { - - @Override - public int compare(GuiComponent guiComponent1, GuiComponent guiComponent2) { - if (guiComponent1.ordering == guiComponent2.ordering) { - if (guiComponent1.zIndex == guiComponent2.zIndex) { - if (guiComponent1.id != null && guiComponent2.id != null) { - return guiComponent1.id.compareToIgnoreCase(guiComponent2.id); - } else { - return guiComponent1.hashCode() - guiComponent2.hashCode(); - } - } else { - // Purposefully sorting so that higher z-indices appear first in the map - return guiComponent2.zIndex - guiComponent1.zIndex; - } - } else { - return guiComponent1.ordering - guiComponent2.ordering; - } - } - }; - public static Comparator zIndexComparator = new Comparator() { - - @Override - public int compare(GuiComponent guiComponent1, GuiComponent guiComponent2) { - if (guiComponent1.zIndex == guiComponent2.zIndex) { - if (guiComponent1.ordering == guiComponent2.ordering) { - if (guiComponent1.id != null && guiComponent2.id != null) { - return guiComponent1.id.compareToIgnoreCase(guiComponent2.id); - } else { - return guiComponent1.hashCode() - guiComponent2.hashCode(); - } - } else { - return guiComponent1.ordering - guiComponent2.ordering; - } - } else { - // Purposefully sorting so that higher z-indices appear first in the map - return guiComponent2.zIndex - guiComponent1.zIndex; - } - } - }; + public static Comparator orderingComparator + = new Comparator() { + @Override + public int compare(GuiComponent guiComponent1, GuiComponent guiComponent2) { + if (guiComponent1.ordering == guiComponent2.ordering) { + if (guiComponent1.zIndex == guiComponent2.zIndex) { + if (guiComponent1.id != null && guiComponent2.id != null) { + return guiComponent1.id.compareToIgnoreCase(guiComponent2.id + ); + } else { + return guiComponent1.hashCode() - guiComponent2.hashCode(); + } + } else { + // Purposefully sorting so that higher z-indices appear first in + // the map + return guiComponent2.zIndex - guiComponent1.zIndex; + } + } else { + return guiComponent1.ordering - guiComponent2.ordering; + } + } + }; + public static Comparator zIndexComparator + = new Comparator() { + @Override + public int compare(GuiComponent guiComponent1, GuiComponent guiComponent2) { + if (guiComponent1.zIndex == guiComponent2.zIndex) { + if (guiComponent1.ordering == guiComponent2.ordering) { + if (guiComponent1.id != null && guiComponent2.id != null) { + return guiComponent1.id.compareToIgnoreCase(guiComponent2.id + ); + } else { + return guiComponent1.hashCode() - guiComponent2.hashCode(); + } + } else { + return guiComponent1.ordering - guiComponent2.ordering; + } + } else { + // Purposefully sorting so that higher z-indices appear first in the + // map + return guiComponent2.zIndex - guiComponent1.zIndex; + } + } + }; protected final GuiBase parentGui; protected final String id; @SideOnly(Side.CLIENT) protected ResourceLocation texture; - protected int positionX, positionY, componentWidth, componentHeight, textureWidth, textureHeight; + protected int positionX, positionY, componentWidth, componentHeight, textureWidth, + textureHeight; protected int ordering = 0; protected int zIndex = 0; protected boolean isVisible = true; @@ -64,15 +68,49 @@ public abstract class GuiComponent implements Comparable { this(parentGui, id, null, 0, 0); } - public GuiComponent(GuiBase parentGui, String id, ResourceLocation texture, int positionX, int positionY) { + public GuiComponent( + GuiBase parentGui, + String id, + ResourceLocation texture, + int positionX, + int positionY + ) { this(parentGui, id, texture, positionX, positionY, 256, 256); } - public GuiComponent(GuiBase parentGui, String id, ResourceLocation texture, int positionX, int positionY, int componentWidth, int componentHeight) { - this(parentGui, id, texture, positionX, positionY, componentWidth, componentHeight, 256, 256); + public GuiComponent( + GuiBase parentGui, + String id, + ResourceLocation texture, + int positionX, + int positionY, + int componentWidth, + int componentHeight + ) { + this( + parentGui, + id, + texture, + positionX, + positionY, + componentWidth, + componentHeight, + 256, + 256 + ); } - public GuiComponent(GuiBase parentGui, String id, ResourceLocation texture, int positionX, int positionY, int componentWidth, int componentHeight, int textureWidth, int textureHeight) { + public GuiComponent( + GuiBase parentGui, + String id, + ResourceLocation texture, + int positionX, + int positionY, + int componentWidth, + int componentHeight, + int textureWidth, + int textureHeight + ) { this.parentGui = parentGui; this.id = id; this.texture = texture; @@ -101,7 +139,8 @@ public abstract class GuiComponent implements Comparable { return this; } - public GuiComponent setTexture(ResourceLocation texture, int textureWidth, int textureHeight) { + public GuiComponent + setTexture(ResourceLocation texture, int textureWidth, int textureHeight) { this.texture = texture; return this.setTextureSize(textureWidth, textureHeight); } @@ -171,7 +210,6 @@ public abstract class GuiComponent implements Comparable { } public GuiComponent setVisible(boolean isVisible) { - if (this.isVisible && !isVisible) { this.onHide(); } else if (!this.isVisible && isVisible) { @@ -187,7 +225,6 @@ public abstract class GuiComponent implements Comparable { } public GuiComponent setEnabled(boolean isEnabled) { - if (this.isEnabled && !isEnabled) { this.onDisable(); } else if (!this.isEnabled && isEnabled) { @@ -226,14 +263,19 @@ public abstract class GuiComponent implements Comparable { * * @param xCoord x position * @param yCoord y position - * @return true if the specified coordinates intersect with this GuiComponent, false otherwise + * @return true if the specified coordinates intersect with this GuiComponent, false + * otherwise */ public boolean intersectsWith(int xCoord, int yCoord) { - return (xCoord >= this.positionX && xCoord <= this.positionX + this.componentWidth) && (yCoord >= this.positionY && yCoord <= this.positionY + this.componentHeight); + return (xCoord >= this.positionX && xCoord <= this.positionX + this.componentWidth + ) + && (yCoord >= this.positionY + && yCoord <= this.positionY + this.componentHeight); } /** - * Checks whether or not the specified coordinate and z index intersects with this GuiComponent + * Checks whether or not the specified coordinate and z index intersects with this + * GuiComponent * * @param xCoord x position * @param yCoord y position @@ -241,16 +283,20 @@ public abstract class GuiComponent implements Comparable { * @return */ public boolean intersectsWith(int xCoord, int yCoord, int zIndex) { - return (xCoord >= this.positionX && xCoord <= this.positionX + this.componentWidth) && (yCoord >= this.positionY && yCoord <= this.positionY + this.componentHeight) && (zIndex == this.zIndex); + return (xCoord >= this.positionX && xCoord <= this.positionX + this.componentWidth + ) + && (yCoord >= this.positionY + && yCoord <= this.positionY + this.componentHeight) + && (zIndex == this.zIndex); } - /** * @param rawMouseX * @param rawMouseY * @param mouseButton */ - public abstract void onMouseButtonClicked(int rawMouseX, int rawMouseY, int mouseButton); + public abstract void + onMouseButtonClicked(int rawMouseX, int rawMouseY, int mouseButton); /** * @@ -268,9 +314,11 @@ public abstract class GuiComponent implements Comparable { public abstract void onMouseButtonUp(int rawMouseX, int rawMouseY, int mouseButton); - public abstract void onMouseButtonRelease(int rawMouseX, int rawMouseY, int mouseButton, long duration); + public abstract void + onMouseButtonRelease(int rawMouseX, int rawMouseY, int mouseButton, long duration); - public abstract void onMouseMove(int prevRawMouseX, int prevRawMouseY, int newRawMouseX, int newRawMouseY); + public abstract void + onMouseMove(int prevRawMouseX, int prevRawMouseY, int newRawMouseX, int newRawMouseY); public abstract void onMouseEnter(int rawMouseX, int rawMouseY); diff --git a/src/main/java/com/pahimar/ee3/client/gui/element/ElementCheckBox.java b/src/main/java/com/pahimar/ee3/client/gui/element/ElementCheckBox.java index 4d8f74ab..b6e6b000 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/element/ElementCheckBox.java +++ b/src/main/java/com/pahimar/ee3/client/gui/element/ElementCheckBox.java @@ -4,35 +4,62 @@ import com.pahimar.repackage.cofh.lib.gui.GuiBase; import com.pahimar.repackage.cofh.lib.gui.element.ElementButton; import net.minecraft.util.ResourceLocation; -public class ElementCheckBox extends ElementButton -{ +public class ElementCheckBox extends ElementButton { private boolean isChecked; - public ElementCheckBox(GuiBase gui, int posX, int posY, String name, int sheetX, int sheetY, int hoverX, int hoverY, int disabledX, int disabledY, int sizeX, int sizeY, int texW, int texH, ResourceLocation texture) - { - super(gui, posX, posY, name, sheetX, sheetY, hoverX, hoverY, disabledX, disabledY, sizeX, sizeY, texW, texH, texture); + public ElementCheckBox( + GuiBase gui, + int posX, + int posY, + String name, + int sheetX, + int sheetY, + int hoverX, + int hoverY, + int disabledX, + int disabledY, + int sizeX, + int sizeY, + int texW, + int texH, + ResourceLocation texture + ) { + super( + gui, + posX, + posY, + name, + sheetX, + sheetY, + hoverX, + hoverY, + disabledX, + disabledY, + sizeX, + sizeY, + texW, + texH, + texture + ); this.isChecked = false; - // TODO Standardize size and textures - should only ever need to know gui, name, and positioning + // TODO Standardize size and textures - should only ever need to know gui, name, + // and positioning } - public boolean isChecked() - { + public boolean isChecked() { return isChecked; } - public ElementCheckBox check() - { + public ElementCheckBox check() { return setIsChecked(true); } - public ElementCheckBox unCheck() - { + public ElementCheckBox unCheck() { return setIsChecked(false); } - public ElementCheckBox setIsChecked(boolean isChecked) - { + public ElementCheckBox setIsChecked(boolean isChecked) { this.isChecked = isChecked; return this; } diff --git a/src/main/java/com/pahimar/ee3/client/gui/element/ElementSearchField.java b/src/main/java/com/pahimar/ee3/client/gui/element/ElementSearchField.java index 7f210224..f3650651 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/element/ElementSearchField.java +++ b/src/main/java/com/pahimar/ee3/client/gui/element/ElementSearchField.java @@ -6,52 +6,47 @@ import com.pahimar.ee3.network.message.MessageGuiElementTextFieldUpdate; import com.pahimar.repackage.cofh.lib.gui.GuiBase; import com.pahimar.repackage.cofh.lib.gui.element.ElementTextField; -public class ElementSearchField extends ElementTextField -{ - public ElementSearchField(GuiBase gui, int posX, int posY, String name, int width, int height) - { +public class ElementSearchField extends ElementTextField { + public ElementSearchField( + GuiBase gui, int posX, int posY, String name, int width, int height + ) { super(gui, posX, posY, name, width, height); } @Override - protected void onCharacterEntered(boolean success) - { - if (success && this.gui.inventorySlots instanceof IElementTextFieldHandler) - { - ((IElementTextFieldHandler) this.gui.inventorySlots).handleElementTextFieldUpdate(this.name, this.getText()); - PacketHandler.INSTANCE.sendToServer(new MessageGuiElementTextFieldUpdate(this)); + protected void onCharacterEntered(boolean success) { + if (success && this.gui.inventorySlots instanceof IElementTextFieldHandler) { + ((IElementTextFieldHandler) this.gui.inventorySlots) + .handleElementTextFieldUpdate(this.name, this.getText()); + PacketHandler.INSTANCE.sendToServer(new MessageGuiElementTextFieldUpdate(this) + ); } } @Override - protected boolean onEnter() - { - if (isFocused()) - { + protected boolean onEnter() { + if (isFocused()) { this.setFocused(false); } return super.onEnter(); } @Override - public boolean onMousePressed(int mouseX, int mouseY, int mouseButton) - { + public boolean onMousePressed(int mouseX, int mouseY, int mouseButton) { super.onMousePressed(mouseX, mouseY, mouseButton); - if (mouseButton == 1) - { + if (mouseButton == 1) { this.setText(""); - PacketHandler.INSTANCE.sendToServer(new MessageGuiElementTextFieldUpdate(this)); + PacketHandler.INSTANCE.sendToServer(new MessageGuiElementTextFieldUpdate(this) + ); } return true; } @Override - public void onMouseReleased(int mouseX, int mouseY) - { + public void onMouseReleased(int mouseX, int mouseY) { super.onMouseReleased(mouseX, mouseY); - if (this.intersectsWith(mouseX, mouseY)) - { + if (this.intersectsWith(mouseX, mouseY)) { this.setFocused(true); } } diff --git a/src/main/java/com/pahimar/ee3/client/gui/element/ElementStatefulButton.java b/src/main/java/com/pahimar/ee3/client/gui/element/ElementStatefulButton.java index de0db66e..94ea7dca 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/element/ElementStatefulButton.java +++ b/src/main/java/com/pahimar/ee3/client/gui/element/ElementStatefulButton.java @@ -4,23 +4,51 @@ import com.pahimar.repackage.cofh.lib.gui.GuiBase; import com.pahimar.repackage.cofh.lib.gui.element.ElementButton; import net.minecraft.util.ResourceLocation; -public class ElementStatefulButton extends ElementButton -{ +public class ElementStatefulButton extends ElementButton { private int state; - public ElementStatefulButton(GuiBase gui, int posX, int posY, String name, int sheetX, int sheetY, int hoverX, int hoverY, int disabledX, int disabledY, int sizeX, int sizeY, int texW, int texH, ResourceLocation texture) - { - super(gui, posX, posY, name, sheetX, sheetY, hoverX, hoverY, disabledX, disabledY, sizeX, sizeY, texW, texH, texture); + public ElementStatefulButton( + GuiBase gui, + int posX, + int posY, + String name, + int sheetX, + int sheetY, + int hoverX, + int hoverY, + int disabledX, + int disabledY, + int sizeX, + int sizeY, + int texW, + int texH, + ResourceLocation texture + ) { + super( + gui, + posX, + posY, + name, + sheetX, + sheetY, + hoverX, + hoverY, + disabledX, + disabledY, + sizeX, + sizeY, + texW, + texH, + texture + ); this.state = 0; } - public int getState() - { + public int getState() { return state; } - public ElementStatefulButton setState(int state) - { + public ElementStatefulButton setState(int state) { this.state = state; return this; } diff --git a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAdminPanel.java b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAdminPanel.java index bfc431d6..52dd756f 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAdminPanel.java +++ b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAdminPanel.java @@ -13,50 +13,79 @@ import net.minecraft.entity.player.InventoryPlayer; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class GuiAdminPanel extends GuiBase -{ - +public class GuiAdminPanel extends GuiBase { private ElementButton learnableButton; private ElementButton recoverableButton; - public GuiAdminPanel(InventoryPlayer inventoryPlayer) - { + public GuiAdminPanel(InventoryPlayer inventoryPlayer) { super(new ContainerAdminPanel(inventoryPlayer), Textures.Gui.ADMIN_PANEL); xSize = 175; ySize = 176; } @Override - public void initGui() - { + public void initGui() { super.initGui(); - learnableButton = new ElementButton(this, 65, 22, "learnable", 0, 0, 0, 20, 0, 40, 100, 20, 100, 60, Textures.Gui.Elements.BUTTON); - recoverableButton = new ElementButton(this, 65, 48, "recoverable", 0, 0, 0, 20, 0, 40, 100, 20, 100, 60, Textures.Gui.Elements.BUTTON); + learnableButton = new ElementButton( + this, + 65, + 22, + "learnable", + 0, + 0, + 0, + 20, + 0, + 40, + 100, + 20, + 100, + 60, + Textures.Gui.Elements.BUTTON + ); + recoverableButton = new ElementButton( + this, + 65, + 48, + "recoverable", + 0, + 0, + 0, + 20, + 0, + 40, + 100, + 20, + 100, + 60, + Textures.Gui.Elements.BUTTON + ); addElement(learnableButton); addElement(recoverableButton); } @Override - protected void drawGuiContainerForegroundLayer(int x, int y) - { + protected void drawGuiContainerForegroundLayer(int x, int y) { super.drawGuiContainerForegroundLayer(x, y); - if (learnableButton.intersectsWith(mouseX, mouseY)) - { - fontRendererObj.drawSplitString("Not Learnable", 81, 28, 100, new GuiColor(255, 255, 255).getColor()); - } - else - { - fontRendererObj.drawSplitString("Learnable", 90, 28, 100, new GuiColor(255, 255, 255).getColor()); + if (learnableButton.intersectsWith(mouseX, mouseY)) { + fontRendererObj.drawSplitString( + "Not Learnable", 81, 28, 100, new GuiColor(255, 255, 255).getColor() + ); + } else { + fontRendererObj.drawSplitString( + "Learnable", 90, 28, 100, new GuiColor(255, 255, 255).getColor() + ); } - fontRendererObj.drawSplitString("Recoverable", 85, 54, 100, new GuiColor(255, 255, 255).getColor()); + fontRendererObj.drawSplitString( + "Recoverable", 85, 54, 100, new GuiColor(255, 255, 255).getColor() + ); } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int x, int y) - { + protected void drawGuiContainerBackgroundLayer(float partialTicks, int x, int y) { mouseX = x - guiLeft; mouseY = y - guiTop; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); @@ -70,14 +99,12 @@ public class GuiAdminPanel extends GuiBase } @Override - protected void updateElementInformation() - { - - } + protected void updateElementInformation() {} @Override - public void handleElementButtonClick(String buttonName, int mouseButton) - { - PacketHandler.INSTANCE.sendToServer(new MessageGuiElementClicked(buttonName, mouseButton)); + public void handleElementButtonClick(String buttonName, int mouseButton) { + PacketHandler.INSTANCE.sendToServer( + new MessageGuiElementClicked(buttonName, mouseButton) + ); } } diff --git a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAlchemicalBag.java b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAlchemicalBag.java index 01066284..f87e10e0 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAlchemicalBag.java +++ b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAlchemicalBag.java @@ -15,60 +15,58 @@ import net.minecraft.util.StatCollector; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class GuiAlchemicalBag extends GuiContainer -{ +public class GuiAlchemicalBag extends GuiContainer { private final ItemStack parentItemStack; private final InventoryAlchemicalBag inventoryAlchemicalBag; - public GuiAlchemicalBag(EntityPlayer entityPlayer, InventoryAlchemicalBag inventoryAlchemicalBag) - { + public GuiAlchemicalBag( + EntityPlayer entityPlayer, InventoryAlchemicalBag inventoryAlchemicalBag + ) { super(new ContainerAlchemicalBag(entityPlayer, inventoryAlchemicalBag)); this.parentItemStack = inventoryAlchemicalBag.parentItemStack; this.inventoryAlchemicalBag = inventoryAlchemicalBag; - if (this.parentItemStack.getItemDamage() == 0) - { + if (this.parentItemStack.getItemDamage() == 0) { xSize = 230; ySize = 186; - } - else if (this.parentItemStack.getItemDamage() == 1) - { + } else if (this.parentItemStack.getItemDamage() == 1) { xSize = 230; ySize = 240; - } - else if (this.parentItemStack.getItemDamage() == 2) - { + } else if (this.parentItemStack.getItemDamage() == 2) { xSize = 248; ySize = 256; } } @Override - protected void drawGuiContainerForegroundLayer(int x, int y) - { - if (this.parentItemStack.getItemDamage() == 0 || this.parentItemStack.getItemDamage() == 1) - { - fontRendererObj.drawString(StatCollector.translateToLocal(inventoryAlchemicalBag.getInventoryName()), 8, 6, Integer.parseInt(Colors.PURE_WHITE, 16)); - fontRendererObj.drawString(StatCollector.translateToLocal(Names.Containers.VANILLA_INVENTORY), 35, ySize - 95 + 2, Integer.parseInt(Colors.PURE_WHITE, 16)); + protected void drawGuiContainerForegroundLayer(int x, int y) { + if (this.parentItemStack.getItemDamage() == 0 + || this.parentItemStack.getItemDamage() == 1) { + fontRendererObj.drawString( + StatCollector.translateToLocal(inventoryAlchemicalBag.getInventoryName()), + 8, + 6, + Integer.parseInt(Colors.PURE_WHITE, 16) + ); + fontRendererObj.drawString( + StatCollector.translateToLocal(Names.Containers.VANILLA_INVENTORY), + 35, + ySize - 95 + 2, + Integer.parseInt(Colors.PURE_WHITE, 16) + ); } } @Override - protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) - { + protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - if (this.parentItemStack.getItemDamage() == 0) - { + if (this.parentItemStack.getItemDamage() == 0) { this.mc.getTextureManager().bindTexture(Textures.Gui.ALCHEMICAL_BAG_SMALL); - } - else if (this.parentItemStack.getItemDamage() == 1) - { + } else if (this.parentItemStack.getItemDamage() == 1) { this.mc.getTextureManager().bindTexture(Textures.Gui.ALCHEMICAL_BAG_MEDIUM); - } - else if (this.parentItemStack.getItemDamage() == 2) - { + } else if (this.parentItemStack.getItemDamage() == 2) { this.mc.getTextureManager().bindTexture(Textures.Gui.ALCHEMICAL_BAG_LARGE); } @@ -78,18 +76,13 @@ public class GuiAlchemicalBag extends GuiContainer } @Override - public void onGuiClosed() - { + public void onGuiClosed() { super.onGuiClosed(); - if (mc.thePlayer != null) - { - for (ItemStack itemStack : mc.thePlayer.inventory.mainInventory) - { - if (itemStack != null) - { - if (NBTHelper.hasKey(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN)) - { + if (mc.thePlayer != null) { + for (ItemStack itemStack : mc.thePlayer.inventory.mainInventory) { + if (itemStack != null) { + if (NBTHelper.hasKey(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN)) { NBTHelper.removeTag(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN); } } @@ -98,9 +91,7 @@ public class GuiAlchemicalBag extends GuiContainer } @Override - protected boolean checkHotbarKeys(int key) - { + protected boolean checkHotbarKeys(int key) { return false; } - } diff --git a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAlchemicalChest.java b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAlchemicalChest.java index 251c2b7a..d62ca885 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAlchemicalChest.java +++ b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAlchemicalChest.java @@ -10,57 +10,56 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.StatCollector; import org.lwjgl.opengl.GL11; -public class GuiAlchemicalChest extends GuiContainer -{ +public class GuiAlchemicalChest extends GuiContainer { private TileEntityAlchemicalChest tileEntityAlchemicalChest; - public GuiAlchemicalChest(InventoryPlayer inventoryPlayer, TileEntityAlchemicalChest alchemicalChest) - { + public GuiAlchemicalChest( + InventoryPlayer inventoryPlayer, TileEntityAlchemicalChest alchemicalChest + ) { super(new ContainerAlchemicalChest(inventoryPlayer, alchemicalChest)); tileEntityAlchemicalChest = alchemicalChest; - if (this.tileEntityAlchemicalChest.getState() == 0) - { + if (this.tileEntityAlchemicalChest.getState() == 0) { xSize = 230; ySize = 186; - } - else if (this.tileEntityAlchemicalChest.getState() == 1) - { + } else if (this.tileEntityAlchemicalChest.getState() == 1) { xSize = 230; ySize = 240; - } - else if (this.tileEntityAlchemicalChest.getState() == 2) - { + } else if (this.tileEntityAlchemicalChest.getState() == 2) { xSize = 248; ySize = 256; } } @Override - protected void drawGuiContainerForegroundLayer(int x, int y) - { - if (tileEntityAlchemicalChest.getState() == 0 || tileEntityAlchemicalChest.getState() == 1) - { - fontRendererObj.drawString(StatCollector.translateToLocal(tileEntityAlchemicalChest.getInventoryName()), 8, 6, Integer.parseInt(Colors.PURE_WHITE, 16)); - fontRendererObj.drawString(StatCollector.translateToLocal(Names.Containers.VANILLA_INVENTORY), 35, ySize - 95 + 2, Integer.parseInt(Colors.PURE_WHITE, 16)); + protected void drawGuiContainerForegroundLayer(int x, int y) { + if (tileEntityAlchemicalChest.getState() == 0 + || tileEntityAlchemicalChest.getState() == 1) { + fontRendererObj.drawString( + StatCollector.translateToLocal(tileEntityAlchemicalChest.getInventoryName( + )), + 8, + 6, + Integer.parseInt(Colors.PURE_WHITE, 16) + ); + fontRendererObj.drawString( + StatCollector.translateToLocal(Names.Containers.VANILLA_INVENTORY), + 35, + ySize - 95 + 2, + Integer.parseInt(Colors.PURE_WHITE, 16) + ); } } @Override - protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) - { + protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - if (tileEntityAlchemicalChest.getState() == 0) - { + if (tileEntityAlchemicalChest.getState() == 0) { this.mc.getTextureManager().bindTexture(Textures.Gui.ALCHEMICAL_CHEST_SMALL); - } - else if (tileEntityAlchemicalChest.getState() == 1) - { + } else if (tileEntityAlchemicalChest.getState() == 1) { this.mc.getTextureManager().bindTexture(Textures.Gui.ALCHEMICAL_CHEST_MEDIUM); - } - else if (tileEntityAlchemicalChest.getState() == 2) - { + } else if (tileEntityAlchemicalChest.getState() == 2) { this.mc.getTextureManager().bindTexture(Textures.Gui.ALCHEMICAL_CHEST_LARGE); } diff --git a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAlchenomicon.java b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAlchenomicon.java index de78e7a8..04360490 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAlchenomicon.java +++ b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAlchenomicon.java @@ -19,29 +19,61 @@ import net.minecraft.util.StatCollector; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class GuiAlchenomicon extends GuiBase -{ +public class GuiAlchenomicon extends GuiBase { private ElementButton prevPageButton; private ElementButton nextPageButton; private ElementTextField searchTextField; - public GuiAlchenomicon(InventoryPlayer inventoryPlayer, ItemStack itemStack) - { - super(new ContainerAlchenomicon(inventoryPlayer.player, itemStack), Textures.Gui.ALCHENOMICON); + public GuiAlchenomicon(InventoryPlayer inventoryPlayer, ItemStack itemStack) { + super( + new ContainerAlchenomicon(inventoryPlayer.player, itemStack), + Textures.Gui.ALCHENOMICON + ); xSize = 256; ySize = 226; } @Override - public void initGui() - { + public void initGui() { super.initGui(); this.drawTitle = false; this.drawInventory = false; - prevPageButton = new ElementButton(this, 15, 177, "prev", 0, 0, 20, 0, 40, 0, 20, 10, 60, 10, Textures.Gui.Elements.ARROW_LEFT); - nextPageButton = new ElementButton(this, 223, 177, "next", 0, 0, 22, 0, 44, 0, 22, 10, 66, 10, Textures.Gui.Elements.ARROW_RIGHT); + prevPageButton = new ElementButton( + this, + 15, + 177, + "prev", + 0, + 0, + 20, + 0, + 40, + 0, + 20, + 10, + 60, + 10, + Textures.Gui.Elements.ARROW_LEFT + ); + nextPageButton = new ElementButton( + this, + 223, + 177, + "next", + 0, + 0, + 22, + 0, + 44, + 0, + 22, + 10, + 66, + 10, + Textures.Gui.Elements.ARROW_RIGHT + ); searchTextField = new ElementSearchField(this, 64, 205, "searchField", 128, 20); searchTextField.setPadding(6, 3, 0, 3); searchTextField.borderColor = new GuiColor(160, 160, 160).getColor(); @@ -53,32 +85,37 @@ public class GuiAlchenomicon extends GuiBase } @Override - protected void drawGuiContainerForegroundLayer(int x, int y) - { + protected void drawGuiContainerForegroundLayer(int x, int y) { super.drawGuiContainerForegroundLayer(x, y); int pageOffset = ((ContainerAlchenomicon) this.inventorySlots).getPageOffset(); - if (this.inventorySlots.getSlot(0).getHasStack()) - { - fontRendererObj.drawString((pageOffset * 2 + 1) + "", 64, 178, new GuiColor(50, 50, 50).getColor()); - } - else - { - if (((ContainerAlchenomicon) this.inventorySlots).getKnownTransmutationsCount() == 0) - { - fontRendererObj.drawSplitString(StatCollector.translateToLocal(Messages.Gui.NO_KNOWN_TRANSMUTATIONS), 142, 20, 100, new GuiColor(50, 50, 50).getColor()); + if (this.inventorySlots.getSlot(0).getHasStack()) { + fontRendererObj.drawString( + (pageOffset * 2 + 1) + "", 64, 178, new GuiColor(50, 50, 50).getColor() + ); + } else { + if (((ContainerAlchenomicon) this.inventorySlots) + .getKnownTransmutationsCount() + == 0) { + fontRendererObj.drawSplitString( + StatCollector.translateToLocal(Messages.Gui.NO_KNOWN_TRANSMUTATIONS), + 142, + 20, + 100, + new GuiColor(50, 50, 50).getColor() + ); } } - if (this.inventorySlots.getSlot(40).getHasStack()) - { - fontRendererObj.drawString((pageOffset * 2 + 2) + "", 186, 178, new GuiColor(50, 50, 50).getColor()); + if (this.inventorySlots.getSlot(40).getHasStack()) { + fontRendererObj.drawString( + (pageOffset * 2 + 2) + "", 186, 178, new GuiColor(50, 50, 50).getColor() + ); } } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int x, int y) - { + protected void drawGuiContainerBackgroundLayer(float partialTicks, int x, int y) { mouseX = x - guiLeft; mouseY = y - guiTop; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); @@ -92,36 +129,31 @@ public class GuiAlchenomicon extends GuiBase } @Override - protected void updateElementInformation() - { - if (((ContainerAlchenomicon) this.inventorySlots).getPageOffset() == 0) - { + protected void updateElementInformation() { + if (((ContainerAlchenomicon) this.inventorySlots).getPageOffset() == 0) { prevPageButton.setDisabled(); - } - else if (!prevPageButton.isEnabled()) - { + } else if (!prevPageButton.isEnabled()) { prevPageButton.setEnabled(true); } - if (((ContainerAlchenomicon) this.inventorySlots).getPageOffset() == ((ContainerAlchenomicon) this.inventorySlots).getMaxPageOffset()) - { + if (((ContainerAlchenomicon) this.inventorySlots).getPageOffset() + == ((ContainerAlchenomicon) this.inventorySlots).getMaxPageOffset()) { nextPageButton.setDisabled(); - } - else if (!nextPageButton.isEnabled()) - { + } else if (!nextPageButton.isEnabled()) { nextPageButton.setEnabled(true); } } @Override - protected void handleMouseClick(Slot slot, int p_146984_2_, int p_146984_3_, int p_146984_4_) - { + protected void + handleMouseClick(Slot slot, int p_146984_2_, int p_146984_3_, int p_146984_4_) { // NOOP } @Override - public void handleElementButtonClick(String buttonName, int mouseButton) - { - PacketHandler.INSTANCE.sendToServer(new MessageGuiElementClicked(buttonName, mouseButton)); + public void handleElementButtonClick(String buttonName, int mouseButton) { + PacketHandler.INSTANCE.sendToServer( + new MessageGuiElementClicked(buttonName, mouseButton) + ); } } diff --git a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAludel.java b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAludel.java index bbab2023..f05644ed 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAludel.java +++ b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiAludel.java @@ -10,12 +10,10 @@ import net.minecraft.entity.player.InventoryPlayer; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class GuiAludel extends GuiContainer -{ +public class GuiAludel extends GuiContainer { private TileEntityAludel tileEntityAludel; - public GuiAludel(InventoryPlayer inventoryPlayer, TileEntityAludel tileEntityAludel) - { + public GuiAludel(InventoryPlayer inventoryPlayer, TileEntityAludel tileEntityAludel) { super(new ContainerAludel(inventoryPlayer, tileEntityAludel)); this.tileEntityAludel = tileEntityAludel; xSize = 176; @@ -23,14 +21,12 @@ public class GuiAludel extends GuiContainer } @Override - protected void drawGuiContainerForegroundLayer(int x, int y) - { + protected void drawGuiContainerForegroundLayer(int x, int y) { // NOOP } @Override - protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) - { + protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(Textures.Gui.ALUDEL); @@ -40,13 +36,21 @@ public class GuiAludel extends GuiContainer this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize); int scaleAdjustment; - if (this.tileEntityAludel.getState() == 1) - { + if (this.tileEntityAludel.getState() == 1) { scaleAdjustment = this.tileEntityAludel.getBurnTimeRemainingScaled(12); - this.drawTexturedModalRect(xStart + 45, yStart + 36 + 34 - scaleAdjustment, 176, 12 - scaleAdjustment, 14, scaleAdjustment + 2); + this.drawTexturedModalRect( + xStart + 45, + yStart + 36 + 34 - scaleAdjustment, + 176, + 12 - scaleAdjustment, + 14, + scaleAdjustment + 2 + ); } scaleAdjustment = this.tileEntityAludel.getCookProgressScaled(24); - this.drawTexturedModalRect(xStart + 80, yStart + 40, 176, 14, scaleAdjustment + 1, 16); + this.drawTexturedModalRect( + xStart + 80, yStart + 40, 176, 14, scaleAdjustment + 1, 16 + ); } } diff --git a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiCalcinator.java b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiCalcinator.java index cc1a62f1..62ee0ce8 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiCalcinator.java +++ b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiCalcinator.java @@ -10,26 +10,24 @@ import net.minecraft.entity.player.InventoryPlayer; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class GuiCalcinator extends GuiContainer -{ +public class GuiCalcinator extends GuiContainer { private TileEntityCalcinator tileEntityCalcinator; - public GuiCalcinator(InventoryPlayer inventoryPlayer, TileEntityCalcinator tileEntityCalcinator) - { + public GuiCalcinator( + InventoryPlayer inventoryPlayer, TileEntityCalcinator tileEntityCalcinator + ) { super(new ContainerCalcinator(inventoryPlayer, tileEntityCalcinator)); ySize = 176; this.tileEntityCalcinator = tileEntityCalcinator; } @Override - protected void drawGuiContainerForegroundLayer(int x, int y) - { + protected void drawGuiContainerForegroundLayer(int x, int y) { // NOOP } @Override - protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) - { + protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(Textures.Gui.CALCINATOR); @@ -39,13 +37,21 @@ public class GuiCalcinator extends GuiContainer this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize); int scaleAdjustment; - if (this.tileEntityCalcinator.getState() == 1) - { + if (this.tileEntityCalcinator.getState() == 1) { scaleAdjustment = this.tileEntityCalcinator.getBurnTimeRemainingScaled(12); - this.drawTexturedModalRect(xStart + 46, yStart + 22 + 23 - scaleAdjustment, 176, 12 - scaleAdjustment, 14, scaleAdjustment + 2); + this.drawTexturedModalRect( + xStart + 46, + yStart + 22 + 23 - scaleAdjustment, + 176, + 12 - scaleAdjustment, + 14, + scaleAdjustment + 2 + ); } scaleAdjustment = this.tileEntityCalcinator.getCookProgressScaled(24); - this.drawTexturedModalRect(xStart + 75, yStart + 30, 176, 14, scaleAdjustment + 1, 16); + this.drawTexturedModalRect( + xStart + 75, yStart + 30, 176, 14, scaleAdjustment + 1, 16 + ); } } diff --git a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiGlassBell.java b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiGlassBell.java index 8c1bb79b..29e67609 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiGlassBell.java +++ b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiGlassBell.java @@ -10,12 +10,12 @@ import net.minecraft.entity.player.InventoryPlayer; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class GuiGlassBell extends GuiContainer -{ +public class GuiGlassBell extends GuiContainer { private TileEntityGlassBell tileEntityGlassBell; - public GuiGlassBell(InventoryPlayer inventoryPlayer, TileEntityGlassBell tileEntityGlassBell) - { + public GuiGlassBell( + InventoryPlayer inventoryPlayer, TileEntityGlassBell tileEntityGlassBell + ) { super(new ContainerGlassBell(inventoryPlayer, tileEntityGlassBell)); this.tileEntityGlassBell = tileEntityGlassBell; xSize = 176; @@ -23,14 +23,12 @@ public class GuiGlassBell extends GuiContainer } @Override - protected void drawGuiContainerForegroundLayer(int x, int y) - { + protected void drawGuiContainerForegroundLayer(int x, int y) { // NOOP } @Override - protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) - { + protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); diff --git a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiPortableCrafting.java b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiPortableCrafting.java index 922c29e3..bbcc54af 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiPortableCrafting.java +++ b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiPortableCrafting.java @@ -3,9 +3,6 @@ package com.pahimar.ee3.client.gui.inventory; import com.pahimar.ee3.inventory.ContainerPortableCrafting; import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.util.NBTHelper; - -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.gui.inventory.GuiContainer; @@ -14,18 +11,20 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class GuiPortableCrafting extends GuiContainer { - public GuiPortableCrafting(EntityPlayer player, World world, int x, int y, int z) { super(new ContainerPortableCrafting(player.inventory, world, x, y, z)); } @Override protected void drawGuiContainerBackgroundLayer(float arg0, int arg1, int arg2) { - GL11.glColor4f((float)1.0f, (float)1.0f, (float)1.0f, (float)1.0f); - this.mc.renderEngine.bindTexture(new ResourceLocation("textures/gui/container/crafting_table.png")); + GL11.glColor4f((float) 1.0f, (float) 1.0f, (float) 1.0f, (float) 1.0f); + this.mc.renderEngine.bindTexture( + new ResourceLocation("textures/gui/container/crafting_table.png") + ); int var5 = (this.width - this.xSize) / 2; int var6 = (this.height - this.ySize) / 2; this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); @@ -33,8 +32,15 @@ public class GuiPortableCrafting extends GuiContainer { @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - this.fontRendererObj.drawString(StatCollector.translateToLocal((String)"container.crafting"), 28, 6, 0x404040); - this.fontRendererObj.drawString(StatCollector.translateToLocal((String)"container.inventory"), 8, this.ySize - 96 + 2, 0x404040); + this.fontRendererObj.drawString( + StatCollector.translateToLocal((String) "container.crafting"), 28, 6, 0x404040 + ); + this.fontRendererObj.drawString( + StatCollector.translateToLocal((String) "container.inventory"), + 8, + this.ySize - 96 + 2, + 0x404040 + ); } @Override @@ -42,10 +48,11 @@ public class GuiPortableCrafting extends GuiContainer { super.onGuiClosed(); if (this.mc.thePlayer != null) { for (ItemStack itemStack : this.mc.thePlayer.inventory.mainInventory) { - if (itemStack == null || !NBTHelper.hasKey(itemStack, Names.NBT.CRAFTING_GUI_OPEN)) continue; + if (itemStack == null + || !NBTHelper.hasKey(itemStack, Names.NBT.CRAFTING_GUI_OPEN)) + continue; NBTHelper.removeTag(itemStack, Names.NBT.CRAFTING_GUI_OPEN); } } } - } diff --git a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiResearchStation.java b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiResearchStation.java index 55d2f774..e5cefb64 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiResearchStation.java +++ b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiResearchStation.java @@ -10,12 +10,13 @@ import net.minecraft.entity.player.InventoryPlayer; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class GuiResearchStation extends GuiContainer -{ +public class GuiResearchStation extends GuiContainer { private TileEntityResearchStation tileEntityResearchStation; - public GuiResearchStation(InventoryPlayer inventoryPlayer, TileEntityResearchStation tileEntityResearchStation) - { + public GuiResearchStation( + InventoryPlayer inventoryPlayer, + TileEntityResearchStation tileEntityResearchStation + ) { super(new ContainerResearchStation(inventoryPlayer, tileEntityResearchStation)); xSize = 256; ySize = 234; @@ -23,8 +24,7 @@ public class GuiResearchStation extends GuiContainer } @Override - protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) - { + protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(Textures.Gui.RESEARCH_STATION); @@ -33,19 +33,24 @@ public class GuiResearchStation extends GuiContainer int yStart = (height - ySize) / 2; this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize); - if (this.tileEntityResearchStation.isItemKnown) - { - this.mc.getTextureManager().bindTexture(Textures.Gui.RESEARCH_STATION_GYLPH_1); + if (this.tileEntityResearchStation.isItemKnown) { + this.mc.getTextureManager().bindTexture(Textures.Gui.RESEARCH_STATION_GYLPH_1 + ); this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize); - } - else - { - int arrowScaleAdjustment = this.tileEntityResearchStation.getLearnProgressScaled(42); - this.drawTexturedModalRect(xStart + 107, yStart + 87, 0, 236, arrowScaleAdjustment, 16); + } else { + int arrowScaleAdjustment + = this.tileEntityResearchStation.getLearnProgressScaled(42); + this.drawTexturedModalRect( + xStart + 107, yStart + 87, 0, 236, arrowScaleAdjustment, 16 + ); - int scaleAdjustment = this.tileEntityResearchStation.getLearnProgressScaled(80); - this.mc.getTextureManager().bindTexture(Textures.Gui.RESEARCH_STATION_GYLPH_1); - this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, (ySize * scaleAdjustment) / 100); + int scaleAdjustment + = this.tileEntityResearchStation.getLearnProgressScaled(80); + this.mc.getTextureManager().bindTexture(Textures.Gui.RESEARCH_STATION_GYLPH_1 + ); + this.drawTexturedModalRect( + xStart, yStart, 0, 0, xSize, (ySize * scaleAdjustment) / 100 + ); } } } diff --git a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiSymbolSelection.java b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiSymbolSelection.java index a1ede9c4..366c2536 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiSymbolSelection.java +++ b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiSymbolSelection.java @@ -3,22 +3,16 @@ package com.pahimar.ee3.client.gui.inventory; import com.pahimar.ee3.inventory.ContainerSymbolSelection; import net.minecraft.client.gui.inventory.GuiContainer; -public class GuiSymbolSelection extends GuiContainer -{ - public GuiSymbolSelection() - { +public class GuiSymbolSelection extends GuiContainer { + public GuiSymbolSelection() { super(new ContainerSymbolSelection()); } @Override - protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) - { - - } + protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) {} @Override - public void drawDefaultBackground() - { + public void drawDefaultBackground() { // NOOP } } diff --git a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiTransmutationArray.java b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiTransmutationArray.java index eacc5a0e..b021e429 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiTransmutationArray.java +++ b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiTransmutationArray.java @@ -10,12 +10,12 @@ import net.minecraft.entity.player.InventoryPlayer; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class GuiTransmutationArray extends GuiBase -{ +public class GuiTransmutationArray extends GuiBase { private TileEntityAlchemyArray tileEntityAlchemyArray; - public GuiTransmutationArray(InventoryPlayer inventoryPlayer, TileEntityAlchemyArray tileEntityAlchemyArray) - { + public GuiTransmutationArray( + InventoryPlayer inventoryPlayer, TileEntityAlchemyArray tileEntityAlchemyArray + ) { super(new ContainerTransmutationArray(inventoryPlayer, tileEntityAlchemyArray)); this.tileEntityAlchemyArray = tileEntityAlchemyArray; xSize = 256; @@ -23,8 +23,7 @@ public class GuiTransmutationArray extends GuiBase } @Override - public void initGui() - { + public void initGui() { super.initGui(); this.drawTitle = false; @@ -32,27 +31,20 @@ public class GuiTransmutationArray extends GuiBase } @Override - protected void drawGuiContainerForegroundLayer(int x, int y) - { + protected void drawGuiContainerForegroundLayer(int x, int y) { super.drawGuiContainerForegroundLayer(x, y); } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int x, int y) - { + protected void drawGuiContainerBackgroundLayer(float partialTicks, int x, int y) { mouseX = x - guiLeft; mouseY = y - guiTop; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - if (tileEntityAlchemyArray.getSize() == 1) - { + if (tileEntityAlchemyArray.getSize() == 1) { bindTexture(Textures.Gui.TRANSMUTATION_ARRAY_1); - } - else if (tileEntityAlchemyArray.getSize() == 2) - { + } else if (tileEntityAlchemyArray.getSize() == 2) { bindTexture(Textures.Gui.TRANSMUTATION_ARRAY_3); - } - else if (tileEntityAlchemyArray.getSize() == 3) - { + } else if (tileEntityAlchemyArray.getSize() == 3) { bindTexture(Textures.Gui.TRANSMUTATION_ARRAY_5); } drawSizedTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize, 256f, 256f); diff --git a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiTransmutationTablet.java b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiTransmutationTablet.java index 17be40f4..4959825e 100644 --- a/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiTransmutationTablet.java +++ b/src/main/java/com/pahimar/ee3/client/gui/inventory/GuiTransmutationTablet.java @@ -22,7 +22,6 @@ import net.minecraft.util.StatCollector; @SideOnly(Side.CLIENT) public class GuiTransmutationTablet extends GuiBase { - private ContainerTransmutationTablet containerTablet; private ElementTextField searchTextField; @@ -41,17 +40,23 @@ public class GuiTransmutationTablet extends GuiBase { private static final int SORT_ASCENDING = 0; private static final int SORT_DESCENDING = 1; - public GuiTransmutationTablet(InventoryPlayer inventoryPlayer, TileEntityTransmutationTablet tileEntityTransmutationTablet) - { - super(new ContainerTransmutationTablet(inventoryPlayer, tileEntityTransmutationTablet), Textures.Gui.TRANSMUTATION_TABLET); + public GuiTransmutationTablet( + InventoryPlayer inventoryPlayer, + TileEntityTransmutationTablet tileEntityTransmutationTablet + ) { + super( + new ContainerTransmutationTablet( + inventoryPlayer, tileEntityTransmutationTablet + ), + Textures.Gui.TRANSMUTATION_TABLET + ); this.containerTablet = (ContainerTransmutationTablet) this.inventorySlots; xSize = 256; ySize = 256; } @Override - public void initGui() - { + public void initGui() { super.initGui(); this.drawTitle = false; @@ -61,44 +66,62 @@ public class GuiTransmutationTablet extends GuiBase { searchTextField.backgroundColor = new GuiColor(0, 0, 0, 0).getColor(); searchTextField.borderColor = new GuiColor(0, 0, 0, 0).getColor(); - sortOptionButton = new ElementStatefulButton(this, 151, 36, "sortOption", 0, 0, 18, 0, 36, 0, 18, 18, 54, 18, Textures.Gui.Elements.BUTTON_SORT_OPTION) - { + sortOptionButton = new ElementStatefulButton( + this, + 151, + 36, + "sortOption", + 0, + 0, + 18, + 0, + 36, + 0, + 18, + 18, + 54, + 18, + Textures.Gui.Elements.BUTTON_SORT_OPTION + ) { @Override - public void drawBackground(int mouseX, int mouseY, float gameTicks) - { + public void drawBackground(int mouseX, int mouseY, float gameTicks) { RenderHelper.bindTexture(texture); - if (isEnabled()) - { - if (getState() == SORT_BY_DISPLAY_NAME) - { + if (isEnabled()) { + if (getState() == SORT_BY_DISPLAY_NAME) { drawTexturedModalRect(posX, posY, 36, 0, sizeX, sizeY); - } - else if (getState() == SORT_BY_ENERGY_VALUE) - { + } else if (getState() == SORT_BY_ENERGY_VALUE) { drawTexturedModalRect(posX, posY, 0, 0, sizeX, sizeY); - } - else if (getState() == SORT_BY_ID) - { + } else if (getState() == SORT_BY_ID) { drawTexturedModalRect(posX, posY, 18, 0, sizeX, sizeY); } } } }; - sortOrderButton = new ElementStatefulButton(this, 151, 58, "sortOrder", 0, 0, 0, 0, 18, 0, 18, 18, 36, 18, Textures.Gui.Elements.BUTTON_SORT_ORDER) - { + sortOrderButton = new ElementStatefulButton( + this, + 151, + 58, + "sortOrder", + 0, + 0, + 0, + 0, + 18, + 0, + 18, + 18, + 36, + 18, + Textures.Gui.Elements.BUTTON_SORT_ORDER + ) { @Override - public void drawBackground(int mouseX, int mouseY, float gameTicks) - { + public void drawBackground(int mouseX, int mouseY, float gameTicks) { RenderHelper.bindTexture(texture); - if (isEnabled()) - { - if (getState() == SORT_ASCENDING) - { + if (isEnabled()) { + if (getState() == SORT_ASCENDING) { drawTexturedModalRect(posX, posY, 0, 0, sizeX, sizeY); - } - else if (getState() == SORT_DESCENDING) - { + } else if (getState() == SORT_DESCENDING) { drawTexturedModalRect(posX, posY, 18, 0, sizeX, sizeY); } } @@ -106,37 +129,31 @@ public class GuiTransmutationTablet extends GuiBase { }; setTooltipByState(); - slider = new ElementSlider(this, "scrollBar", 239, 36, 12, 201, 187, 0) - { + slider = new ElementSlider(this, "scrollBar", 239, 36, 12, 201, 187, 0) { @Override - protected void dragSlider(int x, int y) - { - if (y > _value) - { + protected void dragSlider(int x, int y) { + if (y > _value) { setValue(_value + 1); - } - else - { + } else { setValue(_value - 1); } } @Override - public boolean onMouseWheel(int mouseX, int mouseY, int movement) - { - PacketHandler.INSTANCE.sendToServer(new MessageSliderElementUpdated(this)); + public boolean onMouseWheel(int mouseX, int mouseY, int movement) { + PacketHandler.INSTANCE.sendToServer(new MessageSliderElementUpdated(this) + ); return super.onMouseWheel(mouseX, mouseY, movement); } @Override - public void onStopDragging() - { - PacketHandler.INSTANCE.sendToServer(new MessageSliderElementUpdated(this)); + public void onStopDragging() { + PacketHandler.INSTANCE.sendToServer(new MessageSliderElementUpdated(this) + ); } @Override - public int getSliderY() - { + public int getSliderY() { return _value; } }; @@ -151,76 +168,67 @@ public class GuiTransmutationTablet extends GuiBase { } @Override - protected void drawGuiContainerForegroundLayer(int x, int y) - { + protected void drawGuiContainerForegroundLayer(int x, int y) { super.drawGuiContainerForegroundLayer(x, y); - fontRendererObj.drawString(String.format("%s:", StatCollector.translateToLocal(Messages.ENERGY_VALUE)), 10, 142, Integer.parseInt(Colors.PURE_WHITE, 16)); - fontRendererObj.drawString(String.format("%s", containerTablet.getEnergyValue()), 10, 152, Integer.parseInt(Colors.PURE_WHITE, 16)); + fontRendererObj.drawString( + String.format("%s:", StatCollector.translateToLocal(Messages.ENERGY_VALUE)), + 10, + 142, + Integer.parseInt(Colors.PURE_WHITE, 16) + ); + fontRendererObj.drawString( + String.format("%s", containerTablet.getEnergyValue()), + 10, + 152, + Integer.parseInt(Colors.PURE_WHITE, 16) + ); } @Override - public void updateScreen() - { + public void updateScreen() { super.updateScreen(); tickCount++; } @Override - protected boolean checkHotbarKeys(int key) - { + protected boolean checkHotbarKeys(int key) { return false; } @Override - public void handleElementButtonClick(String buttonName, int mouseButton) - { - if (buttonName.equals("sortOption")) - { - PacketHandler.INSTANCE.sendToServer(new MessageGuiElementClicked(buttonName, mouseButton)); + public void handleElementButtonClick(String buttonName, int mouseButton) { + if (buttonName.equals("sortOption")) { + PacketHandler.INSTANCE.sendToServer( + new MessageGuiElementClicked(buttonName, mouseButton) + ); - if (mouseButton == LEFT_MOUSE_BUTTON) - { - if (sortOptionButton.getState() == SORT_BY_DISPLAY_NAME) - { + if (mouseButton == LEFT_MOUSE_BUTTON) { + if (sortOptionButton.getState() == SORT_BY_DISPLAY_NAME) { sortOptionButton.setState(SORT_BY_ENERGY_VALUE); - } - else if (sortOptionButton.getState() == SORT_BY_ENERGY_VALUE) - { + } else if (sortOptionButton.getState() == SORT_BY_ENERGY_VALUE) { sortOptionButton.setState(SORT_BY_ID); - } - else if (sortOptionButton.getState() == SORT_BY_ID) - { + } else if (sortOptionButton.getState() == SORT_BY_ID) { sortOptionButton.setState(SORT_BY_DISPLAY_NAME); } - } - else if (mouseButton == RIGHT_MOUSE_BUTTON) - { - if (sortOptionButton.getState() == SORT_BY_DISPLAY_NAME) - { + } else if (mouseButton == RIGHT_MOUSE_BUTTON) { + if (sortOptionButton.getState() == SORT_BY_DISPLAY_NAME) { sortOptionButton.setState(SORT_BY_ID); - } - else if (sortOptionButton.getState() == SORT_BY_ENERGY_VALUE) - { + } else if (sortOptionButton.getState() == SORT_BY_ENERGY_VALUE) { sortOptionButton.setState(SORT_BY_DISPLAY_NAME); - } - else if (sortOptionButton.getState() == SORT_BY_ID) - { + } else if (sortOptionButton.getState() == SORT_BY_ID) { sortOptionButton.setState(SORT_BY_ENERGY_VALUE); } } setTooltipByState(); - } - else if (buttonName.equals("sortOrder")) - { - PacketHandler.INSTANCE.sendToServer(new MessageGuiElementClicked(buttonName, mouseButton)); + } else if (buttonName.equals("sortOrder")) { + PacketHandler.INSTANCE.sendToServer( + new MessageGuiElementClicked(buttonName, mouseButton) + ); - if (sortOrderButton.getState() == SORT_ASCENDING) - { + if (sortOrderButton.getState() == SORT_ASCENDING) { sortOrderButton.setState(SORT_DESCENDING); - } - else if (sortOrderButton.getState() == SORT_DESCENDING) - { + } else if (sortOrderButton.getState() == SORT_DESCENDING) { sortOrderButton.setState(SORT_ASCENDING); } @@ -228,29 +236,20 @@ public class GuiTransmutationTablet extends GuiBase { } } - private void setTooltipByState() - { + private void setTooltipByState() { sortOptionButton.clearToolTip(); - if (sortOptionButton.getState() == SORT_BY_DISPLAY_NAME) - { + if (sortOptionButton.getState() == SORT_BY_DISPLAY_NAME) { sortOptionButton.setToolTip(Messages.Tooltips.SORT_BY_DISPLAY_NAME); - } - else if (sortOptionButton.getState() == SORT_BY_ENERGY_VALUE) - { + } else if (sortOptionButton.getState() == SORT_BY_ENERGY_VALUE) { sortOptionButton.setToolTip(Messages.Tooltips.SORT_BY_ENERGY_VALUE); - } - else if (sortOptionButton.getState() == SORT_BY_ID) - { + } else if (sortOptionButton.getState() == SORT_BY_ID) { sortOptionButton.setToolTip(Messages.Tooltips.SORT_BY_ID); } sortOrderButton.clearToolTip(); - if (sortOrderButton.getState() == SORT_ASCENDING) - { + if (sortOrderButton.getState() == SORT_ASCENDING) { sortOrderButton.setToolTip(Messages.Tooltips.SORT_ASCENDING); - } - else if (sortOrderButton.getState() == SORT_DESCENDING) - { + } else if (sortOrderButton.getState() == SORT_DESCENDING) { sortOrderButton.setToolTip(Messages.Tooltips.SORT_DESCENDING); } } diff --git a/src/main/java/com/pahimar/ee3/client/handler/DrawBlockHighlightEventHandler.java b/src/main/java/com/pahimar/ee3/client/handler/DrawBlockHighlightEventHandler.java index 6ae74450..0281d025 100644 --- a/src/main/java/com/pahimar/ee3/client/handler/DrawBlockHighlightEventHandler.java +++ b/src/main/java/com/pahimar/ee3/client/handler/DrawBlockHighlightEventHandler.java @@ -12,7 +12,6 @@ import com.pahimar.ee3.tileentity.TileEntityDummyArray; import com.pahimar.ee3.tileentity.TileEntityEE; import com.pahimar.ee3.util.IModalTool; import com.pahimar.ee3.util.TransmutationHelper; - import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -34,25 +33,29 @@ import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class DrawBlockHighlightEventHandler -{ +public class DrawBlockHighlightEventHandler { private static int pulse; private static boolean doInc; + @SubscribeEvent - public void onDrawBlockHighlightEvent(DrawBlockHighlightEvent event) - { - if (event.currentItem != null) - { - if (event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) - { - if (event.currentItem.getItem() instanceof ItemChalk) - { + public void onDrawBlockHighlightEvent(DrawBlockHighlightEvent event) { + if (event.currentItem != null) { + if (event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + if (event.currentItem.getItem() instanceof ItemChalk) { // if should draw drawAlchemyArrayOverlay(event); } } - if (event.currentItem != null && event.currentItem.getItem() instanceof ITransmutationStone && event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - TransmutationHelper.updateTargetBlock(event.player.worldObj, event.target.blockX, event.target.blockY, event.target.blockZ); + if (event.currentItem != null + && event.currentItem.getItem() instanceof ITransmutationStone + && event.target.typeOfHit + == MovingObjectPosition.MovingObjectType.BLOCK) { + TransmutationHelper.updateTargetBlock( + event.player.worldObj, + event.target.blockX, + event.target.blockY, + event.target.blockZ + ); if (Minecraft.isGuiEnabled() && Minecraft.getMinecraft().inGameHasFocus) { this.drawInWorldTransmutationOverlay(event); } @@ -60,152 +63,399 @@ public class DrawBlockHighlightEventHandler } } - private void drawSelectionBoxForShovel(DrawBlockHighlightEvent event, IModalTool modalTool) - { + private void + drawSelectionBoxForShovel(DrawBlockHighlightEvent event, IModalTool modalTool) { ToolMode toolMode = modalTool.getCurrentToolMode(event.currentItem); - int facing = MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + int facing + = MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D) + & 3; - if (toolMode != ToolMode.UNKNOWN) - { + if (toolMode != ToolMode.UNKNOWN) { event.setCanceled(true); - if (toolMode == ToolMode.STANDARD) - { - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX, event.target.blockY, event.target.blockZ, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); + if (toolMode == ToolMode.STANDARD) { + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX, + event.target.blockY, + event.target.blockZ, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); } } } - private void drawSelectionBoxForPickAxe(DrawBlockHighlightEvent event, IModalTool modalTool) - { + private void + drawSelectionBoxForPickAxe(DrawBlockHighlightEvent event, IModalTool modalTool) { ToolMode toolMode = modalTool.getCurrentToolMode(event.currentItem); - int facing = MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + int facing + = MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D) + & 3; - if (toolMode != ToolMode.UNKNOWN) - { + if (toolMode != ToolMode.UNKNOWN) { event.setCanceled(true); - if (toolMode == ToolMode.STANDARD) - { - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX, event.target.blockY, event.target.blockZ, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); - } - else if (toolMode == ToolMode.WIDE) - { - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX, event.target.blockY, event.target.blockZ, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); + if (toolMode == ToolMode.STANDARD) { + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX, + event.target.blockY, + event.target.blockZ, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); + } else if (toolMode == ToolMode.WIDE) { + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX, + event.target.blockY, + event.target.blockZ, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); - if (event.target.sideHit == ForgeDirection.NORTH.ordinal() || event.target.sideHit == ForgeDirection.SOUTH.ordinal()) - { - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX - 1, event.target.blockY, event.target.blockZ, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX + 1, event.target.blockY, event.target.blockZ, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); + if (event.target.sideHit == ForgeDirection.NORTH.ordinal() + || event.target.sideHit == ForgeDirection.SOUTH.ordinal()) { + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX - 1, + event.target.blockY, + event.target.blockZ, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX + 1, + event.target.blockY, + event.target.blockZ, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); } else if (event.target.sideHit == ForgeDirection.EAST.ordinal() || event.target.sideHit == ForgeDirection.WEST.ordinal()) { - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX, event.target.blockY, event.target.blockZ - 1, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX, event.target.blockY, event.target.blockZ + 1, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); - } - else - { - if (facing == 0 || facing == 2) - { - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX - 1, event.target.blockY, event.target.blockZ, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX + 1, event.target.blockY, event.target.blockZ, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); - } - else - { - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX, event.target.blockY, event.target.blockZ - 1, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX, event.target.blockY, event.target.blockZ + 1, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX, + event.target.blockY, + event.target.blockZ - 1, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX, + event.target.blockY, + event.target.blockZ + 1, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); + } else { + if (facing == 0 || facing == 2) { + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX - 1, + event.target.blockY, + event.target.blockZ, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX + 1, + event.target.blockY, + event.target.blockZ, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); + } else { + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX, + event.target.blockY, + event.target.blockZ - 1, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX, + event.target.blockY, + event.target.blockZ + 1, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); } } - } - else if (toolMode == ToolMode.TALL) - { - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX, event.target.blockY, event.target.blockZ, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); + } else if (toolMode == ToolMode.TALL) { + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX, + event.target.blockY, + event.target.blockZ, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); - if (event.target.sideHit == ForgeDirection.NORTH.ordinal() || event.target.sideHit == ForgeDirection.SOUTH.ordinal() || event.target.sideHit == ForgeDirection.EAST.ordinal() || event.target.sideHit == ForgeDirection.WEST.ordinal()) - { - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX, event.target.blockY - 1, event.target.blockZ, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX, event.target.blockY + 1, event.target.blockZ, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); - } - else - { - if (facing == 1 || facing == 3) - { - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX - 1, event.target.blockY, event.target.blockZ, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX + 1, event.target.blockY, event.target.blockZ, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); - } - else - { - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX, event.target.blockY, event.target.blockZ - 1, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX, event.target.blockY, event.target.blockZ + 1, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); + if (event.target.sideHit == ForgeDirection.NORTH.ordinal() + || event.target.sideHit == ForgeDirection.SOUTH.ordinal() + || event.target.sideHit == ForgeDirection.EAST.ordinal() + || event.target.sideHit == ForgeDirection.WEST.ordinal()) { + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX, + event.target.blockY - 1, + event.target.blockZ, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX, + event.target.blockY + 1, + event.target.blockZ, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); + } else { + if (facing == 1 || facing == 3) { + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX - 1, + event.target.blockY, + event.target.blockZ, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX + 1, + event.target.blockY, + event.target.blockZ, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); + } else { + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX, + event.target.blockY, + event.target.blockZ - 1, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX, + event.target.blockY, + event.target.blockZ + 1, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); } } } } } - private void drawSelectionBoxForHammer(DrawBlockHighlightEvent event, IModalTool modalTool) - { + private void + drawSelectionBoxForHammer(DrawBlockHighlightEvent event, IModalTool modalTool) { ToolMode toolMode = modalTool.getCurrentToolMode(event.currentItem); - int facing = MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + int facing + = MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D) + & 3; - if (toolMode != ToolMode.UNKNOWN) - { + if (toolMode != ToolMode.UNKNOWN) { event.setCanceled(true); - if (toolMode == ToolMode.STANDARD) - { - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX, event.target.blockY, event.target.blockZ, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); + if (toolMode == ToolMode.STANDARD) { + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX, + event.target.blockY, + event.target.blockZ, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); } } } - private void drawSelectionBoxForAxe(DrawBlockHighlightEvent event, IModalTool modalTool) - { + private void + drawSelectionBoxForAxe(DrawBlockHighlightEvent event, IModalTool modalTool) { ToolMode toolMode = modalTool.getCurrentToolMode(event.currentItem); - int facing = MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + int facing + = MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D) + & 3; - if (toolMode != ToolMode.UNKNOWN) - { + if (toolMode != ToolMode.UNKNOWN) { event.setCanceled(true); - if (toolMode == ToolMode.STANDARD) - { - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX, event.target.blockY, event.target.blockZ, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); + if (toolMode == ToolMode.STANDARD) { + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX, + event.target.blockY, + event.target.blockZ, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); } } } - private void drawSelectionBoxForHoe(DrawBlockHighlightEvent event, IModalTool modalTool) - { + private void + drawSelectionBoxForHoe(DrawBlockHighlightEvent event, IModalTool modalTool) { ToolMode toolMode = modalTool.getCurrentToolMode(event.currentItem); - int facing = MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + int facing + = MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D) + & 3; - if (toolMode != ToolMode.UNKNOWN) - { + if (toolMode != ToolMode.UNKNOWN) { event.setCanceled(true); - if (toolMode == ToolMode.STANDARD) - { - drawSelectionBox(event.context, event.player, new MovingObjectPosition(event.target.blockX, event.target.blockY, event.target.blockZ, event.target.sideHit, event.target.hitVec), 0, event.partialTicks); + if (toolMode == ToolMode.STANDARD) { + drawSelectionBox( + event.context, + event.player, + new MovingObjectPosition( + event.target.blockX, + event.target.blockY, + event.target.blockZ, + event.target.sideHit, + event.target.hitVec + ), + 0, + event.partialTicks + ); } } } - private void drawAlchemyArrayOverlay(DrawBlockHighlightEvent event) - { - ChalkSettings chalkSettings = EquivalentExchange3.proxy.getClientProxy().chalkSettings; - AlchemyArray alchemyArray = AlchemyArrayRegistry.getInstance().getAlchemyArray(chalkSettings.getIndex()); + private void drawAlchemyArrayOverlay(DrawBlockHighlightEvent event) { + ChalkSettings chalkSettings + = EquivalentExchange3.proxy.getClientProxy().chalkSettings; + AlchemyArray alchemyArray + = AlchemyArrayRegistry.getInstance().getAlchemyArray(chalkSettings.getIndex() + ); ResourceLocation texture = alchemyArray.getTexture(); int rotation = chalkSettings.getRotation(); double x = event.target.blockX + 0.5F; double y = event.target.blockY + 0.5F; double z = event.target.blockZ + 0.5F; - double iPX = event.player.prevPosX + (event.player.posX - event.player.prevPosX) * event.partialTicks; - double iPY = event.player.prevPosY + (event.player.posY - event.player.prevPosY) * event.partialTicks; - double iPZ = event.player.prevPosZ + (event.player.posZ - event.player.prevPosZ) * event.partialTicks; + double iPX = event.player.prevPosX + + (event.player.posX - event.player.prevPosX) * event.partialTicks; + double iPY = event.player.prevPosY + + (event.player.posY - event.player.prevPosY) * event.partialTicks; + double iPZ = event.player.prevPosZ + + (event.player.posZ - event.player.prevPosZ) * event.partialTicks; float xScale, yScale, zScale; float xShift, yShift, zShift; float xRotate, yRotate, zRotate; int zCorrection = 1; int rotationAngle = 0; - int playerFacing = MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + int playerFacing + = MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D) + & 3; int facingCorrectionAngle = 0; xScale = yScale = zScale = 1; @@ -215,104 +465,96 @@ public class DrawBlockHighlightEventHandler int chargeLevel = ((chalkSettings.getSize() - 1) * 2) + 1; ForgeDirection sideHit = ForgeDirection.getOrientation(event.target.sideHit); - TileEntity tileEntity = event.player.worldObj.getTileEntity(event.target.blockX, event.target.blockY, event.target.blockZ); + TileEntity tileEntity = event.player.worldObj.getTileEntity( + event.target.blockX, event.target.blockY, event.target.blockZ + ); boolean shouldRender = true; - if (tileEntity instanceof TileEntityEE) - { - if (((TileEntityEE) tileEntity).getOrientation() != sideHit) - { + if (tileEntity instanceof TileEntityEE) { + if (((TileEntityEE) tileEntity).getOrientation() != sideHit) { shouldRender = false; } } - if (!canPlaceAlchemyArray(event.currentItem, event.player.worldObj, event.target.blockX, event.target.blockY, event.target.blockZ, event.target.sideHit)) - { + if (!canPlaceAlchemyArray( + event.currentItem, + event.player.worldObj, + event.target.blockX, + event.target.blockY, + event.target.blockZ, + event.target.sideHit + )) { shouldRender = false; } - if (shouldRender) - { - switch (sideHit) - { - case UP: - { + if (shouldRender) { + switch (sideHit) { + case UP: { xScale = zScale = chargeLevel; yShift = 0.001f; xRotate = -1; rotationAngle = (-90 * (rotation + 2)) % 360; facingCorrectionAngle = (-90 * (playerFacing + 2)) % 360; - if (tileEntity instanceof TileEntityAlchemyArray) - { + if (tileEntity instanceof TileEntityAlchemyArray) { y -= 1; } - if (tileEntity instanceof TileEntityDummyArray) - { + if (tileEntity instanceof TileEntityDummyArray) { x = ((TileEntityDummyArray) tileEntity).getTrueXCoord() + 0.5f; - y = ((TileEntityDummyArray) tileEntity).getTrueYCoord() + 0.5f - 1; + y = ((TileEntityDummyArray) tileEntity).getTrueYCoord() + 0.5f + - 1; z = ((TileEntityDummyArray) tileEntity).getTrueXCoord() + 0.5f; } break; } - case DOWN: - { + case DOWN: { xScale = zScale = chargeLevel; yShift = -0.001f; xRotate = 1; rotationAngle = (-90 * (rotation + 2)) % 360; facingCorrectionAngle = (-90 * (playerFacing + 2)) % 360; - if (tileEntity instanceof TileEntityAlchemyArray) - { + if (tileEntity instanceof TileEntityAlchemyArray) { y += 1; } break; } - case NORTH: - { + case NORTH: { xScale = yScale = chargeLevel; zCorrection = -1; zShift = -0.001f; zRotate = 1; rotationAngle = (-90 * (rotation + 1)) % 360; - if (tileEntity instanceof TileEntityAlchemyArray) - { + if (tileEntity instanceof TileEntityAlchemyArray) { z += 1; } break; } - case SOUTH: - { + case SOUTH: { xScale = yScale = chargeLevel; zShift = 0.001f; zRotate = -1; rotationAngle = (-90 * (rotation + 1)) % 360; - if (tileEntity instanceof TileEntityAlchemyArray) - { + if (tileEntity instanceof TileEntityAlchemyArray) { z -= 1; } break; } - case EAST: - { + case EAST: { yScale = zScale = chargeLevel; xShift = 0.001f; yRotate = 1; rotationAngle = (-90 * (rotation + 2)) % 360; - if (tileEntity instanceof TileEntityAlchemyArray) - { + if (tileEntity instanceof TileEntityAlchemyArray) { x -= 1; } break; } - case WEST: - { + case WEST: { yScale = zScale = chargeLevel; xShift = -0.001f; yRotate = -1; rotationAngle = (-90 * (rotation + 2)) % 360; - if (tileEntity instanceof TileEntityAlchemyArray) - { + if (tileEntity instanceof TileEntityAlchemyArray) { x += 1; } break; @@ -321,15 +563,23 @@ public class DrawBlockHighlightEventHandler break; } - if (shouldRender) - { + if (shouldRender) { GL11.glDepthMask(false); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glPushMatrix(); - GL11.glTranslated(-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift); + GL11.glTranslated( + -iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift + ); GL11.glScalef(1F * xScale, 1F * yScale, 1F * zScale); - GL11.glRotatef(rotationAngle, sideHit.offsetX, sideHit.offsetY, sideHit.offsetZ); - GL11.glRotatef(facingCorrectionAngle, sideHit.offsetX, sideHit.offsetY, sideHit.offsetZ); + GL11.glRotatef( + rotationAngle, sideHit.offsetX, sideHit.offsetY, sideHit.offsetZ + ); + GL11.glRotatef( + facingCorrectionAngle, + sideHit.offsetX, + sideHit.offsetY, + sideHit.offsetZ + ); GL11.glRotatef(90, xRotate, yRotate, zRotate); GL11.glTranslated(0, 0, 0.5f * zCorrection); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); @@ -341,19 +591,23 @@ public class DrawBlockHighlightEventHandler } } - private boolean canPlaceAlchemyArray(ItemStack itemStack, World world, int x, int y, int z, int side) - { - ChalkSettings chalkSettings = EquivalentExchange3.proxy.getClientProxy().chalkSettings; + private boolean canPlaceAlchemyArray( + ItemStack itemStack, World world, int x, int y, int z, int side + ) { + ChalkSettings chalkSettings + = EquivalentExchange3.proxy.getClientProxy().chalkSettings; int coordOffset = chalkSettings.getSize() - 1; ForgeDirection orientation = ForgeDirection.getOrientation(side); - AlchemyArray alchemyArray = AlchemyArrayRegistry.getInstance().getAlchemyArray(chalkSettings.getIndex()); + AlchemyArray alchemyArray + = AlchemyArrayRegistry.getInstance().getAlchemyArray(chalkSettings.getIndex() + ); boolean canPlaceAlchemyArray = isValidForArray(world, x, y, z, side); int chargeLevel = ((chalkSettings.getSize() - 1) * 2) + 1; - if (itemStack.getItemDamage() == itemStack.getMaxDamage() && (chargeLevel * chargeLevel) * alchemyArray.getChalkCostPerBlock() == 1) - { + if (itemStack.getItemDamage() == itemStack.getMaxDamage() + && (chargeLevel * chargeLevel) * alchemyArray.getChalkCostPerBlock() == 1) { canPlaceAlchemyArray = true; } else if (itemStack.getMaxDamage() - itemStack.getItemDamage() + 1 < (chargeLevel * chargeLevel) * alchemyArray.getChalkCostPerBlock()) @@ -361,16 +615,12 @@ public class DrawBlockHighlightEventHandler canPlaceAlchemyArray = false; } - if (canPlaceAlchemyArray) - { - if (orientation == ForgeDirection.UP || orientation == ForgeDirection.DOWN) - { - for (int i = x - coordOffset; i <= x + coordOffset; i++) - { - for (int j = z - coordOffset; j <= z + coordOffset; j++) - { - if ((i != x || j != z) && (!isValidForArray(world, i, y, j, side))) - { + if (canPlaceAlchemyArray) { + if (orientation == ForgeDirection.UP || orientation == ForgeDirection.DOWN) { + for (int i = x - coordOffset; i <= x + coordOffset; i++) { + for (int j = z - coordOffset; j <= z + coordOffset; j++) { + if ((i != x || j != z) + && (!isValidForArray(world, i, y, j, side))) { canPlaceAlchemyArray = false; } } @@ -378,25 +628,19 @@ public class DrawBlockHighlightEventHandler } else if (orientation == ForgeDirection.NORTH || orientation == ForgeDirection.SOUTH) { - for (int i = x - coordOffset; i <= x + coordOffset; i++) - { - for (int j = y - coordOffset; j <= y + coordOffset; j++) - { - if ((i != x || j != y) && (!isValidForArray(world, i, j, z, side))) - { + for (int i = x - coordOffset; i <= x + coordOffset; i++) { + for (int j = y - coordOffset; j <= y + coordOffset; j++) { + if ((i != x || j != y) + && (!isValidForArray(world, i, j, z, side))) { canPlaceAlchemyArray = false; } } } - } - else if (orientation == ForgeDirection.EAST || orientation == ForgeDirection.WEST) - { - for (int i = y - coordOffset; i <= y + coordOffset; i++) - { - for (int j = z - coordOffset; j <= z + coordOffset; j++) - { - if ((i != y || j != z) && (!isValidForArray(world, x, i, j, side))) - { + } else if (orientation == ForgeDirection.EAST || orientation == ForgeDirection.WEST) { + for (int i = y - coordOffset; i <= y + coordOffset; i++) { + for (int j = z - coordOffset; j <= z + coordOffset; j++) { + if ((i != y || j != z) + && (!isValidForArray(world, x, i, j, side))) { canPlaceAlchemyArray = false; } } @@ -407,21 +651,31 @@ public class DrawBlockHighlightEventHandler return canPlaceAlchemyArray; } - private boolean isValidForArray(World world, int x, int y, int z, int sideHit) - { + private boolean isValidForArray(World world, int x, int y, int z, int sideHit) { ForgeDirection side = ForgeDirection.getOrientation(sideHit); - return world.isSideSolid(x, y, z, side) && ((side == ForgeDirection.DOWN && world.getBlock(x, y - 1, z).isReplaceable(world, x, y, z)) || - (side == ForgeDirection.UP && world.getBlock(x, y + 1, z).isReplaceable(world, x, y, z)) || - (side == ForgeDirection.NORTH && world.getBlock(x, y, z - 1).isReplaceable(world, x, y, z)) || - (side == ForgeDirection.SOUTH && world.getBlock(x, y, z + 1).isReplaceable(world, x, y, z)) || - (side == ForgeDirection.WEST && world.getBlock(x - 1, y, z).isReplaceable(world, x, y, z)) || - (side == ForgeDirection.EAST && world.getBlock(x + 1, y, z).isReplaceable(world, x, y, z))); + return world.isSideSolid(x, y, z, side) + && ((side == ForgeDirection.DOWN + && world.getBlock(x, y - 1, z).isReplaceable(world, x, y, z)) + || (side == ForgeDirection.UP + && world.getBlock(x, y + 1, z).isReplaceable(world, x, y, z)) + || (side == ForgeDirection.NORTH + && world.getBlock(x, y, z - 1).isReplaceable(world, x, y, z)) + || (side == ForgeDirection.SOUTH + && world.getBlock(x, y, z + 1).isReplaceable(world, x, y, z)) + || (side == ForgeDirection.WEST + && world.getBlock(x - 1, y, z).isReplaceable(world, x, y, z)) + || (side == ForgeDirection.EAST + && world.getBlock(x + 1, y, z).isReplaceable(world, x, y, z))); } - private void drawSelectionBox(RenderGlobal context, EntityPlayer entityPlayer, MovingObjectPosition rayTrace, int i, float partialTicks) - { - if (i == 0 && rayTrace.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) - { + private void drawSelectionBox( + RenderGlobal context, + EntityPlayer entityPlayer, + MovingObjectPosition rayTrace, + int i, + float partialTicks + ) { + if (i == 0 && rayTrace.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); GL11.glColor4f(1f, 1f, 1f, 0.5f); @@ -429,15 +683,38 @@ public class DrawBlockHighlightEventHandler GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDepthMask(false); float f1 = 0.002F; - Block block = entityPlayer.worldObj.getBlock(rayTrace.blockX, rayTrace.blockY, rayTrace.blockZ); + Block block = entityPlayer.worldObj.getBlock( + rayTrace.blockX, rayTrace.blockY, rayTrace.blockZ + ); - if (block.getMaterial() != Material.air) - { - block.setBlockBoundsBasedOnState(entityPlayer.worldObj, rayTrace.blockX, rayTrace.blockY, rayTrace.blockZ); - double d0 = entityPlayer.lastTickPosX + (entityPlayer.posX - entityPlayer.lastTickPosX) * (double) partialTicks; - double d1 = entityPlayer.lastTickPosY + (entityPlayer.posY - entityPlayer.lastTickPosY) * (double) partialTicks; - double d2 = entityPlayer.lastTickPosZ + (entityPlayer.posZ - entityPlayer.lastTickPosZ) * (double) partialTicks; - context.drawOutlinedBoundingBox(block.getSelectedBoundingBoxFromPool(entityPlayer.worldObj, rayTrace.blockX, rayTrace.blockY, rayTrace.blockZ).expand((double) f1, (double) f1, (double) f1).getOffsetBoundingBox(-d0, -d1, -d2), -1); + if (block.getMaterial() != Material.air) { + block.setBlockBoundsBasedOnState( + entityPlayer.worldObj, + rayTrace.blockX, + rayTrace.blockY, + rayTrace.blockZ + ); + double d0 = entityPlayer.lastTickPosX + + (entityPlayer.posX - entityPlayer.lastTickPosX) + * (double) partialTicks; + double d1 = entityPlayer.lastTickPosY + + (entityPlayer.posY - entityPlayer.lastTickPosY) + * (double) partialTicks; + double d2 = entityPlayer.lastTickPosZ + + (entityPlayer.posZ - entityPlayer.lastTickPosZ) + * (double) partialTicks; + context.drawOutlinedBoundingBox( + block + .getSelectedBoundingBoxFromPool( + entityPlayer.worldObj, + rayTrace.blockX, + rayTrace.blockY, + rayTrace.blockZ + ) + .expand((double) f1, (double) f1, (double) f1) + .getOffsetBoundingBox(-d0, -d1, -d2), + -1 + ); } GL11.glDepthMask(true); @@ -450,10 +727,14 @@ public class DrawBlockHighlightEventHandler final double x = event.target.blockX + 0.5f; final double y = event.target.blockY + 0.5f; final double z = event.target.blockZ + 0.5f; - final double iPX = (event.player).prevPosX + ((event.player).posX - (event.player).prevPosX) * event.partialTicks; - final double iPY = (event.player).prevPosY + ((event.player).posY - (event.player).prevPosY) * event.partialTicks; - final double iPZ = (event.player).prevPosZ + ((event.player).posZ - (event.player).prevPosZ) * event.partialTicks; - //final int texture = event.context.renderEngine.func_78341_b("/mods/ee3/textures/effects/noise.png"); + final double iPX = (event.player).prevPosX + + ((event.player).posX - (event.player).prevPosX) * event.partialTicks; + final double iPY = (event.player).prevPosY + + ((event.player).posY - (event.player).prevPosY) * event.partialTicks; + final double iPZ = (event.player).prevPosZ + + ((event.player).posZ - (event.player).prevPosZ) * event.partialTicks; + //final int texture = + //event.context.renderEngine.func_78341_b("/mods/ee3/textures/effects/noise.png"); float xScale = 1.0f; float yScale = 1.0f; float zScale = 1.0f; @@ -462,7 +743,8 @@ public class DrawBlockHighlightEventHandler float zShift = 0.1f; int itemChargeLevel = 0; final int chargeLevel = 1 + itemChargeLevel * 2; - final ForgeDirection sideHit = ForgeDirection.getOrientation(event.target.sideHit); + final ForgeDirection sideHit + = ForgeDirection.getOrientation(event.target.sideHit); switch (sideHit) { case UP: { xScale = chargeLevel + 0.1f; @@ -518,17 +800,25 @@ public class DrawBlockHighlightEventHandler GL11.glPushMatrix(); GL11.glTranslated(-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift); GL11.glScalef(1.0f * xScale, 1.0f * yScale, 1.0f * zScale); - GL11.glRotatef(90.0f, (float)forgeDir.offsetX, (float)forgeDir.offsetY, (float)forgeDir.offsetZ); - GL11.glTranslated(0.0, 0.0, (double)(0.5f * zCorrection)); + GL11.glRotatef( + 90.0f, + (float) forgeDir.offsetX, + (float) forgeDir.offsetY, + (float) forgeDir.offsetZ + ); + GL11.glTranslated(0.0, 0.0, (double) (0.5f * zCorrection)); GL11.glClear(256); - renderPulsingQuad(new ResourceLocation("ee3", "textures/effects/noise.png"), 0.75f); + renderPulsingQuad( + new ResourceLocation("ee3", "textures/effects/noise.png"), 0.75f + ); GL11.glPopMatrix(); } GL11.glEnable(2884); GL11.glDepthMask(true); } - public static void renderPulsingQuad(final ResourceLocation texture, final float maxTransparency) { + public static void + renderPulsingQuad(final ResourceLocation texture, final float maxTransparency) { final float pulseTransparency = getPulseValue() * maxTransparency / 3000.0f; Minecraft.getMinecraft().renderEngine.bindTexture(texture); final Tessellator tessellator = Tessellator.instance; @@ -546,12 +836,11 @@ public class DrawBlockHighlightEventHandler GL11.glDisable(3042); GL11.glDisable(32826); } - + private static int getPulseValue() { if (DrawBlockHighlightEventHandler.doInc) { DrawBlockHighlightEventHandler.pulse += 8; - } - else { + } else { DrawBlockHighlightEventHandler.pulse -= 8; } if (DrawBlockHighlightEventHandler.pulse == 3000) { diff --git a/src/main/java/com/pahimar/ee3/client/handler/HUDTickHandler.java b/src/main/java/com/pahimar/ee3/client/handler/HUDTickHandler.java index aadc3c25..46de9f83 100644 --- a/src/main/java/com/pahimar/ee3/client/handler/HUDTickHandler.java +++ b/src/main/java/com/pahimar/ee3/client/handler/HUDTickHandler.java @@ -16,23 +16,18 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; @SideOnly(Side.CLIENT) -public class HUDTickHandler -{ +public class HUDTickHandler { @SubscribeEvent - public void renderTick(TickEvent.RenderTickEvent event) - { - if (event.phase == TickEvent.Phase.END) - { + public void renderTick(TickEvent.RenderTickEvent event) { + if (event.phase == TickEvent.Phase.END) { Minecraft minecraft = FMLClientHandler.instance().getClient(); EntityPlayer entityPlayer = minecraft.thePlayer; - if (entityPlayer != null) - { + if (entityPlayer != null) { ItemStack currentItemStack = entityPlayer.inventory.getCurrentItem(); - if (Minecraft.isGuiEnabled() && minecraft.inGameHasFocus) - { - if (currentItemStack != null && currentItemStack.getItem() instanceof IOverlayItem) - { + if (Minecraft.isGuiEnabled() && minecraft.inGameHasFocus) { + if (currentItemStack != null + && currentItemStack.getItem() instanceof IOverlayItem) { renderHUDOverlayItem(minecraft, entityPlayer, currentItemStack); } } @@ -40,16 +35,26 @@ public class HUDTickHandler } } - private static void renderHUDOverlayItem(Minecraft minecraft, EntityPlayer entityPlayer, ItemStack itemStack) - { + private static void renderHUDOverlayItem( + Minecraft minecraft, EntityPlayer entityPlayer, ItemStack itemStack + ) { float overlayScale = 2f; float overlayOpacity = 1f; GL11.glPushMatrix(); - ScaledResolution sr = new ScaledResolution(minecraft, minecraft.displayWidth, minecraft.displayHeight); + ScaledResolution sr = new ScaledResolution( + minecraft, minecraft.displayWidth, minecraft.displayHeight + ); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); - GL11.glOrtho(0.0D, sr.getScaledWidth_double(), sr.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D); + GL11.glOrtho( + 0.0D, + sr.getScaledWidth_double(), + sr.getScaledHeight_double(), + 0.0D, + 1000.0D, + 3000.0D + ); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(0.0F, 0.0F, -2000.0F); @@ -65,7 +70,15 @@ public class HUDTickHandler hudOverlayX = (int) (sr.getScaledWidth() - 16 * overlayScale); hudOverlayY = (int) (sr.getScaledHeight() - 16 * overlayScale); - RenderUtils.renderItemIntoGUI(minecraft.fontRenderer, itemStack, hudOverlayX, hudOverlayY, overlayOpacity, overlayScale, -90); + RenderUtils.renderItemIntoGUI( + minecraft.fontRenderer, + itemStack, + hudOverlayX, + hudOverlayY, + overlayOpacity, + overlayScale, + -90 + ); GL11.glDisable(GL11.GL_LIGHTING); GL11.glPopMatrix(); diff --git a/src/main/java/com/pahimar/ee3/client/handler/ItemTooltipEventHandler.java b/src/main/java/com/pahimar/ee3/client/handler/ItemTooltipEventHandler.java index 178dfa31..aff6917e 100644 --- a/src/main/java/com/pahimar/ee3/client/handler/ItemTooltipEventHandler.java +++ b/src/main/java/com/pahimar/ee3/client/handler/ItemTooltipEventHandler.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.client.handler; +import java.util.UUID; + import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.api.exchange.EnergyValue; import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; @@ -21,43 +23,63 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.input.Keyboard; -import java.util.UUID; - @SideOnly(Side.CLIENT) public class ItemTooltipEventHandler { - @SubscribeEvent public void handleItemTooltipEvent(ItemTooltipEvent event) { - - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || (event.entityPlayer != null && (event.entityPlayer.openContainer instanceof ContainerAlchenomicon || event.entityPlayer.openContainer instanceof ContainerTransmutationTablet))) { - + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) + || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) + || (event.entityPlayer != null + && (event.entityPlayer.openContainer instanceof ContainerAlchenomicon + || event.entityPlayer.openContainer + instanceof ContainerTransmutationTablet))) { WrappedStack wrappedItemStack = WrappedStack.wrap(event.itemStack); - EnergyValue energyValue = EnergyValueRegistryProxy.getEnergyValue(wrappedItemStack); - EnergyValue stackEnergyValue = EnergyValueRegistryProxy.getEnergyValueForStack(wrappedItemStack); + EnergyValue energyValue + = EnergyValueRegistryProxy.getEnergyValue(wrappedItemStack); + EnergyValue stackEnergyValue + = EnergyValueRegistryProxy.getEnergyValueForStack(wrappedItemStack); if (energyValue != null) { - if (wrappedItemStack.getStackSize() > 1) { - event.toolTip.add(String.format("Exchange Energy (Item): %s", energyValue)); // TODO Localize - event.toolTip.add(String.format("Exchange Energy (Stack of %s): %s", event.itemStack.stackSize, stackEnergyValue)); // TODO Localize - } - else { + event.toolTip.add( + String.format("Exchange Energy (Item): %s", energyValue) + ); // TODO Localize + event.toolTip.add(String.format( + "Exchange Energy (Stack of %s): %s", + event.itemStack.stackSize, + stackEnergyValue + )); // TODO Localize + } else { + event.toolTip.add( + String.format("Exchange Energy: %s", stackEnergyValue) + ); // TODO Localize - event.toolTip.add(String.format("Exchange Energy: %s", stackEnergyValue)); // TODO Localize - - if (FluidContainerRegistry.getFluidForFilledItem(event.itemStack) != null) { - - FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(event.itemStack); - EnergyValue fluidStackEnergyValue = EnergyValueRegistryProxy.getEnergyValueForStack(fluidStack); + if (FluidContainerRegistry.getFluidForFilledItem(event.itemStack) + != null) { + FluidStack fluidStack + = FluidContainerRegistry.getFluidForFilledItem(event.itemStack + ); + EnergyValue fluidStackEnergyValue + = EnergyValueRegistryProxy.getEnergyValueForStack(fluidStack); if (fluidStackEnergyValue != null) { - event.toolTip.add(String.format(" - Exchange Energy (%smB of %s): %s", fluidStack.amount, fluidStack.getLocalizedName(), fluidStackEnergyValue)); // TODO Localize - event.toolTip.add(String.format(" - Exchange Energy (Container): %s", new EnergyValue(energyValue.getValue() - fluidStackEnergyValue.getValue()))); // TODO Localize + event.toolTip.add(String.format( + " - Exchange Energy (%smB of %s): %s", + fluidStack.amount, + fluidStack.getLocalizedName(), + fluidStackEnergyValue + )); // TODO Localize + event.toolTip.add(String.format( + " - Exchange Energy (Container): %s", + new EnergyValue( + energyValue.getValue() + - fluidStackEnergyValue.getValue() + ) + )); // TODO Localize } } } - } - else { + } else { event.toolTip.add("No Exchange Energy value"); // TODO Localize } @@ -70,22 +92,32 @@ public class ItemTooltipEventHandler { } } - if (((Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) && (event.entityPlayer != null && event.entityPlayer.openContainer instanceof ContainerResearchStation))) { - - if (PlayerKnowledgeRegistryProxy.doesPlayerKnow(event.entityPlayer, event.itemStack)) { - event.toolTip.add("You know how to transmute this"); // TODO Localize with better phrasing + if (((Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) + || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) + && (event.entityPlayer != null + && event.entityPlayer.openContainer instanceof ContainerResearchStation) + )) { + if (PlayerKnowledgeRegistryProxy.doesPlayerKnow( + event.entityPlayer, event.itemStack + )) { + event.toolTip.add("You know how to transmute this" + ); // TODO Localize with better phrasing } } if (event.itemStack.getItem() instanceof IOwnable) { - UUID playerUUID = ItemStackUtils.getOwnerUUID(event.itemStack); if (playerUUID != null && UsernameCache.containsUUID(playerUUID)) { - event.toolTip.add(StatCollector.translateToLocalFormatted(Messages.Tooltips.ITEM_BELONGS_TO, UsernameCache.getLastKnownUsername(playerUUID))); - } - else if (ItemStackUtils.getOwnerName(event.itemStack) != null) { - event.toolTip.add(StatCollector.translateToLocalFormatted(Messages.Tooltips.ITEM_BELONGS_TO, ItemStackUtils.getOwnerName(event.itemStack))); + event.toolTip.add(StatCollector.translateToLocalFormatted( + Messages.Tooltips.ITEM_BELONGS_TO, + UsernameCache.getLastKnownUsername(playerUUID) + )); + } else if (ItemStackUtils.getOwnerName(event.itemStack) != null) { + event.toolTip.add(StatCollector.translateToLocalFormatted( + Messages.Tooltips.ITEM_BELONGS_TO, + ItemStackUtils.getOwnerName(event.itemStack) + )); } } } diff --git a/src/main/java/com/pahimar/ee3/client/handler/KeyInputEventHandler.java b/src/main/java/com/pahimar/ee3/client/handler/KeyInputEventHandler.java index a2ed50d7..6b9958da 100644 --- a/src/main/java/com/pahimar/ee3/client/handler/KeyInputEventHandler.java +++ b/src/main/java/com/pahimar/ee3/client/handler/KeyInputEventHandler.java @@ -14,24 +14,15 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @SideOnly(Side.CLIENT) -public class KeyInputEventHandler -{ - private static Key getPressedKeybinding() - { - if (Keybindings.charge.getIsKeyPressed()) - { +public class KeyInputEventHandler { + private static Key getPressedKeybinding() { + if (Keybindings.charge.getIsKeyPressed()) { return Key.CHARGE; - } - else if (Keybindings.extra.getIsKeyPressed()) - { + } else if (Keybindings.extra.getIsKeyPressed()) { return Key.EXTRA; - } - else if (Keybindings.release.getIsKeyPressed()) - { + } else if (Keybindings.release.getIsKeyPressed()) { return Key.RELEASE; - } - else if (Keybindings.toggle.getIsKeyPressed()) - { + } else if (Keybindings.toggle.getIsKeyPressed()) { return Key.TOGGLE; } @@ -39,32 +30,32 @@ public class KeyInputEventHandler } @SubscribeEvent - public void handleKeyInputEvent(InputEvent.KeyInputEvent event) - { - if (getPressedKeybinding() == Key.UNKNOWN) - { + public void handleKeyInputEvent(InputEvent.KeyInputEvent event) { + if (getPressedKeybinding() == Key.UNKNOWN) { return; } - if (FMLClientHandler.instance().getClient().inGameHasFocus) - { - if (FMLClientHandler.instance().getClientPlayerEntity() != null) - { - EntityPlayer entityPlayer = FMLClientHandler.instance().getClientPlayerEntity(); + if (FMLClientHandler.instance().getClient().inGameHasFocus) { + if (FMLClientHandler.instance().getClientPlayerEntity() != null) { + EntityPlayer entityPlayer + = FMLClientHandler.instance().getClientPlayerEntity(); - if (entityPlayer.getCurrentEquippedItem() != null) - { - ItemStack currentlyEquippedItemStack = entityPlayer.getCurrentEquippedItem(); + if (entityPlayer.getCurrentEquippedItem() != null) { + ItemStack currentlyEquippedItemStack + = entityPlayer.getCurrentEquippedItem(); - if (currentlyEquippedItemStack.getItem() instanceof IKeyBound) - { - if (entityPlayer.worldObj.isRemote) - { - PacketHandler.INSTANCE.sendToServer(new MessageKeyPressed(getPressedKeybinding())); - } - else - { - ((IKeyBound) currentlyEquippedItemStack.getItem()).doKeyBindingAction(entityPlayer, currentlyEquippedItemStack, getPressedKeybinding()); + if (currentlyEquippedItemStack.getItem() instanceof IKeyBound) { + if (entityPlayer.worldObj.isRemote) { + PacketHandler.INSTANCE.sendToServer( + new MessageKeyPressed(getPressedKeybinding()) + ); + } else { + ((IKeyBound) currentlyEquippedItemStack.getItem()) + .doKeyBindingAction( + entityPlayer, + currentlyEquippedItemStack, + getPressedKeybinding() + ); } } } diff --git a/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererAlchemicalChest.java b/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererAlchemicalChest.java index 6adb380e..2474848d 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererAlchemicalChest.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererAlchemicalChest.java @@ -10,49 +10,44 @@ import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class ItemRendererAlchemicalChest implements IItemRenderer -{ +public class ItemRendererAlchemicalChest implements IItemRenderer { private final ModelChest modelChest; - public ItemRendererAlchemicalChest() - { + public ItemRendererAlchemicalChest() { modelChest = new ModelChest(); } @Override - public boolean handleRenderType(ItemStack itemStack, ItemRenderType itemRenderType) - { + public boolean handleRenderType(ItemStack itemStack, ItemRenderType itemRenderType) { return true; } @Override - public boolean shouldUseRenderHelper(ItemRenderType itemRenderType, ItemStack itemStack, ItemRendererHelper itemRendererHelper) - { + public boolean shouldUseRenderHelper( + ItemRenderType itemRenderType, + ItemStack itemStack, + ItemRendererHelper itemRendererHelper + ) { return true; } @Override - public void renderItem(ItemRenderType itemRenderType, ItemStack itemStack, Object... data) - { - switch (itemRenderType) - { - case ENTITY: - { + public void + renderItem(ItemRenderType itemRenderType, ItemStack itemStack, Object... data) { + switch (itemRenderType) { + case ENTITY: { renderAlchemicalChest(0.5F, 0.5F, 0.5F, itemStack.getItemDamage()); break; } - case EQUIPPED: - { + case EQUIPPED: { renderAlchemicalChest(1.0F, 1.0F, 1.0F, itemStack.getItemDamage()); break; } - case EQUIPPED_FIRST_PERSON: - { + case EQUIPPED_FIRST_PERSON: { renderAlchemicalChest(1.0F, 1.0F, 1.0F, itemStack.getItemDamage()); break; } - case INVENTORY: - { + case INVENTORY: { renderAlchemicalChest(0.0F, 0.075F, 0.0F, itemStack.getItemDamage()); break; } @@ -61,19 +56,19 @@ public class ItemRendererAlchemicalChest implements IItemRenderer } } - private void renderAlchemicalChest(float x, float y, float z, int metaData) - { - if (metaData == 0) - { - FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.Model.ALCHEMICAL_CHEST_SMALL); - } - else if (metaData == 1) - { - FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.Model.ALCHEMICAL_CHEST_MEDIUM); - } - else if (metaData == 2) - { - FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.Model.ALCHEMICAL_CHEST_LARGE); + private void renderAlchemicalChest(float x, float y, float z, int metaData) { + if (metaData == 0) { + FMLClientHandler.instance().getClient().renderEngine.bindTexture( + Textures.Model.ALCHEMICAL_CHEST_SMALL + ); + } else if (metaData == 1) { + FMLClientHandler.instance().getClient().renderEngine.bindTexture( + Textures.Model.ALCHEMICAL_CHEST_MEDIUM + ); + } else if (metaData == 2) { + FMLClientHandler.instance().getClient().renderEngine.bindTexture( + Textures.Model.ALCHEMICAL_CHEST_LARGE + ); } GL11.glPushMatrix(); //start diff --git a/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererAludel.java b/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererAludel.java index 2e2d7b9d..d9212e22 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererAludel.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererAludel.java @@ -10,49 +10,44 @@ import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class ItemRendererAludel implements IItemRenderer -{ +public class ItemRendererAludel implements IItemRenderer { private final ModelAludel modelAludel; - public ItemRendererAludel() - { + public ItemRendererAludel() { modelAludel = new ModelAludel(); } @Override - public boolean handleRenderType(ItemStack itemStack, ItemRenderType itemRenderType) - { + public boolean handleRenderType(ItemStack itemStack, ItemRenderType itemRenderType) { return true; } @Override - public boolean shouldUseRenderHelper(ItemRenderType itemRenderType, ItemStack itemStack, ItemRendererHelper itemRendererHelper) - { + public boolean shouldUseRenderHelper( + ItemRenderType itemRenderType, + ItemStack itemStack, + ItemRendererHelper itemRendererHelper + ) { return true; } @Override - public void renderItem(ItemRenderType itemRenderType, ItemStack itemStack, Object... data) - { - switch (itemRenderType) - { - case ENTITY: - { + public void + renderItem(ItemRenderType itemRenderType, ItemStack itemStack, Object... data) { + switch (itemRenderType) { + case ENTITY: { renderAludel(-0.5F, -0.38F, 0.5F); return; } - case EQUIPPED: - { + case EQUIPPED: { renderAludel(0.0F, 0.0F, 1.0F); return; } - case EQUIPPED_FIRST_PERSON: - { + case EQUIPPED_FIRST_PERSON: { renderAludel(0.0F, 0.0F, 1.0F); return; } - case INVENTORY: - { + case INVENTORY: { renderAludel(-1.0F, -0.9F, 0.0F); return; } @@ -60,8 +55,7 @@ public class ItemRendererAludel implements IItemRenderer } } - private void renderAludel(float x, float y, float z) - { + private void renderAludel(float x, float y, float z) { GL11.glPushMatrix(); // Scale, Translate, Rotate @@ -70,7 +64,9 @@ public class ItemRendererAludel implements IItemRenderer GL11.glRotatef(-90F, 1F, 0, 0); // Bind texture - FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.Model.ALUDEL); + FMLClientHandler.instance().getClient().renderEngine.bindTexture( + Textures.Model.ALUDEL + ); // Render modelAludel.render(); diff --git a/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererCalcinator.java b/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererCalcinator.java index b5e2a403..bd111f72 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererCalcinator.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererCalcinator.java @@ -10,60 +10,53 @@ import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class ItemRendererCalcinator implements IItemRenderer -{ +public class ItemRendererCalcinator implements IItemRenderer { private final ModelCalcinator modelCalcinator; - public ItemRendererCalcinator() - { + public ItemRendererCalcinator() { modelCalcinator = new ModelCalcinator(); } @Override - public boolean handleRenderType(ItemStack itemStack, ItemRenderType itemRenderType) - { + public boolean handleRenderType(ItemStack itemStack, ItemRenderType itemRenderType) { return true; } @Override - public boolean shouldUseRenderHelper(ItemRenderType itemRenderType, ItemStack itemStack, ItemRendererHelper itemRendererHelper) - { + public boolean shouldUseRenderHelper( + ItemRenderType itemRenderType, + ItemStack itemStack, + ItemRendererHelper itemRendererHelper + ) { return true; } @Override - public void renderItem(ItemRenderType itemRenderType, ItemStack itemStack, Object... data) - { - switch (itemRenderType) - { - case ENTITY: - { + public void + renderItem(ItemRenderType itemRenderType, ItemStack itemStack, Object... data) { + switch (itemRenderType) { + case ENTITY: { renderCalcinator(-0.5F, 0.0F, 0.5F); return; } - case EQUIPPED: - { + case EQUIPPED: { renderCalcinator(0.0F, 0.0F, 1.0F); return; } - case EQUIPPED_FIRST_PERSON: - { + case EQUIPPED_FIRST_PERSON: { renderCalcinator(0.0F, 0.0F, 1.0F); return; } - case INVENTORY: - { + case INVENTORY: { renderCalcinator(0.0F, -0.1F, 1.0F); return; } - default: - { + default: { } } } - private void renderCalcinator(float x, float y, float z) - { + private void renderCalcinator(float x, float y, float z) { GL11.glPushMatrix(); // Scale, Translate, Rotate @@ -72,7 +65,9 @@ public class ItemRendererCalcinator implements IItemRenderer GL11.glRotatef(-90F, 1F, 0, 0); // Bind texture - FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.Model.CALCINATOR_IDLE); + FMLClientHandler.instance().getClient().renderEngine.bindTexture( + Textures.Model.CALCINATOR_IDLE + ); // Render modelCalcinator.renderPart("Calcinator"); diff --git a/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererGlassBell.java b/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererGlassBell.java index 14b3e542..81497370 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererGlassBell.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererGlassBell.java @@ -10,60 +10,53 @@ import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class ItemRendererGlassBell implements IItemRenderer -{ +public class ItemRendererGlassBell implements IItemRenderer { private final ModelGlassBell modelGlassBell; - public ItemRendererGlassBell() - { + public ItemRendererGlassBell() { modelGlassBell = new ModelGlassBell(); } @Override - public boolean handleRenderType(ItemStack itemStack, ItemRenderType itemRenderType) - { + public boolean handleRenderType(ItemStack itemStack, ItemRenderType itemRenderType) { return true; } @Override - public boolean shouldUseRenderHelper(ItemRenderType itemRenderType, ItemStack itemStack, ItemRendererHelper itemRendererHelper) - { + public boolean shouldUseRenderHelper( + ItemRenderType itemRenderType, + ItemStack itemStack, + ItemRendererHelper itemRendererHelper + ) { return true; } @Override - public void renderItem(ItemRenderType itemRenderType, ItemStack itemStack, Object... data) - { - switch (itemRenderType) - { - case ENTITY: - { + public void + renderItem(ItemRenderType itemRenderType, ItemStack itemStack, Object... data) { + switch (itemRenderType) { + case ENTITY: { renderGlassBell(-0.5F, -1.2F, 0.5F); return; } - case EQUIPPED: - { + case EQUIPPED: { renderGlassBell(-0.2F, -0.85F, 0.8F); return; } - case EQUIPPED_FIRST_PERSON: - { + case EQUIPPED_FIRST_PERSON: { renderGlassBell(-0.2F, -0.85F, 0.8F); return; } - case INVENTORY: - { + case INVENTORY: { renderGlassBell(-1.0F, -1.675F, 0.0F); return; } - default: - { + default: { } } } - private void renderGlassBell(float x, float y, float z) - { + private void renderGlassBell(float x, float y, float z) { GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glPushMatrix(); @@ -74,12 +67,13 @@ public class ItemRendererGlassBell implements IItemRenderer GL11.glRotatef(-90F, 1F, 0, 0); // Bind texture - FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.Model.GLASS_BELL); + FMLClientHandler.instance().getClient().renderEngine.bindTexture( + Textures.Model.GLASS_BELL + ); // Render modelGlassBell.render(); GL11.glPopMatrix(); - } } diff --git a/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererResearchStation.java b/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererResearchStation.java index 4e3bdeea..98f317b6 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererResearchStation.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/item/ItemRendererResearchStation.java @@ -10,60 +10,53 @@ import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class ItemRendererResearchStation implements IItemRenderer -{ +public class ItemRendererResearchStation implements IItemRenderer { private final ModelResearchStation modelResearchStation; - public ItemRendererResearchStation() - { + public ItemRendererResearchStation() { modelResearchStation = new ModelResearchStation(); } @Override - public boolean handleRenderType(ItemStack itemStack, ItemRenderType itemRenderType) - { + public boolean handleRenderType(ItemStack itemStack, ItemRenderType itemRenderType) { return true; } @Override - public boolean shouldUseRenderHelper(ItemRenderType itemRenderType, ItemStack itemStack, ItemRendererHelper itemRendererHelper) - { + public boolean shouldUseRenderHelper( + ItemRenderType itemRenderType, + ItemStack itemStack, + ItemRendererHelper itemRendererHelper + ) { return true; } @Override - public void renderItem(ItemRenderType itemRenderType, ItemStack itemStack, Object... data) - { - switch (itemRenderType) - { - case ENTITY: - { + public void + renderItem(ItemRenderType itemRenderType, ItemStack itemStack, Object... data) { + switch (itemRenderType) { + case ENTITY: { renderCalcinator(-0.5F, 0.0F, 0.5F); return; } - case EQUIPPED: - { + case EQUIPPED: { renderCalcinator(0.0F, 0.0F, 1.0F); return; } - case EQUIPPED_FIRST_PERSON: - { + case EQUIPPED_FIRST_PERSON: { renderCalcinator(0.0F, 0.0F, 1.0F); return; } - case INVENTORY: - { + case INVENTORY: { renderCalcinator(0.0F, -0.1F, 1.0F); return; } - default: - { + default: { } } } - private void renderCalcinator(float x, float y, float z) - { + private void renderCalcinator(float x, float y, float z) { GL11.glPushMatrix(); // Scale, Translate, Rotate @@ -71,7 +64,9 @@ public class ItemRendererResearchStation implements IItemRenderer GL11.glTranslatef(x, y, z); // Bind texture - FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.Model.RESEARCH_STATION); + FMLClientHandler.instance().getClient().renderEngine.bindTexture( + Textures.Model.RESEARCH_STATION + ); // Render modelResearchStation.render(); diff --git a/src/main/java/com/pahimar/ee3/client/renderer/model/ModelAludel.java b/src/main/java/com/pahimar/ee3/client/renderer/model/ModelAludel.java index 6244fc3a..69769a3d 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/model/ModelAludel.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/model/ModelAludel.java @@ -7,17 +7,14 @@ import net.minecraftforge.client.model.AdvancedModelLoader; import net.minecraftforge.client.model.IModelCustom; @SideOnly(Side.CLIENT) -public class ModelAludel -{ +public class ModelAludel { private IModelCustom modelAludel; - public ModelAludel() - { + public ModelAludel() { modelAludel = AdvancedModelLoader.loadModel(Models.ALUDEL); } - public void render() - { + public void render() { modelAludel.renderPart("Base"); } } diff --git a/src/main/java/com/pahimar/ee3/client/renderer/model/ModelAugmentationTable.java b/src/main/java/com/pahimar/ee3/client/renderer/model/ModelAugmentationTable.java index 2980b5da..b29d8365 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/model/ModelAugmentationTable.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/model/ModelAugmentationTable.java @@ -7,17 +7,14 @@ import net.minecraftforge.client.model.AdvancedModelLoader; import net.minecraftforge.client.model.IModelCustom; @SideOnly(Side.CLIENT) -public class ModelAugmentationTable -{ +public class ModelAugmentationTable { private IModelCustom modelAugmentationTable; - public ModelAugmentationTable() - { + public ModelAugmentationTable() { modelAugmentationTable = AdvancedModelLoader.loadModel(Models.AUGMENTATION_TABLE); } - public void render() - { + public void render() { modelAugmentationTable.renderAll(); } } diff --git a/src/main/java/com/pahimar/ee3/client/renderer/model/ModelCalcinator.java b/src/main/java/com/pahimar/ee3/client/renderer/model/ModelCalcinator.java index 2ec0398b..e410130c 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/model/ModelCalcinator.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/model/ModelCalcinator.java @@ -7,22 +7,18 @@ import net.minecraftforge.client.model.AdvancedModelLoader; import net.minecraftforge.client.model.IModelCustom; @SideOnly(Side.CLIENT) -public class ModelCalcinator -{ +public class ModelCalcinator { private IModelCustom modelCalcinator; - public ModelCalcinator() - { + public ModelCalcinator() { modelCalcinator = AdvancedModelLoader.loadModel(Models.CALCINATOR); } - public void render() - { + public void render() { modelCalcinator.renderAll(); } - public void renderPart(String partName) - { + public void renderPart(String partName) { modelCalcinator.renderPart(partName); } } diff --git a/src/main/java/com/pahimar/ee3/client/renderer/model/ModelGlassBell.java b/src/main/java/com/pahimar/ee3/client/renderer/model/ModelGlassBell.java index 6579a2e0..d29bd862 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/model/ModelGlassBell.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/model/ModelGlassBell.java @@ -7,17 +7,14 @@ import net.minecraftforge.client.model.AdvancedModelLoader; import net.minecraftforge.client.model.IModelCustom; @SideOnly(Side.CLIENT) -public class ModelGlassBell -{ +public class ModelGlassBell { private IModelCustom modelGlassBell; - public ModelGlassBell() - { + public ModelGlassBell() { modelGlassBell = AdvancedModelLoader.loadModel(Models.GLASS_BELL); } - public void render() - { + public void render() { modelGlassBell.renderPart("Bell"); } } diff --git a/src/main/java/com/pahimar/ee3/client/renderer/model/ModelResearchStation.java b/src/main/java/com/pahimar/ee3/client/renderer/model/ModelResearchStation.java index f9db273e..ea43fe98 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/model/ModelResearchStation.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/model/ModelResearchStation.java @@ -7,17 +7,14 @@ import net.minecraftforge.client.model.AdvancedModelLoader; import net.minecraftforge.client.model.IModelCustom; @SideOnly(Side.CLIENT) -public class ModelResearchStation -{ +public class ModelResearchStation { private IModelCustom modelResearchStation; - public ModelResearchStation() - { + public ModelResearchStation() { modelResearchStation = AdvancedModelLoader.loadModel(Models.RESEARCH_STATION); } - public void render() - { + public void render() { modelResearchStation.renderAll(); } } diff --git a/src/main/java/com/pahimar/ee3/client/renderer/model/ModelTransmutationTablet.java b/src/main/java/com/pahimar/ee3/client/renderer/model/ModelTransmutationTablet.java index 03802c96..95b696f7 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/model/ModelTransmutationTablet.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/model/ModelTransmutationTablet.java @@ -3,13 +3,11 @@ package com.pahimar.ee3.client.renderer.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; -public class ModelTransmutationTablet extends ModelBase -{ +public class ModelTransmutationTablet extends ModelBase { public ModelRenderer transmutationPad; public ModelRenderer base; - public ModelTransmutationTablet() - { + public ModelTransmutationTablet() { this.textureWidth = 128; this.textureHeight = 58; this.transmutationPad = new ModelRenderer(this, 0, 24); @@ -20,13 +18,11 @@ public class ModelTransmutationTablet extends ModelBase this.base.addBox(-8.0F, 6.0F, -8.0F, 16, 8, 16, 0.0F); } - public void renderTransmutationPad(float scale) - { + public void renderTransmutationPad(float scale) { this.transmutationPad.render(scale); } - public void renderBase(float scale) - { + public void renderBase(float scale) { this.base.render(scale); } } diff --git a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererAlchemicalChest.java b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererAlchemicalChest.java index 4e0004a8..2efa2893 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererAlchemicalChest.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererAlchemicalChest.java @@ -12,33 +12,26 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; @SideOnly(Side.CLIENT) -public class TileEntityRendererAlchemicalChest extends TileEntitySpecialRenderer -{ +public class TileEntityRendererAlchemicalChest extends TileEntitySpecialRenderer { private final ModelChest modelChest = new ModelChest(); @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) - { - if (tileEntity instanceof TileEntityAlchemicalChest) - { - TileEntityAlchemicalChest tileEntityAlchemicalChest = (TileEntityAlchemicalChest) tileEntity; + public void + renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) { + if (tileEntity instanceof TileEntityAlchemicalChest) { + TileEntityAlchemicalChest tileEntityAlchemicalChest + = (TileEntityAlchemicalChest) tileEntity; ForgeDirection direction = null; - if (tileEntityAlchemicalChest.getWorldObj() != null) - { + if (tileEntityAlchemicalChest.getWorldObj() != null) { direction = tileEntityAlchemicalChest.getOrientation(); } - if (tileEntityAlchemicalChest.getState() == 0) - { + if (tileEntityAlchemicalChest.getState() == 0) { this.bindTexture(Textures.Model.ALCHEMICAL_CHEST_SMALL); - } - else if (tileEntityAlchemicalChest.getState() == 1) - { + } else if (tileEntityAlchemicalChest.getState() == 1) { this.bindTexture(Textures.Model.ALCHEMICAL_CHEST_MEDIUM); - } - else if (tileEntityAlchemicalChest.getState() == 2) - { + } else if (tileEntityAlchemicalChest.getState() == 2) { this.bindTexture(Textures.Model.ALCHEMICAL_CHEST_LARGE); } @@ -50,32 +43,29 @@ public class TileEntityRendererAlchemicalChest extends TileEntitySpecialRenderer GL11.glTranslatef(0.5F, 0.5F, 0.5F); short angle = 0; - if (direction != null) - { - if (direction == ForgeDirection.NORTH) - { + if (direction != null) { + if (direction == ForgeDirection.NORTH) { angle = 180; - } - else if (direction == ForgeDirection.SOUTH) - { + } else if (direction == ForgeDirection.SOUTH) { angle = 0; - } - else if (direction == ForgeDirection.WEST) - { + } else if (direction == ForgeDirection.WEST) { angle = 90; - } - else if (direction == ForgeDirection.EAST) - { + } else if (direction == ForgeDirection.EAST) { angle = -90; } } GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - float adjustedLidAngle = tileEntityAlchemicalChest.prevLidAngle + (tileEntityAlchemicalChest.lidAngle - tileEntityAlchemicalChest.prevLidAngle) * tick; + float adjustedLidAngle = tileEntityAlchemicalChest.prevLidAngle + + (tileEntityAlchemicalChest.lidAngle + - tileEntityAlchemicalChest.prevLidAngle) + * tick; adjustedLidAngle = 1.0F - adjustedLidAngle; - adjustedLidAngle = 1.0F - adjustedLidAngle * adjustedLidAngle * adjustedLidAngle; - modelChest.chestLid.rotateAngleX = -(adjustedLidAngle * (float) Math.PI / 2.0F); + adjustedLidAngle + = 1.0F - adjustedLidAngle * adjustedLidAngle * adjustedLidAngle; + modelChest.chestLid.rotateAngleX + = -(adjustedLidAngle * (float) Math.PI / 2.0F); modelChest.renderAll(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); diff --git a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererAlchemyArray.java b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererAlchemyArray.java index 700e3a13..f1e0e480 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererAlchemyArray.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererAlchemyArray.java @@ -13,50 +13,49 @@ import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class TileEntityRendererAlchemyArray extends TileEntitySpecialRenderer -{ +public class TileEntityRendererAlchemyArray extends TileEntitySpecialRenderer { @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) - { - if (tileEntity instanceof TileEntityAlchemyArray) - { - TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) FMLClientHandler.instance().getClient().theWorld.getTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); + public void + renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) { + if (tileEntity instanceof TileEntityAlchemyArray) { + TileEntityAlchemyArray tileEntityAlchemyArray + = (TileEntityAlchemyArray) FMLClientHandler.instance() + .getClient() + .theWorld.getTileEntity( + tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord + ); - if (tileEntityAlchemyArray != null) - { + if (tileEntityAlchemyArray != null) { AlchemyArray alchemyArray = tileEntityAlchemyArray.getAlchemyArray(); - if (alchemyArray != null) - { - if (alchemyArray instanceof ICustomAlchemyArrayRender) - { - ((ICustomAlchemyArrayRender) alchemyArray).doCustomRendering(tileEntity, x, y, z, tileEntityAlchemyArray.getSize(), tileEntityAlchemyArray.getOrientation(), tileEntityAlchemyArray.getRotation(), tick); - } - else - { + if (alchemyArray != null) { + if (alchemyArray instanceof ICustomAlchemyArrayRender) { + ((ICustomAlchemyArrayRender) alchemyArray) + .doCustomRendering( + tileEntity, + x, + y, + z, + tileEntityAlchemyArray.getSize(), + tileEntityAlchemyArray.getOrientation(), + tileEntityAlchemyArray.getRotation(), + tick + ); + } else { int scale = 1; double xShift = 0.5d, yShift = 0.5d, zShift = 0.5d; float xRotate = 0, yRotate = 0, zRotate = 0; int rotationAngle = 0; - if (tileEntityAlchemyArray.getSize() == 1) - { + if (tileEntityAlchemyArray.getSize() == 1) { scale = 1; - } - else if (tileEntityAlchemyArray.getSize() == 2) - { + } else if (tileEntityAlchemyArray.getSize() == 2) { scale = 3; - } - else if (tileEntityAlchemyArray.getSize() == 3) - { + } else if (tileEntityAlchemyArray.getSize() == 3) { scale = 5; - } - else if (tileEntityAlchemyArray.getSize() == 4) - { + } else if (tileEntityAlchemyArray.getSize() == 4) { scale = 7; - } - else if (tileEntityAlchemyArray.getSize() == 5) - { + } else if (tileEntityAlchemyArray.getSize() == 5) { scale = 9; } @@ -67,10 +66,10 @@ public class TileEntityRendererAlchemyArray extends TileEntitySpecialRenderer GL11.glDepthMask(false); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); - if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.UP) - { - if (tileEntityAlchemyArray.getRotation() == ForgeDirection.NORTH) - { + if (tileEntityAlchemyArray.getOrientation() + == ForgeDirection.UP) { + if (tileEntityAlchemyArray.getRotation() + == ForgeDirection.NORTH) { rotationAngle = 0; } else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.EAST) @@ -91,8 +90,8 @@ public class TileEntityRendererAlchemyArray extends TileEntitySpecialRenderer } else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.DOWN) { - if (tileEntityAlchemyArray.getRotation() == ForgeDirection.NORTH) - { + if (tileEntityAlchemyArray.getRotation() + == ForgeDirection.NORTH) { rotationAngle = 0; } else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.EAST) @@ -113,8 +112,8 @@ public class TileEntityRendererAlchemyArray extends TileEntitySpecialRenderer } else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.NORTH) { - if (tileEntityAlchemyArray.getRotation() == ForgeDirection.UP) - { + if (tileEntityAlchemyArray.getRotation() + == ForgeDirection.UP) { rotationAngle = -90; } else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.EAST) @@ -135,8 +134,8 @@ public class TileEntityRendererAlchemyArray extends TileEntitySpecialRenderer } else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.SOUTH) { - if (tileEntityAlchemyArray.getRotation() == ForgeDirection.UP) - { + if (tileEntityAlchemyArray.getRotation() + == ForgeDirection.UP) { rotationAngle = -90; } else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.EAST) @@ -157,8 +156,8 @@ public class TileEntityRendererAlchemyArray extends TileEntitySpecialRenderer } else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.EAST) { - if (tileEntityAlchemyArray.getRotation() == ForgeDirection.UP) - { + if (tileEntityAlchemyArray.getRotation() + == ForgeDirection.UP) { rotationAngle = 180; } else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.DOWN) @@ -179,8 +178,8 @@ public class TileEntityRendererAlchemyArray extends TileEntitySpecialRenderer } else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.WEST) { - if (tileEntityAlchemyArray.getRotation() == ForgeDirection.UP) - { + if (tileEntityAlchemyArray.getRotation() + == ForgeDirection.UP) { rotationAngle = 180; } else if (tileEntityAlchemyArray.getRotation() == ForgeDirection.DOWN) @@ -203,7 +202,12 @@ public class TileEntityRendererAlchemyArray extends TileEntitySpecialRenderer GL11.glPushMatrix(); GL11.glTranslated(x + xShift, y + yShift, z + zShift); GL11.glScalef(1f * scale, 1f * scale, 1f * scale); - GL11.glRotatef(rotationAngle, tileEntityAlchemyArray.getOrientation().offsetX, tileEntityAlchemyArray.getOrientation().offsetY, tileEntityAlchemyArray.getOrientation().offsetZ); + GL11.glRotatef( + rotationAngle, + tileEntityAlchemyArray.getOrientation().offsetX, + tileEntityAlchemyArray.getOrientation().offsetY, + tileEntityAlchemyArray.getOrientation().offsetZ + ); GL11.glRotatef(90, xRotate, yRotate, zRotate); RenderUtils.renderQuad(alchemyArray.getTexture()); GL11.glPopMatrix(); diff --git a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererAludel.java b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererAludel.java index 7c5672ca..35a701bb 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererAludel.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererAludel.java @@ -17,18 +17,14 @@ import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class TileEntityRendererAludel extends TileEntitySpecialRenderer -{ +public class TileEntityRendererAludel extends TileEntitySpecialRenderer { private final ModelAludel modelAludel = new ModelAludel(); private final RenderItem customRenderItem; - public TileEntityRendererAludel() - { - customRenderItem = new RenderItem() - { + public TileEntityRendererAludel() { + customRenderItem = new RenderItem() { @Override - public boolean shouldBob() - { + public boolean shouldBob() { return false; } }; @@ -37,10 +33,9 @@ public class TileEntityRendererAludel extends TileEntitySpecialRenderer } @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) - { - if (tileEntity instanceof TileEntityAludel) - { + public void + renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) { + if (tileEntity instanceof TileEntityAludel) { TileEntityAludel tileEntityAludel = (TileEntityAludel) tileEntity; GL11.glPushMatrix(); @@ -61,20 +56,27 @@ public class TileEntityRendererAludel extends TileEntitySpecialRenderer */ GL11.glPushMatrix(); - TileEntity tileGlassBell = tileEntityAludel.getWorldObj().getTileEntity(tileEntityAludel.xCoord, tileEntityAludel.yCoord + 1, tileEntityAludel.zCoord); + TileEntity tileGlassBell = tileEntityAludel.getWorldObj().getTileEntity( + tileEntityAludel.xCoord, + tileEntityAludel.yCoord + 1, + tileEntityAludel.zCoord + ); - if (tileGlassBell instanceof TileEntityGlassBell) - { - if (tileEntityAludel.outputItemStack != null) - { - float scaleFactor = getGhostItemScaleFactor(tileEntityAludel.outputItemStack); - float rotationAngle = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL); + if (tileGlassBell instanceof TileEntityGlassBell) { + if (tileEntityAludel.outputItemStack != null) { + float scaleFactor + = getGhostItemScaleFactor(tileEntityAludel.outputItemStack); + float rotationAngle = (float + ) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL); - EntityItem ghostEntityItem = new EntityItem(tileEntityAludel.getWorldObj()); + EntityItem ghostEntityItem + = new EntityItem(tileEntityAludel.getWorldObj()); ghostEntityItem.hoverStart = 0.0F; ghostEntityItem.setEntityItemStack(tileEntityAludel.outputItemStack); - GL11.glTranslatef((float) x + 0.5F, (float) y + 1.25F, (float) z + 0.5F); + GL11.glTranslatef( + (float) x + 0.5F, (float) y + 1.25F, (float) z + 0.5F + ); GL11.glScalef(scaleFactor, scaleFactor, scaleFactor); GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F); @@ -86,62 +88,44 @@ public class TileEntityRendererAludel extends TileEntitySpecialRenderer } } - private void scaleTranslateRotate(double x, double y, double z, ForgeDirection orientation) - { - if (orientation == ForgeDirection.NORTH) - { + private void + scaleTranslateRotate(double x, double y, double z, ForgeDirection orientation) { + if (orientation == ForgeDirection.NORTH) { GL11.glTranslated(x + 1, y, z); GL11.glRotatef(180F, 0F, 1F, 0F); GL11.glRotatef(-90F, 1F, 0F, 0F); - } - else if (orientation == ForgeDirection.EAST) - { + } else if (orientation == ForgeDirection.EAST) { GL11.glTranslated(x + 1, y, z + 1); GL11.glRotatef(90F, 0F, 1F, 0F); GL11.glRotatef(-90F, 1F, 0F, 0F); - } - else if (orientation == ForgeDirection.SOUTH) - { + } else if (orientation == ForgeDirection.SOUTH) { GL11.glTranslated(x, y, z + 1); GL11.glRotatef(0F, 0F, 1F, 0F); GL11.glRotatef(-90F, 1F, 0F, 0F); - } - else if (orientation == ForgeDirection.WEST) - { + } else if (orientation == ForgeDirection.WEST) { GL11.glTranslated(x, y, z); GL11.glRotatef(-90F, 0F, 1F, 0F); GL11.glRotatef(-90F, 1F, 0F, 0F); } } - private float getGhostItemScaleFactor(ItemStack itemStack) - { + private float getGhostItemScaleFactor(ItemStack itemStack) { float scaleFactor = 1.0F; - if (itemStack != null) - { + if (itemStack != null) { byte numBlocks = 1; - if (itemStack.stackSize > 1) - { + if (itemStack.stackSize > 1) { numBlocks = 2; - } - else if (itemStack.stackSize > 5) - { + } else if (itemStack.stackSize > 5) { numBlocks = 3; - } - else if (itemStack.stackSize > 20) - { + } else if (itemStack.stackSize > 20) { numBlocks = 4; - } - else if (itemStack.stackSize > 40) - { + } else if (itemStack.stackSize > 40) { numBlocks = 5; } - if (itemStack.getItem() instanceof ItemBlock) - { - switch (numBlocks) - { + if (itemStack.getItem() instanceof ItemBlock) { + switch (numBlocks) { case 1: return 0.90F; case 2: @@ -155,11 +139,8 @@ public class TileEntityRendererAludel extends TileEntitySpecialRenderer default: return 0.90F; } - } - else - { - switch (numBlocks) - { + } else { + switch (numBlocks) { case 1: return 0.65F; case 2: diff --git a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererCalcinator.java b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererCalcinator.java index 7c3da0c4..bb4ace13 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererCalcinator.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererCalcinator.java @@ -13,45 +13,53 @@ import net.minecraft.util.MathHelper; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class TileEntityRendererCalcinator extends TileEntitySpecialRenderer -{ +public class TileEntityRendererCalcinator extends TileEntitySpecialRenderer { private final ModelCalcinator modelCalcinator = new ModelCalcinator(); - private static float[] getBlendedDustColour(int leftStackSize, int leftStackMeta, int rightStackSize, int rightStackMeta) - { + private static float[] getBlendedDustColour( + int leftStackSize, int leftStackMeta, int rightStackSize, int rightStackMeta + ) { int totalDustStacksSize = leftStackSize + rightStackSize; - if (totalDustStacksSize > 0) - { - int leftStackColour = Integer.parseInt(Colors.DUST_COLOURS[MathHelper.clamp_int(leftStackMeta, 0, Colors.DUST_COLOURS.length)], 16); - int rightStackColour = Integer.parseInt(Colors.DUST_COLOURS[MathHelper.clamp_int(rightStackMeta, 0, Colors.DUST_COLOURS.length)], 16); + if (totalDustStacksSize > 0) { + int leftStackColour = Integer.parseInt( + Colors.DUST_COLOURS + [MathHelper.clamp_int(leftStackMeta, 0, Colors.DUST_COLOURS.length)], + 16 + ); + int rightStackColour = Integer.parseInt( + Colors.DUST_COLOURS + [MathHelper.clamp_int(rightStackMeta, 0, Colors.DUST_COLOURS.length)], + 16 + ); float leftStackRatio = leftStackSize * 1f / totalDustStacksSize; float rightStackRatio = rightStackSize * 1f / totalDustStacksSize; - float[][] blendedColours = ColorUtils.getFloatBlendedColours(leftStackColour, rightStackColour, 32); + float[][] blendedColours = ColorUtils.getFloatBlendedColours( + leftStackColour, rightStackColour, 32 + ); - if (blendedColours.length > 0) - { - if (Float.compare(leftStackRatio, rightStackRatio) > 0) - { - return blendedColours[Math.round((1 - leftStackRatio) * (blendedColours.length - 1))]; - } - else - { - return blendedColours[Math.round(rightStackRatio * (blendedColours.length - 1))]; + if (blendedColours.length > 0) { + if (Float.compare(leftStackRatio, rightStackRatio) > 0) { + return blendedColours[Math.round( + (1 - leftStackRatio) * (blendedColours.length - 1) + )]; + } else { + return blendedColours[Math.round( + rightStackRatio * (blendedColours.length - 1) + )]; } } } - return new float[]{1F, 1F, 1F}; + return new float[] { 1F, 1F, 1F }; } @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) - { - if (tileEntity instanceof TileEntityCalcinator) - { + public void + renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) { + if (tileEntity instanceof TileEntityCalcinator) { TileEntityCalcinator tileEntityCalcinator = (TileEntityCalcinator) tileEntity; GL11.glPushMatrix(); @@ -63,39 +71,39 @@ public class TileEntityRendererCalcinator extends TileEntitySpecialRenderer GL11.glRotatef(-90F, 1F, 0F, 0F); // Bind texture - if (tileEntityCalcinator.getState() == 1) - { + if (tileEntityCalcinator.getState() == 1) { this.bindTexture(Textures.Model.CALCINATOR_ACTIVE); - } - else - { + } else { this.bindTexture(Textures.Model.CALCINATOR_IDLE); } // Render modelCalcinator.renderPart("Calcinator"); - int dustStackSize = tileEntityCalcinator.leftStackSize + tileEntityCalcinator.rightStackSize; + int dustStackSize = tileEntityCalcinator.leftStackSize + + tileEntityCalcinator.rightStackSize; - if (dustStackSize > 0) - { + if (dustStackSize > 0) { GL11.glPushMatrix(); - // Reverse previous rotation to get back into a workable frame of reference + // Reverse previous rotation to get back into a workable frame of + // reference GL11.glRotatef(90F, 1F, 0F, 0F); GL11.glRotatef(-45F, 0F, 1F, 0F); - float[] dustColour = getBlendedDustColour(tileEntityCalcinator.leftStackSize, tileEntityCalcinator.leftStackMeta, tileEntityCalcinator.rightStackSize, tileEntityCalcinator.rightStackMeta); + float[] dustColour = getBlendedDustColour( + tileEntityCalcinator.leftStackSize, + tileEntityCalcinator.leftStackMeta, + tileEntityCalcinator.rightStackSize, + tileEntityCalcinator.rightStackMeta + ); GL11.glColor4f(dustColour[0], dustColour[1], dustColour[2], 1F); - if (dustStackSize <= 32) - { + if (dustStackSize <= 32) { GL11.glScalef(0.25F, 0.25F, 0.25F); GL11.glTranslatef(0.0F, 2.20F, -2.1125F); - } - else if (dustStackSize <= 64) - { + } else if (dustStackSize <= 64) { GL11.glScalef(0.5F, 0.5F, 0.5F); GL11.glTranslatef(-0.0125F, 0.75F, -0.7125F); } diff --git a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererGlassBell.java b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererGlassBell.java index 4a41669f..8bdd1768 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererGlassBell.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererGlassBell.java @@ -16,19 +16,14 @@ import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class TileEntityRendererGlassBell extends TileEntitySpecialRenderer -{ +public class TileEntityRendererGlassBell extends TileEntitySpecialRenderer { private final ModelGlassBell modelGlassBell = new ModelGlassBell(); private final RenderItem customRenderItem; - public TileEntityRendererGlassBell() - { - customRenderItem = new RenderItem() - { + public TileEntityRendererGlassBell() { + customRenderItem = new RenderItem() { @Override - public boolean shouldBob() - { - + public boolean shouldBob() { return false; } }; @@ -37,10 +32,9 @@ public class TileEntityRendererGlassBell extends TileEntitySpecialRenderer } @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) - { - if (tileEntity instanceof TileEntityGlassBell) - { + public void + renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) { + if (tileEntity instanceof TileEntityGlassBell) { TileEntityGlassBell tileEntityGlassBell = (TileEntityGlassBell) tileEntity; GL11.glDisable(GL11.GL_CULL_FACE); @@ -65,17 +59,26 @@ public class TileEntityRendererGlassBell extends TileEntitySpecialRenderer */ GL11.glPushMatrix(); - if (tileEntityGlassBell.outputItemStack != null) - { - // TODO Stop the ghost item rendering in the event that the client's game is paused - float scaleFactor = getGhostItemScaleFactor(tileEntityGlassBell.outputItemStack); - float rotationAngle = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL); + if (tileEntityGlassBell.outputItemStack != null) { + // TODO Stop the ghost item rendering in the event that the client's game + // is paused + float scaleFactor + = getGhostItemScaleFactor(tileEntityGlassBell.outputItemStack); + float rotationAngle + = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL); - EntityItem ghostEntityItem = new EntityItem(tileEntityGlassBell.getWorldObj()); + EntityItem ghostEntityItem + = new EntityItem(tileEntityGlassBell.getWorldObj()); ghostEntityItem.hoverStart = 0.0F; ghostEntityItem.setEntityItemStack(tileEntityGlassBell.outputItemStack); - translateGhostItemByOrientation(ghostEntityItem.getEntityItem(), x, y, z, tileEntityGlassBell.getOrientation()); + translateGhostItemByOrientation( + ghostEntityItem.getEntityItem(), + x, + y, + z, + tileEntityGlassBell.getOrientation() + ); GL11.glScalef(scaleFactor, scaleFactor, scaleFactor); GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F); @@ -88,184 +91,172 @@ public class TileEntityRendererGlassBell extends TileEntitySpecialRenderer } } - private void renderGlassBellByOrientation(double x, double y, double z, ForgeDirection forgeDirection) - { - switch (forgeDirection) - { - case DOWN: - { + private void renderGlassBellByOrientation( + double x, double y, double z, ForgeDirection forgeDirection + ) { + switch (forgeDirection) { + case DOWN: { GL11.glScalef(1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) x + 0.0F, (float) y + 2.0F, (float) z + 0.0F); GL11.glRotatef(90F, 1F, 0F, 0F); return; } - case UP: - { + case UP: { GL11.glScalef(1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) x + 0.0F, (float) y + -1.0F, (float) z + 1.0F); GL11.glRotatef(-90F, 1F, 0F, 0F); return; } - case NORTH: - { + case NORTH: { GL11.glScalef(1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) x + 1.0F, (float) y + 0.0F, (float) z + 2.0F); GL11.glRotatef(180F, 0F, 1F, 0F); return; } - case SOUTH: - { + case SOUTH: { GL11.glScalef(1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) x + 0.0F, (float) y + 0.0F, (float) z + -1.0F); return; } - case EAST: - { + case EAST: { GL11.glScalef(1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) x + -1.0F, (float) y + 1.0F, (float) z + 1.0F); GL11.glRotatef(-90F, 0F, 0F, 1F); GL11.glRotatef(-90F, 1F, 0F, 0F); return; } - case WEST: - { + case WEST: { GL11.glScalef(1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) x + 2.0F, (float) y + 0.0F, (float) z + 1.0F); GL11.glRotatef(90F, 0F, 0F, 1F); GL11.glRotatef(-90F, 1F, 0F, 0F); return; } - case UNKNOWN: - { + case UNKNOWN: { return; } - default: - { + default: { } } } - private void translateGhostItemByOrientation(ItemStack ghostItemStack, double x, double y, double z, ForgeDirection forgeDirection) - { - if (ghostItemStack != null) - { - if (ghostItemStack.getItem() instanceof ItemBlock) - { - switch (forgeDirection) - { - case DOWN: - { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.7F, (float) z + 0.5F); + private void translateGhostItemByOrientation( + ItemStack ghostItemStack, + double x, + double y, + double z, + ForgeDirection forgeDirection + ) { + if (ghostItemStack != null) { + if (ghostItemStack.getItem() instanceof ItemBlock) { + switch (forgeDirection) { + case DOWN: { + GL11.glTranslatef( + (float) x + 0.5F, (float) y + 0.7F, (float) z + 0.5F + ); return; } - case UP: - { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.25F, (float) z + 0.5F); + case UP: { + GL11.glTranslatef( + (float) x + 0.5F, (float) y + 0.25F, (float) z + 0.5F + ); return; } - case NORTH: - { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.7F); + case NORTH: { + GL11.glTranslatef( + (float) x + 0.5F, (float) y + 0.5F, (float) z + 0.7F + ); return; } - case SOUTH: - { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.3F); + case SOUTH: { + GL11.glTranslatef( + (float) x + 0.5F, (float) y + 0.5F, (float) z + 0.3F + ); return; } - case EAST: - { - GL11.glTranslatef((float) x + 0.3F, (float) y + 0.5F, (float) z + 0.5F); + case EAST: { + GL11.glTranslatef( + (float) x + 0.3F, (float) y + 0.5F, (float) z + 0.5F + ); return; } - case WEST: - { - GL11.glTranslatef((float) x + 0.70F, (float) y + 0.5F, (float) z + 0.5F); + case WEST: { + GL11.glTranslatef( + (float) x + 0.70F, (float) y + 0.5F, (float) z + 0.5F + ); return; } - case UNKNOWN: - { + case UNKNOWN: { return; } - default: - { + default: { } } - } - else - { - switch (forgeDirection) - { - case DOWN: - { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.6F, (float) z + 0.5F); + } else { + switch (forgeDirection) { + case DOWN: { + GL11.glTranslatef( + (float) x + 0.5F, (float) y + 0.6F, (float) z + 0.5F + ); return; } - case UP: - { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.20F, (float) z + 0.5F); + case UP: { + GL11.glTranslatef( + (float) x + 0.5F, (float) y + 0.20F, (float) z + 0.5F + ); return; } - case NORTH: - { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.7F); + case NORTH: { + GL11.glTranslatef( + (float) x + 0.5F, (float) y + 0.4F, (float) z + 0.7F + ); return; } - case SOUTH: - { - GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.3F); + case SOUTH: { + GL11.glTranslatef( + (float) x + 0.5F, (float) y + 0.4F, (float) z + 0.3F + ); return; } - case EAST: - { - GL11.glTranslatef((float) x + 0.3F, (float) y + 0.4F, (float) z + 0.5F); + case EAST: { + GL11.glTranslatef( + (float) x + 0.3F, (float) y + 0.4F, (float) z + 0.5F + ); return; } - case WEST: - { - GL11.glTranslatef((float) x + 0.70F, (float) y + 0.4F, (float) z + 0.5F); + case WEST: { + GL11.glTranslatef( + (float) x + 0.70F, (float) y + 0.4F, (float) z + 0.5F + ); return; } - case UNKNOWN: - { + case UNKNOWN: { return; } - default: - { + default: { } } } } } - private float getGhostItemScaleFactor(ItemStack itemStack) - { + private float getGhostItemScaleFactor(ItemStack itemStack) { float scaleFactor = 1.0F; - if (itemStack != null) - { + if (itemStack != null) { byte numBlocks = 1; - if (itemStack.stackSize > 1) - { + if (itemStack.stackSize > 1) { numBlocks = 2; - } - else if (itemStack.stackSize > 5) - { + } else if (itemStack.stackSize > 5) { numBlocks = 3; - } - else if (itemStack.stackSize > 20) - { + } else if (itemStack.stackSize > 20) { numBlocks = 4; - } - else if (itemStack.stackSize > 40) - { + } else if (itemStack.stackSize > 40) { numBlocks = 5; } - if (itemStack.getItem() instanceof ItemBlock) - { - switch (numBlocks) - { + if (itemStack.getItem() instanceof ItemBlock) { + switch (numBlocks) { case 1: return 0.90F; case 2: @@ -279,11 +270,8 @@ public class TileEntityRendererGlassBell extends TileEntitySpecialRenderer default: return 0.90F; } - } - else - { - switch (numBlocks) - { + } else { + switch (numBlocks) { case 1: return 0.65F; case 2: diff --git a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererResearchStation.java b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererResearchStation.java index 4d9817e8..0eedc1e2 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererResearchStation.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererResearchStation.java @@ -15,32 +15,27 @@ import net.minecraft.tileentity.TileEntity; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class TileEntityRendererResearchStation extends TileEntitySpecialRenderer -{ +public class TileEntityRendererResearchStation extends TileEntitySpecialRenderer { private final ModelResearchStation modelResearchStation = new ModelResearchStation(); private final RenderItem customRenderItem; - - public TileEntityRendererResearchStation() - { - customRenderItem = new RenderItem() - { - @Override - public boolean shouldBob() - { + public TileEntityRendererResearchStation() { + customRenderItem = new RenderItem() { + @Override + public boolean shouldBob() { return false; } }; customRenderItem.setRenderManager(RenderManager.instance); } - + @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) - { - if (tileEntity instanceof TileEntityResearchStation) - { - TileEntityResearchStation tileEntityResearchStation = (TileEntityResearchStation) tileEntity; + public void + renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) { + if (tileEntity instanceof TileEntityResearchStation) { + TileEntityResearchStation tileEntityResearchStation + = (TileEntityResearchStation) tileEntity; /** * Render the Research Station @@ -58,19 +53,22 @@ public class TileEntityRendererResearchStation extends TileEntitySpecialRenderer modelResearchStation.render(); GL11.glPopMatrix(); - + /** * Render the Tome of Alchemical Knowledge */ GL11.glPushMatrix(); - ItemStack alchenomicon = tileEntityResearchStation.getStackInSlot(TileEntityResearchStation.ALCHENOMICON_SLOT_INVENTORY_INDEX); - if (Minecraft.getMinecraft().gameSettings.fancyGraphics && alchenomicon != null) - { - EntityItem ghostEntityItem = new EntityItem(tileEntityResearchStation.getWorldObj()); + ItemStack alchenomicon = tileEntityResearchStation.getStackInSlot( + TileEntityResearchStation.ALCHENOMICON_SLOT_INVENTORY_INDEX + ); + if (Minecraft.getMinecraft().gameSettings.fancyGraphics + && alchenomicon != null) { + EntityItem ghostEntityItem + = new EntityItem(tileEntityResearchStation.getWorldObj()); ghostEntityItem.hoverStart = 0.0F; ghostEntityItem.setEntityItemStack(alchenomicon); - + GL11.glTranslated(x + 0.6F, y + 1.015625F, z + 0.35F); GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(45F, 0.0F, 0.0F, 1.0F); diff --git a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererTransmutationTablet.java b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererTransmutationTablet.java index a0775caf..741f9a4a 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererTransmutationTablet.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererTransmutationTablet.java @@ -13,16 +13,16 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; @SideOnly(Side.CLIENT) -public class TileEntityRendererTransmutationTablet extends TileEntitySpecialRenderer -{ - private final ModelTransmutationTablet modelTransmutationTablet = new ModelTransmutationTablet(); +public class TileEntityRendererTransmutationTablet extends TileEntitySpecialRenderer { + private final ModelTransmutationTablet modelTransmutationTablet + = new ModelTransmutationTablet(); @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) - { - if (tileEntity instanceof TileEntityTransmutationTablet) - { - TileEntityTransmutationTablet tileEntityTransmutationTablet = (TileEntityTransmutationTablet) tileEntity; + public void + renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) { + if (tileEntity instanceof TileEntityTransmutationTablet) { + TileEntityTransmutationTablet tileEntityTransmutationTablet + = (TileEntityTransmutationTablet) tileEntity; this.bindTexture(Textures.Model.TRANSMUTATION_TABLET); GL11.glPushMatrix(); @@ -30,30 +30,21 @@ public class TileEntityRendererTransmutationTablet extends TileEntitySpecialRend GL11.glTranslatef((float) x, (float) y, (float) z); GL11.glTranslatef(0.5F, -0.375F, 0.5F); modelTransmutationTablet.renderBase(0.0625f); - if (tileEntityTransmutationTablet.isStructureValid()) - { + if (tileEntityTransmutationTablet.isStructureValid()) { modelTransmutationTablet.renderTransmutationPad(0.0625f); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); - if (tileEntityTransmutationTablet.isStructureValid()) - { + if (tileEntityTransmutationTablet.isStructureValid()) { int rotationAngle = 0; - if (tileEntityTransmutationTablet.getRotation() == ForgeDirection.NORTH) - { + if (tileEntityTransmutationTablet.getRotation() == ForgeDirection.NORTH) { rotationAngle = 0; - } - else if (tileEntityTransmutationTablet.getRotation() == ForgeDirection.EAST) - { + } else if (tileEntityTransmutationTablet.getRotation() == ForgeDirection.EAST) { rotationAngle = -90; - } - else if (tileEntityTransmutationTablet.getRotation() == ForgeDirection.SOUTH) - { + } else if (tileEntityTransmutationTablet.getRotation() == ForgeDirection.SOUTH) { rotationAngle = 180; - } - else if (tileEntityTransmutationTablet.getRotation() == ForgeDirection.WEST) - { + } else if (tileEntityTransmutationTablet.getRotation() == ForgeDirection.WEST) { rotationAngle = 90; } @@ -65,7 +56,12 @@ public class TileEntityRendererTransmutationTablet extends TileEntitySpecialRend GL11.glPushMatrix(); GL11.glTranslated(x + 0.5d, y + 0.63d, z + 0.5d); GL11.glScalef(2f, 2f, 2f); - GL11.glRotatef(rotationAngle, tileEntityTransmutationTablet.getOrientation().offsetX, tileEntityTransmutationTablet.getOrientation().offsetY, tileEntityTransmutationTablet.getOrientation().offsetZ); + GL11.glRotatef( + rotationAngle, + tileEntityTransmutationTablet.getOrientation().offsetX, + tileEntityTransmutationTablet.getOrientation().offsetY, + tileEntityTransmutationTablet.getOrientation().offsetZ + ); GL11.glRotatef(90, -1, 0, 0); RenderUtils.renderQuad(Textures.AlchemyArray.TRANSMUTATION_ALCHEMY_ARRAY); GL11.glPopMatrix(); diff --git a/src/main/java/com/pahimar/ee3/client/settings/Keybindings.java b/src/main/java/com/pahimar/ee3/client/settings/Keybindings.java index 408b4dd2..39c6cf3e 100644 --- a/src/main/java/com/pahimar/ee3/client/settings/Keybindings.java +++ b/src/main/java/com/pahimar/ee3/client/settings/Keybindings.java @@ -7,10 +7,13 @@ import net.minecraft.client.settings.KeyBinding; import org.lwjgl.input.Keyboard; @SideOnly(Side.CLIENT) -public class Keybindings -{ - public static KeyBinding charge = new KeyBinding(Names.Keys.CHARGE, Keyboard.KEY_V, Names.Keys.CATEGORY); - public static KeyBinding extra = new KeyBinding(Names.Keys.EXTRA, Keyboard.KEY_C, Names.Keys.CATEGORY); - public static KeyBinding release = new KeyBinding(Names.Keys.RELEASE, Keyboard.KEY_R, Names.Keys.CATEGORY); - public static KeyBinding toggle = new KeyBinding(Names.Keys.TOGGLE, Keyboard.KEY_G, Names.Keys.CATEGORY); +public class Keybindings { + public static KeyBinding charge + = new KeyBinding(Names.Keys.CHARGE, Keyboard.KEY_V, Names.Keys.CATEGORY); + public static KeyBinding extra + = new KeyBinding(Names.Keys.EXTRA, Keyboard.KEY_C, Names.Keys.CATEGORY); + public static KeyBinding release + = new KeyBinding(Names.Keys.RELEASE, Keyboard.KEY_R, Names.Keys.CATEGORY); + public static KeyBinding toggle + = new KeyBinding(Names.Keys.TOGGLE, Keyboard.KEY_G, Names.Keys.CATEGORY); } diff --git a/src/main/java/com/pahimar/ee3/client/util/ClientParticleHelper.java b/src/main/java/com/pahimar/ee3/client/util/ClientParticleHelper.java index d3752677..314074d1 100644 --- a/src/main/java/com/pahimar/ee3/client/util/ClientParticleHelper.java +++ b/src/main/java/com/pahimar/ee3/client/util/ClientParticleHelper.java @@ -2,10 +2,18 @@ package com.pahimar.ee3.client.util; import cpw.mods.fml.client.FMLClientHandler; -public class ClientParticleHelper -{ - public static void spawnParticleAtLocation(String particleName, double xCoord, double yCoord, double zCoord, double xVelocity, double yVelocity, double zVelocity) - { - FMLClientHandler.instance().getWorldClient().spawnParticle(particleName, xCoord, yCoord, zCoord, xVelocity, yVelocity, zVelocity); +public class ClientParticleHelper { + public static void spawnParticleAtLocation( + String particleName, + double xCoord, + double yCoord, + double zCoord, + double xVelocity, + double yVelocity, + double zVelocity + ) { + FMLClientHandler.instance().getWorldClient().spawnParticle( + particleName, xCoord, yCoord, zCoord, xVelocity, yVelocity, zVelocity + ); } } diff --git a/src/main/java/com/pahimar/ee3/client/util/ClientSoundHelper.java b/src/main/java/com/pahimar/ee3/client/util/ClientSoundHelper.java index cae272ae..11e740a4 100644 --- a/src/main/java/com/pahimar/ee3/client/util/ClientSoundHelper.java +++ b/src/main/java/com/pahimar/ee3/client/util/ClientSoundHelper.java @@ -4,10 +4,24 @@ import com.pahimar.ee3.util.ResourceLocationHelper; import cpw.mods.fml.client.FMLClientHandler; import net.minecraft.client.audio.PositionedSoundRecord; -public class ClientSoundHelper -{ - public static void playSound(String soundName, float xCoord, float yCoord, float zCoord, float volume, float pitch) - { - FMLClientHandler.instance().getClient().getSoundHandler().playSound(new PositionedSoundRecord(ResourceLocationHelper.getResourceLocation(soundName), volume, pitch, xCoord, yCoord, zCoord)); +public class ClientSoundHelper { + public static void playSound( + String soundName, + float xCoord, + float yCoord, + float zCoord, + float volume, + float pitch + ) { + FMLClientHandler.instance().getClient().getSoundHandler().playSound( + new PositionedSoundRecord( + ResourceLocationHelper.getResourceLocation(soundName), + volume, + pitch, + xCoord, + yCoord, + zCoord + ) + ); } } diff --git a/src/main/java/com/pahimar/ee3/client/util/ColorUtils.java b/src/main/java/com/pahimar/ee3/client/util/ColorUtils.java index 6a50f8d9..6d1bb846 100644 --- a/src/main/java/com/pahimar/ee3/client/util/ColorUtils.java +++ b/src/main/java/com/pahimar/ee3/client/util/ColorUtils.java @@ -1,9 +1,7 @@ package com.pahimar.ee3.client.util; -public class ColorUtils -{ - public static byte[] convertIntColourToByteArray(int intColour) - { +public class ColorUtils { + public static byte[] convertIntColourToByteArray(int intColour) { byte[] colourByteArray = new byte[3]; colourByteArray[0] = (byte) (intColour >> 16 & 255); @@ -13,8 +11,7 @@ public class ColorUtils return colourByteArray; } - public static float[] convertIntColourToFloatArray(int intColour) - { + public static float[] convertIntColourToFloatArray(int intColour) { float[] colourFloatArray = new float[3]; colourFloatArray[0] = ((intColour >> 16 & 0xFF) / 255F); @@ -24,19 +21,21 @@ public class ColorUtils return colourFloatArray; } - public static byte[][] getByteBlendedColours(byte[] firstColour, byte[] secondColour, int steps) - { - if (firstColour.length == 3 && secondColour.length == 3 && steps > 0) - { + public static byte[][] getByteBlendedColours( + byte[] firstColour, byte[] secondColour, int steps + ) { + if (firstColour.length == 3 && secondColour.length == 3 && steps > 0) { byte[][] blendedColours = new byte[steps + 2][3]; - byte redDifference = (byte) (((secondColour[0] & 0xFF) - (firstColour[0] & 0xFF)) / steps); - byte greenDifference = (byte) (((secondColour[1] & 0xFF) - (firstColour[1] & 0xFF)) / steps); - byte blueDifference = (byte) (((secondColour[2] & 0xFF) - (firstColour[2] & 0xFF)) / steps); + byte redDifference + = (byte) (((secondColour[0] & 0xFF) - (firstColour[0] & 0xFF)) / steps); + byte greenDifference + = (byte) (((secondColour[1] & 0xFF) - (firstColour[1] & 0xFF)) / steps); + byte blueDifference + = (byte) (((secondColour[2] & 0xFF) - (firstColour[2] & 0xFF)) / steps); blendedColours[0] = firstColour; - for (int i = 1; i < blendedColours.length - 1; i++) - { + for (int i = 1; i < blendedColours.length - 1; i++) { blendedColours[i][0] = (byte) (firstColour[0] + i * redDifference); blendedColours[i][1] = (byte) (firstColour[1] + i * greenDifference); blendedColours[i][2] = (byte) (firstColour[2] + i * blueDifference); @@ -49,40 +48,38 @@ public class ColorUtils return null; } - public static float[][] getFloatBlendedColours(byte[] firstColour, byte[] secondColour, int steps) - { - byte[][] byteBlendedColours = getByteBlendedColours(firstColour, secondColour, steps); + public static float[][] getFloatBlendedColours( + byte[] firstColour, byte[] secondColour, int steps + ) { + byte[][] byteBlendedColours + = getByteBlendedColours(firstColour, secondColour, steps); - if (byteBlendedColours != null) - { + if (byteBlendedColours != null) { float[][] floatBlendedColours = new float[byteBlendedColours.length][3]; - for (int i = 0; i < byteBlendedColours.length; i++) - { + for (int i = 0; i < byteBlendedColours.length; i++) { floatBlendedColours[i][0] = (byteBlendedColours[i][0] & 0xFF) / 255F; floatBlendedColours[i][1] = (byteBlendedColours[i][1] & 0xFF) / 255F; floatBlendedColours[i][2] = (byteBlendedColours[i][2] & 0xFF) / 255F; } return floatBlendedColours; - } - else - { + } else { return null; } } - public static float[][] getFloatBlendedColours(int firstColour, int secondColour, int steps) - { + public static float[][] getFloatBlendedColours( + int firstColour, int secondColour, int steps + ) { byte[] firstColourByteArray = convertIntColourToByteArray(firstColour); byte[] secondColourByteArray = convertIntColourToByteArray(secondColour); - if (firstColourByteArray != null && secondColourByteArray != null) - { - return getFloatBlendedColours(firstColourByteArray, secondColourByteArray, steps); - } - else - { + if (firstColourByteArray != null && secondColourByteArray != null) { + return getFloatBlendedColours( + firstColourByteArray, secondColourByteArray, steps + ); + } else { return null; } } diff --git a/src/main/java/com/pahimar/ee3/client/util/RenderUtils.java b/src/main/java/com/pahimar/ee3/client/util/RenderUtils.java index c5916f36..0f448c57 100644 --- a/src/main/java/com/pahimar/ee3/client/util/RenderUtils.java +++ b/src/main/java/com/pahimar/ee3/client/util/RenderUtils.java @@ -11,20 +11,29 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; public class RenderUtils { - public static void bindTexture(ResourceLocation texture) { FMLClientHandler.instance().getClient().getTextureManager().bindTexture(texture); } - public static int getCenteredTextOffset(FontRenderer fontRenderer, String string, int width) { + public static int + getCenteredTextOffset(FontRenderer fontRenderer, String string, int width) { return (width - fontRenderer.getStringWidth(string)) / 2; } - public static void renderItemIntoGUI(FontRenderer fontRenderer, ItemStack itemStack, int x, int y, float opacity, float scale, int zLevel) { - + public static void renderItemIntoGUI( + FontRenderer fontRenderer, + ItemStack itemStack, + int x, + int y, + float opacity, + float scale, + int zLevel + ) { IIcon icon = itemStack.getIconIndex(); GL11.glDisable(GL11.GL_LIGHTING); - FMLClientHandler.instance().getClient().renderEngine.bindTexture(TextureMap.locationItemsTexture); + FMLClientHandler.instance().getClient().renderEngine.bindTexture( + TextureMap.locationItemsTexture + ); int overlayColour = itemStack.getItem().getColorFromItemStack(itemStack, 0); float red = (overlayColour >> 16 & 255) / 255.0F; float green = (overlayColour >> 8 & 255) / 255.0F; @@ -32,16 +41,21 @@ public class RenderUtils { GL11.glColor4f(red, green, blue, opacity); Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(x, y + 16 * scale, zLevel, icon.getMinU(), icon.getMaxV()); - tessellator.addVertexWithUV(x + 16 * scale, y + 16 * scale, zLevel, icon.getMaxU(), icon.getMaxV()); - tessellator.addVertexWithUV(x + 16 * scale, y, zLevel, icon.getMaxU(), icon.getMinV()); + tessellator.addVertexWithUV( + x, y + 16 * scale, zLevel, icon.getMinU(), icon.getMaxV() + ); + tessellator.addVertexWithUV( + x + 16 * scale, y + 16 * scale, zLevel, icon.getMaxU(), icon.getMaxV() + ); + tessellator.addVertexWithUV( + x + 16 * scale, y, zLevel, icon.getMaxU(), icon.getMinV() + ); tessellator.addVertexWithUV(x, y, zLevel, icon.getMinU(), icon.getMinV()); tessellator.draw(); GL11.glEnable(GL11.GL_LIGHTING); } public static void renderQuad(ResourceLocation texture) { - FMLClientHandler.instance().getClient().renderEngine.bindTexture(texture); Tessellator tessellator = Tessellator.instance; GL11.glEnable(GL12.GL_RESCALE_NORMAL); @@ -58,8 +72,8 @@ public class RenderUtils { GL11.glDisable(GL12.GL_RESCALE_NORMAL); } - public static void renderPulsingQuad(ResourceLocation texture, float maxTransparency) { - + public static void + renderPulsingQuad(ResourceLocation texture, float maxTransparency) { float pulseTransparency = (float) getPulseValue() * maxTransparency; FMLClientHandler.instance().getClient().renderEngine.bindTexture(texture); Tessellator tessellator = Tessellator.instance; diff --git a/src/main/java/com/pahimar/ee3/command/CommandEE.java b/src/main/java/com/pahimar/ee3/command/CommandEE.java index 9dc8a6c5..0f29c9e9 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandEE.java +++ b/src/main/java/com/pahimar/ee3/command/CommandEE.java @@ -1,5 +1,8 @@ package com.pahimar.ee3.command; +import java.util.ArrayList; +import java.util.List; + import com.google.common.base.Joiner; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; @@ -7,11 +10,7 @@ import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; import net.minecraft.command.WrongUsageException; -import java.util.ArrayList; -import java.util.List; - public class CommandEE extends CommandBase { - private static List modCommands = new ArrayList<>(); private static List commands = new ArrayList<>(); @@ -27,14 +26,12 @@ public class CommandEE extends CommandBase { @Override public void processCommand(ICommandSender commandSender, String[] args) { - boolean found = false; if (args.length >= 1) { - for (CommandBase command : modCommands) { - - if (command.getCommandName().equalsIgnoreCase(args[0]) && command.canCommandSenderUseCommand(commandSender)) { + if (command.getCommandName().equalsIgnoreCase(args[0]) + && command.canCommandSenderUseCommand(commandSender)) { found = true; command.processCommand(commandSender, args); } @@ -42,17 +39,17 @@ public class CommandEE extends CommandBase { } if (!found) { - throw new WrongUsageException("Invalid command. Usage: /ee3 " + Joiner.on(" ").join(commands)); + throw new WrongUsageException( + "Invalid command. Usage: /ee3 " + Joiner.on(" ").join(commands) + ); } } @Override public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { - if (args.length == 1) { return getListOfStringsFromIterableMatchingLastWord(args, commands); - } - else if (args.length >= 2) { + } else if (args.length >= 2) { for (CommandBase command : modCommands) { if (command.getCommandName().equalsIgnoreCase(args[0])) { return command.addTabCompletionOptions(commandSender, args); diff --git a/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetCurrentItem.java b/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetCurrentItem.java index e48ade9b..f146b1e4 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetCurrentItem.java +++ b/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetCurrentItem.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.command; +import java.util.List; + import com.pahimar.ee3.api.knowledge.PlayerKnowledgeRegistryProxy; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; @@ -10,66 +12,63 @@ import net.minecraft.command.WrongUsageException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import java.util.List; - -public class CommandPlayerForgetCurrentItem extends CommandBase -{ +public class CommandPlayerForgetCurrentItem extends CommandBase { @Override - public String getCommandName() - { + public String getCommandName() { return Names.Commands.PLAYER_FORGET_CURRENT_ITEM; } @Override - public int getRequiredPermissionLevel() - { + public int getRequiredPermissionLevel() { return 2; } @Override - public String getCommandUsage(ICommandSender commandSender) - { + public String getCommandUsage(ICommandSender commandSender) { return Messages.Commands.PLAYER_FORGET_CURRENT_ITEM_USAGE; } @Override - public void processCommand(ICommandSender commandSender, String[] args) - { - if (args.length < 2) - { - throw new WrongUsageException(Messages.Commands.PLAYER_FORGET_CURRENT_ITEM_USAGE); - } - else - { + public void processCommand(ICommandSender commandSender, String[] args) { + if (args.length < 2) { + throw new WrongUsageException( + Messages.Commands.PLAYER_FORGET_CURRENT_ITEM_USAGE + ); + } else { EntityPlayer entityPlayer = getPlayer(commandSender, args[1]); - if (entityPlayer != null) - { - ItemStack itemStack = ((EntityPlayer) commandSender).getCurrentEquippedItem(); - if (itemStack != null) - { - PlayerKnowledgeRegistryProxy.makePlayerForget(entityPlayer, itemStack); - func_152373_a(commandSender, this, Messages.Commands.PLAYER_FORGET_CURRENT_ITEM_SUCCESS, new Object[]{commandSender.getCommandSenderName(), entityPlayer.getCommandSenderName(), itemStack.func_151000_E()}); - } - else - { + if (entityPlayer != null) { + ItemStack itemStack + = ((EntityPlayer) commandSender).getCurrentEquippedItem(); + if (itemStack != null) { + PlayerKnowledgeRegistryProxy.makePlayerForget( + entityPlayer, itemStack + ); + func_152373_a( + commandSender, + this, + Messages.Commands.PLAYER_FORGET_CURRENT_ITEM_SUCCESS, + new Object[] { commandSender.getCommandSenderName(), + entityPlayer.getCommandSenderName(), + itemStack.func_151000_E() } + ); + } else { throw new WrongUsageException(Messages.Commands.NO_ITEM); } - } - else - { + } else { throw new WrongUsageException(Messages.Commands.PLAYER_NOT_FOUND_ERROR); } } } @Override - public List addTabCompletionOptions(ICommandSender commandSender, String[] args) - { - if (args.length == 2) - { - return getListOfStringsMatchingLastWord(args, FMLCommonHandler.instance().getMinecraftServerInstance().getAllUsernames()); + public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { + if (args.length == 2) { + return getListOfStringsMatchingLastWord( + args, + FMLCommonHandler.instance().getMinecraftServerInstance().getAllUsernames() + ); } return null; diff --git a/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetEverything.java b/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetEverything.java index b4b3b8b2..9747a592 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetEverything.java +++ b/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetEverything.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.command; +import java.util.List; + import com.pahimar.ee3.api.knowledge.PlayerKnowledgeRegistryProxy; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; @@ -9,57 +11,52 @@ import net.minecraft.command.ICommandSender; import net.minecraft.command.WrongUsageException; import net.minecraft.entity.player.EntityPlayer; -import java.util.List; - -public class CommandPlayerForgetEverything extends CommandBase -{ +public class CommandPlayerForgetEverything extends CommandBase { @Override - public String getCommandName() - { + public String getCommandName() { return Names.Commands.PLAYER_FORGET_EVERYTHING; } @Override - public int getRequiredPermissionLevel() - { + public int getRequiredPermissionLevel() { return 2; } @Override - public String getCommandUsage(ICommandSender commandSender) - { + public String getCommandUsage(ICommandSender commandSender) { return Messages.Commands.PLAYER_FORGET_EVERYTHING_USAGE; } @Override - public void processCommand(ICommandSender commandSender, String[] args) - { - if (args.length < 2) - { - throw new WrongUsageException(Messages.Commands.PLAYER_FORGET_EVERYTHING_USAGE); - } - else - { + public void processCommand(ICommandSender commandSender, String[] args) { + if (args.length < 2) { + throw new WrongUsageException(Messages.Commands.PLAYER_FORGET_EVERYTHING_USAGE + ); + } else { EntityPlayer entityPlayer = getPlayer(commandSender, args[1]); - if (entityPlayer != null) - { + if (entityPlayer != null) { PlayerKnowledgeRegistryProxy.makePlayerForgetAll(entityPlayer); - func_152373_a(commandSender, this, Messages.Commands.PLAYER_FORGET_EVERYTHING_SUCCESS, new Object[]{commandSender.getCommandSenderName(), entityPlayer.getCommandSenderName()}); - } - else - { + func_152373_a( + commandSender, + this, + Messages.Commands.PLAYER_FORGET_EVERYTHING_SUCCESS, + new Object[] { commandSender.getCommandSenderName(), + entityPlayer.getCommandSenderName() } + ); + } else { throw new WrongUsageException(Messages.Commands.PLAYER_NOT_FOUND_ERROR); } } } @Override - public List addTabCompletionOptions(ICommandSender commandSender, String[] args) - { - if (args.length == 2) - { - return getListOfStringsMatchingLastWord(args, FMLCommonHandler.instance().getMinecraftServerInstance().getAllUsernames()); + public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { + if (args.length == 2) { + return getListOfStringsMatchingLastWord( + args, + FMLCommonHandler.instance().getMinecraftServerInstance().getAllUsernames() + ); } return null; diff --git a/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetItem.java b/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetItem.java index 3a02999e..b70dc77b 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetItem.java +++ b/src/main/java/com/pahimar/ee3/command/CommandPlayerForgetItem.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.command; +import java.util.List; + import com.pahimar.ee3.api.knowledge.PlayerKnowledgeRegistryProxy; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; @@ -14,94 +16,94 @@ import net.minecraft.nbt.JsonToNBT; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import java.util.List; - -public class CommandPlayerForgetItem extends CommandBase -{ +public class CommandPlayerForgetItem extends CommandBase { @Override - public String getCommandName() - { + public String getCommandName() { return Names.Commands.PLAYER_FORGET_ITEM; } @Override - public int getRequiredPermissionLevel() - { + public int getRequiredPermissionLevel() { return 2; } @Override - public String getCommandUsage(ICommandSender commandSender) - { + public String getCommandUsage(ICommandSender commandSender) { return Messages.Commands.PLAYER_FORGET_ITEM_USAGE; } @Override - public void processCommand(ICommandSender commandSender, String[] args) - { - if (args.length < 3) - { + public void processCommand(ICommandSender commandSender, String[] args) { + if (args.length < 3) { throw new WrongUsageException(Messages.Commands.PLAYER_FORGET_ITEM_USAGE); - } - else - { + } else { EntityPlayer entityPlayer = getPlayer(commandSender, args[1]); - if (entityPlayer != null) - { + if (entityPlayer != null) { Item item = getItemByText(commandSender, args[2]); int metaData = 0; - if (args.length >= 4) - { + if (args.length >= 4) { metaData = parseInt(commandSender, args[3]); } ItemStack itemStack = new ItemStack(item, 1, metaData); - if (args.length >= 5) - { - String stringNBTData = func_147178_a(commandSender, args, 4).getUnformattedText(); + if (args.length >= 5) { + String stringNBTData + = func_147178_a(commandSender, args, 4).getUnformattedText(); - try - { + try { NBTBase nbtBase = JsonToNBT.func_150315_a(stringNBTData); - if (!(nbtBase instanceof NBTTagCompound)) - { - func_152373_a(commandSender, this, Messages.Commands.INVALID_NBT_TAG_ERROR, new Object[]{"Not a valid tag"}); + if (!(nbtBase instanceof NBTTagCompound)) { + func_152373_a( + commandSender, + this, + Messages.Commands.INVALID_NBT_TAG_ERROR, + new Object[] { "Not a valid tag" } + ); return; } itemStack.setTagCompound((NBTTagCompound) nbtBase); - } - catch (Exception exception) - { - func_152373_a(commandSender, this, Messages.Commands.INVALID_NBT_TAG_ERROR, new Object[]{exception.getMessage()}); + } catch (Exception exception) { + func_152373_a( + commandSender, + this, + Messages.Commands.INVALID_NBT_TAG_ERROR, + new Object[] { exception.getMessage() } + ); return; } } PlayerKnowledgeRegistryProxy.makePlayerForget(entityPlayer, itemStack); - func_152373_a(commandSender, this, Messages.Commands.PLAYER_FORGET_ITEM_SUCCESS, new Object[]{commandSender.getCommandSenderName(), entityPlayer.getCommandSenderName(), itemStack.func_151000_E()}); - } - else - { + func_152373_a( + commandSender, + this, + Messages.Commands.PLAYER_FORGET_ITEM_SUCCESS, + new Object[] { commandSender.getCommandSenderName(), + entityPlayer.getCommandSenderName(), + itemStack.func_151000_E() } + ); + } else { throw new WrongUsageException(Messages.Commands.PLAYER_NOT_FOUND_ERROR); } } } @Override - public List addTabCompletionOptions(ICommandSender commandSender, String[] args) - { - if (args.length == 2) - { - return getListOfStringsMatchingLastWord(args, FMLCommonHandler.instance().getMinecraftServerInstance().getAllUsernames()); - } - else if (args.length == 3) - { - return getListOfStringsFromIterableMatchingLastWord(args, Item.itemRegistry.getKeys()); + public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { + if (args.length == 2) { + return getListOfStringsMatchingLastWord( + args, + FMLCommonHandler.instance().getMinecraftServerInstance().getAllUsernames() + ); + } else if (args.length == 3) { + return getListOfStringsFromIterableMatchingLastWord( + args, Item.itemRegistry.getKeys() + ); } return null; diff --git a/src/main/java/com/pahimar/ee3/command/CommandPlayerLearnCurrentItem.java b/src/main/java/com/pahimar/ee3/command/CommandPlayerLearnCurrentItem.java index 535f69f2..187b965a 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandPlayerLearnCurrentItem.java +++ b/src/main/java/com/pahimar/ee3/command/CommandPlayerLearnCurrentItem.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.command; +import java.util.List; + import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.api.knowledge.PlayerKnowledgeRegistryProxy; import com.pahimar.ee3.reference.Messages; @@ -11,69 +13,63 @@ import net.minecraft.command.WrongUsageException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import java.util.List; - -public class CommandPlayerLearnCurrentItem extends CommandBase -{ +public class CommandPlayerLearnCurrentItem extends CommandBase { @Override - public String getCommandName() - { + public String getCommandName() { return Names.Commands.PLAYER_LEARN_CURRENT_ITEM; } @Override - public int getRequiredPermissionLevel() - { + public int getRequiredPermissionLevel() { return 2; } @Override - public String getCommandUsage(ICommandSender commandSender) - { + public String getCommandUsage(ICommandSender commandSender) { return Messages.Commands.PLAYER_LEARN_CURRENT_ITEM_USAGE; } @Override - public void processCommand(ICommandSender commandSender, String[] args) - { - if (args.length < 2) - { - throw new WrongUsageException(Messages.Commands.PLAYER_LEARN_CURRENT_ITEM_USAGE); - } - else - { + public void processCommand(ICommandSender commandSender, String[] args) { + if (args.length < 2) { + throw new WrongUsageException( + Messages.Commands.PLAYER_LEARN_CURRENT_ITEM_USAGE + ); + } else { EntityPlayer entityPlayer = getPlayer(commandSender, args[1]); - if (entityPlayer != null) - { - ItemStack itemStack = ((EntityPlayer) commandSender).getCurrentEquippedItem(); + if (entityPlayer != null) { + ItemStack itemStack + = ((EntityPlayer) commandSender).getCurrentEquippedItem(); - if (itemStack != null) - { - if (BlacklistRegistryProxy.isLearnable(itemStack)) - { + if (itemStack != null) { + if (BlacklistRegistryProxy.isLearnable(itemStack)) { PlayerKnowledgeRegistryProxy.teachPlayer(entityPlayer, itemStack); - func_152373_a(commandSender, this, Messages.Commands.PLAYER_LEARN_CURRENT_ITEM_SUCCESS, new Object[]{commandSender.getCommandSenderName(), entityPlayer.getCommandSenderName(), itemStack.func_151000_E()}); + func_152373_a( + commandSender, + this, + Messages.Commands.PLAYER_LEARN_CURRENT_ITEM_SUCCESS, + new Object[] { commandSender.getCommandSenderName(), + entityPlayer.getCommandSenderName(), + itemStack.func_151000_E() } + ); } - } - else - { + } else { throw new WrongUsageException(Messages.Commands.NO_ITEM); } - } - else - { + } else { throw new WrongUsageException(Messages.Commands.PLAYER_NOT_FOUND_ERROR); } } } @Override - public List addTabCompletionOptions(ICommandSender commandSender, String[] args) - { - if (args.length == 2) - { - return getListOfStringsMatchingLastWord(args, FMLCommonHandler.instance().getMinecraftServerInstance().getAllUsernames()); + public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { + if (args.length == 2) { + return getListOfStringsMatchingLastWord( + args, + FMLCommonHandler.instance().getMinecraftServerInstance().getAllUsernames() + ); } return null; diff --git a/src/main/java/com/pahimar/ee3/command/CommandPlayerLearnItem.java b/src/main/java/com/pahimar/ee3/command/CommandPlayerLearnItem.java index b79492fa..228e35b3 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandPlayerLearnItem.java +++ b/src/main/java/com/pahimar/ee3/command/CommandPlayerLearnItem.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.command; +import java.util.List; + import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.api.knowledge.PlayerKnowledgeRegistryProxy; import com.pahimar.ee3.reference.Messages; @@ -15,97 +17,96 @@ import net.minecraft.nbt.JsonToNBT; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import java.util.List; - -public class CommandPlayerLearnItem extends CommandBase -{ +public class CommandPlayerLearnItem extends CommandBase { @Override - public String getCommandName() - { + public String getCommandName() { return Names.Commands.PLAYER_LEARN_ITEM; } @Override - public int getRequiredPermissionLevel() - { + public int getRequiredPermissionLevel() { return 2; } @Override - public String getCommandUsage(ICommandSender commandSender) - { + public String getCommandUsage(ICommandSender commandSender) { return Messages.Commands.PLAYER_LEARN_ITEM_USAGE; } @Override - public void processCommand(ICommandSender commandSender, String[] args) - { - if (args.length < 3) - { + public void processCommand(ICommandSender commandSender, String[] args) { + if (args.length < 3) { throw new WrongUsageException(Messages.Commands.PLAYER_LEARN_ITEM_USAGE); - } - else - { + } else { EntityPlayer entityPlayer = getPlayer(commandSender, args[1]); - if (entityPlayer != null) - { + if (entityPlayer != null) { Item item = getItemByText(commandSender, args[2]); int metaData = 0; - if (args.length >= 4) - { + if (args.length >= 4) { metaData = parseInt(commandSender, args[3]); } ItemStack itemStack = new ItemStack(item, 1, metaData); - if (args.length >= 5) - { - String stringNBTData = func_147178_a(commandSender, args, 4).getUnformattedText(); + if (args.length >= 5) { + String stringNBTData + = func_147178_a(commandSender, args, 4).getUnformattedText(); - try - { + try { NBTBase nbtBase = JsonToNBT.func_150315_a(stringNBTData); - if (!(nbtBase instanceof NBTTagCompound)) - { - func_152373_a(commandSender, this, Messages.Commands.INVALID_NBT_TAG_ERROR, new Object[]{"Not a valid tag"}); + if (!(nbtBase instanceof NBTTagCompound)) { + func_152373_a( + commandSender, + this, + Messages.Commands.INVALID_NBT_TAG_ERROR, + new Object[] { "Not a valid tag" } + ); return; } itemStack.setTagCompound((NBTTagCompound) nbtBase); - } - catch (Exception exception) - { - func_152373_a(commandSender, this, Messages.Commands.INVALID_NBT_TAG_ERROR, new Object[]{exception.getMessage()}); + } catch (Exception exception) { + func_152373_a( + commandSender, + this, + Messages.Commands.INVALID_NBT_TAG_ERROR, + new Object[] { exception.getMessage() } + ); return; } } - if (BlacklistRegistryProxy.isLearnable(itemStack)) - { + if (BlacklistRegistryProxy.isLearnable(itemStack)) { PlayerKnowledgeRegistryProxy.teachPlayer(entityPlayer, itemStack); - func_152373_a(commandSender, this, Messages.Commands.PLAYER_LEARN_ITEM_SUCCESS, new Object[]{commandSender.getCommandSenderName(), entityPlayer.getCommandSenderName(), itemStack.func_151000_E()}); + func_152373_a( + commandSender, + this, + Messages.Commands.PLAYER_LEARN_ITEM_SUCCESS, + new Object[] { commandSender.getCommandSenderName(), + entityPlayer.getCommandSenderName(), + itemStack.func_151000_E() } + ); } - } - else - { + } else { throw new WrongUsageException(Messages.Commands.PLAYER_NOT_FOUND_ERROR); } } } @Override - public List addTabCompletionOptions(ICommandSender commandSender, String[] args) - { - if (args.length == 2) - { - return getListOfStringsMatchingLastWord(args, FMLCommonHandler.instance().getMinecraftServerInstance().getAllUsernames()); - } - else if (args.length == 3) - { - return getListOfStringsFromIterableMatchingLastWord(args, Item.itemRegistry.getKeys()); + public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { + if (args.length == 2) { + return getListOfStringsMatchingLastWord( + args, + FMLCommonHandler.instance().getMinecraftServerInstance().getAllUsernames() + ); + } else if (args.length == 3) { + return getListOfStringsFromIterableMatchingLastWord( + args, Item.itemRegistry.getKeys() + ); } return null; diff --git a/src/main/java/com/pahimar/ee3/command/CommandRegenEnergyValues.java b/src/main/java/com/pahimar/ee3/command/CommandRegenEnergyValues.java index 4c1095ea..5bb88de9 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandRegenEnergyValues.java +++ b/src/main/java/com/pahimar/ee3/command/CommandRegenEnergyValues.java @@ -1,5 +1,9 @@ package com.pahimar.ee3.command; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + import com.pahimar.ee3.exchange.EnergyValueRegistry; import com.pahimar.ee3.handler.ConfigurationHandler; import com.pahimar.ee3.network.PacketHandler; @@ -13,12 +17,7 @@ import net.minecraft.command.WrongUsageException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChatComponentTranslation; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - public class CommandRegenEnergyValues extends CommandBase { - private static Map requesterMap = new HashMap<>(); @Override @@ -38,36 +37,44 @@ public class CommandRegenEnergyValues extends CommandBase { @Override public void processCommand(ICommandSender commandSender, String[] args) { - boolean shouldRegen = true; float coolDown = 0f; UUID commandSenderUUID = ((EntityPlayer) commandSender).getUniqueID(); if (requesterMap.containsKey(commandSenderUUID)) { - // TODO Switch to nanoTime from currentTimeMillis - long timeDifference = (System.nanoTime() - requesterMap.get(commandSenderUUID).longValue()) / 100000; + long timeDifference + = (System.nanoTime() - requesterMap.get(commandSenderUUID).longValue()) + / 100000; - if (timeDifference >= (ConfigurationHandler.Settings.serverSyncThreshold * 1000)) { + if (timeDifference + >= (ConfigurationHandler.Settings.serverSyncThreshold * 1000)) { requesterMap.remove(commandSenderUUID); - } - else { - coolDown = (ConfigurationHandler.Settings.serverSyncThreshold * 1000) - timeDifference; + } else { + coolDown = (ConfigurationHandler.Settings.serverSyncThreshold * 1000) + - timeDifference; shouldRegen = false; } - } - else { + } else { requesterMap.put(commandSenderUUID, System.nanoTime() / 100000); } if (shouldRegen) { - LogHelper.info(EnergyValueRegistry.ENERGY_VALUE_MARKER, "Regenerating energy values at {}'s request", commandSender.getCommandSenderName()); + LogHelper.info( + EnergyValueRegistry.ENERGY_VALUE_MARKER, + "Regenerating energy values at {}'s request", + commandSender.getCommandSenderName() + ); EnergyValueRegistry.INSTANCE.compute(); PacketHandler.INSTANCE.sendToAll(new MessageSyncEnergyValues()); - commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.REGEN_ENERGY_VALUES_SUCCESS)); - } - else { - throw new WrongUsageException(Messages.Commands.REGEN_ENERGY_VALUES_DENIED, new Object[]{coolDown / 1000f}); + commandSender.addChatMessage(new ChatComponentTranslation( + Messages.Commands.REGEN_ENERGY_VALUES_SUCCESS + )); + } else { + throw new WrongUsageException( + Messages.Commands.REGEN_ENERGY_VALUES_DENIED, + new Object[] { coolDown / 1000f } + ); } } } diff --git a/src/main/java/com/pahimar/ee3/command/CommandRunTest.java b/src/main/java/com/pahimar/ee3/command/CommandRunTest.java index 4b011c56..d8285a5a 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandRunTest.java +++ b/src/main/java/com/pahimar/ee3/command/CommandRunTest.java @@ -1,5 +1,9 @@ package com.pahimar.ee3.command; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + import com.pahimar.ee3.reference.Files; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; @@ -11,12 +15,7 @@ import net.minecraft.command.ICommandSender; import net.minecraft.command.WrongUsageException; import net.minecraft.util.ChatComponentTranslation; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - public class CommandRunTest extends CommandEE { - @Override public String getCommandName() { return Names.Commands.RUN_TEST; @@ -34,57 +33,75 @@ public class CommandRunTest extends CommandEE { @Override public void processCommand(ICommandSender commandSender, String[] args) { - if (args.length == 2) { - boolean testFound = false; if (Files.globalTestDirectory != null) { for (File testCaseFile : Files.globalTestDirectory.listFiles()) { - if (testCaseFile.isFile() && testCaseFile.getName().equalsIgnoreCase(args[1])) { + if (testCaseFile.isFile() + && testCaseFile.getName().equalsIgnoreCase(args[1])) { testFound = true; - EnergyValueTestSuite energyValueTestSuite = new EnergyValueTestSuite(testCaseFile); - LogHelper.info(EnergyValueTestSuite.TEST_MARKER, "BEGIN TEST ({})", testCaseFile.getName()); + EnergyValueTestSuite energyValueTestSuite + = new EnergyValueTestSuite(testCaseFile); + LogHelper.info( + EnergyValueTestSuite.TEST_MARKER, + "BEGIN TEST ({})", + testCaseFile.getName() + ); energyValueTestSuite.run(); - LogHelper.info(EnergyValueTestSuite.TEST_MARKER, "END TEST ({})", testCaseFile.getName()); + LogHelper.info( + EnergyValueTestSuite.TEST_MARKER, + "END TEST ({})", + testCaseFile.getName() + ); } } if (testFound) { - commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.RUN_TESTS_SUCCESS, args[1])); + commandSender.addChatMessage(new ChatComponentTranslation( + Messages.Commands.RUN_TESTS_SUCCESS, args[1] + )); + } else { + commandSender.addChatMessage(new ChatComponentTranslation( + Messages.Commands.RUN_TESTS_NOT_FOUND, args[1] + )); } - else { - commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.RUN_TESTS_NOT_FOUND, args[1])); - } - } - else { + } else { throw new WrongUsageException(Messages.Commands.RUN_TEST_USAGE); } - } - else { + } else { throw new WrongUsageException(Messages.Commands.RUN_TEST_USAGE); } } @Override public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { - if (args.length == 2) { - - File testCaseDirectory = new File(FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler().getWorldDirectory(), "data" + File.separator + Reference.LOWERCASE_MOD_ID + File.separator + "energyvalues" + File.separator + "testcases"); + File testCaseDirectory = new File( + FMLCommonHandler.instance() + .getMinecraftServerInstance() + .getEntityWorld() + .getSaveHandler() + .getWorldDirectory(), + "data" + File.separator + Reference.LOWERCASE_MOD_ID + File.separator + + "energyvalues" + File.separator + "testcases" + ); testCaseDirectory.mkdirs(); ArrayList fileNames = new ArrayList<>(); if (Files.globalTestDirectory != null) { for (File testCaseFile : Files.globalTestDirectory.listFiles()) { - if (testCaseFile.isFile() && testCaseFile.getAbsolutePath().endsWith(".json")) { + if (testCaseFile.isFile() + && testCaseFile.getAbsolutePath().endsWith(".json")) { fileNames.add(testCaseFile.getName()); } } } - return getListOfStringsMatchingLastWord(args, fileNames.toArray(new String[0])); + return getListOfStringsMatchingLastWord( + args, fileNames.toArray(new String[0]) + ); } return null; diff --git a/src/main/java/com/pahimar/ee3/command/CommandSetCurrentItemLearnable.java b/src/main/java/com/pahimar/ee3/command/CommandSetCurrentItemLearnable.java index 007c1627..31c2abdc 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSetCurrentItemLearnable.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSetCurrentItemLearnable.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.command; +import java.util.List; + import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; @@ -10,10 +12,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentTranslation; -import java.util.List; - public class CommandSetCurrentItemLearnable extends CommandBase { - @Override public String getCommandName() { return Names.Commands.SET_CURRENT_ITEM_LEARNABLE; @@ -31,19 +30,24 @@ public class CommandSetCurrentItemLearnable extends CommandBase { @Override public void processCommand(ICommandSender commandSender, String[] args) { - ItemStack itemStack = ((EntityPlayer) commandSender).getCurrentEquippedItem(); if (itemStack != null) { if (!BlacklistRegistryProxy.isLearnable(itemStack)) { BlacklistRegistryProxy.setAsLearnable(itemStack); - func_152373_a(commandSender, this, Messages.Commands.SET_CURRENT_ITEM_LEARNABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()}); + func_152373_a( + commandSender, + this, + Messages.Commands.SET_CURRENT_ITEM_LEARNABLE_SUCCESS, + new Object[] { commandSender.getCommandSenderName(), + itemStack.func_151000_E() } + ); + } else { + commandSender.addChatMessage(new ChatComponentTranslation( + Messages.Commands.SET_CURRENT_ITEM_LEARNABLE_NO_EFFECT, itemStack + )); } - else { - commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.SET_CURRENT_ITEM_LEARNABLE_NO_EFFECT, itemStack)); - } - } - else { + } else { throw new WrongUsageException(Messages.Commands.NO_ITEM); } } diff --git a/src/main/java/com/pahimar/ee3/command/CommandSetCurrentItemNotLearnable.java b/src/main/java/com/pahimar/ee3/command/CommandSetCurrentItemNotLearnable.java index b50a508b..e1f2ff0c 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSetCurrentItemNotLearnable.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSetCurrentItemNotLearnable.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.command; +import java.util.List; + import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; @@ -10,10 +12,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentTranslation; -import java.util.List; - public class CommandSetCurrentItemNotLearnable extends CommandBase { - @Override public String getCommandName() { return Names.Commands.SET_CURRENT_ITEM_NOT_LEARNABLE; @@ -31,19 +30,24 @@ public class CommandSetCurrentItemNotLearnable extends CommandBase { @Override public void processCommand(ICommandSender commandSender, String[] args) { - ItemStack itemStack = ((EntityPlayer) commandSender).getCurrentEquippedItem(); if (itemStack != null) { if (BlacklistRegistryProxy.isLearnable(itemStack)) { BlacklistRegistryProxy.setAsNotLearnable(itemStack); - func_152373_a(commandSender, this, Messages.Commands.SET_CURRENT_ITEM_NOT_LEARNABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()}); + func_152373_a( + commandSender, + this, + Messages.Commands.SET_CURRENT_ITEM_NOT_LEARNABLE_SUCCESS, + new Object[] { commandSender.getCommandSenderName(), + itemStack.func_151000_E() } + ); + } else { + commandSender.addChatMessage(new ChatComponentTranslation( + Messages.Commands.SET_CURRENT_ITEM_NOT_LEARNABLE_NO_EFFECT, itemStack + )); } - else { - commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.SET_CURRENT_ITEM_NOT_LEARNABLE_NO_EFFECT, itemStack)); - } - } - else { + } else { throw new WrongUsageException(Messages.Commands.NO_ITEM); } } diff --git a/src/main/java/com/pahimar/ee3/command/CommandSetCurrentItemNotRecoverable.java b/src/main/java/com/pahimar/ee3/command/CommandSetCurrentItemNotRecoverable.java index d9a5b503..84371324 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSetCurrentItemNotRecoverable.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSetCurrentItemNotRecoverable.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.command; +import java.util.List; + import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; @@ -10,10 +12,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentTranslation; -import java.util.List; - public class CommandSetCurrentItemNotRecoverable extends CommandBase { - @Override public String getCommandName() { return Names.Commands.SET_CURRENT_ITEM_NOT_RECOVERABLE; @@ -31,19 +30,25 @@ public class CommandSetCurrentItemNotRecoverable extends CommandBase { @Override public void processCommand(ICommandSender commandSender, String[] args) { - ItemStack itemStack = ((EntityPlayer) commandSender).getCurrentEquippedItem(); if (itemStack != null) { if (BlacklistRegistryProxy.isExchangeable(itemStack)) { BlacklistRegistryProxy.setAsNotExchangeable(itemStack); - func_152373_a(commandSender, this, Messages.Commands.SET_CURRENT_ITEM_NOT_RECOVERABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()}); + func_152373_a( + commandSender, + this, + Messages.Commands.SET_CURRENT_ITEM_NOT_RECOVERABLE_SUCCESS, + new Object[] { commandSender.getCommandSenderName(), + itemStack.func_151000_E() } + ); + } else { + commandSender.addChatMessage(new ChatComponentTranslation( + Messages.Commands.SET_CURRENT_ITEM_NOT_RECOVERABLE_NO_EFFECT, + itemStack + )); } - else { - commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.SET_CURRENT_ITEM_NOT_RECOVERABLE_NO_EFFECT, itemStack)); - } - } - else { + } else { throw new WrongUsageException(Messages.Commands.NO_ITEM); } } diff --git a/src/main/java/com/pahimar/ee3/command/CommandSetCurrentItemRecoverable.java b/src/main/java/com/pahimar/ee3/command/CommandSetCurrentItemRecoverable.java index 2afa8435..006db2cd 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSetCurrentItemRecoverable.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSetCurrentItemRecoverable.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.command; +import java.util.List; + import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; @@ -10,10 +12,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentTranslation; -import java.util.List; - public class CommandSetCurrentItemRecoverable extends CommandBase { - @Override public String getCommandName() { return Names.Commands.SET_CURRENT_ITEM_RECOVERABLE; @@ -31,19 +30,24 @@ public class CommandSetCurrentItemRecoverable extends CommandBase { @Override public void processCommand(ICommandSender commandSender, String[] args) { - ItemStack itemStack = ((EntityPlayer) commandSender).getCurrentEquippedItem(); if (itemStack != null) { if (!BlacklistRegistryProxy.isExchangeable(itemStack)) { BlacklistRegistryProxy.setAsExchangeable(itemStack); - func_152373_a(commandSender, this, Messages.Commands.SET_CURRENT_ITEM_RECOVERABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()}); + func_152373_a( + commandSender, + this, + Messages.Commands.SET_CURRENT_ITEM_RECOVERABLE_SUCCESS, + new Object[] { commandSender.getCommandSenderName(), + itemStack.func_151000_E() } + ); + } else { + commandSender.addChatMessage(new ChatComponentTranslation( + Messages.Commands.SET_CURRENT_ITEM_RECOVERABLE_NO_EFFECT, itemStack + )); } - else { - commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.SET_CURRENT_ITEM_RECOVERABLE_NO_EFFECT, itemStack)); - } - } - else { + } else { throw new WrongUsageException(Messages.Commands.NO_ITEM); } } diff --git a/src/main/java/com/pahimar/ee3/command/CommandSetEnergyValue.java b/src/main/java/com/pahimar/ee3/command/CommandSetEnergyValue.java index 57bac02c..c9d00d9c 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSetEnergyValue.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSetEnergyValue.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.command; +import java.util.List; + import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.api.exchange.EnergyValue; import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; @@ -19,71 +21,64 @@ import net.minecraft.nbt.JsonToNBT; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import java.util.List; - -public class CommandSetEnergyValue extends CommandBase -{ +public class CommandSetEnergyValue extends CommandBase { @Override - public String getCommandName() - { + public String getCommandName() { return Names.Commands.SET_ENERGY_VALUE; } @Override - public int getRequiredPermissionLevel() - { + public int getRequiredPermissionLevel() { return 2; } @Override - public String getCommandUsage(ICommandSender commandSender) - { + public String getCommandUsage(ICommandSender commandSender) { return Messages.Commands.SET_ENERGY_VALUE_USAGE; } @Override - public void processCommand(ICommandSender commandSender, String[] args) - { - if (args.length < 4) - { + public void processCommand(ICommandSender commandSender, String[] args) { + if (args.length < 4) { throw new WrongUsageException(Messages.Commands.SET_ENERGY_VALUE_USAGE); - } - else - { + } else { Item item = getItemByText(commandSender, args[2]); float energyValue = 0; int metaData = 0; - if (args.length >= 4) - { + if (args.length >= 4) { energyValue = (float) parseDoubleWithMin(commandSender, args[3], 0); - } - else if (args.length >= 5) - { + } else if (args.length >= 5) { metaData = parseInt(commandSender, args[4]); } ItemStack itemStack = new ItemStack(item, 1, metaData); - if (args.length >= 6) - { - String stringNBTData = func_147178_a(commandSender, args, 5).getUnformattedText(); + if (args.length >= 6) { + String stringNBTData + = func_147178_a(commandSender, args, 5).getUnformattedText(); - try - { + try { NBTBase nbtBase = JsonToNBT.func_150315_a(stringNBTData); - if (!(nbtBase instanceof NBTTagCompound)) - { - func_152373_a(commandSender, this, Messages.Commands.INVALID_NBT_TAG_ERROR, new Object[]{"Not a valid tag"}); + if (!(nbtBase instanceof NBTTagCompound)) { + func_152373_a( + commandSender, + this, + Messages.Commands.INVALID_NBT_TAG_ERROR, + new Object[] { "Not a valid tag" } + ); return; } itemStack.setTagCompound((NBTTagCompound) nbtBase); - } - catch (Exception exception) - { - func_152373_a(commandSender, this, Messages.Commands.INVALID_NBT_TAG_ERROR, new Object[]{exception.getMessage()}); + } catch (Exception exception) { + func_152373_a( + commandSender, + this, + Messages.Commands.INVALID_NBT_TAG_ERROR, + new Object[] { exception.getMessage() } + ); return; } } @@ -91,52 +86,70 @@ public class CommandSetEnergyValue extends CommandBase WrappedStack wrappedStack = WrappedStack.wrap(itemStack); EnergyValue newEnergyValue = new EnergyValue(energyValue); - if (wrappedStack != null && newEnergyValue != null) - { + if (wrappedStack != null && newEnergyValue != null) { if (Float.compare(newEnergyValue.getValue(), 0) > 0) { - if (args[1].equalsIgnoreCase("pre")) { - EnergyValueRegistryProxy.setEnergyValue(wrappedStack, newEnergyValue, EnergyValueRegistryProxy.Phase.PRE_CALCULATION); - } - else if (args[1].equalsIgnoreCase("post")) { - EnergyValueRegistryProxy.setEnergyValue(wrappedStack, newEnergyValue); - PacketHandler.INSTANCE.sendToAll(new MessageSetEnergyValue(wrappedStack, newEnergyValue)); - } - else { - throw new WrongUsageException(Messages.Commands.SET_ENERGY_VALUE_USAGE); + EnergyValueRegistryProxy.setEnergyValue( + wrappedStack, + newEnergyValue, + EnergyValueRegistryProxy.Phase.PRE_CALCULATION + ); + } else if (args[1].equalsIgnoreCase("post")) { + EnergyValueRegistryProxy.setEnergyValue( + wrappedStack, newEnergyValue + ); + PacketHandler.INSTANCE.sendToAll( + new MessageSetEnergyValue(wrappedStack, newEnergyValue) + ); + } else { + throw new WrongUsageException( + Messages.Commands.SET_ENERGY_VALUE_USAGE + ); } EnergyValueRegistry.INSTANCE.save(); // Notify admins and log the value change - func_152373_a(commandSender, this, Messages.Commands.SET_ENERGY_VALUE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), args[1], itemStack.func_151000_E(), newEnergyValue.getChatComponent()}); - } - else if (Float.compare(newEnergyValue.getValue(), 0) == 0) { - + func_152373_a( + commandSender, + this, + Messages.Commands.SET_ENERGY_VALUE_SUCCESS, + new Object[] { commandSender.getCommandSenderName(), + args[1], + itemStack.func_151000_E(), + newEnergyValue.getChatComponent() } + ); + } else if (Float.compare(newEnergyValue.getValue(), 0) == 0) { BlacklistRegistryProxy.setAsNotLearnable(wrappedStack); BlacklistRegistryProxy.setAsNotExchangeable(wrappedStack); // TODO Remove energy value from EnergyValueRegistry - PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE)); - PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE)); - func_152373_a(commandSender, this, "%s set %s as not learnable and not exchangeable", new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()}); + PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry( + itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE + )); + PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry( + itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE + )); + func_152373_a( + commandSender, + this, + "%s set %s as not learnable and not exchangeable", + new Object[] { commandSender.getCommandSenderName(), + itemStack.func_151000_E() } + ); } - } - else - { + } else { throw new WrongUsageException(Messages.Commands.SET_ENERGY_VALUE_USAGE); } } } @Override - public List addTabCompletionOptions(ICommandSender commandSender, String[] args) - { - if (args.length == 2) - { + public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { + if (args.length == 2) { return getListOfStringsMatchingLastWord(args, "pre", "post"); - } - else if (args.length == 3) - { - return getListOfStringsFromIterableMatchingLastWord(args, Item.itemRegistry.getKeys()); + } else if (args.length == 3) { + return getListOfStringsFromIterableMatchingLastWord( + args, Item.itemRegistry.getKeys() + ); } return null; diff --git a/src/main/java/com/pahimar/ee3/command/CommandSetEnergyValueCurrentItem.java b/src/main/java/com/pahimar/ee3/command/CommandSetEnergyValueCurrentItem.java index 0512b6ce..39def63d 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSetEnergyValueCurrentItem.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSetEnergyValueCurrentItem.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.command; +import java.util.List; + import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.api.exchange.EnergyValue; import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; @@ -16,99 +18,107 @@ import net.minecraft.command.WrongUsageException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import java.util.List; - -public class CommandSetEnergyValueCurrentItem extends CommandBase -{ +public class CommandSetEnergyValueCurrentItem extends CommandBase { @Override - public String getCommandName() - { + public String getCommandName() { return Names.Commands.SET_ENERGY_VALUE_CURRENT_ITEM; } @Override - public int getRequiredPermissionLevel() - { + public int getRequiredPermissionLevel() { return 2; } @Override - public String getCommandUsage(ICommandSender commandSender) - { + public String getCommandUsage(ICommandSender commandSender) { return Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_USAGE; } @Override - public void processCommand(ICommandSender commandSender, String[] args) - { - if (args.length < 3) - { - throw new WrongUsageException(Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_USAGE); - } - else - { + public void processCommand(ICommandSender commandSender, String[] args) { + if (args.length < 3) { + throw new WrongUsageException( + Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_USAGE + ); + } else { float energyValue = 0; - if (args.length >= 3) - { + if (args.length >= 3) { energyValue = (float) parseDoubleWithMin(commandSender, args[2], 0); } ItemStack itemStack = ((EntityPlayer) commandSender).getCurrentEquippedItem(); - if (itemStack != null) - { + if (itemStack != null) { WrappedStack wrappedStack = WrappedStack.wrap(itemStack); EnergyValue newEnergyValue = new EnergyValue(energyValue); - if (wrappedStack != null && newEnergyValue != null) - { + if (wrappedStack != null && newEnergyValue != null) { if (Float.compare(newEnergyValue.getValue(), 0) > 0) { - if (args[1].equalsIgnoreCase("pre")) { - EnergyValueRegistryProxy.setEnergyValue(wrappedStack, newEnergyValue, EnergyValueRegistryProxy.Phase.PRE_CALCULATION); - } - else if (args[1].equalsIgnoreCase("post")) { - EnergyValueRegistryProxy.setEnergyValue(wrappedStack, newEnergyValue); - PacketHandler.INSTANCE.sendToAll(new MessageSetEnergyValue(wrappedStack, newEnergyValue)); - } - else { - throw new WrongUsageException(Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_USAGE); + EnergyValueRegistryProxy.setEnergyValue( + wrappedStack, + newEnergyValue, + EnergyValueRegistryProxy.Phase.PRE_CALCULATION + ); + } else if (args[1].equalsIgnoreCase("post")) { + EnergyValueRegistryProxy.setEnergyValue( + wrappedStack, newEnergyValue + ); + PacketHandler.INSTANCE.sendToAll( + new MessageSetEnergyValue(wrappedStack, newEnergyValue) + ); + } else { + throw new WrongUsageException( + Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_USAGE + ); } // Notify admins and log the value change - func_152373_a(commandSender, this, Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_SUCCESS, new Object[]{commandSender.getCommandSenderName(), args[1], itemStack.func_151000_E(), newEnergyValue.getChatComponent()}); - } - else if (Float.compare(newEnergyValue.getValue(), 0) == 0) { - + func_152373_a( + commandSender, + this, + Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_SUCCESS, + new Object[] { commandSender.getCommandSenderName(), + args[1], + itemStack.func_151000_E(), + newEnergyValue.getChatComponent() } + ); + } else if (Float.compare(newEnergyValue.getValue(), 0) == 0) { BlacklistRegistryProxy.setAsNotLearnable(wrappedStack); BlacklistRegistryProxy.setAsNotExchangeable(wrappedStack); // TODO Remove energy value from EnergyValueRegistry // TODO Sync change with client - PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE)); - PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE)); - func_152373_a(commandSender, this, "%s set %s as not learnable and not exchangeable", new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()}); + PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry( + itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE + )); + PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry( + itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE + )); + func_152373_a( + commandSender, + this, + "%s set %s as not learnable and not exchangeable", + new Object[] { commandSender.getCommandSenderName(), + itemStack.func_151000_E() } + ); } - } - else - { - throw new WrongUsageException(Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_USAGE); + } else { + throw new WrongUsageException( + Messages.Commands.SET_ENERGY_VALUE_CURRENT_ITEM_USAGE + ); } EnergyValueRegistry.INSTANCE.save(); - } - else - { + } else { throw new WrongUsageException(Messages.Commands.NO_ITEM); } } } @Override - public List addTabCompletionOptions(ICommandSender commandSender, String[] args) - { - if (args.length == 2) - { + public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { + if (args.length == 2) { return getListOfStringsMatchingLastWord(args, "pre", "post"); } diff --git a/src/main/java/com/pahimar/ee3/command/CommandSetItemLearnable.java b/src/main/java/com/pahimar/ee3/command/CommandSetItemLearnable.java index e1e7a266..9315ec1d 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSetItemLearnable.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSetItemLearnable.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.command; +import java.util.List; + import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.network.PacketHandler; import com.pahimar.ee3.network.message.MessageSetBlacklistEntry; @@ -14,82 +16,87 @@ import net.minecraft.nbt.JsonToNBT; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import java.util.List; - -public class CommandSetItemLearnable extends CommandBase -{ +public class CommandSetItemLearnable extends CommandBase { @Override - public String getCommandName() - { + public String getCommandName() { return Names.Commands.SET_ITEM_LEARNABLE; } @Override - public int getRequiredPermissionLevel() - { + public int getRequiredPermissionLevel() { return 2; } @Override - public String getCommandUsage(ICommandSender commandSender) - { + public String getCommandUsage(ICommandSender commandSender) { return Messages.Commands.SET_ITEM_LEARNABLE_USAGE; } @Override - public void processCommand(ICommandSender commandSender, String[] args) - { - if (args.length < 2) - { + public void processCommand(ICommandSender commandSender, String[] args) { + if (args.length < 2) { throw new WrongUsageException(Messages.Commands.SET_ITEM_LEARNABLE_USAGE); - } - else - { + } else { Item item = getItemByText(commandSender, args[1]); int metaData = 0; - if (args.length >= 3) - { + if (args.length >= 3) { metaData = parseInt(commandSender, args[2]); } ItemStack itemStack = new ItemStack(item, 1, metaData); - if (args.length >= 4) - { - String stringNBTData = func_147178_a(commandSender, args, 3).getUnformattedText(); + if (args.length >= 4) { + String stringNBTData + = func_147178_a(commandSender, args, 3).getUnformattedText(); - try - { + try { NBTBase nbtBase = JsonToNBT.func_150315_a(stringNBTData); - if (!(nbtBase instanceof NBTTagCompound)) - { - func_152373_a(commandSender, this, Messages.Commands.INVALID_NBT_TAG_ERROR, new Object[]{"Not a valid tag"}); + if (!(nbtBase instanceof NBTTagCompound)) { + func_152373_a( + commandSender, + this, + Messages.Commands.INVALID_NBT_TAG_ERROR, + new Object[] { "Not a valid tag" } + ); return; } itemStack.setTagCompound((NBTTagCompound) nbtBase); - } - catch (Exception exception) - { - func_152373_a(commandSender, this, Messages.Commands.INVALID_NBT_TAG_ERROR, new Object[]{exception.getMessage()}); + } catch (Exception exception) { + func_152373_a( + commandSender, + this, + Messages.Commands.INVALID_NBT_TAG_ERROR, + new Object[] { exception.getMessage() } + ); return; } } - BlacklistRegistryProxy.removeFromBlacklist(itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE); - PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE, false)); - func_152373_a(commandSender, this, Messages.Commands.SET_ITEM_LEARNABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()}); + BlacklistRegistryProxy.removeFromBlacklist( + itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE + ); + PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry( + itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE, false + )); + func_152373_a( + commandSender, + this, + Messages.Commands.SET_ITEM_LEARNABLE_SUCCESS, + new Object[] { commandSender.getCommandSenderName(), + itemStack.func_151000_E() } + ); } } @Override - public List addTabCompletionOptions(ICommandSender commandSender, String[] args) - { - if (args.length == 2) - { - return getListOfStringsFromIterableMatchingLastWord(args, Item.itemRegistry.getKeys()); + public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { + if (args.length == 2) { + return getListOfStringsFromIterableMatchingLastWord( + args, Item.itemRegistry.getKeys() + ); } return null; diff --git a/src/main/java/com/pahimar/ee3/command/CommandSetItemNotLearnable.java b/src/main/java/com/pahimar/ee3/command/CommandSetItemNotLearnable.java index 42f3b9a9..c4aa7e0a 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSetItemNotLearnable.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSetItemNotLearnable.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.command; +import java.util.List; + import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.network.PacketHandler; import com.pahimar.ee3.network.message.MessageSetBlacklistEntry; @@ -14,82 +16,87 @@ import net.minecraft.nbt.JsonToNBT; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import java.util.List; - -public class CommandSetItemNotLearnable extends CommandBase -{ +public class CommandSetItemNotLearnable extends CommandBase { @Override - public String getCommandName() - { + public String getCommandName() { return Names.Commands.SET_ITEM_NOT_LEARNABLE; } @Override - public int getRequiredPermissionLevel() - { + public int getRequiredPermissionLevel() { return 2; } @Override - public String getCommandUsage(ICommandSender commandSender) - { + public String getCommandUsage(ICommandSender commandSender) { return Messages.Commands.SET_ITEM_NOT_LEARNABLE_USAGE; } @Override - public void processCommand(ICommandSender commandSender, String[] args) - { - if (args.length < 2) - { + public void processCommand(ICommandSender commandSender, String[] args) { + if (args.length < 2) { throw new WrongUsageException(Messages.Commands.SET_ITEM_NOT_LEARNABLE_USAGE); - } - else - { + } else { Item item = getItemByText(commandSender, args[1]); int metaData = 0; - if (args.length >= 3) - { + if (args.length >= 3) { metaData = parseInt(commandSender, args[2]); } ItemStack itemStack = new ItemStack(item, 1, metaData); - if (args.length >= 4) - { - String stringNBTData = func_147178_a(commandSender, args, 3).getUnformattedText(); + if (args.length >= 4) { + String stringNBTData + = func_147178_a(commandSender, args, 3).getUnformattedText(); - try - { + try { NBTBase nbtBase = JsonToNBT.func_150315_a(stringNBTData); - if (!(nbtBase instanceof NBTTagCompound)) - { - func_152373_a(commandSender, this, Messages.Commands.INVALID_NBT_TAG_ERROR, new Object[]{"Not a valid tag"}); + if (!(nbtBase instanceof NBTTagCompound)) { + func_152373_a( + commandSender, + this, + Messages.Commands.INVALID_NBT_TAG_ERROR, + new Object[] { "Not a valid tag" } + ); return; } itemStack.setTagCompound((NBTTagCompound) nbtBase); - } - catch (Exception exception) - { - func_152373_a(commandSender, this, Messages.Commands.INVALID_NBT_TAG_ERROR, new Object[]{exception.getMessage()}); + } catch (Exception exception) { + func_152373_a( + commandSender, + this, + Messages.Commands.INVALID_NBT_TAG_ERROR, + new Object[] { exception.getMessage() } + ); return; } } - BlacklistRegistryProxy.addToBlacklist(itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE); - PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE)); - func_152373_a(commandSender, this, Messages.Commands.SET_ITEM_NOT_LEARNABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()}); + BlacklistRegistryProxy.addToBlacklist( + itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE + ); + PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry( + itemStack, BlacklistRegistryProxy.Blacklist.KNOWLEDGE + )); + func_152373_a( + commandSender, + this, + Messages.Commands.SET_ITEM_NOT_LEARNABLE_SUCCESS, + new Object[] { commandSender.getCommandSenderName(), + itemStack.func_151000_E() } + ); } } @Override - public List addTabCompletionOptions(ICommandSender commandSender, String[] args) - { - if (args.length == 2) - { - return getListOfStringsFromIterableMatchingLastWord(args, Item.itemRegistry.getKeys()); + public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { + if (args.length == 2) { + return getListOfStringsFromIterableMatchingLastWord( + args, Item.itemRegistry.getKeys() + ); } return null; diff --git a/src/main/java/com/pahimar/ee3/command/CommandSetItemNotRecoverable.java b/src/main/java/com/pahimar/ee3/command/CommandSetItemNotRecoverable.java index 0d5f918f..79c2c818 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSetItemNotRecoverable.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSetItemNotRecoverable.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.command; +import java.util.List; + import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.network.PacketHandler; import com.pahimar.ee3.network.message.MessageSetBlacklistEntry; @@ -14,82 +16,88 @@ import net.minecraft.nbt.JsonToNBT; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import java.util.List; - -public class CommandSetItemNotRecoverable extends CommandBase -{ +public class CommandSetItemNotRecoverable extends CommandBase { @Override - public String getCommandName() - { + public String getCommandName() { return Names.Commands.SET_ITEM_NOT_RECOVERABLE; } @Override - public int getRequiredPermissionLevel() - { + public int getRequiredPermissionLevel() { return 2; } @Override - public String getCommandUsage(ICommandSender commandSender) - { + public String getCommandUsage(ICommandSender commandSender) { return Messages.Commands.SET_ITEM_NOT_RECOVERABLE_USAGE; } @Override - public void processCommand(ICommandSender commandSender, String[] args) - { - if (args.length < 2) - { - throw new WrongUsageException(Messages.Commands.SET_ITEM_NOT_RECOVERABLE_USAGE); - } - else - { + public void processCommand(ICommandSender commandSender, String[] args) { + if (args.length < 2) { + throw new WrongUsageException(Messages.Commands.SET_ITEM_NOT_RECOVERABLE_USAGE + ); + } else { Item item = getItemByText(commandSender, args[1]); int metaData = 0; - if (args.length >= 3) - { + if (args.length >= 3) { metaData = parseInt(commandSender, args[2]); } ItemStack itemStack = new ItemStack(item, 1, metaData); - if (args.length >= 4) - { - String stringNBTData = func_147178_a(commandSender, args, 3).getUnformattedText(); + if (args.length >= 4) { + String stringNBTData + = func_147178_a(commandSender, args, 3).getUnformattedText(); - try - { + try { NBTBase nbtBase = JsonToNBT.func_150315_a(stringNBTData); - if (!(nbtBase instanceof NBTTagCompound)) - { - func_152373_a(commandSender, this, Messages.Commands.INVALID_NBT_TAG_ERROR, new Object[]{"Not a valid tag"}); + if (!(nbtBase instanceof NBTTagCompound)) { + func_152373_a( + commandSender, + this, + Messages.Commands.INVALID_NBT_TAG_ERROR, + new Object[] { "Not a valid tag" } + ); return; } itemStack.setTagCompound((NBTTagCompound) nbtBase); - } - catch (Exception exception) - { - func_152373_a(commandSender, this, Messages.Commands.INVALID_NBT_TAG_ERROR, new Object[]{exception.getMessage()}); + } catch (Exception exception) { + func_152373_a( + commandSender, + this, + Messages.Commands.INVALID_NBT_TAG_ERROR, + new Object[] { exception.getMessage() } + ); return; } } - BlacklistRegistryProxy.addToBlacklist(itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE); - PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE)); - func_152373_a(commandSender, this, Messages.Commands.SET_ITEM_NOT_RECOVERABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()}); + BlacklistRegistryProxy.addToBlacklist( + itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE + ); + PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry( + itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE + )); + func_152373_a( + commandSender, + this, + Messages.Commands.SET_ITEM_NOT_RECOVERABLE_SUCCESS, + new Object[] { commandSender.getCommandSenderName(), + itemStack.func_151000_E() } + ); } } @Override - public List addTabCompletionOptions(ICommandSender commandSender, String[] args) - { - if (args.length == 2) - { - return getListOfStringsFromIterableMatchingLastWord(args, Item.itemRegistry.getKeys()); + public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { + if (args.length == 2) { + return getListOfStringsFromIterableMatchingLastWord( + args, Item.itemRegistry.getKeys() + ); } return null; diff --git a/src/main/java/com/pahimar/ee3/command/CommandSetItemRecoverable.java b/src/main/java/com/pahimar/ee3/command/CommandSetItemRecoverable.java index cb6b2ffa..907c0ea5 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSetItemRecoverable.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSetItemRecoverable.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.command; +import java.util.List; + import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.network.PacketHandler; import com.pahimar.ee3.network.message.MessageSetBlacklistEntry; @@ -14,82 +16,87 @@ import net.minecraft.nbt.JsonToNBT; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import java.util.List; - -public class CommandSetItemRecoverable extends CommandBase -{ +public class CommandSetItemRecoverable extends CommandBase { @Override - public String getCommandName() - { + public String getCommandName() { return Names.Commands.SET_ITEM_RECOVERABLE; } @Override - public int getRequiredPermissionLevel() - { + public int getRequiredPermissionLevel() { return 2; } @Override - public String getCommandUsage(ICommandSender commandSender) - { + public String getCommandUsage(ICommandSender commandSender) { return Messages.Commands.SET_ITEM_RECOVERABLE_USAGE; } @Override - public void processCommand(ICommandSender commandSender, String[] args) - { - if (args.length < 2) - { + public void processCommand(ICommandSender commandSender, String[] args) { + if (args.length < 2) { throw new WrongUsageException(Messages.Commands.SET_ITEM_RECOVERABLE_USAGE); - } - else - { + } else { Item item = getItemByText(commandSender, args[1]); int metaData = 0; - if (args.length >= 3) - { + if (args.length >= 3) { metaData = parseInt(commandSender, args[2]); } ItemStack itemStack = new ItemStack(item, 1, metaData); - if (args.length >= 4) - { - String stringNBTData = func_147178_a(commandSender, args, 3).getUnformattedText(); + if (args.length >= 4) { + String stringNBTData + = func_147178_a(commandSender, args, 3).getUnformattedText(); - try - { + try { NBTBase nbtBase = JsonToNBT.func_150315_a(stringNBTData); - if (!(nbtBase instanceof NBTTagCompound)) - { - func_152373_a(commandSender, this, Messages.Commands.INVALID_NBT_TAG_ERROR, new Object[]{"Not a valid tag"}); + if (!(nbtBase instanceof NBTTagCompound)) { + func_152373_a( + commandSender, + this, + Messages.Commands.INVALID_NBT_TAG_ERROR, + new Object[] { "Not a valid tag" } + ); return; } itemStack.setTagCompound((NBTTagCompound) nbtBase); - } - catch (Exception exception) - { - func_152373_a(commandSender, this, Messages.Commands.INVALID_NBT_TAG_ERROR, new Object[]{exception.getMessage()}); + } catch (Exception exception) { + func_152373_a( + commandSender, + this, + Messages.Commands.INVALID_NBT_TAG_ERROR, + new Object[] { exception.getMessage() } + ); return; } } - BlacklistRegistryProxy.removeFromBlacklist(itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE); - PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry(itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE, true)); - func_152373_a(commandSender, this, Messages.Commands.SET_ITEM_RECOVERABLE_SUCCESS, new Object[]{commandSender.getCommandSenderName(), itemStack.func_151000_E()}); + BlacklistRegistryProxy.removeFromBlacklist( + itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE + ); + PacketHandler.INSTANCE.sendToAll(new MessageSetBlacklistEntry( + itemStack, BlacklistRegistryProxy.Blacklist.EXCHANGE, true + )); + func_152373_a( + commandSender, + this, + Messages.Commands.SET_ITEM_RECOVERABLE_SUCCESS, + new Object[] { commandSender.getCommandSenderName(), + itemStack.func_151000_E() } + ); } } @Override - public List addTabCompletionOptions(ICommandSender commandSender, String[] args) - { - if (args.length == 2) - { - return getListOfStringsFromIterableMatchingLastWord(args, Item.itemRegistry.getKeys()); + public List addTabCompletionOptions(ICommandSender commandSender, String[] args) { + if (args.length == 2) { + return getListOfStringsFromIterableMatchingLastWord( + args, Item.itemRegistry.getKeys() + ); } return null; diff --git a/src/main/java/com/pahimar/ee3/command/CommandSyncEnergyValues.java b/src/main/java/com/pahimar/ee3/command/CommandSyncEnergyValues.java index dcfcde01..232074a2 100644 --- a/src/main/java/com/pahimar/ee3/command/CommandSyncEnergyValues.java +++ b/src/main/java/com/pahimar/ee3/command/CommandSyncEnergyValues.java @@ -1,5 +1,9 @@ package com.pahimar.ee3.command; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + import com.pahimar.ee3.exchange.EnergyValueRegistry; import com.pahimar.ee3.handler.ConfigurationHandler; import com.pahimar.ee3.network.PacketHandler; @@ -13,12 +17,7 @@ import net.minecraft.command.WrongUsageException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChatComponentTranslation; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -public class CommandSyncEnergyValues extends CommandBase -{ +public class CommandSyncEnergyValues extends CommandBase { private static Map requesterMap = new HashMap<>(); @Override @@ -38,35 +37,43 @@ public class CommandSyncEnergyValues extends CommandBase @Override public void processCommand(ICommandSender commandSender, String[] args) { - boolean shouldSync = true; float coolDown = 0f; UUID commandSenderUUID = ((EntityPlayer) commandSender).getUniqueID(); if (requesterMap.containsKey(commandSenderUUID)) { - // TODO Switch to nanoTime from currentTimeMillis - long timeDifference = (System.nanoTime() - requesterMap.get(commandSenderUUID).longValue()) / 100000; + long timeDifference + = (System.nanoTime() - requesterMap.get(commandSenderUUID).longValue()) + / 100000; - if (timeDifference >= (ConfigurationHandler.Settings.serverSyncThreshold * 1000)) { + if (timeDifference + >= (ConfigurationHandler.Settings.serverSyncThreshold * 1000)) { requesterMap.remove(commandSenderUUID); - } - else { - coolDown = (ConfigurationHandler.Settings.serverSyncThreshold * 1000) - timeDifference; + } else { + coolDown = (ConfigurationHandler.Settings.serverSyncThreshold * 1000) + - timeDifference; shouldSync = false; } - } - else { + } else { requesterMap.put(commandSenderUUID, System.nanoTime() / 100000); } if (shouldSync) { - LogHelper.info(EnergyValueRegistry.ENERGY_VALUE_MARKER, "Syncing energy values with all players at {}'s request", commandSender.getCommandSenderName()); + LogHelper.info( + EnergyValueRegistry.ENERGY_VALUE_MARKER, + "Syncing energy values with all players at {}'s request", + commandSender.getCommandSenderName() + ); PacketHandler.INSTANCE.sendToAll(new MessageSyncEnergyValues()); - commandSender.addChatMessage(new ChatComponentTranslation(Messages.Commands.SYNC_ENERGY_VALUES_SUCCESS)); - } - else { - throw new WrongUsageException(Messages.Commands.SYNC_ENERGY_VALUES_DENIED, new Object[]{coolDown / 1000f}); + commandSender.addChatMessage( + new ChatComponentTranslation(Messages.Commands.SYNC_ENERGY_VALUES_SUCCESS) + ); + } else { + throw new WrongUsageException( + Messages.Commands.SYNC_ENERGY_VALUES_DENIED, + new Object[] { coolDown / 1000f } + ); } } } diff --git a/src/main/java/com/pahimar/ee3/creativetab/CreativeTab.java b/src/main/java/com/pahimar/ee3/creativetab/CreativeTab.java index f0e697d7..59d0e658 100644 --- a/src/main/java/com/pahimar/ee3/creativetab/CreativeTab.java +++ b/src/main/java/com/pahimar/ee3/creativetab/CreativeTab.java @@ -5,14 +5,12 @@ import com.pahimar.ee3.reference.Reference; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; -public class CreativeTab -{ - public static final CreativeTabs EE3_TAB = new CreativeTabs(Reference.LOWERCASE_MOD_ID) - { - @Override - public Item getTabIconItem() - { - return ModItems.shardMinium; - } - }; +public class CreativeTab { + public static final CreativeTabs EE3_TAB + = new CreativeTabs(Reference.LOWERCASE_MOD_ID) { + @Override + public Item getTabIconItem() { + return ModItems.shardMinium; + } + }; } diff --git a/src/main/java/com/pahimar/ee3/exchange/EMCRegistry.java b/src/main/java/com/pahimar/ee3/exchange/EMCRegistry.java index e65f0b04..b478b703 100644 --- a/src/main/java/com/pahimar/ee3/exchange/EMCRegistry.java +++ b/src/main/java/com/pahimar/ee3/exchange/EMCRegistry.java @@ -4,17 +4,13 @@ import java.util.Set; import com.pahimar.ee3.api.exchange.EnergyValue; import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy.Phase; - -import moze_intel.projecte.api.proxy.IEMCProxy; - import com.pahimar.ee3.api.exchange.IEnergyValueRegistry; - +import moze_intel.projecte.api.proxy.IEMCProxy; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class EMCRegistry implements IEnergyValueRegistry { - public static EMCRegistry INSTANCE = null; private IEMCProxy emc; @@ -25,7 +21,8 @@ public class EMCRegistry implements IEnergyValueRegistry { @Override public boolean hasEnergyValue(Object object, boolean strict) { WrappedStack wrapped = WrappedStack.wrap(object); - if (wrapped == null) return false; + if (wrapped == null) + return false; object = wrapped.getWrappedObject(); if (object instanceof Item) { return emc.hasValue((Item) object); @@ -40,7 +37,8 @@ public class EMCRegistry implements IEnergyValueRegistry { @Override public EnergyValue getEnergyValue(Object object, boolean strict) { WrappedStack wrapped = WrappedStack.wrap(object); - if (wrapped == null) return null; + if (wrapped == null) + return null; object = wrapped.getWrappedObject(); if (object instanceof Item) { return new EnergyValue(emc.getValue((Item) object)); @@ -55,9 +53,11 @@ public class EMCRegistry implements IEnergyValueRegistry { @Override public EnergyValue getEnergyValueForStack(Object object, boolean strict) { WrappedStack wrapped = WrappedStack.wrap(object); - if (wrapped == null) return null; + if (wrapped == null) + return null; EnergyValue value = getEnergyValue(object, strict); - if (value == null) return null; + if (value == null) + return null; return new EnergyValue(wrapped.getStackSize() * value.getValue()); } @@ -68,14 +68,18 @@ public class EMCRegistry implements IEnergyValueRegistry { @Override public void setEnergyValue(Object object, EnergyValue energyValue, Phase phase) { - if (phase != Phase.PRE_CALCULATION) return; + if (phase != Phase.PRE_CALCULATION) + return; if (object instanceof Item) { - emc.registerCustomEMC(new ItemStack((Item) object), (int) energyValue.getValue()); + emc.registerCustomEMC( + new ItemStack((Item) object), (int) energyValue.getValue() + ); } else if (object instanceof ItemStack) { emc.registerCustomEMC((ItemStack) object, (int) energyValue.getValue()); } else if (object instanceof Block) { - emc.registerCustomEMC(new ItemStack((Block) object), (int) energyValue.getValue()); + emc.registerCustomEMC( + new ItemStack((Block) object), (int) energyValue.getValue() + ); } } - } diff --git a/src/main/java/com/pahimar/ee3/exchange/EnergyValueRegistry.java b/src/main/java/com/pahimar/ee3/exchange/EnergyValueRegistry.java index 11738625..59d4c5cb 100644 --- a/src/main/java/com/pahimar/ee3/exchange/EnergyValueRegistry.java +++ b/src/main/java/com/pahimar/ee3/exchange/EnergyValueRegistry.java @@ -1,5 +1,12 @@ package com.pahimar.ee3.exchange; +import static com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy.Phase; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.*; +import java.util.stream.Collectors; + import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedMap; import com.pahimar.ee3.api.event.EnergyValueEvent; @@ -22,15 +29,7 @@ import net.minecraftforge.oredict.OreDictionary; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; -import java.io.File; -import java.io.FileNotFoundException; -import java.util.*; -import java.util.stream.Collectors; - -import static com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy.Phase; - public class EnergyValueRegistry implements IEnergyValueRegistry { - public static final EnergyValueRegistry INSTANCE = new EnergyValueRegistry(); private ImmutableSortedMap stackValueMap; @@ -47,11 +46,12 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { public static File preCalculationValuesFile; public static File postCalculationValuesFile; - public static final Marker ENERGY_VALUE_MARKER = MarkerManager.getMarker("EE3_ENERGY_VALUE", LogHelper.MOD_MARKER); + public static final Marker ENERGY_VALUE_MARKER + = MarkerManager.getMarker("EE3_ENERGY_VALUE", LogHelper.MOD_MARKER); private EnergyValueRegistry() { - - ImmutableSortedMap.Builder stackMapBuilder = ImmutableSortedMap.naturalOrder(); + ImmutableSortedMap.Builder stackMapBuilder + = ImmutableSortedMap.naturalOrder(); stackValueMap = stackMapBuilder.build(); preCalculationStackValueMap = new TreeMap<>(); @@ -61,84 +61,103 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { } /** - * Returns an {@link EnergyValue} for a {@link Object} in the provided {@link Map>} of {@link WrappedStack}s mapped - * to EnergyValues + * Returns an {@link EnergyValue} for a {@link Object} in the provided {@link Map>} of + * {@link WrappedStack}s mapped to EnergyValues * *

The order of checking is as follows;

*
    - *
  1. {@link ItemStack}s whose {@link Item}s implement {@link IEnergyValueProvider}
  2. - *
  3. Direct EnergyValue mapping of the provided Object in the provided Map
  4. - *
  5. The following criteria are only checked (in order) in the event that this is a non-strict query; - *
      - *
    1. - * ItemStacks that are part of an {@link OreDictionary} entry are checked to see if - * all Ores they are registered to have the same non-null EnergyValue assigned to - * it - *
        - *
      • - * e.g., ItemStack X is associated with OreDictionary entries A, B and C. An EnergyValue - * would be returned for X only if A, B and C all had the same non-null EnergyValue + *
      • {@link ItemStack}s whose {@link Item}s implement {@link + * IEnergyValueProvider}
      • Direct EnergyValue mapping of the provided Object in + * the provided Map
      • The following criteria are only checked (in order) in the + * event that this is a non-strict query;
        1. ItemStacks that are part of an + * {@link OreDictionary} entry are checked to see if all Ores they + * are registered to have the same non-null EnergyValue assigned to it
          • e.g., + * ItemStack X is associated with OreDictionary entries A, B and C. An EnergyValue + * would be returned for X only if A, B and C all had the + * same non-null EnergyValue *
          • *
          *
        2. *
        3. - * ItemStacks are checked to see if there exist {@link OreDictionary#WILDCARD_VALUE} equivalents + * ItemStacks are checked to see if there exist {@link + * OreDictionary#WILDCARD_VALUE} equivalents *
        4. *
        5. - * {@link OreStack}s are checked to see if all members of the OreDictionary entry represented by the - * OreStack have the same non-null EnergyValue (similar to the case for ItemStacks above) + * {@link OreStack}s are checked to see if all members of the + * OreDictionary entry represented by the OreStack have the same non-null EnergyValue + * (similar to the case for ItemStacks above) *
        6. *
        *
      • *
    * - * @param valueMap a {@link Map} of {@link EnergyValue}'s mapped to {@link WrappedStack}'s - * @param object the {@link Object} that is being checked for a corresponding {@link EnergyValue} - * @param strict whether this is a strict (e.g., only looking for direct value assignment vs associative value + * @param valueMap a {@link Map} of {@link EnergyValue}'s mapped to {@link + * WrappedStack}'s + * @param object the {@link Object} that is being checked for a corresponding {@link + * EnergyValue} + * @param strict whether this is a strict (e.g., only looking for direct value + * assignment vs associative value * assignments) query or not - * @return an {@link EnergyValue} if there is one to be found for the provided {@link Object} in the provided Map, null otherwise + * @return an {@link EnergyValue} if there is one to be found for the provided {@link + * Object} in the provided Map, null otherwise */ - public static EnergyValue getEnergyValue(Map valueMap, Object object, boolean strict) { - + public static EnergyValue getEnergyValue( + Map valueMap, Object object, boolean strict + ) { if (WrappedStack.canBeWrapped(object)) { - WrappedStack wrappedStack = WrappedStack.wrap(object, 1); Object wrappedObject = wrappedStack.getWrappedObject(); - if (wrappedObject instanceof ItemStack && ((ItemStack) wrappedObject).getItem() instanceof IEnergyValueProvider && !strict) { + if (wrappedObject instanceof ItemStack + && ((ItemStack) wrappedObject).getItem() instanceof IEnergyValueProvider + && !strict) { + EnergyValue energyValue + = ((IEnergyValueProvider) ((ItemStack) wrappedObject).getItem()) + .getEnergyValue(((ItemStack) wrappedObject)); - EnergyValue energyValue = ((IEnergyValueProvider) ((ItemStack) wrappedObject).getItem()).getEnergyValue(((ItemStack) wrappedObject)); - - if (energyValue != null && Float.compare(energyValue.getValue(), 0f) > 0) { + if (energyValue != null + && Float.compare(energyValue.getValue(), 0f) > 0) { return energyValue; } } if (valueMap != null && !valueMap.isEmpty()) { - /** - * First check to see if the object is a WILDCARD_VALUE ItemStack, as if it is it will match any similar - * ItemStack. If it is check to see how many objects it matches in the given map. If there is at least - * one similar object found, find the lowest energy value out of all the similar objects + * First check to see if the object is a WILDCARD_VALUE ItemStack, as if + * it is it will match any similar ItemStack. If it is check to see how + * many objects it matches in the given map. If there is at least one + * similar object found, find the lowest energy value out of all the + * similar objects */ - if (wrappedObject instanceof ItemStack && ((ItemStack) wrappedObject).getItemDamage() == OreDictionary.WILDCARD_VALUE) { - - Set equivalentStacks = valueMap.keySet().stream() - .filter(wrappedStack::equals) - .filter(wrappedStack1 -> wrappedStack1.getWrappedObject() instanceof ItemStack) - .filter(wrappedStack1 -> ((ItemStack) wrappedStack1.getWrappedObject()).getItemDamage() != OreDictionary.WILDCARD_VALUE) - .collect(Collectors.toCollection(TreeSet::new)); + if (wrappedObject instanceof ItemStack + && ((ItemStack) wrappedObject).getItemDamage() + == OreDictionary.WILDCARD_VALUE) { + Set equivalentStacks + = valueMap.keySet() + .stream() + .filter(wrappedStack::equals) + .filter( + wrappedStack1 + -> wrappedStack1.getWrappedObject() instanceof ItemStack + ) + .filter( + wrappedStack1 + -> ((ItemStack) wrappedStack1.getWrappedObject()) + .getItemDamage() + != OreDictionary.WILDCARD_VALUE + ) + .collect(Collectors.toCollection(TreeSet::new)); if (equivalentStacks.size() >= 1) { EnergyValue lowestValue = null; for (WrappedStack wrappedStack1 : equivalentStacks) { - EnergyValue currentValue = getEnergyValue(valueMap, wrappedStack1, strict); + EnergyValue currentValue + = getEnergyValue(valueMap, wrappedStack1, strict); if (lowestValue == null) { lowestValue = currentValue; - } - else if (currentValue.compareTo(lowestValue) < 0) { + } else if (currentValue.compareTo(lowestValue) < 0) { lowestValue = currentValue; } } @@ -150,17 +169,14 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { // Check for an exact mapping if (valueMap.containsKey(wrappedStack)) { return valueMap.get(wrappedStack); - } - else if (!strict) { - + } else if (!strict) { if (wrappedObject instanceof ItemStack) { - - ItemStack unValuedItemStack = ItemStack.copyItemStack((ItemStack) wrappedObject); + ItemStack unValuedItemStack + = ItemStack.copyItemStack((ItemStack) wrappedObject); EnergyValue minEnergyValue = null; int[] oreIds = OreDictionary.getOreIDs(unValuedItemStack); if (oreIds.length > 0) { - EnergyValue energyValue = null; boolean allHaveSameValue = true; @@ -168,23 +184,22 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { String oreName = OreDictionary.getOreName(oreId); if (!"Unknown".equalsIgnoreCase(oreName)) { + WrappedStack oreStack + = WrappedStack.wrap(new OreStack(oreName)); - WrappedStack oreStack = WrappedStack.wrap(new OreStack(oreName)); - - if (oreStack != null && valueMap.containsKey(oreStack)) { - + if (oreStack != null + && valueMap.containsKey(oreStack)) { if (energyValue == null) { energyValue = valueMap.get(oreStack); - } - else if (!energyValue.equals(valueMap.get(oreStack))) { + } else if (!energyValue.equals( + valueMap.get(oreStack) + )) { allHaveSameValue = false; } - } - else { + } else { allHaveSameValue = false; } - } - else { + } else { allHaveSameValue = false; } } @@ -192,18 +207,26 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { if (allHaveSameValue) { return energyValue; } - } - else { + } else { for (WrappedStack valuedWrappedStack : valueMap.keySet()) { - if (valuedWrappedStack.getWrappedObject() instanceof ItemStack) { - if (Item.getIdFromItem(((ItemStack) valuedWrappedStack.getWrappedObject()).getItem()) == Item.getIdFromItem(unValuedItemStack.getItem())) { + if (valuedWrappedStack.getWrappedObject() + instanceof ItemStack) { + if (Item.getIdFromItem(((ItemStack) valuedWrappedStack + .getWrappedObject()) + .getItem()) + == Item.getIdFromItem(unValuedItemStack.getItem() + )) { + ItemStack valuedItemStack = (ItemStack + ) valuedWrappedStack.getWrappedObject(); + if (valuedItemStack.getItemDamage() + == OreDictionary.WILDCARD_VALUE + || unValuedItemStack.getItemDamage() + == OreDictionary.WILDCARD_VALUE) { + EnergyValue energyValue + = valueMap.get(valuedWrappedStack); - ItemStack valuedItemStack = (ItemStack) valuedWrappedStack.getWrappedObject(); - if (valuedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE || unValuedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) { - - EnergyValue energyValue = valueMap.get(valuedWrappedStack); - - if (energyValue.compareTo(minEnergyValue) < 0) { + if (energyValue.compareTo(minEnergyValue) + < 0) { minEnergyValue = energyValue; } } @@ -211,29 +234,29 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { } } } - } - else if (wrappedObject instanceof OreStack) { - + } else if (wrappedObject instanceof OreStack) { OreStack oreStack = (OreStack) wrappedObject; - List itemStacks = OreDictionary.getOres(oreStack.oreName); + List itemStacks + = OreDictionary.getOres(oreStack.oreName); if (!itemStacks.isEmpty()) { - EnergyValue energyValue = null; boolean allHaveSameValue = true; for (ItemStack itemStack : itemStacks) { - WrappedStack wrappedItemStack = WrappedStack.wrap(itemStack, 1); + WrappedStack wrappedItemStack + = WrappedStack.wrap(itemStack, 1); - if (wrappedItemStack != null && valueMap.containsKey(wrappedItemStack)) { + if (wrappedItemStack != null + && valueMap.containsKey(wrappedItemStack)) { if (energyValue == null) { energyValue = valueMap.get(wrappedItemStack); - } - else if (!energyValue.equals(valueMap.get(wrappedItemStack))) { + } else if (!energyValue.equals( + valueMap.get(wrappedItemStack) + )) { allHaveSameValue = false; } - } - else { + } else { allHaveSameValue = false; } } @@ -251,92 +274,107 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { } /** - * Calculates an {@link EnergyValue} for the provided {@link WrappedStack} output from the provided - * {@link Collection} of WrappedStack inputs and {@link Map} of energy value mappings to objects. We calculate the - * energy value for the output by, for each input, summing the input's energy value * the input's stack size. That - * sum is then divided by the stack size of the output. If any of the inputs do not have an energy - * value then no energy value can be calculated for the output - therefore we return null + * Calculates an {@link EnergyValue} for the provided {@link WrappedStack} output from + * the provided + * {@link Collection} of WrappedStack inputs and {@link Map} of energy value mappings + * to objects. We calculate the energy value for the output by, for each input, + * summing the input's energy value * the input's stack size. That sum is then divided + * by the stack size of the output. If any of the inputs do not have + * an energy value then no energy value can be calculated for the output - therefore + * we return null * - * @param valueMap a {@link Map} of {@link EnergyValue}'s mapped to {@link WrappedStack}'s + * @param valueMap a {@link Map} of {@link EnergyValue}'s mapped to {@link + * WrappedStack}'s * @param wrappedOutput the {@link WrappedStack} output for that the inputs "create" - * @param wrappedInputs a {@link Collection} of {@link WrappedStack}s that "create" the output - * @return an {@link EnergyValue} if there is one that can be calculated, null otherwise + * @param wrappedInputs a {@link Collection} of {@link WrappedStack}s that "create" + * the output + * @return an {@link EnergyValue} if there is one that can be calculated, null + * otherwise */ - private static EnergyValue computeFromInputs(Map valueMap, WrappedStack wrappedOutput, Collection wrappedInputs) { - + private static EnergyValue computeFromInputs( + Map valueMap, + WrappedStack wrappedOutput, + Collection wrappedInputs + ) { float sumOfValues = 0f; for (WrappedStack wrappedInput : wrappedInputs) { - EnergyValue inputValue; int stackSize = Integer.MIN_VALUE; if (wrappedInput.getWrappedObject() instanceof ItemStack) { - ItemStack inputItemStack = (ItemStack) wrappedInput.getWrappedObject(); // Check if we are dealing with a potential fluid - if (FluidContainerRegistry.getFluidForFilledItem(inputItemStack) != null) { - - if (inputItemStack.getItem().getContainerItem(inputItemStack) != null) { - stackSize = FluidContainerRegistry.getFluidForFilledItem(inputItemStack).amount * wrappedInput.getStackSize(); - inputValue = getEnergyValue(valueMap, FluidContainerRegistry.getFluidForFilledItem(inputItemStack), false); - } - else { + if (FluidContainerRegistry.getFluidForFilledItem(inputItemStack) + != null) { + if (inputItemStack.getItem().getContainerItem(inputItemStack) + != null) { + stackSize + = FluidContainerRegistry.getFluidForFilledItem(inputItemStack) + .amount + * wrappedInput.getStackSize(); + inputValue = getEnergyValue( + valueMap, + FluidContainerRegistry.getFluidForFilledItem(inputItemStack), + false + ); + } else { inputValue = getEnergyValue(valueMap, wrappedInput, false); } - } - else if (inputItemStack.getItem().getContainerItem(inputItemStack) != null) { + } else if (inputItemStack.getItem().getContainerItem(inputItemStack) != null) { + ItemStack inputContainerItemStack + = inputItemStack.getItem().getContainerItem(inputItemStack); - ItemStack inputContainerItemStack = inputItemStack.getItem().getContainerItem(inputItemStack); - - if (getEnergyValue(valueMap, inputItemStack, false) != null && getEnergyValue(valueMap, inputContainerItemStack, false) != null) { - float itemStackValue = getEnergyValue(valueMap, inputItemStack, false).getValue(); - float containerStackValue = getEnergyValue(valueMap, inputContainerItemStack, false).getValue(); - inputValue = new EnergyValue(itemStackValue - containerStackValue); - } - else { + if (getEnergyValue(valueMap, inputItemStack, false) != null + && getEnergyValue(valueMap, inputContainerItemStack, false) + != null) { + float itemStackValue + = getEnergyValue(valueMap, inputItemStack, false).getValue(); + float containerStackValue + = getEnergyValue(valueMap, inputContainerItemStack, false) + .getValue(); + inputValue + = new EnergyValue(itemStackValue - containerStackValue); + } else { inputValue = new EnergyValue(0); } - } - else if (!inputItemStack.getItem().doesContainerItemLeaveCraftingGrid(inputItemStack)) { + } else if (!inputItemStack.getItem().doesContainerItemLeaveCraftingGrid( + inputItemStack + )) { inputValue = new EnergyValue(0); - } - else if (OreDictionary.getOreIDs(inputItemStack).length > 0) { + } else if (OreDictionary.getOreIDs(inputItemStack).length > 0) { inputValue = getEnergyValue(valueMap, wrappedInput, true); - } - else { + } else { inputValue = getEnergyValue(valueMap, wrappedInput, false); } - } - else if (wrappedInput.getWrappedObject() instanceof OreStack) { - + } else if (wrappedInput.getWrappedObject() instanceof OreStack) { OreStack inputOreStack = (OreStack) wrappedInput.getWrappedObject(); inputValue = getEnergyValue(valueMap, wrappedInput, false); for (ItemStack itemStack : OreDictionary.getOres(inputOreStack.oreName)) { - if (!itemStack.getItem().doesContainerItemLeaveCraftingGrid(itemStack)) { + if (!itemStack.getItem().doesContainerItemLeaveCraftingGrid(itemStack + )) { inputValue = new EnergyValue(0); } } - } - else { + } else { inputValue = getEnergyValue(valueMap, wrappedInput, false); } if (inputValue != null) { - if (stackSize == Integer.MIN_VALUE) { stackSize = wrappedInput.getStackSize(); } sumOfValues += inputValue.getValue() * stackSize; - } - else { + } else { return null; } } - return EnergyValue.factor(new EnergyValue(sumOfValues), wrappedOutput.getStackSize()); + return EnergyValue.factor( + new EnergyValue(sumOfValues), wrappedOutput.getStackSize() + ); } /** @@ -367,9 +405,11 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { } /** - * Checks if there exists an {@link EnergyValue} associated with the provided {@link Object}. + * Checks if there exists an {@link EnergyValue} associated with the provided {@link + * Object}. * - * @param object the {@link Object} that is being checked for a corresponding {@link EnergyValue} + * @param object the {@link Object} that is being checked for a corresponding {@link + * EnergyValue} * @return true if the provided object has an energy value, false otherwise */ public boolean hasEnergyValue(Object object) { @@ -377,10 +417,13 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { } /** - * Checks if there exists an {@link EnergyValue} associated with the provided {@link Object} + * Checks if there exists an {@link EnergyValue} associated with the provided {@link + * Object} * - * @param object the {@link Object} that is being checked for a corresponding {@link EnergyValue} - * @param strict whether this is a strict (e.g., only looking for direct value assignment vs associative value + * @param object the {@link Object} that is being checked for a corresponding {@link + * EnergyValue} + * @param strict whether this is a strict (e.g., only looking for direct value + * assignment vs associative value * assignments) query or not * @return true if the provided object has an energy value, false otherwise */ @@ -389,9 +432,11 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { } /** - * Returns an {@link EnergyValue} associated with the provided {@link Object} (if there is one) + * Returns an {@link EnergyValue} associated with the provided {@link Object} (if + * there is one) * - * @param object the {@link Object} that is being checked for a corresponding {@link EnergyValue} + * @param object the {@link Object} that is being checked for a corresponding {@link + * EnergyValue} * @return an {@link EnergyValue} if there is one to be found, null otherwise */ public EnergyValue getEnergyValue(Object object) { @@ -399,10 +444,13 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { } /** - * Returns an {@link EnergyValue} associated with the provided {@link Object} (if there is one) + * Returns an {@link EnergyValue} associated with the provided {@link Object} (if + * there is one) * - * @param object the {@link Object} that is being checked for a corresponding {@link EnergyValue} - * @param strict whether this is a strict (e.g., only looking for direct value assignment vs associative value + * @param object the {@link Object} that is being checked for a corresponding {@link + * EnergyValue} + * @param strict whether this is a strict (e.g., only looking for direct value + * assignment vs associative value * assignments) query or not * @return an {@link EnergyValue} if there is one to be found, null otherwise */ @@ -411,15 +459,17 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { } /** - * Returns an {@link EnergyValue} associated with the provided {@link Object} (if there is one) + * Returns an {@link EnergyValue} associated with the provided {@link Object} (if + * there is one) * - * @param object the {@link Object} that is being checked for a corresponding {@link EnergyValue} - * @param strict whether this is a strict (e.g., only looking for direct value assignment vs associative value + * @param object the {@link Object} that is being checked for a corresponding {@link + * EnergyValue} + * @param strict whether this is a strict (e.g., only looking for direct value + * assignment vs associative value * assignments) query or not * @return an {@link EnergyValue} if there is one to be found, null otherwise */ public EnergyValue getEnergyValueForStack(Object object, boolean strict) { - WrappedStack wrappedObject = WrappedStack.wrap(object); EnergyValue energyValue = getEnergyValue(object, strict); if (wrappedObject != null && energyValue != null) { @@ -447,25 +497,25 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { * @param upperBound * @return */ - public Set getStacksInRange(EnergyValue lowerBound, EnergyValue upperBound) { + public Set + getStacksInRange(EnergyValue lowerBound, EnergyValue upperBound) { + Set filteredItemStacks + = new TreeSet<>(Comparators.ENERGY_VALUE_ITEM_STACK_COMPARATOR); - Set filteredItemStacks = new TreeSet<>(Comparators.ENERGY_VALUE_ITEM_STACK_COMPARATOR); - - Set greaterThanLowerBound = getStacksInRange(getEnergyValues(), lowerBound, false); - Set lesserThanUpperBound = getStacksInRange(getEnergyValues(), upperBound, true); + Set greaterThanLowerBound + = getStacksInRange(getEnergyValues(), lowerBound, false); + Set lesserThanUpperBound + = getStacksInRange(getEnergyValues(), upperBound, true); if (!greaterThanLowerBound.isEmpty() && !lesserThanUpperBound.isEmpty()) { - for (ItemStack itemStack : greaterThanLowerBound) { if (lesserThanUpperBound.contains(itemStack)) { filteredItemStacks.add(itemStack); } } - } - else if (!greaterThanLowerBound.isEmpty()) { + } else if (!greaterThanLowerBound.isEmpty()) { return greaterThanLowerBound; - } - else if (!lesserThanUpperBound.isEmpty()) { + } else if (!lesserThanUpperBound.isEmpty()) { return lesserThanUpperBound; } @@ -480,17 +530,29 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { * @param isUpperBound * @return */ - private static Set getStacksInRange(Map valueMap, EnergyValue energyValueBound, boolean isUpperBound) { - + private static Set getStacksInRange( + Map valueMap, + EnergyValue energyValueBound, + boolean isUpperBound + ) { Set itemStacks = filterForItemStacks(valueMap.keySet()); if (valueMap != null) { if (energyValueBound != null) { if (isUpperBound) { - return FilterUtils.filterByEnergyValue(itemStacks, energyValueBound, FilterUtils.ValueFilterType.VALUE_LOWER_THAN_BOUND, Comparators.ENERGY_VALUE_ITEM_STACK_COMPARATOR); - } - else { - return FilterUtils.filterByEnergyValue(itemStacks, energyValueBound, FilterUtils.ValueFilterType.VALUE_GREATER_THAN_BOUND, Comparators.ENERGY_VALUE_ITEM_STACK_COMPARATOR); + return FilterUtils.filterByEnergyValue( + itemStacks, + energyValueBound, + FilterUtils.ValueFilterType.VALUE_LOWER_THAN_BOUND, + Comparators.ENERGY_VALUE_ITEM_STACK_COMPARATOR + ); + } else { + return FilterUtils.filterByEnergyValue( + itemStacks, + energyValueBound, + FilterUtils.ValueFilterType.VALUE_GREATER_THAN_BOUND, + Comparators.ENERGY_VALUE_ITEM_STACK_COMPARATOR + ); } } } @@ -498,11 +560,11 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { return new TreeSet<>(Collections.EMPTY_SET); } - /** - * Sets an {@link EnergyValue} for the provided {@link Object} (if it can be wrapped in a {@link WrappedStack}. - * Depending on whether or not this is a pre-calculation value assignment it's also possible for the calculated - * energy value map to be recomputed to take into account the new mapping. + * Sets an {@link EnergyValue} for the provided {@link Object} (if it can be wrapped + * in a {@link WrappedStack}. Depending on whether or not this is a pre-calculation + * value assignment it's also possible for the calculated energy value map to be + * recomputed to take into account the new mapping. * * @param object the object the energy value is being assigned for * @param energyValue the energy value being setEnergyValue on the object @@ -513,48 +575,67 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { } /** - * Sets an {@link EnergyValue} for the provided {@link Object} (if it can be wrapped in a {@link WrappedStack}. - * Depending on whether or not this is a pre-calculation value assignment it's also possible for the calculated - * energy value map to be recomputed to take into account the new mapping. + * Sets an {@link EnergyValue} for the provided {@link Object} (if it can be wrapped + * in a {@link WrappedStack}. Depending on whether or not this is a pre-calculation + * value assignment it's also possible for the calculated energy value map to be + * recomputed to take into account the new mapping. * * @param object the object the energy value is being assigned for * @param energyValue the energy value being setEnergyValue on the object * @param phase the {@link Phase} of energy value assignment to set this value for - * @param doRegenValues whether or not the energy value map needs recomputing. Only an option if the energy value + * @param doRegenValues whether or not the energy value map needs recomputing. Only an + * option if the energy value * is being assigned in the PRE_CALCULATION phase */ - public void setEnergyValue(Object object, EnergyValue energyValue, Phase phase, boolean doRegenValues) { - - if (WrappedStack.canBeWrapped(object) && energyValue != null && Float.compare(energyValue.getValue(), 0f) > 0) { - + public void setEnergyValue( + Object object, EnergyValue energyValue, Phase phase, boolean doRegenValues + ) { + if (WrappedStack.canBeWrapped(object) && energyValue != null + && Float.compare(energyValue.getValue(), 0f) > 0) { WrappedStack wrappedStack = WrappedStack.wrap(object, 1); - EnergyValue factoredEnergyValue = EnergyValue.factor(energyValue, wrappedStack.getStackSize()); + EnergyValue factoredEnergyValue + = EnergyValue.factor(energyValue, wrappedStack.getStackSize()); if (phase == Phase.PRE_CALCULATION) { - if (!FMLCommonHandler.instance().bus().post(new EnergyValueEvent.SetEnergyValueEvent(wrappedStack, factoredEnergyValue, Phase.PRE_CALCULATION))) { - + if (!FMLCommonHandler.instance().bus().post( + new EnergyValueEvent.SetEnergyValueEvent( + wrappedStack, factoredEnergyValue, Phase.PRE_CALCULATION + ) + )) { preCalculationStackValueMap.put(wrappedStack, factoredEnergyValue); if (doRegenValues) { compute(); - } - else { + } else { valuesNeedRegeneration = true; } } - } - else if (!FMLCommonHandler.instance().bus().post(new EnergyValueEvent.SetEnergyValueEvent(wrappedStack, factoredEnergyValue, Phase.POST_CALCULATION))) { - - TreeMap valueMap = new TreeMap<>(stackValueMap); + } else if (!FMLCommonHandler.instance().bus().post( + new EnergyValueEvent.SetEnergyValueEvent( + wrappedStack, factoredEnergyValue, Phase.POST_CALCULATION + ) + )) { + TreeMap valueMap + = new TreeMap<>(stackValueMap); valueMap.put(wrappedStack, energyValue); - ImmutableSortedMap.Builder stackMappingsBuilder = ImmutableSortedMap.naturalOrder(); + ImmutableSortedMap.Builder stackMappingsBuilder + = ImmutableSortedMap.naturalOrder(); stackValueMap = stackMappingsBuilder.putAll(valueMap).build(); postCalculationStackValueMap.put(wrappedStack, factoredEnergyValue); } if (ConfigurationHandler.Settings.energyValueDebugLoggingEnabled) { - LogHelper.info(ENERGY_VALUE_MARKER, "[{}] Mod '{}' set a {} value of {} on object '{}' with doRegen = {}", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), phase, energyValue, wrappedStack, doRegenValues); + LogHelper.info( + ENERGY_VALUE_MARKER, + "[{}] Mod '{}' set a {} value of {} on object '{}' with doRegen = {}", + LoaderHelper.getLoaderState(), + Loader.instance().activeModContainer().getModId(), + phase, + energyValue, + wrappedStack, + doRegenValues + ); } } } @@ -574,7 +655,6 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { * This is where the magic happens */ public void compute() { - valuesNeedRegeneration = false; // Initialize the "working copy" energy value map @@ -585,53 +665,88 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { Map fileValueMap = null; try { fileValueMap = SerializationHelper.readMapFromFile(preCalculationValuesFile); - } - catch (FileNotFoundException e) { - LogHelper.warn(ENERGY_VALUE_MARKER, "No pre calculation energy values were loaded from file - could not find {}", preCalculationValuesFile.getAbsolutePath()); + } catch (FileNotFoundException e) { + LogHelper.warn( + ENERGY_VALUE_MARKER, + "No pre calculation energy values were loaded from file - could not find {}", + preCalculationValuesFile.getAbsolutePath() + ); } if (fileValueMap != null) { for (WrappedStack wrappedStack : fileValueMap.keySet()) { - if (wrappedStack != null && wrappedStack.getWrappedObject() != null && fileValueMap.get(wrappedStack) != null) { - preCalculationStackValueMap.put(wrappedStack, fileValueMap.get(wrappedStack)); + if (wrappedStack != null && wrappedStack.getWrappedObject() != null + && fileValueMap.get(wrappedStack) != null) { + preCalculationStackValueMap.put( + wrappedStack, fileValueMap.get(wrappedStack) + ); } } } // Add in all pre-calculation energy value mappings - preCalculationStackValueMap.keySet().stream() - .filter(wrappedStack -> wrappedStack != null && wrappedStack.getWrappedObject() != null && preCalculationStackValueMap.get(wrappedStack) != null) - .forEach(wrappedStack -> stackValueMap.put(wrappedStack, preCalculationStackValueMap.get(wrappedStack))); + preCalculationStackValueMap.keySet() + .stream() + .filter( + wrappedStack + -> wrappedStack != null && wrappedStack.getWrappedObject() != null + && preCalculationStackValueMap.get(wrappedStack) != null + ) + .forEach( + wrappedStack + -> stackValueMap.put( + wrappedStack, preCalculationStackValueMap.get(wrappedStack) + ) + ); - // Calculate values from the known methods to create items, and the pre-calculation value mappings - Map computedStackValueMap = calculateStackValueMap(stackValueMap); + // Calculate values from the known methods to create items, and the + // pre-calculation value mappings + Map computedStackValueMap + = calculateStackValueMap(stackValueMap); for (WrappedStack wrappedStack : computedStackValueMap.keySet()) { stackValueMap.put(wrappedStack, computedStackValueMap.get(wrappedStack)); } -// stackValueMap.putAll(calculateStackValueMap(stackValueMap)); + // stackValueMap.putAll(calculateStackValueMap(stackValueMap)); // Load in post calculation value assignments from file fileValueMap = null; try { fileValueMap = SerializationHelper.readMapFromFile(postCalculationValuesFile); - } - catch (FileNotFoundException e) { - LogHelper.warn(ENERGY_VALUE_MARKER, "No post calculation energy values were loaded from file - could not find {}", postCalculationValuesFile.getAbsolutePath()); + } catch (FileNotFoundException e) { + LogHelper.warn( + ENERGY_VALUE_MARKER, + "No post calculation energy values were loaded from file - could not find {}", + postCalculationValuesFile.getAbsolutePath() + ); } if (fileValueMap != null) { for (WrappedStack wrappedStack : fileValueMap.keySet()) { - if (wrappedStack != null && wrappedStack.getWrappedObject() != null && fileValueMap.get(wrappedStack) != null) { - postCalculationStackValueMap.put(wrappedStack, fileValueMap.get(wrappedStack)); + if (wrappedStack != null && wrappedStack.getWrappedObject() != null + && fileValueMap.get(wrappedStack) != null) { + postCalculationStackValueMap.put( + wrappedStack, fileValueMap.get(wrappedStack) + ); } } } // Add in all post-calculation energy value mappings - postCalculationStackValueMap.keySet().stream() - .filter(wrappedStack -> wrappedStack != null && wrappedStack.getWrappedObject() != null && postCalculationStackValueMap.get(wrappedStack) != null) - .forEach(wrappedStack -> stackValueMap.put(wrappedStack, postCalculationStackValueMap.get(wrappedStack))); + postCalculationStackValueMap.keySet() + .stream() + .filter( + wrappedStack + -> wrappedStack != null && wrappedStack.getWrappedObject() != null + && postCalculationStackValueMap.get(wrappedStack) != null + ) + .forEach( + wrappedStack + -> stackValueMap.put( + wrappedStack, postCalculationStackValueMap.get(wrappedStack) + ) + ); // Bake the final calculated energy value maps - ImmutableSortedMap.Builder stackMappingsBuilder = ImmutableSortedMap.naturalOrder(); + ImmutableSortedMap.Builder stackMappingsBuilder + = ImmutableSortedMap.naturalOrder(); stackMappingsBuilder.putAll(stackValueMap); this.stackValueMap = stackMappingsBuilder.build(); calculateValueStackMap(); @@ -642,8 +757,18 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { // Report the objects for which we were unable to compute an energy value for if (ConfigurationHandler.Settings.energyValueDebugLoggingEnabled) { uncomputedStacks.stream() - .filter(wrappedStack -> getEnergyValue(stackValueMap, wrappedStack, false) == null) - .forEach(wrappedStack -> LogHelper.info(ENERGY_VALUE_MARKER, "Unable to compute an energy value for {}", wrappedStack)); + .filter( + wrappedStack + -> getEnergyValue(stackValueMap, wrappedStack, false) == null + ) + .forEach( + wrappedStack + -> LogHelper.info( + ENERGY_VALUE_MARKER, + "Unable to compute an energy value for {}", + wrappedStack + ) + ); } } @@ -652,8 +777,8 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { * @param stackValueMap * @return */ - private Map calculateStackValueMap(Map stackValueMap) { - + private Map + calculateStackValueMap(Map stackValueMap) { LogHelper.info(ENERGY_VALUE_MARKER, "Beginning energy value calculation"); long startingTime = System.nanoTime(); @@ -661,34 +786,46 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { Map tempComputedMap = new TreeMap<>(); int passNumber = 0; - while ((passNumber == 0 || tempComputedMap.size() != computedMap.size()) && passNumber < 16) { - + while ((passNumber == 0 || tempComputedMap.size() != computedMap.size()) + && passNumber < 16) { long passStartTime = System.nanoTime(); passNumber++; computedMap.putAll(tempComputedMap); tempComputedMap = new TreeMap<>(computedMap); - for (WrappedStack recipeOutput : RecipeRegistry.INSTANCE.getRecipeMappings().keySet()) { - + for (WrappedStack recipeOutput : + RecipeRegistry.INSTANCE.getRecipeMappings().keySet()) { WrappedStack unitWrappedStack = WrappedStack.wrap(recipeOutput, 1); - // We won't attempt to recalculate values that already have a pre-calculation value assignment + // We won't attempt to recalculate values that already have a + // pre-calculation value assignment if (!stackValueMap.containsKey(unitWrappedStack)) { - for (Set recipeInputs : RecipeRegistry.INSTANCE.getRecipeMappings().get(recipeOutput)) { - - EnergyValue currentOutputValue = getEnergyValue(tempComputedMap, unitWrappedStack, false); - EnergyValue computedOutputValue = computeFromInputs(tempComputedMap, recipeOutput, recipeInputs); - - if (computedOutputValue != null && computedOutputValue.compareTo(currentOutputValue) < 0) { + for (Set recipeInputs : + RecipeRegistry.INSTANCE.getRecipeMappings().get(recipeOutput)) { + EnergyValue currentOutputValue + = getEnergyValue(tempComputedMap, unitWrappedStack, false); + EnergyValue computedOutputValue = computeFromInputs( + tempComputedMap, recipeOutput, recipeInputs + ); + if (computedOutputValue != null + && computedOutputValue.compareTo(currentOutputValue) < 0) { uncomputedStacks.remove(unitWrappedStack); - if (ConfigurationHandler.Settings.energyValueDebugLoggingEnabled) { - LogHelper.info(ENERGY_VALUE_MARKER, "Pass {}: Calculated value {} for object {} with recipe inputs {} and output {}", passNumber, computedOutputValue, unitWrappedStack, recipeInputs, recipeOutput); + if (ConfigurationHandler.Settings + .energyValueDebugLoggingEnabled) { + LogHelper.info( + ENERGY_VALUE_MARKER, + "Pass {}: Calculated value {} for object {} with recipe inputs {} and output {}", + passNumber, + computedOutputValue, + unitWrappedStack, + recipeInputs, + recipeOutput + ); } tempComputedMap.put(unitWrappedStack, computedOutputValue); - } - else if (computedOutputValue != null) { + } else if (computedOutputValue != null) { uncomputedStacks.add(unitWrappedStack); } } @@ -697,23 +834,31 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { long passDuration = System.nanoTime() - passStartTime; if (ConfigurationHandler.Settings.energyValueDebugLoggingEnabled) { - LogHelper.info(ENERGY_VALUE_MARKER, "Pass {}: Calculated {} different values for objects in {} ms", passNumber, tempComputedMap.size(), passDuration / 100000); + LogHelper.info( + ENERGY_VALUE_MARKER, + "Pass {}: Calculated {} different values for objects in {} ms", + passNumber, + tempComputedMap.size(), + passDuration / 100000 + ); } } long endingTime = System.nanoTime() - startingTime; - LogHelper.info(ENERGY_VALUE_MARKER, "Finished energy value calculation - calculated {} new values for objects in {} ms", computedMap.size() - stackValueMap.size(), endingTime / 100000); + LogHelper.info( + ENERGY_VALUE_MARKER, + "Finished energy value calculation - calculated {} new values for objects in {} ms", + computedMap.size() - stackValueMap.size(), + endingTime / 100000 + ); return computedMap; } private void calculateValueStackMap() { - SortedMap> tempValueMap = new TreeMap<>(); for (WrappedStack wrappedStack : getEnergyValues().keySet()) { - if (wrappedStack != null) { - EnergyValue energyValue = getEnergyValues().get(wrappedStack); if (energyValue != null) { @@ -721,9 +866,10 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { if (!(tempValueMap.get(energyValue).contains(wrappedStack))) { tempValueMap.get(energyValue).add(wrappedStack); } - } - else { - tempValueMap.put(energyValue, new TreeSet<>(Arrays.asList(wrappedStack))); + } else { + tempValueMap.put( + energyValue, new TreeSet<>(Arrays.asList(wrappedStack)) + ); } } } @@ -732,15 +878,15 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { } private static Set filterForItemStacks(Set wrappedStacks) { - Set itemStacks = new TreeSet<>(Comparators.ID_COMPARATOR); for (WrappedStack wrappedStack : wrappedStacks) { if (wrappedStack.getWrappedObject() instanceof ItemStack) { itemStacks.add((ItemStack) wrappedStack.getWrappedObject()); - } - else if (wrappedStack.getWrappedObject() instanceof OreStack) { - itemStacks.addAll(OreDictionary.getOres(((OreStack) wrappedStack.getWrappedObject()).oreName)); + } else if (wrappedStack.getWrappedObject() instanceof OreStack) { + itemStacks.addAll(OreDictionary.getOres( + ((OreStack) wrappedStack.getWrappedObject()).oreName + )); } } @@ -748,48 +894,57 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { } /** - * Saves the pre-calculation, post-calculation, and calculated energy value maps to disk + * Saves the pre-calculation, post-calculation, and calculated energy value maps to + * disk */ public void save() { - /** - * If the current values were synched to us from a server, do not save them to disk as they would override - * the local ones + * If the current values were synched to us from a server, do not save them to + * disk as they would override the local ones */ if (shouldSave) { if (valuesNeedRegeneration) { if (energyValuesFile.exists()) { energyValuesFile.delete(); } - } - else { + } else { SerializationHelper.writeMapToFile(stackValueMap, energyValuesFile); } } - SerializationHelper.writeMapToFile(preCalculationStackValueMap, preCalculationValuesFile); - SerializationHelper.writeMapToFile(postCalculationStackValueMap, postCalculationValuesFile); + SerializationHelper.writeMapToFile( + preCalculationStackValueMap, preCalculationValuesFile + ); + SerializationHelper.writeMapToFile( + postCalculationStackValueMap, postCalculationValuesFile + ); } /** - * Loads the pre-calculation, post-calculation, and calculated energy value maps from disk. In the event that either - * the pre/post calculation maps can not be loaded from disk they will be initialized as empty maps. If the - * calculated energy value map can not be loaded from disk then the values will be computed from the pre/post + * Loads the pre-calculation, post-calculation, and calculated energy value maps from + * disk. In the event that either the pre/post calculation maps can not be loaded from + * disk they will be initialized as empty maps. If the calculated energy value map can + * not be loaded from disk then the values will be computed from the pre/post * calculation maps */ public void load() { - // Load in pre calculation value assignments from file Map fileValueMap = null; try { fileValueMap = SerializationHelper.readMapFromFile(preCalculationValuesFile); - } - catch (FileNotFoundException e) { - LogHelper.warn(ENERGY_VALUE_MARKER, "No pre calculation energy values were loaded from file - could not find {}", preCalculationValuesFile.getAbsolutePath()); + } catch (FileNotFoundException e) { + LogHelper.warn( + ENERGY_VALUE_MARKER, + "No pre calculation energy values were loaded from file - could not find {}", + preCalculationValuesFile.getAbsolutePath() + ); } if (fileValueMap != null) { for (WrappedStack wrappedStack : fileValueMap.keySet()) { - if (wrappedStack != null && wrappedStack.getWrappedObject() != null && fileValueMap.get(wrappedStack) != null) { - preCalculationStackValueMap.put(wrappedStack, fileValueMap.get(wrappedStack)); + if (wrappedStack != null && wrappedStack.getWrappedObject() != null + && fileValueMap.get(wrappedStack) != null) { + preCalculationStackValueMap.put( + wrappedStack, fileValueMap.get(wrappedStack) + ); } } } @@ -798,14 +953,20 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { fileValueMap = null; try { fileValueMap = SerializationHelper.readMapFromFile(postCalculationValuesFile); - } - catch (FileNotFoundException e) { - LogHelper.warn(ENERGY_VALUE_MARKER, "No post calculation energy values were loaded from file - could not find {}", postCalculationValuesFile.getAbsolutePath()); + } catch (FileNotFoundException e) { + LogHelper.warn( + ENERGY_VALUE_MARKER, + "No post calculation energy values were loaded from file - could not find {}", + postCalculationValuesFile.getAbsolutePath() + ); } if (fileValueMap != null) { for (WrappedStack wrappedStack : fileValueMap.keySet()) { - if (wrappedStack != null && wrappedStack.getWrappedObject() != null && fileValueMap.get(wrappedStack) != null) { - postCalculationStackValueMap.put(wrappedStack, fileValueMap.get(wrappedStack)); + if (wrappedStack != null && wrappedStack.getWrappedObject() != null + && fileValueMap.get(wrappedStack) != null) { + postCalculationStackValueMap.put( + wrappedStack, fileValueMap.get(wrappedStack) + ); } } } @@ -814,16 +975,22 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { fileValueMap = null; try { fileValueMap = SerializationHelper.readMapFromFile(energyValuesFile); - } - catch (FileNotFoundException e) { - LogHelper.warn("No calculated energy values were loaded from file - could not find {}", energyValuesFile.getAbsolutePath()); - LogHelper.info("Recomputing energy values", energyValuesFile.getAbsolutePath()); + } catch (FileNotFoundException e) { + LogHelper.warn( + "No calculated energy values were loaded from file - could not find {}", + energyValuesFile.getAbsolutePath() + ); + LogHelper.info( + "Recomputing energy values", energyValuesFile.getAbsolutePath() + ); compute(); } if (fileValueMap != null) { - ImmutableSortedMap.Builder stackMapBuilder = ImmutableSortedMap.naturalOrder(); + ImmutableSortedMap.Builder stackMapBuilder + = ImmutableSortedMap.naturalOrder(); for (WrappedStack wrappedStack : fileValueMap.keySet()) { - if (wrappedStack != null && wrappedStack.getWrappedObject() != null && fileValueMap.get(wrappedStack) != null) { + if (wrappedStack != null && wrappedStack.getWrappedObject() != null + && fileValueMap.get(wrappedStack) != null) { stackMapBuilder.put(wrappedStack, fileValueMap.get(wrappedStack)); } } @@ -837,15 +1004,22 @@ public class EnergyValueRegistry implements IEnergyValueRegistry { * * @param valueMap */ - public void load(Map valueMap){ - + public void load(Map valueMap) { if (valueMap != null) { - setShouldSave(false); - ImmutableSortedMap.Builder stackMappingsBuilder = ImmutableSortedMap.naturalOrder(); - valueMap.keySet().stream() - .filter(wrappedStack -> wrappedStack != null && wrappedStack.getWrappedObject() != null && valueMap.get(wrappedStack) != null) - .forEach(wrappedStack -> stackMappingsBuilder.put(wrappedStack, valueMap.get(wrappedStack))); + ImmutableSortedMap.Builder stackMappingsBuilder + = ImmutableSortedMap.naturalOrder(); + valueMap.keySet() + .stream() + .filter( + wrappedStack + -> wrappedStack != null && wrappedStack.getWrappedObject() != null + && valueMap.get(wrappedStack) != null + ) + .forEach( + wrappedStack + -> stackMappingsBuilder.put(wrappedStack, valueMap.get(wrappedStack)) + ); stackValueMap = stackMappingsBuilder.build(); calculateValueStackMap(); } diff --git a/src/main/java/com/pahimar/ee3/exchange/OreStack.java b/src/main/java/com/pahimar/ee3/exchange/OreStack.java index ed96d1c3..f68391ec 100644 --- a/src/main/java/com/pahimar/ee3/exchange/OreStack.java +++ b/src/main/java/com/pahimar/ee3/exchange/OreStack.java @@ -1,16 +1,15 @@ package com.pahimar.ee3.exchange; +import java.util.Arrays; +import java.util.Collection; +import java.util.Comparator; + import com.pahimar.ee3.reference.Comparators; import com.pahimar.ee3.util.FilterUtils; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.oredict.OreDictionary; -import java.util.Arrays; -import java.util.Collection; -import java.util.Comparator; - public final class OreStack implements Comparable { - public String oreName; public int stackSize; @@ -19,27 +18,22 @@ public final class OreStack implements Comparable { if (oreStack2 != null && oreStack2.oreName != null) { if (oreStack1.oreName.equalsIgnoreCase(oreStack2.oreName)) { return oreStack1.stackSize - oreStack2.stackSize; - } - else { + } else { return oreStack1.oreName.compareToIgnoreCase(oreStack2.oreName); } - } - else { + } else { return -1; } - } - else { + } else { if (oreStack2 != null) { return 1; - } - else { + } else { return 0; } } }; - private OreStack() { - } + private OreStack() {} public OreStack(String oreName) { this(oreName, 1); @@ -56,7 +50,6 @@ public final class OreStack implements Comparable { } public static boolean compareOreNames(OreStack oreStack1, OreStack oreStack2) { - if (oreStack1 != null && oreStack2 != null) { if ((oreStack1.oreName != null) && (oreStack2.oreName != null)) { return oreStack1.oreName.equalsIgnoreCase(oreStack2.oreName); @@ -71,9 +64,12 @@ public final class OreStack implements Comparable { } public static OreStack getOreStackFrom(Collection objects) { - for (String oreName : OreDictionary.getOreNames()) { - if (Comparators.ITEM_STACK_COLLECTION_COMPARATOR.compare(FilterUtils.filterForItemStacks(objects), OreDictionary.getOres(oreName)) == 0) { + if (Comparators.ITEM_STACK_COLLECTION_COMPARATOR.compare( + FilterUtils.filterForItemStacks(objects), + OreDictionary.getOres(oreName) + ) + == 0) { return new OreStack(oreName, 1); } } @@ -87,24 +83,22 @@ public final class OreStack implements Comparable { @Override public boolean equals(Object object) { - return object instanceof OreStack && (comparator.compare(this, (OreStack) object) == 0); + return object instanceof OreStack + && (comparator.compare(this, (OreStack) object) == 0); } public NBTTagCompound writeToNBT(NBTTagCompound nbtTagCompound) { - nbtTagCompound.setString("oreName", oreName); nbtTagCompound.setInteger("stackSize", stackSize); return nbtTagCompound; } public void readFromNBT(NBTTagCompound nbtTagCompound) { - this.oreName = nbtTagCompound.getString("oreName"); this.stackSize = nbtTagCompound.getInteger("stackSize"); } public static OreStack loadOreStackFromNBT(NBTTagCompound nbtTagCompound) { - OreStack oreStack = new OreStack(); oreStack.readFromNBT(nbtTagCompound); return oreStack.oreName != null ? oreStack : null; diff --git a/src/main/java/com/pahimar/ee3/exchange/WrappedStack.java b/src/main/java/com/pahimar/ee3/exchange/WrappedStack.java index d475904b..9c5dc387 100644 --- a/src/main/java/com/pahimar/ee3/exchange/WrappedStack.java +++ b/src/main/java/com/pahimar/ee3/exchange/WrappedStack.java @@ -1,5 +1,9 @@ package com.pahimar.ee3.exchange; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + import com.pahimar.ee3.util.FluidHelper; import com.pahimar.ee3.util.ItemStackUtils; import net.minecraft.block.Block; @@ -8,167 +12,115 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; - public final class WrappedStack implements Comparable { - private final Object wrappedStack; private int stackSize; public WrappedStack() { - stackSize = -1; wrappedStack = null; } private WrappedStack(Object object) { - if (object instanceof Item) { object = new ItemStack((Item) object); - } - else if (object instanceof Block) { + } else if (object instanceof Block) { object = new ItemStack((Block) object); - } - else if (object instanceof Fluid) { + } else if (object instanceof Fluid) { object = new FluidStack((Fluid) object, 1000); } if (object instanceof ItemStack) { - if (((ItemStack) object).getItem() != null) { - stackSize = ((ItemStack) object).stackSize; wrappedStack = ItemStackUtils.clone((ItemStack) object, 1); - } - else { - + } else { stackSize = -1; wrappedStack = null; } - } - else if (object instanceof OreStack) { - + } else if (object instanceof OreStack) { OreStack oreStack = new OreStack((OreStack) object); stackSize = oreStack.stackSize; oreStack.stackSize = 1; wrappedStack = oreStack; - } - else if (object instanceof ArrayList) { - + } else if (object instanceof ArrayList) { ArrayList objectList = (ArrayList) object; OreStack possibleOreStack = OreStack.getOreStackFrom(objectList); if (possibleOreStack != null) { - stackSize = possibleOreStack.stackSize; possibleOreStack.stackSize = 1; wrappedStack = possibleOreStack; - } - else { - + } else { stackSize = -1; wrappedStack = null; } - } - else if (object instanceof FluidStack) { - + } else if (object instanceof FluidStack) { FluidStack fluidStack = ((FluidStack) object).copy(); stackSize = fluidStack.amount; fluidStack.amount = 1; wrappedStack = fluidStack; - } - else if (object instanceof WrappedStack) { - + } else if (object instanceof WrappedStack) { WrappedStack wrappedStackObject = (WrappedStack) object; if (wrappedStackObject.getWrappedObject() != null) { - this.stackSize = wrappedStackObject.stackSize; this.wrappedStack = wrappedStackObject.wrappedStack; - } - else { - + } else { stackSize = -1; wrappedStack = null; } - } - else { - + } else { stackSize = -1; wrappedStack = null; } } private WrappedStack(Object object, int stackSize) { - if (object instanceof Item) { - object = new ItemStack((Item) object); - } - else if (object instanceof Block) { - + } else if (object instanceof Block) { object = new ItemStack((Block) object); - } - else if (object instanceof Fluid) { - + } else if (object instanceof Fluid) { object = new FluidStack((Fluid) object, 1000); } if (object instanceof ItemStack) { - this.stackSize = stackSize; wrappedStack = ItemStackUtils.clone((ItemStack) object, 1); - } - else if (object instanceof OreStack) { - + } else if (object instanceof OreStack) { OreStack oreStack = new OreStack((OreStack) object); this.stackSize = stackSize; oreStack.stackSize = 1; wrappedStack = oreStack; - } - else if (object instanceof ArrayList) { - + } else if (object instanceof ArrayList) { OreStack possibleOreStack = OreStack.getOreStackFrom((ArrayList) object); if (possibleOreStack != null) { - this.stackSize = stackSize; possibleOreStack.stackSize = 1; wrappedStack = possibleOreStack; - } - else { - + } else { this.stackSize = -1; wrappedStack = null; } - } - else if (object instanceof FluidStack) { - + } else if (object instanceof FluidStack) { FluidStack fluidStack = ((FluidStack) object).copy(); this.stackSize = stackSize; fluidStack.amount = 1; wrappedStack = fluidStack; - } - else if (object instanceof WrappedStack) { - + } else if (object instanceof WrappedStack) { WrappedStack wrappedStackObject = (WrappedStack) object; if (wrappedStackObject.getWrappedObject() != null) { - this.stackSize = stackSize; this.wrappedStack = wrappedStackObject.wrappedStack; - } - else { - + } else { this.stackSize = -1; wrappedStack = null; } - } - else { - + } else { this.stackSize = -1; wrappedStack = null; } @@ -179,29 +131,21 @@ public final class WrappedStack implements Comparable { } public static boolean canBeWrapped(Object object) { - if (object instanceof WrappedStack) { return true; - } - else if (object instanceof Item || object instanceof Block) { + } else if (object instanceof Item || object instanceof Block) { return true; - } - else if (object instanceof ItemStack) { - + } else if (object instanceof ItemStack) { if (((ItemStack) object).getItem() != null) { return true; } - } - else if (object instanceof OreStack) { + } else if (object instanceof OreStack) { return true; - } - else if (object instanceof List) { - + } else if (object instanceof List) { if (OreStack.getOreStackFrom((List) object) != null) { return true; } - } - else if (object instanceof Fluid || object instanceof FluidStack) { + } else if (object instanceof Fluid || object instanceof FluidStack) { return true; } @@ -217,7 +161,6 @@ public final class WrappedStack implements Comparable { } public static WrappedStack wrap(Object object) { - if (canBeWrapped(object)) { return new WrappedStack(object); } @@ -226,7 +169,6 @@ public final class WrappedStack implements Comparable { } public static WrappedStack wrap(Object object, int stackSize) { - if (canBeWrapped(object)) { return new WrappedStack(object, stackSize); } @@ -236,7 +178,8 @@ public final class WrappedStack implements Comparable { @Override public boolean equals(Object object) { - return object instanceof WrappedStack && (this.compareTo((WrappedStack) object) == 0); + return object instanceof WrappedStack + && (this.compareTo((WrappedStack) object) == 0); } /** @@ -254,115 +197,114 @@ public final class WrappedStack implements Comparable { */ @Override public String toString() { - if (wrappedStack instanceof ItemStack) { ItemStack itemStack = (ItemStack) wrappedStack; String unlocalizedName = null; try { if (itemStack.getItem() != null) { - unlocalizedName = Item.itemRegistry.getNameForObject(itemStack.getItem()); + unlocalizedName + = Item.itemRegistry.getNameForObject(itemStack.getItem()); } if (unlocalizedName == null) { unlocalizedName = itemStack.getUnlocalizedName(); } - } - catch (ArrayIndexOutOfBoundsException e) { + } catch (ArrayIndexOutOfBoundsException e) { unlocalizedName = "no-name"; } if (itemStack.hasTagCompound()) { - return String.format("%sxitemStack[%s@%s:%s]", stackSize, unlocalizedName, itemStack.getItemDamage(), itemStack.getTagCompound()); + return String.format( + "%sxitemStack[%s@%s:%s]", + stackSize, + unlocalizedName, + itemStack.getItemDamage(), + itemStack.getTagCompound() + ); + } else { + return String.format( + "%sxitemStack[%s@%s]", + stackSize, + unlocalizedName, + itemStack.getItemDamage() + ); } - else { - return String.format("%sxitemStack[%s@%s]", stackSize, unlocalizedName, itemStack.getItemDamage()); - } - } - else if (wrappedStack instanceof OreStack) { + } else if (wrappedStack instanceof OreStack) { OreStack oreStack = (OreStack) wrappedStack; return String.format("%sxoreStack[%s]", stackSize, oreStack.oreName); - } - else if (wrappedStack instanceof FluidStack) { + } else if (wrappedStack instanceof FluidStack) { FluidStack fluidStack = (FluidStack) wrappedStack; - return String.format("%sxfluidStack[%s]", stackSize, fluidStack.getFluid().getName()); - } - else { + return String.format( + "%sxfluidStack[%s]", stackSize, fluidStack.getFluid().getName() + ); + } else { return "null-wrappedstack"; } } - public static final Comparator COMPARATOR = new Comparator() { + public static final Comparator COMPARATOR + = new Comparator() { + @Override + public int compare(WrappedStack wrappedStack1, WrappedStack wrappedStack2) { + if (wrappedStack1.wrappedStack instanceof ItemStack) { + if (wrappedStack2.wrappedStack instanceof ItemStack) { + int compareResult = ItemStackUtils.compare( + (ItemStack) wrappedStack1.wrappedStack, + (ItemStack) wrappedStack2.wrappedStack + ); - @Override - public int compare(WrappedStack wrappedStack1, WrappedStack wrappedStack2) { + if (compareResult == 0) { + return wrappedStack1.stackSize - wrappedStack2.stackSize; + } else { + return compareResult; + } + } else { + return 1; + } + } else if (wrappedStack1.wrappedStack instanceof OreStack) { + if (wrappedStack2.wrappedStack instanceof ItemStack) { + return -1; + } else if (wrappedStack2.wrappedStack instanceof OreStack) { + int compareResult = OreStack.compare( + (OreStack) wrappedStack1.wrappedStack, + (OreStack) wrappedStack2.wrappedStack + ); - if (wrappedStack1.wrappedStack instanceof ItemStack) { + if (compareResult == 0) { + return wrappedStack1.stackSize - wrappedStack2.stackSize; + } else { + return compareResult; + } + } else { + return 1; + } + } else if (wrappedStack1.wrappedStack instanceof FluidStack) { + if (wrappedStack2.wrappedStack instanceof ItemStack + || wrappedStack2.wrappedStack instanceof OreStack) { + return -1; + } else if (wrappedStack2.wrappedStack instanceof FluidStack) { + int compareResult = FluidHelper.compare( + (FluidStack) wrappedStack1.wrappedStack, + (FluidStack) wrappedStack2.wrappedStack + ); - if (wrappedStack2.wrappedStack instanceof ItemStack) { + if (compareResult == 0) { + return wrappedStack1.stackSize - wrappedStack2.stackSize; + } else { + return compareResult; + } + } else { + return 1; + } + } else if (wrappedStack1.wrappedStack == null) { + if (wrappedStack2.wrappedStack != null) { + return -1; + } else { + return 0; + } + } - int compareResult = ItemStackUtils.compare((ItemStack) wrappedStack1.wrappedStack, (ItemStack) wrappedStack2.wrappedStack); - - if (compareResult == 0) { - return wrappedStack1.stackSize - wrappedStack2.stackSize; - } - else { - return compareResult; - } - } - else { - return 1; - } - } - else if (wrappedStack1.wrappedStack instanceof OreStack) { - - if (wrappedStack2.wrappedStack instanceof ItemStack) { - return -1; - } - else if (wrappedStack2.wrappedStack instanceof OreStack) { - - int compareResult = OreStack.compare((OreStack) wrappedStack1.wrappedStack, (OreStack) wrappedStack2.wrappedStack); - - if (compareResult == 0) { - return wrappedStack1.stackSize - wrappedStack2.stackSize; - } - else { - return compareResult; - } - } - else { - return 1; - } - } - else if (wrappedStack1.wrappedStack instanceof FluidStack) { - - if (wrappedStack2.wrappedStack instanceof ItemStack || wrappedStack2.wrappedStack instanceof OreStack) { - return -1; - } - else if (wrappedStack2.wrappedStack instanceof FluidStack) { - - int compareResult = FluidHelper.compare((FluidStack) wrappedStack1.wrappedStack, (FluidStack) wrappedStack2.wrappedStack); - - if (compareResult == 0) { - return wrappedStack1.stackSize - wrappedStack2.stackSize; - } - else { - return compareResult; - } - } - else { - return 1; - } - } - else if (wrappedStack1.wrappedStack == null) { - if (wrappedStack2.wrappedStack != null) { - return -1; - } - else { - return 0; - } - } - - return 0; - } - }; + return 0; + } + }; } diff --git a/src/main/java/com/pahimar/ee3/handler/ConfigurationHandler.java b/src/main/java/com/pahimar/ee3/handler/ConfigurationHandler.java index 55170c7a..6850623d 100644 --- a/src/main/java/com/pahimar/ee3/handler/ConfigurationHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/ConfigurationHandler.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.handler; +import java.io.File; + import com.pahimar.ee3.reference.Reference; import com.pahimar.ee3.util.ConfigurationHelper; import cpw.mods.fml.client.event.ConfigChangedEvent; @@ -7,10 +9,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.util.StatCollector; import net.minecraftforge.common.config.Configuration; -import java.io.File; - public class ConfigurationHandler { - public static Configuration configuration; private static final String CATEGORY_SOUND = "general.sound"; @@ -19,7 +18,6 @@ public class ConfigurationHandler { private static final String CATEGORY_SERVER = "general.server"; public static void init(File configFile) { - if (configuration == null) { configuration = new Configuration(configFile, true); loadConfiguration(); @@ -27,45 +25,54 @@ public class ConfigurationHandler { } private static void loadConfiguration() { - Settings.serverSyncThreshold = configuration.getInt( - Settings.SERVER_SYNC_THRESHOLD_NAME, - CATEGORY_SERVER, - Settings.SERVER_SYNC_THRESHOLD_DEFAULT, - Settings.SERVER_SYNC_THRESHOLD_MIN, - Settings.SERVER_SYNC_THRESHOLD_MAX, - StatCollector.translateToLocal(Settings.SERVER_SYNC_THRESHOLD_COMMENT), - Settings.SERVER_SYNC_THRESHOLD_LABEL); + Settings.SERVER_SYNC_THRESHOLD_NAME, + CATEGORY_SERVER, + Settings.SERVER_SYNC_THRESHOLD_DEFAULT, + Settings.SERVER_SYNC_THRESHOLD_MIN, + Settings.SERVER_SYNC_THRESHOLD_MAX, + StatCollector.translateToLocal(Settings.SERVER_SYNC_THRESHOLD_COMMENT), + Settings.SERVER_SYNC_THRESHOLD_LABEL + ); - Settings.regenerateEnergyValuesWhen = ConfigurationHelper.getString(configuration, - Settings.ENERGY_VALUE_REGENERATE_WHEN_NAME, - CATEGORY_ENERGY_VALUE, - Settings.ENERGY_VALUE_REGENERATE_WHEN_DEFAULT, - StatCollector.translateToLocal(Settings.ENERGY_VALUE_REGENERATE_WHEN_COMMENT), - Settings.ENERGY_VALUE_REGENERATE_WHEN_OPTIONS, - Settings.ENERGY_VALUE_REGENERATE_WHEN_LABEL); + Settings.regenerateEnergyValuesWhen = ConfigurationHelper.getString( + configuration, + Settings.ENERGY_VALUE_REGENERATE_WHEN_NAME, + CATEGORY_ENERGY_VALUE, + Settings.ENERGY_VALUE_REGENERATE_WHEN_DEFAULT, + StatCollector.translateToLocal(Settings.ENERGY_VALUE_REGENERATE_WHEN_COMMENT), + Settings.ENERGY_VALUE_REGENERATE_WHEN_OPTIONS, + Settings.ENERGY_VALUE_REGENERATE_WHEN_LABEL + ); Settings.energyValueDebugLoggingEnabled = configuration.getBoolean( - Settings.ENERGY_VALUE_DEBUG_LOGGING_ENABLED_NAME, - CATEGORY_ENERGY_VALUE, - Settings.ENERGY_VALUE_DEBUG_LOGGING_ENABLED_DEFAULT, - StatCollector.translateToLocal(Settings.ENERGY_VALUE_DEBUG_LOGGING_ENABLED_COMMENT), - Settings.ENERGY_VALUE_DEBUG_LOGGING_ENABLED_LABEL); + Settings.ENERGY_VALUE_DEBUG_LOGGING_ENABLED_NAME, + CATEGORY_ENERGY_VALUE, + Settings.ENERGY_VALUE_DEBUG_LOGGING_ENABLED_DEFAULT, + StatCollector.translateToLocal( + Settings.ENERGY_VALUE_DEBUG_LOGGING_ENABLED_COMMENT + ), + Settings.ENERGY_VALUE_DEBUG_LOGGING_ENABLED_LABEL + ); - Settings.soundMode = ConfigurationHelper.getString(configuration, - Settings.SOUND_MODE_NAME, - CATEGORY_SOUND, - Settings.SOUND_MODE_DEFAULT, - StatCollector.translateToLocal(Settings.SOUND_MODE_COMMENT), - Settings.SOUND_MODE_OPTIONS, - Settings.SOUND_MODE_LABEL); + Settings.soundMode = ConfigurationHelper.getString( + configuration, + Settings.SOUND_MODE_NAME, + CATEGORY_SOUND, + Settings.SOUND_MODE_DEFAULT, + StatCollector.translateToLocal(Settings.SOUND_MODE_COMMENT), + Settings.SOUND_MODE_OPTIONS, + Settings.SOUND_MODE_LABEL + ); Settings.playerKnowledgeTemplateEnabled = configuration.getBoolean( - Settings.USE_PLAYER_KNOWLEDGE_TEMPLATE_NAME, - CATEGORY_PLAYER_KNOWLEDGE, - Settings.USE_PLAYER_KNOWLEDGE_TEMPLATE_DEFAULT, - StatCollector.translateToLocal(Settings.USE_PLAYER_KNOWLEDGE_TEMPLATE_COMMENT), - Settings.USE_PLAYER_KNOWLEDGE_TEMPLATE_LABEL); + Settings.USE_PLAYER_KNOWLEDGE_TEMPLATE_NAME, + CATEGORY_PLAYER_KNOWLEDGE, + Settings.USE_PLAYER_KNOWLEDGE_TEMPLATE_DEFAULT, + StatCollector.translateToLocal(Settings.USE_PLAYER_KNOWLEDGE_TEMPLATE_COMMENT + ), + Settings.USE_PLAYER_KNOWLEDGE_TEMPLATE_LABEL + ); if (configuration.hasChanged()) { configuration.save(); @@ -73,34 +80,42 @@ public class ConfigurationHandler { } @SubscribeEvent - public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) { - + public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event + ) { if (event.modID.equalsIgnoreCase(Reference.MOD_ID)) { loadConfiguration(); } } public static class Settings { - public static int serverSyncThreshold; private static final String SERVER_SYNC_THRESHOLD_NAME = "sync_threshold"; - private static final String SERVER_SYNC_THRESHOLD_LABEL = "server.sync_threshold.label"; - private static final String SERVER_SYNC_THRESHOLD_COMMENT = "server.sync_threshold.comment"; + private static final String SERVER_SYNC_THRESHOLD_LABEL + = "server.sync_threshold.label"; + private static final String SERVER_SYNC_THRESHOLD_COMMENT + = "server.sync_threshold.comment"; private static final int SERVER_SYNC_THRESHOLD_DEFAULT = 5; private static final int SERVER_SYNC_THRESHOLD_MIN = 0; private static final int SERVER_SYNC_THRESHOLD_MAX = Short.MAX_VALUE; public static String regenerateEnergyValuesWhen; - private static final String ENERGY_VALUE_REGENERATE_WHEN_NAME = "regenerate_values_when"; - private static final String ENERGY_VALUE_REGENERATE_WHEN_LABEL = "energy_value.regenerate_values_when.label"; - private static final String ENERGY_VALUE_REGENERATE_WHEN_COMMENT = "energy_value.regenerate_values_when.comment"; + private static final String ENERGY_VALUE_REGENERATE_WHEN_NAME + = "regenerate_values_when"; + private static final String ENERGY_VALUE_REGENERATE_WHEN_LABEL + = "energy_value.regenerate_values_when.label"; + private static final String ENERGY_VALUE_REGENERATE_WHEN_COMMENT + = "energy_value.regenerate_values_when.comment"; private static final String ENERGY_VALUE_REGENERATE_WHEN_DEFAULT = "As Needed"; - private static final String[] ENERGY_VALUE_REGENERATE_WHEN_OPTIONS = new String[]{"As Needed", "Always"}; + private static final String[] ENERGY_VALUE_REGENERATE_WHEN_OPTIONS + = new String[] { "As Needed", "Always" }; public static boolean energyValueDebugLoggingEnabled; - private static final String ENERGY_VALUE_DEBUG_LOGGING_ENABLED_NAME = "debug_logging_enabled"; - private static final String ENERGY_VALUE_DEBUG_LOGGING_ENABLED_LABEL = "energy_value.debug_logging_enabled.label"; - private static final String ENERGY_VALUE_DEBUG_LOGGING_ENABLED_COMMENT = "energy_value.debug_logging_enabled.comment"; + private static final String ENERGY_VALUE_DEBUG_LOGGING_ENABLED_NAME + = "debug_logging_enabled"; + private static final String ENERGY_VALUE_DEBUG_LOGGING_ENABLED_LABEL + = "energy_value.debug_logging_enabled.label"; + private static final String ENERGY_VALUE_DEBUG_LOGGING_ENABLED_COMMENT + = "energy_value.debug_logging_enabled.comment"; private static final boolean ENERGY_VALUE_DEBUG_LOGGING_ENABLED_DEFAULT = false; public static String soundMode; @@ -108,12 +123,15 @@ public class ConfigurationHandler { private static final String SOUND_MODE_LABEL = "sound.mode.label"; private static final String SOUND_MODE_COMMENT = "sound.mode.comment"; private static final String SOUND_MODE_DEFAULT = "All"; - private static final String[] SOUND_MODE_OPTIONS = new String[]{"All", "Self", "None"}; + private static final String[] SOUND_MODE_OPTIONS + = new String[] { "All", "Self", "None" }; public static boolean playerKnowledgeTemplateEnabled; private static final String USE_PLAYER_KNOWLEDGE_TEMPLATE_NAME = "use_template"; - private static final String USE_PLAYER_KNOWLEDGE_TEMPLATE_LABEL = "player_knowledge.use_template.label"; - private static final String USE_PLAYER_KNOWLEDGE_TEMPLATE_COMMENT = "player_knowledge.use_template.comment"; + private static final String USE_PLAYER_KNOWLEDGE_TEMPLATE_LABEL + = "player_knowledge.use_template.label"; + private static final String USE_PLAYER_KNOWLEDGE_TEMPLATE_COMMENT + = "player_knowledge.use_template.comment"; private static final boolean USE_PLAYER_KNOWLEDGE_TEMPLATE_DEFAULT = true; } } diff --git a/src/main/java/com/pahimar/ee3/handler/CraftingHandler.java b/src/main/java/com/pahimar/ee3/handler/CraftingHandler.java index 72a36643..7b7b174e 100644 --- a/src/main/java/com/pahimar/ee3/handler/CraftingHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/CraftingHandler.java @@ -7,8 +7,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; import net.minecraft.item.crafting.CraftingManager; -public class CraftingHandler -{ +public class CraftingHandler { public static void init() { // Add in the ability to dye Alchemical Bags CraftingManager.getInstance().getRecipeList().add(new RecipesAlchemicalBagDyes()); diff --git a/src/main/java/com/pahimar/ee3/handler/DrawBlockHighlightHandler.java b/src/main/java/com/pahimar/ee3/handler/DrawBlockHighlightHandler.java index 6df259ac..233b8d6a 100644 --- a/src/main/java/com/pahimar/ee3/handler/DrawBlockHighlightHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/DrawBlockHighlightHandler.java @@ -2,7 +2,6 @@ package com.pahimar.ee3.handler; import com.pahimar.ee3.item.ITransmutationStone; import com.pahimar.ee3.util.TransmutationHelper; - import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; @@ -15,40 +14,45 @@ import net.minecraftforge.client.event.DrawBlockHighlightEvent; public class DrawBlockHighlightHandler { private static int pulse; private static boolean doInc; - + @SubscribeEvent public void onDrawBlockHighlightEvent(final DrawBlockHighlightEvent event) { final Minecraft minecraft = FMLClientHandler.instance().getClient(); - if (event.currentItem != null && event.currentItem.getItem() instanceof ITransmutationStone && event.target.typeOfHit == MovingObjectType.BLOCK) { - TransmutationHelper.updateTargetBlock(event.player.worldObj, event.target.blockX, event.target.blockY, event.target.blockZ); - /*if (Minecraft.isGuiEnabled() && minecraft.inGameHasFocus && ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION) { + if (event.currentItem != null + && event.currentItem.getItem() instanceof ITransmutationStone + && event.target.typeOfHit == MovingObjectType.BLOCK) { + TransmutationHelper.updateTargetBlock( + event.player.worldObj, + event.target.blockX, + event.target.blockY, + event.target.blockZ + ); + /*if (Minecraft.isGuiEnabled() && minecraft.inGameHasFocus && + ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION) { this.drawInWorldTransmutationOverlay(event); }*/ } } - + /*public void drawInWorldTransmutationOverlay(final DrawBlockHighlightEvent event) { final double x = event.target.blockX + 0.5f; final double y = event.target.blockY + 0.5f; final double z = event.target.blockZ + 0.5f; - final double iPX = ((Entity)event.player).prevPosX + (((Entity)event.player).posX - ((Entity)event.player).prevPosX) * event.partialTicks; - final double iPY = ((Entity)event.player).prevPosY + (((Entity)event.player).posY - ((Entity)event.player).prevPosY) * event.partialTicks; - final double iPZ = ((Entity)event.player).prevPosZ + (((Entity)event.player).posZ - ((Entity)event.player).prevPosZ) * event.partialTicks; - final int texture = event.context.renderEngine.func_78341_b("/mods/ee3/textures/effects/noise.png"); - float xScale = 1.0f; - float yScale = 1.0f; - float zScale = 1.0f; - float xShift = 0.1f; - float yShift = 0.1f; - float zShift = 0.1f; - int itemChargeLevel = 0; - if (event.currentItem.getItem() instanceof IChargeable) { - itemChargeLevel = ((IChargeable)event.currentItem.getItem()).getCharge(event.currentItem); + final double iPX = ((Entity)event.player).prevPosX + (((Entity)event.player).posX + - ((Entity)event.player).prevPosX) * event.partialTicks; final double iPY = + ((Entity)event.player).prevPosY + (((Entity)event.player).posY - + ((Entity)event.player).prevPosY) * event.partialTicks; final double iPZ = + ((Entity)event.player).prevPosZ + (((Entity)event.player).posZ - + ((Entity)event.player).prevPosZ) * event.partialTicks; final int texture = + event.context.renderEngine.func_78341_b("/mods/ee3/textures/effects/noise.png"); float + xScale = 1.0f; float yScale = 1.0f; float zScale = 1.0f; float xShift = 0.1f; float + yShift = 0.1f; float zShift = 0.1f; int itemChargeLevel = 0; if + (event.currentItem.getItem() instanceof IChargeable) { itemChargeLevel = + ((IChargeable)event.currentItem.getItem()).getCharge(event.currentItem); } final int chargeLevel = 1 + itemChargeLevel * 2; - final ForgeDirection sideHit = ForgeDirection.getOrientation(event.target.sideHit); - switch (sideHit) { - case UP: { + final ForgeDirection sideHit = + ForgeDirection.getOrientation(event.target.sideHit); switch (sideHit) { case UP: { xScale = chargeLevel + 0.1f; zScale = chargeLevel + 0.1f; xShift = 0.0f; @@ -102,8 +106,8 @@ public class DrawBlockHighlightHandler { GL11.glPushMatrix(); GL11.glTranslated(-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift); GL11.glScalef(1.0f * xScale, 1.0f * yScale, 1.0f * zScale); - GL11.glRotatef(90.0f, (float)forgeDir.offsetX, (float)forgeDir.offsetY, (float)forgeDir.offsetZ); - GL11.glTranslated(0.0, 0.0, (double)(0.5f * zCorrection)); + GL11.glRotatef(90.0f, (float)forgeDir.offsetX, (float)forgeDir.offsetY, + (float)forgeDir.offsetZ); GL11.glTranslated(0.0, 0.0, (double)(0.5f * zCorrection)); GL11.glClear(256); renderPulsingQuad(texture, 0.75f); GL11.glPopMatrix(); @@ -111,7 +115,7 @@ public class DrawBlockHighlightHandler { GL11.glEnable(2884); GL11.glDepthMask(true); } - + public static void renderPulsingQuad(final int texture, final float maxTransparency) { final float pulseTransparency = getPulseValue() * maxTransparency / 3000.0f; GL11.glBindTexture(3553, texture); @@ -130,7 +134,7 @@ public class DrawBlockHighlightHandler { GL11.glDisable(3042); GL11.glDisable(32826); } - + private static int getPulseValue() { if (DrawBlockHighlightHandler.doInc) { DrawBlockHighlightHandler.pulse += 8; @@ -146,7 +150,7 @@ public class DrawBlockHighlightHandler { } return DrawBlockHighlightHandler.pulse; }*/ - + static { DrawBlockHighlightHandler.pulse = 0; DrawBlockHighlightHandler.doInc = true; diff --git a/src/main/java/com/pahimar/ee3/handler/EntityLivingHandler.java b/src/main/java/com/pahimar/ee3/handler/EntityLivingHandler.java index 4e8ab5a2..34e16fd5 100644 --- a/src/main/java/com/pahimar/ee3/handler/EntityLivingHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/EntityLivingHandler.java @@ -1,22 +1,28 @@ package com.pahimar.ee3.handler; import com.pahimar.ee3.util.ItemUtil; - import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraftforge.event.entity.living.LivingDeathEvent; public class EntityLivingHandler { - @SubscribeEvent public void onEntityLivingDeath(LivingDeathEvent event) { if (event.source.getDamageType().equals("player")) { - ItemUtil.dropMiniumShard((EntityPlayer)event.source.getSourceOfDamage(), event.entityLiving); - } - if (event.source.getSourceOfDamage() instanceof EntityArrow && ((EntityArrow)event.source.getSourceOfDamage()).shootingEntity != null && ((EntityArrow)event.source.getSourceOfDamage()).shootingEntity instanceof EntityPlayer) { - ItemUtil.dropMiniumShard((EntityPlayer)((EntityArrow)event.source.getSourceOfDamage()).shootingEntity, event.entityLiving); + ItemUtil.dropMiniumShard( + (EntityPlayer) event.source.getSourceOfDamage(), event.entityLiving + ); } - } - + if (event.source.getSourceOfDamage() instanceof EntityArrow + && ((EntityArrow) event.source.getSourceOfDamage()).shootingEntity != null + && ((EntityArrow) event.source.getSourceOfDamage()).shootingEntity + instanceof EntityPlayer) { + ItemUtil.dropMiniumShard( + (EntityPlayer) ((EntityArrow) event.source.getSourceOfDamage()) + .shootingEntity, + event.entityLiving + ); + } + } } diff --git a/src/main/java/com/pahimar/ee3/handler/EquivalencyHandler.java b/src/main/java/com/pahimar/ee3/handler/EquivalencyHandler.java index c5e9d928..d3878315 100644 --- a/src/main/java/com/pahimar/ee3/handler/EquivalencyHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/EquivalencyHandler.java @@ -4,25 +4,22 @@ import java.util.ArrayList; import com.pahimar.ee3.util.ItemStackUtils; import com.pahimar.ee3.util.LogHelper; - -import org.apache.logging.log4j.Level; - import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import org.apache.logging.log4j.Level; -public class EquivalencyHandler -{ +public class EquivalencyHandler { private static final EquivalencyHandler instance; private static ArrayList> equivalencyList; - + public static EquivalencyHandler instance() { return EquivalencyHandler.instance; } - + public ArrayList> getAllLists() { return EquivalencyHandler.equivalencyList; } - + public void addObjects(final Object obj1, final Object obj2) { final ItemStack stack1 = ItemStackUtils.convertObjectToItemStack(obj1); final ItemStack stack2 = ItemStackUtils.convertObjectToItemStack(obj2); @@ -36,19 +33,17 @@ public class EquivalencyHandler currentList = EquivalencyHandler.equivalencyList.get(stack1Index); currentList.add(stack2); EquivalencyHandler.equivalencyList.set(stack1Index, currentList); - } - else if (stack1Index == null && stack2Index != null) { + } else if (stack1Index == null && stack2Index != null) { currentList = EquivalencyHandler.equivalencyList.get(stack2Index); currentList.add(stack1); EquivalencyHandler.equivalencyList.set(stack2Index, currentList); - } - else if (stack1Index == null && stack2Index == null) { + } else if (stack1Index == null && stack2Index == null) { currentList.add(stack1); currentList.add(stack2); EquivalencyHandler.equivalencyList.add(currentList); } } - + public void addObjects(final Object... objList) { if (objList.length < 2) { return; @@ -57,11 +52,12 @@ public class EquivalencyHandler this.addObjects(objList[i], objList[i + 1]); } } - + public Integer getIndexInList(final Object obj) { final ItemStack checkStack = ItemStackUtils.convertObjectToItemStack(obj); for (int i = 0; i < EquivalencyHandler.equivalencyList.size(); ++i) { - final ArrayList currentList = EquivalencyHandler.equivalencyList.get(i); + final ArrayList currentList + = EquivalencyHandler.equivalencyList.get(i); for (final ItemStack currentStack : currentList) { if (ItemStack.areItemStacksEqual(checkStack, currentStack)) { return new Integer(i); @@ -70,19 +66,21 @@ public class EquivalencyHandler } return null; } - + public Integer getIndexInList(final Item id, final int meta) { for (int i = 0; i < EquivalencyHandler.equivalencyList.size(); ++i) { - final ArrayList currentList = EquivalencyHandler.equivalencyList.get(i); + final ArrayList currentList + = EquivalencyHandler.equivalencyList.get(i); for (final ItemStack currentStack : currentList) { - if (id == currentStack.getItem() && meta == currentStack.getItemDamage()) { + if (id == currentStack.getItem() + && meta == currentStack.getItemDamage()) { return new Integer(i); } } } return null; } - + public ArrayList getEquivalencyList(final Object obj) { final ItemStack checkStack = ItemStackUtils.convertObjectToItemStack(obj); if (checkStack == null) { @@ -97,18 +95,19 @@ public class EquivalencyHandler } return null; } - + public ArrayList getEquivalencyList(final Item id, final int meta) { for (final ArrayList list : EquivalencyHandler.equivalencyList) { for (final ItemStack currentStack : list) { - if (id == currentStack.getItem() && meta == currentStack.getItemDamage()) { + if (id == currentStack.getItem() + && meta == currentStack.getItemDamage()) { return list; } } } return null; } - + public ItemStack getNextInList(final Object obj) { final ItemStack checkStack = ItemStackUtils.convertObjectToItemStack(obj); if (checkStack != null) { @@ -116,7 +115,7 @@ public class EquivalencyHandler } return null; } - + public ItemStack getNextInList(final Item id, final int meta) { final ArrayList list = this.getEquivalencyList(id, meta); ItemStack returnStack = null; @@ -127,7 +126,8 @@ public class EquivalencyHandler } while (i < list.size()) { final ItemStack currentStack = list.get(i); - if (id == currentStack.getItem() && meta == currentStack.getItemDamage()) { + if (id == currentStack.getItem() + && meta == currentStack.getItemDamage()) { returnStack = list.get((i + 1) % list.size()); break; } @@ -136,7 +136,7 @@ public class EquivalencyHandler } return returnStack; } - + public ItemStack getPrevInList(final Object obj) { final ItemStack checkStack = ItemStackUtils.convertObjectToItemStack(obj); if (checkStack != null) { @@ -144,7 +144,7 @@ public class EquivalencyHandler } return null; } - + public ItemStack getPrevInList(final Item id, final int meta) { final ArrayList list = this.getEquivalencyList(id, meta); ItemStack returnStack = null; @@ -155,7 +155,8 @@ public class EquivalencyHandler } while (i < list.size()) { final ItemStack currentStack = list.get(i); - if (id == currentStack.getItem() && meta == currentStack.getItemDamage()) { + if (id == currentStack.getItem() + && meta == currentStack.getItemDamage()) { final int index = (i - 1 + list.size()) % list.size(); returnStack = list.get(index); break; @@ -165,20 +166,35 @@ public class EquivalencyHandler } return returnStack; } - + public boolean areEquivalent(final Object obj1, final Object obj2) { - return this.getEquivalencyList(obj1) != null && this.getEquivalencyList(obj2) != null && ((ItemStackUtils.convertObjectToItemStack(obj1).getItem() == ItemStackUtils.convertObjectToItemStack(obj2).getItem() && ItemStackUtils.convertObjectToItemStack(obj1).getItemDamage() == ItemStackUtils.convertObjectToItemStack(obj2).getItemDamage()) || this.getEquivalencyList(obj1).equals(this.getEquivalencyList(obj2))); + return this.getEquivalencyList(obj1) != null + && this.getEquivalencyList(obj2) != null + && ((ItemStackUtils.convertObjectToItemStack(obj1).getItem() + == ItemStackUtils.convertObjectToItemStack(obj2).getItem() + && ItemStackUtils.convertObjectToItemStack(obj1).getItemDamage() + == ItemStackUtils.convertObjectToItemStack(obj2).getItemDamage()) + || this.getEquivalencyList(obj1).equals(this.getEquivalencyList(obj2))); } - + public boolean areWorldEquivalent(final Object obj1, final Object obj2) { final ItemStack first = ItemStackUtils.convertObjectToItemStack(obj1); if (first == null) { return false; } final ItemStack second = ItemStackUtils.convertObjectToItemStack(obj2); - return second != null && (this.getEquivalencyList(first.getItem(), first.getItemDamage()) != null && this.getEquivalencyList(second.getItem(), second.getItemDamage()) != null) && ((first.getItem() == second.getItem() && first.getItemDamage() == second.getItemDamage()) || this.getEquivalencyList(first.getItem(), first.getItemDamage()).equals(this.getEquivalencyList(second.getItem(), second.getItemDamage()))); + return second != null + && (this.getEquivalencyList(first.getItem(), first.getItemDamage()) != null + && this.getEquivalencyList(second.getItem(), second.getItemDamage()) + != null) + && ((first.getItem() == second.getItem() + && first.getItemDamage() == second.getItemDamage()) + || this.getEquivalencyList(first.getItem(), first.getItemDamage()) + .equals(this.getEquivalencyList( + second.getItem(), second.getItemDamage() + ))); } - + public void debug() { int i = 0; for (final ArrayList list : EquivalencyHandler.equivalencyList) { @@ -186,7 +202,7 @@ public class EquivalencyHandler ++i; } } - + static { instance = new EquivalencyHandler(); EquivalencyHandler.equivalencyList = new ArrayList(); diff --git a/src/main/java/com/pahimar/ee3/handler/FuelHandler.java b/src/main/java/com/pahimar/ee3/handler/FuelHandler.java index 72c1a8b6..eef882bb 100644 --- a/src/main/java/com/pahimar/ee3/handler/FuelHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/FuelHandler.java @@ -9,46 +9,37 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntityFurnace; -public class FuelHandler implements IFuelHandler -{ - private static final ItemStack ALCHEMICAL_COAL = new ItemStack(ModItems.alchemicalFuel, 1, 0); - private static final ItemStack MOBIUS_FUEL = new ItemStack(ModItems.alchemicalFuel, 1, 1); - private static final ItemStack AETERNALIS_FUEL = new ItemStack(ModItems.alchemicalFuel, 1, 2); +public class FuelHandler implements IFuelHandler { + private static final ItemStack ALCHEMICAL_COAL + = new ItemStack(ModItems.alchemicalFuel, 1, 0); + private static final ItemStack MOBIUS_FUEL + = new ItemStack(ModItems.alchemicalFuel, 1, 1); + private static final ItemStack AETERNALIS_FUEL + = new ItemStack(ModItems.alchemicalFuel, 1, 2); - private static final ItemStack ALCHEMICAL_COAL_BLOCK = new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 0); - private static final ItemStack MOBIUS_FUEL_BLOCK = new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 1); - private static final ItemStack AETERNALIS_FUEL_BLOCK = new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 2); + private static final ItemStack ALCHEMICAL_COAL_BLOCK + = new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 0); + private static final ItemStack MOBIUS_FUEL_BLOCK + = new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 1); + private static final ItemStack AETERNALIS_FUEL_BLOCK + = new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 2); @Override - public int getBurnTime(ItemStack fuel) - { - if (fuel.getItem() instanceof ItemAlchemicalFuel) - { - if (fuel.getItemDamage() == ALCHEMICAL_COAL.getItemDamage()) - { + public int getBurnTime(ItemStack fuel) { + if (fuel.getItem() instanceof ItemAlchemicalFuel) { + if (fuel.getItemDamage() == ALCHEMICAL_COAL.getItemDamage()) { return 8 * TileEntityFurnace.getItemBurnTime(new ItemStack(Items.coal)); - } - else if (fuel.getItemDamage() == MOBIUS_FUEL.getItemDamage()) - { + } else if (fuel.getItemDamage() == MOBIUS_FUEL.getItemDamage()) { return 8 * getBurnTime(ALCHEMICAL_COAL); - } - else if (fuel.getItemDamage() == AETERNALIS_FUEL.getItemDamage()) - { + } else if (fuel.getItemDamage() == AETERNALIS_FUEL.getItemDamage()) { return 8 * getBurnTime(MOBIUS_FUEL); } - } - else if (fuel.getItem() instanceof ItemBlockAlchemicalFuel) - { - if (fuel.getItemDamage() == ALCHEMICAL_COAL_BLOCK.getItemDamage()) - { + } else if (fuel.getItem() instanceof ItemBlockAlchemicalFuel) { + if (fuel.getItemDamage() == ALCHEMICAL_COAL_BLOCK.getItemDamage()) { return 9 * getBurnTime(ALCHEMICAL_COAL); - } - else if (fuel.getItemDamage() == MOBIUS_FUEL_BLOCK.getItemDamage()) - { + } else if (fuel.getItemDamage() == MOBIUS_FUEL_BLOCK.getItemDamage()) { return 9 * getBurnTime(MOBIUS_FUEL); - } - else if (fuel.getItemDamage() == AETERNALIS_FUEL_BLOCK.getItemDamage()) - { + } else if (fuel.getItemDamage() == AETERNALIS_FUEL_BLOCK.getItemDamage()) { return 9 * getBurnTime(AETERNALIS_FUEL); } } diff --git a/src/main/java/com/pahimar/ee3/handler/GuiHandler.java b/src/main/java/com/pahimar/ee3/handler/GuiHandler.java index 73ae87b6..f69a7d80 100644 --- a/src/main/java/com/pahimar/ee3/handler/GuiHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/GuiHandler.java @@ -8,63 +8,58 @@ import cpw.mods.fml.common.network.IGuiHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; -public class GuiHandler implements IGuiHandler -{ +public class GuiHandler implements IGuiHandler { @Override - public Object getServerGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z) - { + public Object getServerGuiElement( + int id, EntityPlayer entityPlayer, World world, int x, int y, int z + ) { if (id == GUIs.PORTABLE_CRAFTING.ordinal()) { return new ContainerPortableCrafting(entityPlayer.inventory, world, x, y, z); - } - else if (id == GUIs.ALCHEMICAL_CHEST.ordinal()) - { - TileEntityAlchemicalChest tileEntityAlchemicalChest = (TileEntityAlchemicalChest) world.getTileEntity(x, y, z); - return new ContainerAlchemicalChest(entityPlayer.inventory, tileEntityAlchemicalChest); - } - else if (id == GUIs.GLASS_BELL.ordinal()) - { - TileEntityGlassBell tileEntityGlassBell = (TileEntityGlassBell) world.getTileEntity(x, y, z); + } else if (id == GUIs.ALCHEMICAL_CHEST.ordinal()) { + TileEntityAlchemicalChest tileEntityAlchemicalChest + = (TileEntityAlchemicalChest) world.getTileEntity(x, y, z); + return new ContainerAlchemicalChest( + entityPlayer.inventory, tileEntityAlchemicalChest + ); + } else if (id == GUIs.GLASS_BELL.ordinal()) { + TileEntityGlassBell tileEntityGlassBell + = (TileEntityGlassBell) world.getTileEntity(x, y, z); return new ContainerGlassBell(entityPlayer.inventory, tileEntityGlassBell); - } - else if (id == GUIs.ALCHEMICAL_BAG.ordinal()) - { - return new ContainerAlchemicalBag(entityPlayer, new InventoryAlchemicalBag(entityPlayer.getHeldItem())); - } - else if (id == GUIs.ALCHENOMICON.ordinal()) - { + } else if (id == GUIs.ALCHEMICAL_BAG.ordinal()) { + return new ContainerAlchemicalBag( + entityPlayer, new InventoryAlchemicalBag(entityPlayer.getHeldItem()) + ); + } else if (id == GUIs.ALCHENOMICON.ordinal()) { return new ContainerAlchenomicon(entityPlayer, entityPlayer.getHeldItem()); - } - else if (id == GUIs.CALCINATOR.ordinal()) - { - TileEntityCalcinator tileEntityCalcinator = (TileEntityCalcinator) world.getTileEntity(x, y, z); + } else if (id == GUIs.CALCINATOR.ordinal()) { + TileEntityCalcinator tileEntityCalcinator + = (TileEntityCalcinator) world.getTileEntity(x, y, z); return new ContainerCalcinator(entityPlayer.inventory, tileEntityCalcinator); - } - else if (id == GUIs.ALUDEL.ordinal()) - { - TileEntityAludel tileEntityAludel = (TileEntityAludel) world.getTileEntity(x, y, z); + } else if (id == GUIs.ALUDEL.ordinal()) { + TileEntityAludel tileEntityAludel + = (TileEntityAludel) world.getTileEntity(x, y, z); return new ContainerAludel(entityPlayer.inventory, tileEntityAludel); - } - else if (id == GUIs.RESEARCH_STATION.ordinal()) - { - TileEntityResearchStation tileEntityResearchStation = (TileEntityResearchStation) world.getTileEntity(x, y, z); - return new ContainerResearchStation(entityPlayer.inventory, tileEntityResearchStation); - } - else if (id == GUIs.TRANSMUTATION_TABLET.ordinal()) - { - TileEntityTransmutationTablet tileEntityTransmutationTablet = (TileEntityTransmutationTablet) world.getTileEntity(x, y, z); - return new ContainerTransmutationTablet(entityPlayer.inventory, tileEntityTransmutationTablet); - } - else if (id == GUIs.TRANSMUTATION_ARRAY.ordinal()) - { - TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(x, y, z); - return new ContainerTransmutationArray(entityPlayer.inventory, tileEntityAlchemyArray); - } - else if (id == GUIs.SYMBOL_SELECTION.ordinal()) - { + } else if (id == GUIs.RESEARCH_STATION.ordinal()) { + TileEntityResearchStation tileEntityResearchStation + = (TileEntityResearchStation) world.getTileEntity(x, y, z); + return new ContainerResearchStation( + entityPlayer.inventory, tileEntityResearchStation + ); + } else if (id == GUIs.TRANSMUTATION_TABLET.ordinal()) { + TileEntityTransmutationTablet tileEntityTransmutationTablet + = (TileEntityTransmutationTablet) world.getTileEntity(x, y, z); + return new ContainerTransmutationTablet( + entityPlayer.inventory, tileEntityTransmutationTablet + ); + } else if (id == GUIs.TRANSMUTATION_ARRAY.ordinal()) { + TileEntityAlchemyArray tileEntityAlchemyArray + = (TileEntityAlchemyArray) world.getTileEntity(x, y, z); + return new ContainerTransmutationArray( + entityPlayer.inventory, tileEntityAlchemyArray + ); + } else if (id == GUIs.SYMBOL_SELECTION.ordinal()) { return new ContainerSymbolSelection(); - } - else if (id == GUIs.ADMIN_PANEL.ordinal()) - { + } else if (id == GUIs.ADMIN_PANEL.ordinal()) { return new ContainerAdminPanel(entityPlayer.inventory); } @@ -72,60 +67,58 @@ public class GuiHandler implements IGuiHandler } @Override - public Object getClientGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z) - { + public Object getClientGuiElement( + int id, EntityPlayer entityPlayer, World world, int x, int y, int z + ) { if (id == GUIs.PORTABLE_CRAFTING.ordinal()) { return new GuiPortableCrafting(entityPlayer, world, x, y, z); - } - else if (id == GUIs.ALCHEMICAL_CHEST.ordinal()) - { - TileEntityAlchemicalChest tileEntityAlchemicalChest = (TileEntityAlchemicalChest) world.getTileEntity(x, y, z); - return new GuiAlchemicalChest(entityPlayer.inventory, tileEntityAlchemicalChest); - } - else if (id == GUIs.GLASS_BELL.ordinal()) - { - TileEntityGlassBell tileEntityGlassBell = (TileEntityGlassBell) world.getTileEntity(x, y, z); + } else if (id == GUIs.ALCHEMICAL_CHEST.ordinal()) { + TileEntityAlchemicalChest tileEntityAlchemicalChest + = (TileEntityAlchemicalChest) world.getTileEntity(x, y, z); + return new GuiAlchemicalChest( + entityPlayer.inventory, tileEntityAlchemicalChest + ); + } else if (id == GUIs.GLASS_BELL.ordinal()) { + TileEntityGlassBell tileEntityGlassBell + = (TileEntityGlassBell) world.getTileEntity(x, y, z); return new GuiGlassBell(entityPlayer.inventory, tileEntityGlassBell); - } - else if (id == GUIs.ALCHEMICAL_BAG.ordinal()) - { - return new GuiAlchemicalBag(entityPlayer, new InventoryAlchemicalBag(entityPlayer.getHeldItem())); - } - else if (id == GUIs.ALCHENOMICON.ordinal()) - { - return new GuiAlchenomicon(entityPlayer.inventory, entityPlayer.getHeldItem()); - } - else if (id == GUIs.CALCINATOR.ordinal()) - { - TileEntityCalcinator tileEntityCalcinator = (TileEntityCalcinator) world.getTileEntity(x, y, z); + } else if (id == GUIs.ALCHEMICAL_BAG.ordinal()) { + return new GuiAlchemicalBag( + entityPlayer, new InventoryAlchemicalBag(entityPlayer.getHeldItem()) + ); + } else if (id == GUIs.ALCHENOMICON.ordinal()) { + return new GuiAlchenomicon( + entityPlayer.inventory, entityPlayer.getHeldItem() + ); + } else if (id == GUIs.CALCINATOR.ordinal()) { + TileEntityCalcinator tileEntityCalcinator + = (TileEntityCalcinator) world.getTileEntity(x, y, z); return new GuiCalcinator(entityPlayer.inventory, tileEntityCalcinator); - } - else if (id == GUIs.ALUDEL.ordinal()) - { - TileEntityAludel tileEntityAludel = (TileEntityAludel) world.getTileEntity(x, y, z); + } else if (id == GUIs.ALUDEL.ordinal()) { + TileEntityAludel tileEntityAludel + = (TileEntityAludel) world.getTileEntity(x, y, z); return new GuiAludel(entityPlayer.inventory, tileEntityAludel); - } - else if (id == GUIs.RESEARCH_STATION.ordinal()) - { - TileEntityResearchStation tileEntityResearchStation = (TileEntityResearchStation) world.getTileEntity(x, y, z); - return new GuiResearchStation(entityPlayer.inventory, tileEntityResearchStation); - } - else if (id == GUIs.TRANSMUTATION_TABLET.ordinal()) - { - TileEntityTransmutationTablet tileEntityTransmutationTablet = (TileEntityTransmutationTablet) world.getTileEntity(x, y, z); - return new GuiTransmutationTablet(entityPlayer.inventory, tileEntityTransmutationTablet); - } - else if (id == GUIs.TRANSMUTATION_ARRAY.ordinal()) - { - TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(x, y, z); - return new GuiTransmutationArray(entityPlayer.inventory, tileEntityAlchemyArray); - } - else if (id == GUIs.SYMBOL_SELECTION.ordinal()) - { + } else if (id == GUIs.RESEARCH_STATION.ordinal()) { + TileEntityResearchStation tileEntityResearchStation + = (TileEntityResearchStation) world.getTileEntity(x, y, z); + return new GuiResearchStation( + entityPlayer.inventory, tileEntityResearchStation + ); + } else if (id == GUIs.TRANSMUTATION_TABLET.ordinal()) { + TileEntityTransmutationTablet tileEntityTransmutationTablet + = (TileEntityTransmutationTablet) world.getTileEntity(x, y, z); + return new GuiTransmutationTablet( + entityPlayer.inventory, tileEntityTransmutationTablet + ); + } else if (id == GUIs.TRANSMUTATION_ARRAY.ordinal()) { + TileEntityAlchemyArray tileEntityAlchemyArray + = (TileEntityAlchemyArray) world.getTileEntity(x, y, z); + return new GuiTransmutationArray( + entityPlayer.inventory, tileEntityAlchemyArray + ); + } else if (id == GUIs.SYMBOL_SELECTION.ordinal()) { return new GuiSymbolSelection(); - } - else if (id == GUIs.ADMIN_PANEL.ordinal()) - { + } else if (id == GUIs.ADMIN_PANEL.ordinal()) { return new GuiAdminPanel(entityPlayer.inventory); } diff --git a/src/main/java/com/pahimar/ee3/handler/ItemEventHandler.java b/src/main/java/com/pahimar/ee3/handler/ItemEventHandler.java index 0ec74502..177e429e 100644 --- a/src/main/java/com/pahimar/ee3/handler/ItemEventHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/ItemEventHandler.java @@ -9,19 +9,17 @@ import net.minecraftforge.event.entity.item.ItemTossEvent; import net.minecraftforge.event.entity.player.EntityItemPickupEvent; import net.minecraftforge.event.entity.player.PlayerDropsEvent; -public class ItemEventHandler -{ +public class ItemEventHandler { @SubscribeEvent - public void onItemTossEvent(ItemTossEvent itemTossEvent) - { + public void onItemTossEvent(ItemTossEvent itemTossEvent) { NBTHelper.clearStatefulNBTTags(itemTossEvent.entityItem.getEntityItem()); //Close the Alchemical Bag GUI when the Alchemical bag is tossed - if (itemTossEvent.player.openContainer instanceof ContainerAlchemicalBag) - { - if (((ContainerAlchemicalBag) itemTossEvent.player.openContainer).isItemStackParent(itemTossEvent.entityItem.getEntityItem())) - { - //We have to remove the itemstack we are throwing from the inventory now to prevent a loop (will also happen after this event has been fired) + if (itemTossEvent.player.openContainer instanceof ContainerAlchemicalBag) { + if (((ContainerAlchemicalBag) itemTossEvent.player.openContainer) + .isItemStackParent(itemTossEvent.entityItem.getEntityItem())) { + //We have to remove the itemstack we are throwing from the inventory now + //to prevent a loop (will also happen after this event has been fired) itemTossEvent.player.inventory.setItemStack(null); itemTossEvent.player.closeScreen(); } @@ -29,22 +27,18 @@ public class ItemEventHandler } @SubscribeEvent - public void onItemPickupEvent(PlayerEvent.ItemPickupEvent itemPickupEvent) - { + public void onItemPickupEvent(PlayerEvent.ItemPickupEvent itemPickupEvent) { NBTHelper.clearStatefulNBTTags(itemPickupEvent.pickedUp.getEntityItem()); } @SubscribeEvent - public void onEntityItemPickupEvent(EntityItemPickupEvent entityItemPickupEvent) - { + public void onEntityItemPickupEvent(EntityItemPickupEvent entityItemPickupEvent) { NBTHelper.clearStatefulNBTTags(entityItemPickupEvent.item.getEntityItem()); } @SubscribeEvent - public void onPlayerDropsEvent(PlayerDropsEvent playerDropsEvent) - { - for (EntityItem entityItem : playerDropsEvent.drops) - { + public void onPlayerDropsEvent(PlayerDropsEvent playerDropsEvent) { + for (EntityItem entityItem : playerDropsEvent.drops) { NBTHelper.clearStatefulNBTTags(entityItem.getEntityItem()); } } diff --git a/src/main/java/com/pahimar/ee3/handler/PlayerEventHandler.java b/src/main/java/com/pahimar/ee3/handler/PlayerEventHandler.java index 5ef20221..f00691d7 100644 --- a/src/main/java/com/pahimar/ee3/handler/PlayerEventHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/PlayerEventHandler.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.handler; +import static com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy.Blacklist; + import com.pahimar.ee3.network.PacketHandler; import com.pahimar.ee3.network.message.MessageChalkSettings; import com.pahimar.ee3.network.message.MessageSyncBlacklist; @@ -10,26 +12,35 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; -import static com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy.Blacklist; - public class PlayerEventHandler { - @SubscribeEvent - public void onPlayerLoggedIn(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent event) { - + public void + onPlayerLoggedIn(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent event + ) { if (event.player != null) { - NBTTagCompound playerCustomData = EntityHelper.getCustomEntityData(event.player); + NBTTagCompound playerCustomData + = EntityHelper.getCustomEntityData(event.player); // Chalk Settings ChalkSettings chalkSettings = new ChalkSettings(); chalkSettings.readFromNBT(playerCustomData); chalkSettings.writeToNBT(playerCustomData); EntityHelper.saveCustomEntityData(event.player, playerCustomData); - PacketHandler.INSTANCE.sendTo(new MessageChalkSettings(chalkSettings), (EntityPlayerMP) event.player); + PacketHandler.INSTANCE.sendTo( + new MessageChalkSettings(chalkSettings), (EntityPlayerMP) event.player + ); - PacketHandler.INSTANCE.sendTo(new MessageSyncEnergyValues(), (EntityPlayerMP) event.player); - PacketHandler.INSTANCE.sendTo(new MessageSyncBlacklist(Blacklist.KNOWLEDGE), (EntityPlayerMP) event.player); - PacketHandler.INSTANCE.sendTo(new MessageSyncBlacklist(Blacklist.EXCHANGE), (EntityPlayerMP) event.player); + PacketHandler.INSTANCE.sendTo( + new MessageSyncEnergyValues(), (EntityPlayerMP) event.player + ); + PacketHandler.INSTANCE.sendTo( + new MessageSyncBlacklist(Blacklist.KNOWLEDGE), + (EntityPlayerMP) event.player + ); + PacketHandler.INSTANCE.sendTo( + new MessageSyncBlacklist(Blacklist.EXCHANGE), + (EntityPlayerMP) event.player + ); } } } diff --git a/src/main/java/com/pahimar/ee3/handler/WorldEventHandler.java b/src/main/java/com/pahimar/ee3/handler/WorldEventHandler.java index ba510b0d..1b465463 100644 --- a/src/main/java/com/pahimar/ee3/handler/WorldEventHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/WorldEventHandler.java @@ -11,25 +11,29 @@ import cpw.mods.fml.relauncher.Side; import net.minecraftforge.event.world.WorldEvent; public class WorldEventHandler { - public static boolean hasInitilialized = false; @SubscribeEvent public void onWorldLoadEvent(WorldEvent.Load event) { - - if (!hasInitilialized && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { - + if (!hasInitilialized + && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { RecipeRegistry.INSTANCE.registerVanillaRecipes(); AludelRecipeManager.registerRecipes(); long startTime = System.nanoTime(); - if (ConfigurationHandler.Settings.regenerateEnergyValuesWhen.equalsIgnoreCase("As Needed")) { + if (ConfigurationHandler.Settings.regenerateEnergyValuesWhen.equalsIgnoreCase( + "As Needed" + )) { EnergyValueRegistry.INSTANCE.load(); - } - else { + } else { EnergyValueRegistry.INSTANCE.compute(); } - LogHelper.info(EnergyValueRegistry.ENERGY_VALUE_MARKER, "Energy value system initialized {} values after {} ms", EnergyValueRegistry.INSTANCE.getEnergyValues().size(), (System.nanoTime() - startTime) / 100000); + LogHelper.info( + EnergyValueRegistry.ENERGY_VALUE_MARKER, + "Energy value system initialized {} values after {} ms", + EnergyValueRegistry.INSTANCE.getEnergyValues().size(), + (System.nanoTime() - startTime) / 100000 + ); hasInitilialized = true; PlayerKnowledgeRegistry.INSTANCE.load(); diff --git a/src/main/java/com/pahimar/ee3/handler/WorldTransmutationHandler.java b/src/main/java/com/pahimar/ee3/handler/WorldTransmutationHandler.java index 7869d0c4..37275b57 100644 --- a/src/main/java/com/pahimar/ee3/handler/WorldTransmutationHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/WorldTransmutationHandler.java @@ -2,7 +2,6 @@ package com.pahimar.ee3.handler; import com.pahimar.ee3.api.event.WorldTransmutationEvent; import com.pahimar.ee3.util.TransmutationHelper; - import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; @@ -11,7 +10,18 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; public class WorldTransmutationHandler { - public static void handleWorldTransmutation(EntityPlayer thePlayer, int originX, int originY, int originZ, byte rangeX, byte rangeY, byte rangeZ, ForgeDirection sideHit, Block block, int metadata) { + public static void handleWorldTransmutation( + EntityPlayer thePlayer, + int originX, + int originY, + int originZ, + byte rangeX, + byte rangeY, + byte rangeZ, + ForgeDirection sideHit, + Block block, + int metadata + ) { //actionRequestEvent actionRequestEvent = null; WorldTransmutationEvent actionEvent = null; int lowerBoundX = -1 * rangeX / 2; @@ -58,36 +68,79 @@ public class WorldTransmutationHandler { for (int x = lowerBoundX; x <= upperBoundX; ++x) { for (int y = lowerBoundY; y <= upperBoundY; ++y) { for (int z = lowerBoundZ; z <= upperBoundZ; ++z) { - actionEvent = new WorldTransmutationEvent(originX + x, originY + y, originZ + z, thePlayer.worldObj, block, metadata, sideHit, thePlayer); + actionEvent = new WorldTransmutationEvent( + originX + x, + originY + y, + originZ + z, + thePlayer.worldObj, + block, + metadata, + sideHit, + thePlayer + ); if (actionEvent != null) { - //actionRequestEvent = new ActionRequestEvent(thePlayer, actionEvent, originX + x, originY + y, originZ + z, sideHit); + //actionRequestEvent = new ActionRequestEvent(thePlayer, + //actionEvent, originX + x, originY + y, originZ + z, sideHit); //MinecraftForge.EVENT_BUS.post(actionRequestEvent); //if (actionRequestEvent.allowEvent != Event.Result.DENY) { - MinecraftForge.EVENT_BUS.post(actionEvent); + MinecraftForge.EVENT_BUS.post(actionEvent); //} - /*if (actionEvent.actionResult == ActionEvent.ActionResult.SUCCESS) { - if (!anySuccess) { - anySuccess = true; + /*if (actionEvent.actionResult == + ActionEvent.ActionResult.SUCCESS) { if (!anySuccess) { anySuccess + = true; } - PacketDispatcher.sendPacketToAllAround((double)(originX + x), (double)(originY + y), (double)(originZ + z), 64.0, ((Entity)thePlayer).worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSpawnParticle("largesmoke", originX + x + xShift * xSign, originY + y + yShift * ySign, originZ + z + zShift * zSign, 0.0 * xSign, 0.05 * ySign, 0.0 * zSign))); - PacketDispatcher.sendPacketToAllAround((double)(originX + x), (double)(originY + y), (double)(originZ + z), 64.0, ((Entity)thePlayer).worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSpawnParticle("largeexplode", originX + x + xShift * xSign, originY + y + yShift * ySign, originZ + z + zShift * zSign, 0.0 * xSign, 0.15 * ySign, 0.0 * zSign))); + PacketDispatcher.sendPacketToAllAround((double)(originX + x), + (double)(originY + y), (double)(originZ + z), 64.0, + ((Entity)thePlayer).worldObj.provider.dimensionId, + PacketTypeHandler.populatePacket(new + PacketSpawnParticle("largesmoke", originX + x + xShift * xSign, + originY + y + yShift * ySign, originZ + z + zShift * zSign, 0.0 * + xSign, 0.05 * ySign, 0.0 * zSign))); + PacketDispatcher.sendPacketToAllAround((double)(originX + x), + (double)(originY + y), (double)(originZ + z), 64.0, + ((Entity)thePlayer).worldObj.provider.dimensionId, + PacketTypeHandler.populatePacket(new + PacketSpawnParticle("largeexplode", originX + x + xShift * xSign, + originY + y + yShift * ySign, originZ + z + zShift * zSign, 0.0 * + xSign, 0.15 * ySign, 0.0 * zSign))); } - else if (actionEvent.actionResult == ActionEvent.ActionResult.FAILURE && actionEvent.world.func_72798_a(originX + x, originY + y, originZ + z) != 0) { - PacketDispatcher.sendPacketToAllAround((double)(originX + x), (double)(originY + y), (double)(originZ + z), 64.0, ((Entity)thePlayer).worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSpawnParticle("reddust", originX + x + xShift * xSign, originY + y + yShift * ySign, originZ + z + zShift * zSign, 0.0 * xSign, 0.05 * ySign, 0.0 * zSign))); - PacketDispatcher.sendPacketToAllAround((double)(originX + x), (double)(originY + y), (double)(originZ + z), 64.0, ((Entity)thePlayer).worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSpawnParticle("witchMagic", originX + x + xShift * xSign, originY + y + yShift * ySign, originZ + z + zShift * zSign, 0.0 * xSign, 0.05 * ySign, 0.0 * zSign))); + else if (actionEvent.actionResult == + ActionEvent.ActionResult.FAILURE && + actionEvent.world.func_72798_a(originX + x, originY + y, originZ + + z) != 0) { PacketDispatcher.sendPacketToAllAround((double)(originX + + x), (double)(originY + y), (double)(originZ + z), 64.0, + ((Entity)thePlayer).worldObj.provider.dimensionId, + PacketTypeHandler.populatePacket(new + PacketSpawnParticle("reddust", originX + x + xShift * xSign, + originY + y + yShift * ySign, originZ + z + zShift * zSign, 0.0 * + xSign, 0.05 * ySign, 0.0 * zSign))); + PacketDispatcher.sendPacketToAllAround((double)(originX + x), + (double)(originY + y), (double)(originZ + z), 64.0, + ((Entity)thePlayer).worldObj.provider.dimensionId, + PacketTypeHandler.populatePacket(new + PacketSpawnParticle("witchMagic", originX + x + xShift * xSign, + originY + y + yShift * ySign, originZ + z + zShift * zSign, 0.0 * + xSign, 0.05 * ySign, 0.0 * zSign))); }*/ } } } } if (anySuccess) { - //PacketDispatcher.sendPacketToAllAround((double)originX, (double)originY, (double)originZ, 64.0, ((Entity)thePlayer).worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSoundEvent(thePlayer.field_71092_bJ, "mods.ee3.sound.transmute", originX, originY, originZ, 0.5f, 1.0f))); - } - else { - //PacketDispatcher.sendPacketToAllAround((double)originX, (double)originY, (double)originZ, 64.0, ((Entity)thePlayer).worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSoundEvent(thePlayer.field_71092_bJ, "mods.ee3.sound.fail", originX, originY, originZ, 1.5f, 1.5f))); + //PacketDispatcher.sendPacketToAllAround((double)originX, (double)originY, + //(double)originZ, 64.0, ((Entity)thePlayer).worldObj.provider.dimensionId, + //PacketTypeHandler.populatePacket(new + //PacketSoundEvent(thePlayer.field_71092_bJ, "mods.ee3.sound.transmute", + //originX, originY, originZ, 0.5f, 1.0f))); + } else { + //PacketDispatcher.sendPacketToAllAround((double)originX, (double)originY, + //(double)originZ, 64.0, ((Entity)thePlayer).worldObj.provider.dimensionId, + //PacketTypeHandler.populatePacket(new + //PacketSoundEvent(thePlayer.field_71092_bJ, "mods.ee3.sound.fail", originX, + //originY, originZ, 1.5f, 1.5f))); } } - + @SubscribeEvent public void onWorldTransmutationEvent(WorldTransmutationEvent event) { Block block = event.world.getBlock(event.x, event.y, event.z); @@ -99,20 +152,38 @@ public class WorldTransmutationHandler { ItemStack worldStack = new ItemStack(block, 1, meta); ItemStack targetStack = new ItemStack(event.block, 1, event.blockMetadata); ItemStack handItem = event.player.getCurrentEquippedItem(); - if (!worldStack.isItemEqual(targetStack) && EquivalencyHandler.instance().areWorldEquivalent(worldStack, targetStack) && handItem != null && handItem.getItemDamage() <= handItem.getMaxDamage()) { - result = TransmutationHelper.transmuteInWorld(event.world, event.player, handItem, event.x, event.y, event.z, event.block, event.blockMetadata); + if (!worldStack.isItemEqual(targetStack) + && EquivalencyHandler.instance().areWorldEquivalent(worldStack, targetStack) + && handItem != null && handItem.getItemDamage() <= handItem.getMaxDamage()) { + result = TransmutationHelper.transmuteInWorld( + event.world, + event.player, + handItem, + event.x, + event.y, + event.z, + event.block, + event.blockMetadata + ); } if (result) { //event.actionResult = ActionEvent.ActionResult.SUCCESS; int currentSlot = event.player.inventory.currentItem; handItem.damageItem(1, event.player); if (handItem.stackSize < 1) { - event.player.inventory.setInventorySlotContents(currentSlot, (ItemStack)null); - //PacketDispatcher.sendPacketToPlayer(PacketTypeHandler.populatePacket(new PacketItemUpdate((byte)currentSlot, (byte)0)), (Player)event.player); - event.player.worldObj.playSoundAtEntity(event.player, "random.break", 0.8f, 0.8f + event.player.worldObj.rand.nextFloat() * 0.4f); + event.player.inventory.setInventorySlotContents( + currentSlot, (ItemStack) null + ); + //PacketDispatcher.sendPacketToPlayer(PacketTypeHandler.populatePacket(new + //PacketItemUpdate((byte)currentSlot, (byte)0)), (Player)event.player); + event.player.worldObj.playSoundAtEntity( + event.player, + "random.break", + 0.8f, + 0.8f + event.player.worldObj.rand.nextFloat() * 0.4f + ); } - } - else { + } else { //event.actionResult = ActionEvent.ActionResult.FAILURE; } } diff --git a/src/main/java/com/pahimar/ee3/init/Abilities.java b/src/main/java/com/pahimar/ee3/init/Abilities.java index 5cc27064..e1be0648 100644 --- a/src/main/java/com/pahimar/ee3/init/Abilities.java +++ b/src/main/java/com/pahimar/ee3/init/Abilities.java @@ -7,19 +7,23 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; public class Abilities { - public static void init() { - for (String oreName : OreDictionary.getOreNames()) { if (oreName.startsWith("ore")) { - OreDictionary.getOres(oreName).forEach(BlacklistRegistryProxy::setAsNotLearnable); + OreDictionary.getOres(oreName).forEach( + BlacklistRegistryProxy::setAsNotLearnable + ); BlacklistRegistryProxy.setAsNotLearnable(new OreStack(oreName)); } } BlacklistRegistryProxy.setAsNotLearnable(new ItemStack(Blocks.coal_ore)); BlacklistRegistryProxy.setAsNotLearnable(ModItems.shardMinium); - BlacklistRegistryProxy.setAsNotLearnable(new ItemStack(ModItems.alchemicalDust, 1, 1)); - BlacklistRegistryProxy.setAsNotLearnable(new ItemStack(ModItems.alchemicalDust, 1, 2)); + BlacklistRegistryProxy.setAsNotLearnable( + new ItemStack(ModItems.alchemicalDust, 1, 1) + ); + BlacklistRegistryProxy.setAsNotLearnable( + new ItemStack(ModItems.alchemicalDust, 1, 2) + ); } } \ No newline at end of file diff --git a/src/main/java/com/pahimar/ee3/init/AlchemyArrays.java b/src/main/java/com/pahimar/ee3/init/AlchemyArrays.java index cba93d2f..6de10570 100644 --- a/src/main/java/com/pahimar/ee3/init/AlchemyArrays.java +++ b/src/main/java/com/pahimar/ee3/init/AlchemyArrays.java @@ -5,8 +5,8 @@ import com.pahimar.ee3.api.array.AlchemyArrayRegistryProxy; import com.pahimar.ee3.array.AlchemyArrayTransmutation; public class AlchemyArrays { - - public static final AlchemyArray transmutationAlchemyArray = new AlchemyArrayTransmutation(); + public static final AlchemyArray transmutationAlchemyArray + = new AlchemyArrayTransmutation(); public static void registerAlchemyArrays() { AlchemyArrayRegistryProxy.registerAlchemyArray(transmutationAlchemyArray); diff --git a/src/main/java/com/pahimar/ee3/init/EnergyValues.java b/src/main/java/com/pahimar/ee3/init/EnergyValues.java index 8d6f153c..6ec1b22f 100644 --- a/src/main/java/com/pahimar/ee3/init/EnergyValues.java +++ b/src/main/java/com/pahimar/ee3/init/EnergyValues.java @@ -1,8 +1,9 @@ package com.pahimar.ee3.init; +import static com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy.Phase; + import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; import com.pahimar.ee3.exchange.OreStack; - import cpw.mods.fml.common.Loader; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -10,166 +11,380 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.oredict.OreDictionary; -import static com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy.Phase; - public class EnergyValues { - - private static final String[] DYES = {"Black", "Red", "Green", "Brown", "Blue", "Purple", "Cyan", "LightGray", "Gray", "Pink", "Lime", "Yellow", "LightBlue", "Magenta", "Orange", "White"}; + private static final String[] DYES + = { "Black", "Red", "Green", "Brown", "Blue", "Purple", + "Cyan", "LightGray", "Gray", "Pink", "Lime", "Yellow", + "LightBlue", "Magenta", "Orange", "White" }; public static void init() { - /* Equivalent Exchange 3 */ /** * Alchemical Dusts */ - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(ModItems.alchemicalDust, 1, 0), 1, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(ModItems.alchemicalDust, 1, 1), 64, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(ModItems.alchemicalDust, 1, 2), 2048, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(ModItems.alchemicalDust, 1, 3), 8192, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(ModItems.alchemicalDust, 1, 0), 1, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(ModItems.alchemicalDust, 1, 1), 64, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(ModItems.alchemicalDust, 1, 2), 2048, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(ModItems.alchemicalDust, 1, 3), 8192, Phase.PRE_CALCULATION + ); /** * Minium Shard */ - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(ModItems.shardMinium), 8192, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(ModItems.shardMinium), 8192, Phase.PRE_CALCULATION + ); - if (Loader.isModLoaded("ProjectE")) return; + if (Loader.isModLoaded("ProjectE")) + return; // OreDictionary assignment - EnergyValueRegistryProxy.setEnergyValue(new OreStack("cobblestone"), 1, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("dustRedstone"), 32, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("cobblestone"), 1, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("dustRedstone"), 32, Phase.PRE_CALCULATION + ); for (int i = 0; i < DYES.length; i++) { - EnergyValueRegistryProxy.setEnergyValue(new OreStack("dye" + DYES[i]), 16, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("dye" + DYES[i]), 16, Phase.PRE_CALCULATION + ); } - EnergyValueRegistryProxy.setEnergyValue(new OreStack("gemDiamond"), 8192, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("gemEmerald"), 8192, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("gemLapis"), 864, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("gemQuartz"), 256, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("ingotGold"), 2048, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("ingotIron"), 256, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("logWood"), 32, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("oreCoal"), 32, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("oreDiamond"), 8192, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("oreEmerald"), 8192, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("oreGold"), 2048, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("oreIron"), 256, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("oreLapis"), 864, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("oreQuartz"), 256, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("oreRedstone"), 32, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("plankWood"), 8, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("record"), 2048, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("sand"), 1, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("sandstone"), 4, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("slabWood"), 4, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("slimeball"), 24, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("stairWood"), 12, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("stickWood"), 4, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("stone"), 1, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("treeLeaves"), 1, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new OreStack("treeSapling"), 32, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("gemDiamond"), 8192, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("gemEmerald"), 8192, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("gemLapis"), 864, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("gemQuartz"), 256, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("ingotGold"), 2048, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("ingotIron"), 256, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("logWood"), 32, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("oreCoal"), 32, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("oreDiamond"), 8192, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("oreEmerald"), 8192, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("oreGold"), 2048, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("oreIron"), 256, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("oreLapis"), 864, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("oreQuartz"), 256, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("oreRedstone"), 32, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("plankWood"), 8, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("record"), 2048, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("sand"), 1, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("sandstone"), 4, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("slabWood"), 4, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("slimeball"), 24, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("stairWood"), 12, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("stickWood"), 4, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("stone"), 1, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("treeLeaves"), 1, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new OreStack("treeSapling"), 32, Phase.PRE_CALCULATION + ); // Fluids - EnergyValueRegistryProxy.setEnergyValue(FluidRegistry.WATER, 0.001, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(FluidRegistry.LAVA, 0.064, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(FluidRegistry.getFluid("milk"), 0.064, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + FluidRegistry.WATER, 0.001, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + FluidRegistry.LAVA, 0.064, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + FluidRegistry.getFluid("milk"), 0.064, Phase.PRE_CALCULATION + ); /* Building Blocks */ EnergyValueRegistryProxy.setEnergyValue(Blocks.stone, 1, Phase.PRE_CALCULATION); EnergyValueRegistryProxy.setEnergyValue(Blocks.grass, 1, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Blocks.dirt, 1, OreDictionary.WILDCARD_VALUE), 1, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Blocks.cobblestone, 1, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Blocks.sand, 1, OreDictionary.WILDCARD_VALUE), 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Blocks.dirt, 1, OreDictionary.WILDCARD_VALUE), + 1, + Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Blocks.cobblestone, 1, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Blocks.sand, 1, OreDictionary.WILDCARD_VALUE), + 1, + Phase.PRE_CALCULATION + ); EnergyValueRegistryProxy.setEnergyValue(Blocks.gravel, 4, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Blocks.glass, 1, OreDictionary.WILDCARD_VALUE), 1, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Blocks.sandstone, 1, OreDictionary.WILDCARD_VALUE), 4, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Blocks.mossy_cobblestone, 1, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Blocks.obsidian, 64, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Blocks.glass, 1, OreDictionary.WILDCARD_VALUE), + 1, + Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Blocks.sandstone, 1, OreDictionary.WILDCARD_VALUE), + 4, + Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Blocks.mossy_cobblestone, 1, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Blocks.obsidian, 64, Phase.PRE_CALCULATION + ); EnergyValueRegistryProxy.setEnergyValue(Blocks.ice, 1, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Blocks.pumpkin, 144, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Blocks.netherrack, 1, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Blocks.soul_sand, 49, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Blocks.stonebrick, 1, OreDictionary.WILDCARD_VALUE), 1, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Blocks.mycelium, 1, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Blocks.end_stone, 1, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Blocks.hardened_clay, 256, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + Blocks.pumpkin, 144, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Blocks.netherrack, 1, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Blocks.soul_sand, 49, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Blocks.stonebrick, 1, OreDictionary.WILDCARD_VALUE), + 1, + Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Blocks.mycelium, 1, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Blocks.end_stone, 1, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Blocks.hardened_clay, 256, Phase.PRE_CALCULATION + ); /* Decoration Blocks */ EnergyValueRegistryProxy.setEnergyValue(Blocks.web, 12, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Blocks.tallgrass, 1, OreDictionary.WILDCARD_VALUE), 1, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Blocks.deadbush, 1, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Blocks.yellow_flower, 16, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Blocks.red_flower, 1, OreDictionary.WILDCARD_VALUE), 16, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Blocks.brown_mushroom, 32, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Blocks.red_mushroom, 32, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Blocks.red_mushroom, 32, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Blocks.snow_layer, 0.125f, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Blocks.tallgrass, 1, OreDictionary.WILDCARD_VALUE), + 1, + Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Blocks.deadbush, 1, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Blocks.yellow_flower, 16, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Blocks.red_flower, 1, OreDictionary.WILDCARD_VALUE), + 16, + Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Blocks.brown_mushroom, 32, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Blocks.red_mushroom, 32, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Blocks.red_mushroom, 32, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Blocks.snow_layer, 0.125f, Phase.PRE_CALCULATION + ); EnergyValueRegistryProxy.setEnergyValue(Blocks.cactus, 8, Phase.PRE_CALCULATION); EnergyValueRegistryProxy.setEnergyValue(Blocks.vine, 8, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Blocks.waterlily, 16, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Blocks.anvil, 1, 1), 5290.667f, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Blocks.anvil, 1, 2), 2645.333f, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Blocks.double_plant, 1, OreDictionary.WILDCARD_VALUE), 32, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + Blocks.waterlily, 16, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Blocks.anvil, 1, 1), 5290.667f, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Blocks.anvil, 1, 2), 2645.333f, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Blocks.double_plant, 1, OreDictionary.WILDCARD_VALUE), + 32, + Phase.PRE_CALCULATION + ); /* Redstone */ - EnergyValueRegistryProxy.setEnergyValue(Items.redstone, 32, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + Items.redstone, 32, Phase.PRE_CALCULATION + ); /* Transportation */ EnergyValueRegistryProxy.setEnergyValue(Items.saddle, 192, Phase.PRE_CALCULATION); /* Miscellaneous */ - EnergyValueRegistryProxy.setEnergyValue(Items.snowball, 0.25f, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + Items.snowball, 0.25f, Phase.PRE_CALCULATION + ); EnergyValueRegistryProxy.setEnergyValue(Items.bone, 48, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.ender_pearl, 1024, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + Items.ender_pearl, 1024, Phase.PRE_CALCULATION + ); /* Foodstuffs */ EnergyValueRegistryProxy.setEnergyValue(Items.apple, 24, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.porkchop, 24, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.cooked_porkchop, 24, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.fish, 1, OreDictionary.WILDCARD_VALUE), 24, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.cooked_fished, 1, OreDictionary.WILDCARD_VALUE), 24, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + Items.porkchop, 24, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Items.cooked_porkchop, 24, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Items.fish, 1, OreDictionary.WILDCARD_VALUE), + 24, + Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Items.cooked_fished, 1, OreDictionary.WILDCARD_VALUE), + 24, + Phase.PRE_CALCULATION + ); EnergyValueRegistryProxy.setEnergyValue(Items.melon, 16, Phase.PRE_CALCULATION); EnergyValueRegistryProxy.setEnergyValue(Items.beef, 24, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.cooked_beef, 24, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + Items.cooked_beef, 24, Phase.PRE_CALCULATION + ); EnergyValueRegistryProxy.setEnergyValue(Items.chicken, 24, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.cooked_chicken, 24, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.rotten_flesh, 24, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.spider_eye, 128, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + Items.cooked_chicken, 24, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Items.rotten_flesh, 24, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Items.spider_eye, 128, Phase.PRE_CALCULATION + ); EnergyValueRegistryProxy.setEnergyValue(Items.carrot, 24, Phase.PRE_CALCULATION); EnergyValueRegistryProxy.setEnergyValue(Items.potato, 24, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.baked_potato, 24, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.poisonous_potato, 24, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + Items.baked_potato, 24, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Items.poisonous_potato, 24, Phase.PRE_CALCULATION + ); /* Brewing */ - EnergyValueRegistryProxy.setEnergyValue(Items.ghast_tear, 4096, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + Items.ghast_tear, 4096, Phase.PRE_CALCULATION + ); /* Materials */ - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.coal, 1, 0), 32, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.coal, 1, 1), 32, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.diamond, 8192, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.iron_ingot, 256, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.gold_ingot, 2048, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Items.coal, 1, 0), 32, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Items.coal, 1, 1), 32, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Items.diamond, 8192, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Items.iron_ingot, 256, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Items.gold_ingot, 2048, Phase.PRE_CALCULATION + ); EnergyValueRegistryProxy.setEnergyValue(Items.string, 12, Phase.PRE_CALCULATION); EnergyValueRegistryProxy.setEnergyValue(Items.feather, 48, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.gunpowder, 192, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.wheat_seeds, 16, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + Items.gunpowder, 192, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Items.wheat_seeds, 16, Phase.PRE_CALCULATION + ); EnergyValueRegistryProxy.setEnergyValue(Items.wheat, 24, Phase.PRE_CALCULATION); EnergyValueRegistryProxy.setEnergyValue(Items.flint, 4, Phase.PRE_CALCULATION); EnergyValueRegistryProxy.setEnergyValue(Items.leather, 64, Phase.PRE_CALCULATION); EnergyValueRegistryProxy.setEnergyValue(Items.brick, 64, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.clay_ball, 64, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + Items.clay_ball, 64, Phase.PRE_CALCULATION + ); EnergyValueRegistryProxy.setEnergyValue(Items.reeds, 32, Phase.PRE_CALCULATION); EnergyValueRegistryProxy.setEnergyValue(Items.egg, 32, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.glowstone_dust, 384, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.dye, 1, 0), 16, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.dye, 1, 2), 16, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.dye, 1, 3), 16, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.dye, 1, 4), 864, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.dye, 1, 5), 16, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(new ItemStack(Items.dye, 1, 6), 16, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.blaze_rod, 1536, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.nether_wart, 24, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.emerald, 8192, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.nether_star, 24576, Phase.PRE_CALCULATION); - EnergyValueRegistryProxy.setEnergyValue(Items.netherbrick, 1, Phase.PRE_CALCULATION); + EnergyValueRegistryProxy.setEnergyValue( + Items.glowstone_dust, 384, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Items.dye, 1, 0), 16, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Items.dye, 1, 2), 16, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Items.dye, 1, 3), 16, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Items.dye, 1, 4), 864, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Items.dye, 1, 5), 16, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + new ItemStack(Items.dye, 1, 6), 16, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Items.blaze_rod, 1536, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Items.nether_wart, 24, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Items.emerald, 8192, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Items.nether_star, 24576, Phase.PRE_CALCULATION + ); + EnergyValueRegistryProxy.setEnergyValue( + Items.netherbrick, 1, Phase.PRE_CALCULATION + ); EnergyValueRegistryProxy.setEnergyValue(Items.quartz, 256, Phase.PRE_CALCULATION); } } diff --git a/src/main/java/com/pahimar/ee3/init/ModBlocks.java b/src/main/java/com/pahimar/ee3/init/ModBlocks.java index de575dc2..2ab9b8f6 100644 --- a/src/main/java/com/pahimar/ee3/init/ModBlocks.java +++ b/src/main/java/com/pahimar/ee3/init/ModBlocks.java @@ -9,8 +9,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; @GameRegistry.ObjectHolder(Reference.MOD_ID) -public class ModBlocks -{ +public class ModBlocks { public static final BlockEE chalkBlock = new BlockChalk(); public static final BlockEE alchemicalFuelBlock = new BlockAlchemicalFuel(); public static final BlockTileEntityEE alchemicalChest = new BlockAlchemicalChest(); @@ -21,22 +20,32 @@ public class ModBlocks public static final BlockEE ashInfusedStone = new BlockAshInfusedStone(); public static final BlockTileEntityEE alchemyArray = new BlockAlchemyArray(); public static final BlockTileEntityEE dummyArray = new BlockDummyArray(); - public static final BlockTileEntityEE transmutationTablet = new BlockTransmutationTablet(); + public static final BlockTileEntityEE transmutationTablet + = new BlockTransmutationTablet(); public static final Block ashInfusedStoneSlab = new BlockAshInfusedStoneSlab(); - public static void init() - { + public static void init() { GameRegistry.registerBlock(calcinator, Names.Blocks.CALCINATOR); GameRegistry.registerBlock(aludel, Names.Blocks.ALUDEL); GameRegistry.registerBlock(glassBell, Names.Blocks.GLASS_BELL); GameRegistry.registerBlock(researchStation, Names.Blocks.RESEARCH_STATION); - GameRegistry.registerBlock(alchemicalChest, ItemBlockAlchemicalChest.class, Names.Blocks.ALCHEMICAL_CHEST); + GameRegistry.registerBlock( + alchemicalChest, ItemBlockAlchemicalChest.class, Names.Blocks.ALCHEMICAL_CHEST + ); GameRegistry.registerBlock(chalkBlock, Names.Blocks.CHALK); - GameRegistry.registerBlock(alchemicalFuelBlock, ItemBlockAlchemicalFuel.class, Names.Blocks.ALCHEMICAL_FUEL); + GameRegistry.registerBlock( + alchemicalFuelBlock, + ItemBlockAlchemicalFuel.class, + Names.Blocks.ALCHEMICAL_FUEL + ); GameRegistry.registerBlock(ashInfusedStone, Names.Blocks.ASH_INFUSED_STONE); GameRegistry.registerBlock(alchemyArray, Names.Blocks.ALCHEMY_ARRAY); GameRegistry.registerBlock(dummyArray, Names.Blocks.DUMMY_ARRAY); - GameRegistry.registerBlock(transmutationTablet, Names.Blocks.TRANSMUTATION_TABLET); - GameRegistry.registerBlock(ashInfusedStoneSlab, Names.Blocks.ASH_INFUSED_STONE_SLAB); + GameRegistry.registerBlock( + transmutationTablet, Names.Blocks.TRANSMUTATION_TABLET + ); + GameRegistry.registerBlock( + ashInfusedStoneSlab, Names.Blocks.ASH_INFUSED_STONE_SLAB + ); } } diff --git a/src/main/java/com/pahimar/ee3/init/ModItems.java b/src/main/java/com/pahimar/ee3/init/ModItems.java index 9257f365..30aa8840 100644 --- a/src/main/java/com/pahimar/ee3/init/ModItems.java +++ b/src/main/java/com/pahimar/ee3/init/ModItems.java @@ -6,8 +6,7 @@ import com.pahimar.ee3.reference.Reference; import cpw.mods.fml.common.registry.GameRegistry; @GameRegistry.ObjectHolder(Reference.MOD_ID) -public class ModItems -{ +public class ModItems { public static final ItemEE alchemicalBag = new ItemAlchemicalBag(); public static final ItemEE alchemicalDust = new ItemAlchemicalDust(); public static final ItemEE alchemicalFuel = new ItemAlchemicalFuel(); @@ -19,8 +18,7 @@ public class ModItems public static final ItemEE chalk = new ItemChalk(); public static final ItemEE alchenomicon = new ItemAlchenomicon(); - public static void init() - { + public static void init() { GameRegistry.registerItem(alchemicalBag, Names.Items.ALCHEMICAL_BAG); GameRegistry.registerItem(alchemicalDust, Names.Items.ALCHEMICAL_DUST); GameRegistry.registerItem(alchemicalFuel, Names.Items.ALCHEMICAL_FUEL); @@ -30,6 +28,8 @@ public class ModItems GameRegistry.registerItem(stonePhilosophers, Names.Items.PHILOSOPHERS_STONE); GameRegistry.registerItem(chalk, Names.Items.CHALK); GameRegistry.registerItem(alchemicalUpgrade, Names.Items.ALCHEMICAL_UPGRADE); - GameRegistry.registerItem(alchenomicon, Names.Items.ALCHENOMICON, Names.Items.ALCHEMICAL_TOME); + GameRegistry.registerItem( + alchenomicon, Names.Items.ALCHENOMICON, Names.Items.ALCHEMICAL_TOME + ); } } diff --git a/src/main/java/com/pahimar/ee3/init/Recipes.java b/src/main/java/com/pahimar/ee3/init/Recipes.java index 793a52e5..7a58df88 100644 --- a/src/main/java/com/pahimar/ee3/init/Recipes.java +++ b/src/main/java/com/pahimar/ee3/init/Recipes.java @@ -8,80 +8,253 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; -public class Recipes -{ - public static void init() - { +public class Recipes { + public static void init() { initModRecipes(); initAludelRecipes(); } - private static void initModRecipes() - { - GameRegistry.addShapedRecipe(new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 0), "fff", "fff", "fff", 'f', new ItemStack(ModItems.alchemicalFuel, 1, 0)); - GameRegistry.addShapedRecipe(new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 1), "fff", "fff", "fff", 'f', new ItemStack(ModItems.alchemicalFuel, 1, 1)); - GameRegistry.addShapedRecipe(new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 2), "fff", "fff", "fff", 'f', new ItemStack(ModItems.alchemicalFuel, 1, 2)); + private static void initModRecipes() { + GameRegistry.addShapedRecipe( + new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 0), + "fff", + "fff", + "fff", + 'f', + new ItemStack(ModItems.alchemicalFuel, 1, 0) + ); + GameRegistry.addShapedRecipe( + new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 1), + "fff", + "fff", + "fff", + 'f', + new ItemStack(ModItems.alchemicalFuel, 1, 1) + ); + GameRegistry.addShapedRecipe( + new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 2), + "fff", + "fff", + "fff", + 'f', + new ItemStack(ModItems.alchemicalFuel, 1, 2) + ); - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.alchemicalFuel, 9, 0), new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 0)); - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.alchemicalFuel, 9, 1), new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 1)); - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.alchemicalFuel, 9, 2), new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 2)); + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.alchemicalFuel, 9, 0), + new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 0) + ); + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.alchemicalFuel, 9, 1), + new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 1) + ); + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.alchemicalFuel, 9, 2), + new ItemStack(ModBlocks.alchemicalFuelBlock, 1, 2) + ); - GameRegistry.addShapedRecipe(new ItemStack(ModBlocks.ashInfusedStoneSlab, 6), "sss", 's', new ItemStack(ModBlocks.ashInfusedStone)); - GameRegistry.addShapedRecipe(new ItemStack(ModBlocks.ashInfusedStone, 1), "s", "s", 's', new ItemStack(ModBlocks.ashInfusedStoneSlab)); + GameRegistry.addShapedRecipe( + new ItemStack(ModBlocks.ashInfusedStoneSlab, 6), + "sss", + 's', + new ItemStack(ModBlocks.ashInfusedStone) + ); + GameRegistry.addShapedRecipe( + new ItemStack(ModBlocks.ashInfusedStone, 1), + "s", + "s", + 's', + new ItemStack(ModBlocks.ashInfusedStoneSlab) + ); - GameRegistry.addShapelessRecipe(new ItemStack(ModItems.chalk), new ItemStack(Items.dye, 1, 15), new ItemStack(Items.clay_ball)); - GameRegistry.addShapedRecipe(new ItemStack(ModBlocks.chalkBlock), "cc", "cc", 'c', ModItems.chalk); + GameRegistry.addShapelessRecipe( + new ItemStack(ModItems.chalk), + new ItemStack(Items.dye, 1, 15), + new ItemStack(Items.clay_ball) + ); + GameRegistry.addShapedRecipe( + new ItemStack(ModBlocks.chalkBlock), "cc", "cc", 'c', ModItems.chalk + ); - GameRegistry.addShapedRecipe(new ItemStack(ModBlocks.glassBell), "ggg", "g g", "g g", 'g', Blocks.glass); - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.calcinator), "i i", "sis", "s s", 'i', "ingotIron", 's', Blocks.stone)); - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.aludel), "iii", "sis", "iii", 'i', "ingotIron", 's', Blocks.stone)); - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModBlocks.researchStation), "ipi", " s ", "sss", 'i', "ingotIron", 's', Blocks.stone, 'p', "slabWood")); + GameRegistry.addShapedRecipe( + new ItemStack(ModBlocks.glassBell), "ggg", "g g", "g g", 'g', Blocks.glass + ); + GameRegistry.addRecipe(new ShapedOreRecipe( + new ItemStack(ModBlocks.calcinator), + "i i", + "sis", + "s s", + 'i', + "ingotIron", + 's', + Blocks.stone + )); + GameRegistry.addRecipe(new ShapedOreRecipe( + new ItemStack(ModBlocks.aludel), + "iii", + "sis", + "iii", + 'i', + "ingotIron", + 's', + Blocks.stone + )); + GameRegistry.addRecipe(new ShapedOreRecipe( + new ItemStack(ModBlocks.researchStation), + "ipi", + " s ", + "sss", + 'i', + "ingotIron", + 's', + Blocks.stone, + 'p', + "slabWood" + )); - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.stoneInert), "sis", "igi", "sis", 's', Blocks.stone, 'i', "ingotIron", 'g', "ingotGold")); + GameRegistry.addRecipe(new ShapedOreRecipe( + new ItemStack(ModItems.stoneInert), + "sis", + "igi", + "sis", + 's', + Blocks.stone, + 'i', + "ingotIron", + 'g', + "ingotGold" + )); } - private static void initAludelRecipes() - { + private static void initAludelRecipes() { // Ash + Verdant = Azure - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModItems.alchemicalDust, 1, 2), new ItemStack(ModItems.alchemicalDust, 1, 0), new ItemStack(ModItems.alchemicalDust, 32, 1)); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModItems.alchemicalDust, 1, 2), + new ItemStack(ModItems.alchemicalDust, 1, 0), + new ItemStack(ModItems.alchemicalDust, 32, 1) + ); // Ash + Azure = Minium - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModItems.alchemicalDust, 1, 3), new ItemStack(ModItems.alchemicalDust, 1, 0), new ItemStack(ModItems.alchemicalDust, 4, 2)); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModItems.alchemicalDust, 1, 3), + new ItemStack(ModItems.alchemicalDust, 1, 0), + new ItemStack(ModItems.alchemicalDust, 4, 2) + ); // Alchemical Coal - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModItems.alchemicalFuel, 1, 0), new ItemStack(Items.coal, 1, 0), new ItemStack(ModItems.alchemicalDust, 32, 1)); - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModItems.alchemicalFuel, 1, 0), new ItemStack(Items.coal, 1, 0), new ItemStack(ModItems.alchemicalDust, 1, 2)); - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModItems.alchemicalFuel, 4, 0), new ItemStack(Items.coal, 4, 0), new ItemStack(ModItems.alchemicalDust, 1, 3)); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModItems.alchemicalFuel, 1, 0), + new ItemStack(Items.coal, 1, 0), + new ItemStack(ModItems.alchemicalDust, 32, 1) + ); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModItems.alchemicalFuel, 1, 0), + new ItemStack(Items.coal, 1, 0), + new ItemStack(ModItems.alchemicalDust, 1, 2) + ); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModItems.alchemicalFuel, 4, 0), + new ItemStack(Items.coal, 4, 0), + new ItemStack(ModItems.alchemicalDust, 1, 3) + ); // Mobius Fuel - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModItems.alchemicalFuel, 1, 1), new ItemStack(ModItems.alchemicalFuel, 1, 0), new ItemStack(ModItems.alchemicalDust, 7, 2)); - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModItems.alchemicalFuel, 1, 1), new ItemStack(ModItems.alchemicalFuel, 1, 0), new ItemStack(ModItems.alchemicalDust, 2, 3)); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModItems.alchemicalFuel, 1, 1), + new ItemStack(ModItems.alchemicalFuel, 1, 0), + new ItemStack(ModItems.alchemicalDust, 7, 2) + ); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModItems.alchemicalFuel, 1, 1), + new ItemStack(ModItems.alchemicalFuel, 1, 0), + new ItemStack(ModItems.alchemicalDust, 2, 3) + ); // Aeternalis Fuel - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModItems.alchemicalFuel, 1, 2), new ItemStack(ModItems.alchemicalFuel, 1, 1), new ItemStack(ModItems.alchemicalDust, 56, 2)); - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModItems.alchemicalFuel, 1, 2), new ItemStack(ModItems.alchemicalFuel, 1, 1), new ItemStack(ModItems.alchemicalDust, 14, 3)); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModItems.alchemicalFuel, 1, 2), + new ItemStack(ModItems.alchemicalFuel, 1, 1), + new ItemStack(ModItems.alchemicalDust, 56, 2) + ); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModItems.alchemicalFuel, 1, 2), + new ItemStack(ModItems.alchemicalFuel, 1, 1), + new ItemStack(ModItems.alchemicalDust, 14, 3) + ); // Alchemical Chest - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModBlocks.alchemicalChest, 1, 0), new ItemStack(Blocks.chest, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust, 8, 1)); - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModBlocks.alchemicalChest, 1, 0), new ItemStack(Blocks.trapped_chest, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust, 8, 1)); - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModBlocks.alchemicalChest, 1, 1), new ItemStack(Blocks.chest, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust, 8, 2)); - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModBlocks.alchemicalChest, 1, 1), new ItemStack(ModBlocks.alchemicalChest, 1, 0), new ItemStack(ModItems.alchemicalDust, 8, 2)); - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModBlocks.alchemicalChest, 1, 2), new ItemStack(Blocks.chest, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust, 8, 3)); - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModBlocks.alchemicalChest, 1, 2), new ItemStack(ModBlocks.alchemicalChest, 1, 0), new ItemStack(ModItems.alchemicalDust, 8, 3)); - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModBlocks.alchemicalChest, 1, 2), new ItemStack(ModBlocks.alchemicalChest, 1, 1), new ItemStack(ModItems.alchemicalDust, 8, 3)); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModBlocks.alchemicalChest, 1, 0), + new ItemStack(Blocks.chest, 1, OreDictionary.WILDCARD_VALUE), + new ItemStack(ModItems.alchemicalDust, 8, 1) + ); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModBlocks.alchemicalChest, 1, 0), + new ItemStack(Blocks.trapped_chest, 1, OreDictionary.WILDCARD_VALUE), + new ItemStack(ModItems.alchemicalDust, 8, 1) + ); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModBlocks.alchemicalChest, 1, 1), + new ItemStack(Blocks.chest, 1, OreDictionary.WILDCARD_VALUE), + new ItemStack(ModItems.alchemicalDust, 8, 2) + ); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModBlocks.alchemicalChest, 1, 1), + new ItemStack(ModBlocks.alchemicalChest, 1, 0), + new ItemStack(ModItems.alchemicalDust, 8, 2) + ); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModBlocks.alchemicalChest, 1, 2), + new ItemStack(Blocks.chest, 1, OreDictionary.WILDCARD_VALUE), + new ItemStack(ModItems.alchemicalDust, 8, 3) + ); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModBlocks.alchemicalChest, 1, 2), + new ItemStack(ModBlocks.alchemicalChest, 1, 0), + new ItemStack(ModItems.alchemicalDust, 8, 3) + ); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModBlocks.alchemicalChest, 1, 2), + new ItemStack(ModBlocks.alchemicalChest, 1, 1), + new ItemStack(ModItems.alchemicalDust, 8, 3) + ); // Minium Stone - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModItems.stoneMinium), new ItemStack(ModItems.stoneInert), new ItemStack(ModItems.shardMinium, 8)); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModItems.stoneMinium), + new ItemStack(ModItems.stoneInert), + new ItemStack(ModItems.shardMinium, 8) + ); // Alchenomicon - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModItems.alchenomicon), new ItemStack(Items.book), new ItemStack(ModItems.alchemicalDust, 1, 3)); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModItems.alchenomicon), + new ItemStack(Items.book), + new ItemStack(ModItems.alchemicalDust, 1, 3) + ); // Alchemical bags - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModItems.alchemicalBag, 1, 0), new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust, 8, 1)); - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModItems.alchemicalBag, 1, 1), new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust, 8, 2)); - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModItems.alchemicalBag, 1, 2), new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(ModItems.alchemicalDust, 8, 3)); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModItems.alchemicalBag, 1, 0), + new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE), + new ItemStack(ModItems.alchemicalDust, 8, 1) + ); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModItems.alchemicalBag, 1, 1), + new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE), + new ItemStack(ModItems.alchemicalDust, 8, 2) + ); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModItems.alchemicalBag, 1, 2), + new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE), + new ItemStack(ModItems.alchemicalDust, 8, 3) + ); // Infused Stone - AludelRecipeManager.getInstance().addRecipe(new ItemStack(ModBlocks.ashInfusedStone), new ItemStack(Blocks.stone), new ItemStack(ModItems.alchemicalDust, 1, 0)); + AludelRecipeManager.getInstance().addRecipe( + new ItemStack(ModBlocks.ashInfusedStone), + new ItemStack(Blocks.stone), + new ItemStack(ModItems.alchemicalDust, 1, 0) + ); } } diff --git a/src/main/java/com/pahimar/ee3/init/RecipesTransmutationStone.java b/src/main/java/com/pahimar/ee3/init/RecipesTransmutationStone.java index 6b8e719e..b28b1818 100644 --- a/src/main/java/com/pahimar/ee3/init/RecipesTransmutationStone.java +++ b/src/main/java/com/pahimar/ee3/init/RecipesTransmutationStone.java @@ -9,7 +9,6 @@ import java.util.Map; import com.pahimar.ee3.handler.EquivalencyHandler; import com.pahimar.ee3.util.ItemStackUtils; import com.pahimar.ee3.util.RecipeHelper; - import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -17,7 +16,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; public class RecipesTransmutationStone { - private static ItemStack philStone; private static ItemStack miniumStone; public static List transmutationStones; @@ -38,55 +36,202 @@ public class RecipesTransmutationStone { } public static void initTransmutationRecipes(ItemStack transmutationStone) { - RecipeHelper.addRecipe(Items.flint, transmutationStone, Blocks.cobblestone, Blocks.cobblestone, Blocks.cobblestone, Blocks.cobblestone); - RecipeHelper.addRecipe(new ItemStack(Blocks.cobblestone, 4), transmutationStone, Items.flint); - RecipeHelper.addRecipe(Blocks.gravel, transmutationStone, Blocks.dirt, Blocks.dirt, Blocks.dirt, Blocks.dirt); - RecipeHelper.addRecipe(new ItemStack(Blocks.dirt, 4), transmutationStone, Blocks.gravel); - RecipeHelper.addRecipe(new ItemStack(Blocks.sand, 4), transmutationStone, RecipesTransmutationStone.anySandStone); - RecipeHelper.addRecipe(Blocks.planks, transmutationStone, Items.stick, Items.stick); - RecipeHelper.addRecipe(Blocks.log, transmutationStone, RecipesTransmutationStone.anyPlank, RecipesTransmutationStone.anyPlank, RecipesTransmutationStone.anyPlank, RecipesTransmutationStone.anyPlank); - RecipeHelper.addRecipe(Items.clay_ball, transmutationStone, Blocks.gravel, Blocks.gravel, Blocks.gravel, Blocks.gravel); - RecipeHelper.addRecipe(Items.clay_ball, transmutationStone, RecipesTransmutationStone.anySandStone, RecipesTransmutationStone.anySandStone, RecipesTransmutationStone.anySandStone, RecipesTransmutationStone.anySandStone); - RecipeHelper.addRecipe(Items.clay_ball, transmutationStone, Items.flint, Items.flint, Items.flint, Items.flint); - RecipeHelper.addRecipe(new ItemStack(Blocks.gravel, 4), transmutationStone, Items.clay_ball); - RecipeHelper.addRecipe(Blocks.obsidian, transmutationStone, RecipesTransmutationStone.anyWood, RecipesTransmutationStone.anyWood); - RecipeHelper.addRecipe(new ItemStack(Blocks.log, 2), transmutationStone, Blocks.obsidian); - RecipeHelper.addRecipe(new ItemStack(Items.clay_ball, 4), transmutationStone, Blocks.clay); - RecipeHelper.addRecipe(Items.iron_ingot, transmutationStone, Blocks.obsidian, Blocks.obsidian, Blocks.obsidian, Blocks.obsidian); - RecipeHelper.addRecipe(Items.iron_ingot, transmutationStone, Blocks.clay, Blocks.clay, Blocks.clay, Blocks.clay); - RecipeHelper.addRecipe(new ItemStack(Blocks.clay, 4), transmutationStone, Items.iron_ingot); - RecipeHelper.addRecipe(Items.gold_ingot, transmutationStone, Items.iron_ingot, Items.iron_ingot, Items.iron_ingot, Items.iron_ingot, Items.iron_ingot, Items.iron_ingot, Items.iron_ingot, Items.iron_ingot); - RecipeHelper.addRecipe(new ItemStack(Items.iron_ingot, 8), transmutationStone, Items.gold_ingot); - RecipeHelper.addRecipe(Items.diamond, transmutationStone, Items.gold_ingot, Items.gold_ingot, Items.gold_ingot, Items.gold_ingot); - RecipeHelper.addRecipe(new ItemStack(Items.gold_ingot, 4), transmutationStone, Items.diamond); - RecipeHelper.addRecipe(Blocks.gold_block, transmutationStone, Blocks.iron_block, Blocks.iron_block, Blocks.iron_block, Blocks.iron_block, Blocks.iron_block, Blocks.iron_block, Blocks.iron_block, Blocks.iron_block); - RecipeHelper.addRecipe(new ItemStack(Blocks.iron_block, 8), transmutationStone, Blocks.gold_block); - RecipeHelper.addRecipe(Blocks.diamond_block, transmutationStone, Blocks.gold_block, Blocks.gold_block, Blocks.gold_block, Blocks.gold_block); - RecipeHelper.addRecipe(new ItemStack(Blocks.gold_block, 4), transmutationStone, Blocks.diamond_block); - RecipeHelper.addRecipe(Items.ender_pearl, transmutationStone, Items.iron_ingot, Items.iron_ingot, Items.iron_ingot, Items.iron_ingot); - RecipeHelper.addRecipe(new ItemStack(Items.iron_ingot, 4), transmutationStone, Items.ender_pearl); + RecipeHelper.addRecipe( + Items.flint, + transmutationStone, + Blocks.cobblestone, + Blocks.cobblestone, + Blocks.cobblestone, + Blocks.cobblestone + ); + RecipeHelper.addRecipe( + new ItemStack(Blocks.cobblestone, 4), transmutationStone, Items.flint + ); + RecipeHelper.addRecipe( + Blocks.gravel, + transmutationStone, + Blocks.dirt, + Blocks.dirt, + Blocks.dirt, + Blocks.dirt + ); + RecipeHelper.addRecipe( + new ItemStack(Blocks.dirt, 4), transmutationStone, Blocks.gravel + ); + RecipeHelper.addRecipe( + new ItemStack(Blocks.sand, 4), + transmutationStone, + RecipesTransmutationStone.anySandStone + ); + RecipeHelper.addRecipe( + Blocks.planks, transmutationStone, Items.stick, Items.stick + ); + RecipeHelper.addRecipe( + Blocks.log, + transmutationStone, + RecipesTransmutationStone.anyPlank, + RecipesTransmutationStone.anyPlank, + RecipesTransmutationStone.anyPlank, + RecipesTransmutationStone.anyPlank + ); + RecipeHelper.addRecipe( + Items.clay_ball, + transmutationStone, + Blocks.gravel, + Blocks.gravel, + Blocks.gravel, + Blocks.gravel + ); + RecipeHelper.addRecipe( + Items.clay_ball, + transmutationStone, + RecipesTransmutationStone.anySandStone, + RecipesTransmutationStone.anySandStone, + RecipesTransmutationStone.anySandStone, + RecipesTransmutationStone.anySandStone + ); + RecipeHelper.addRecipe( + Items.clay_ball, + transmutationStone, + Items.flint, + Items.flint, + Items.flint, + Items.flint + ); + RecipeHelper.addRecipe( + new ItemStack(Blocks.gravel, 4), transmutationStone, Items.clay_ball + ); + RecipeHelper.addRecipe( + Blocks.obsidian, + transmutationStone, + RecipesTransmutationStone.anyWood, + RecipesTransmutationStone.anyWood + ); + RecipeHelper.addRecipe( + new ItemStack(Blocks.log, 2), transmutationStone, Blocks.obsidian + ); + RecipeHelper.addRecipe( + new ItemStack(Items.clay_ball, 4), transmutationStone, Blocks.clay + ); + RecipeHelper.addRecipe( + Items.iron_ingot, + transmutationStone, + Blocks.obsidian, + Blocks.obsidian, + Blocks.obsidian, + Blocks.obsidian + ); + RecipeHelper.addRecipe( + Items.iron_ingot, + transmutationStone, + Blocks.clay, + Blocks.clay, + Blocks.clay, + Blocks.clay + ); + RecipeHelper.addRecipe( + new ItemStack(Blocks.clay, 4), transmutationStone, Items.iron_ingot + ); + RecipeHelper.addRecipe( + Items.gold_ingot, + transmutationStone, + Items.iron_ingot, + Items.iron_ingot, + Items.iron_ingot, + Items.iron_ingot, + Items.iron_ingot, + Items.iron_ingot, + Items.iron_ingot, + Items.iron_ingot + ); + RecipeHelper.addRecipe( + new ItemStack(Items.iron_ingot, 8), transmutationStone, Items.gold_ingot + ); + RecipeHelper.addRecipe( + Items.diamond, + transmutationStone, + Items.gold_ingot, + Items.gold_ingot, + Items.gold_ingot, + Items.gold_ingot + ); + RecipeHelper.addRecipe( + new ItemStack(Items.gold_ingot, 4), transmutationStone, Items.diamond + ); + RecipeHelper.addRecipe( + Blocks.gold_block, + transmutationStone, + Blocks.iron_block, + Blocks.iron_block, + Blocks.iron_block, + Blocks.iron_block, + Blocks.iron_block, + Blocks.iron_block, + Blocks.iron_block, + Blocks.iron_block + ); + RecipeHelper.addRecipe( + new ItemStack(Blocks.iron_block, 8), transmutationStone, Blocks.gold_block + ); + RecipeHelper.addRecipe( + Blocks.diamond_block, + transmutationStone, + Blocks.gold_block, + Blocks.gold_block, + Blocks.gold_block, + Blocks.gold_block + ); + RecipeHelper.addRecipe( + new ItemStack(Blocks.gold_block, 4), transmutationStone, Blocks.diamond_block + ); + RecipeHelper.addRecipe( + Items.ender_pearl, + transmutationStone, + Items.iron_ingot, + Items.iron_ingot, + Items.iron_ingot, + Items.iron_ingot + ); + RecipeHelper.addRecipe( + new ItemStack(Items.iron_ingot, 4), transmutationStone, Items.ender_pearl + ); } public static void initEquivalenceRecipes(ItemStack stone) { - for (ArrayList itemStackList : EquivalencyHandler.instance().getAllLists()) { + for (ArrayList itemStackList : + EquivalencyHandler.instance().getAllLists()) { ItemStack[] currentList = new ItemStack[itemStackList.size()]; currentList = itemStackList.toArray(currentList); for (int i = 0; i < currentList.length; ++i) { int outputI = (i == currentList.length - 1) ? 0 : (i + 1); - RecipeHelper.addRecipe(currentList[outputI], stone, ItemStackUtils.convertSingleStackToPluralStacks(currentList[i])); + RecipeHelper.addRecipe( + currentList[outputI], + stone, + ItemStackUtils.convertSingleStackToPluralStacks(currentList[i]) + ); } } } public static void initReconstructiveRecipes(ItemStack stone) { - RecipeHelper.addRecipe(Items.bone, stone, RecipesTransmutationStone.dyeBoneMeal, RecipesTransmutationStone.dyeBoneMeal, RecipesTransmutationStone.dyeBoneMeal); - RecipeHelper.addRecipe(Items.blaze_rod, stone, Items.blaze_powder, Items.blaze_powder); + RecipeHelper.addRecipe( + Items.bone, + stone, + RecipesTransmutationStone.dyeBoneMeal, + RecipesTransmutationStone.dyeBoneMeal, + RecipesTransmutationStone.dyeBoneMeal + ); + RecipeHelper.addRecipe( + Items.blaze_rod, stone, Items.blaze_powder, Items.blaze_powder + ); } public static void initDestructorRecipes(ItemStack stone) { RecipeHelper.addRecipe(Blocks.cobblestone, stone, Blocks.stone); RecipeHelper.addRecipe(Blocks.sand, stone, Blocks.glass); - RecipeHelper.addRecipe(new ItemStack(Items.glowstone_dust, 4), stone, Blocks.glowstone); + RecipeHelper.addRecipe( + new ItemStack(Items.glowstone_dust, 4), stone, Blocks.glowstone + ); RecipeHelper.addRecipe(new ItemStack(Items.brick, 4), stone, Blocks.brick_block); } @@ -95,39 +240,76 @@ public class RecipesTransmutationStone { Iterator iterFurnaceKeyMap = furnaceMap.keySet().iterator(); while (iterFurnaceKeyMap.hasNext()) { ItemStack furnaceMapKey = iterFurnaceKeyMap.next(); - RecipeHelper.addSmeltingRecipe(furnaceMapKey, stone, RecipesTransmutationStone.anyCoal); + RecipeHelper.addSmeltingRecipe( + furnaceMapKey, stone, RecipesTransmutationStone.anyCoal + ); } } protected static void initEquivalencyList() { - EquivalencyHandler.instance().addObjects(Blocks.sand, Blocks.dirt, Blocks.cobblestone, Blocks.grass); + EquivalencyHandler.instance().addObjects( + Blocks.sand, Blocks.dirt, Blocks.cobblestone, Blocks.grass + ); EquivalencyHandler.instance().addObjects(Blocks.yellow_flower, Blocks.red_flower); - EquivalencyHandler.instance().addObjects(Blocks.red_mushroom, Blocks.brown_mushroom); + EquivalencyHandler.instance().addObjects( + Blocks.red_mushroom, Blocks.brown_mushroom + ); EquivalencyHandler.instance().addObjects(Items.pumpkin_seeds, Items.melon_seeds); EquivalencyHandler.instance().addObjects(Blocks.pumpkin, Blocks.melon_block); - EquivalencyHandler.instance().addObjects(Blocks.spruce_stairs, Blocks.birch_stairs, Blocks.jungle_stairs); - EquivalencyHandler.instance().addObjects(new ItemStack(Items.paper, 3), new ItemStack(Items.reeds, 3)); - EquivalencyHandler.instance().addObjects(new ItemStack(Items.flint, 2), new ItemStack(Blocks.gravel, 2), new ItemStack(Blocks.sandstone, 2, 0), new ItemStack(Blocks.sandstone, 2, 1), new ItemStack(Blocks.sandstone, 2, 2)); - EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Blocks.planks, 4)); - EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Blocks.log, 4)); - EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Blocks.wooden_slab, 4)); - EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Blocks.sapling, 4)); - EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Blocks.leaves, 4)); - EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Blocks.tallgrass, 3)); - EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Blocks.wool, 16)); - EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Blocks.stonebrick, 4)); - EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Items.dye, 16, 3, 4, 15)); + EquivalencyHandler.instance().addObjects( + Blocks.spruce_stairs, Blocks.birch_stairs, Blocks.jungle_stairs + ); + EquivalencyHandler.instance().addObjects( + new ItemStack(Items.paper, 3), new ItemStack(Items.reeds, 3) + ); + EquivalencyHandler.instance().addObjects( + new ItemStack(Items.flint, 2), + new ItemStack(Blocks.gravel, 2), + new ItemStack(Blocks.sandstone, 2, 0), + new ItemStack(Blocks.sandstone, 2, 1), + new ItemStack(Blocks.sandstone, 2, 2) + ); + EquivalencyHandler.instance().addObjects( + RecipeHelper.getMetaCycle(Blocks.planks, 4) + ); + EquivalencyHandler.instance().addObjects(RecipeHelper.getMetaCycle(Blocks.log, 4) + ); + EquivalencyHandler.instance().addObjects( + RecipeHelper.getMetaCycle(Blocks.wooden_slab, 4) + ); + EquivalencyHandler.instance().addObjects( + RecipeHelper.getMetaCycle(Blocks.sapling, 4) + ); + EquivalencyHandler.instance().addObjects( + RecipeHelper.getMetaCycle(Blocks.leaves, 4) + ); + EquivalencyHandler.instance().addObjects( + RecipeHelper.getMetaCycle(Blocks.tallgrass, 3) + ); + EquivalencyHandler.instance().addObjects( + RecipeHelper.getMetaCycle(Blocks.wool, 16) + ); + EquivalencyHandler.instance().addObjects( + RecipeHelper.getMetaCycle(Blocks.stonebrick, 4) + ); + EquivalencyHandler.instance().addObjects( + RecipeHelper.getMetaCycle(Items.dye, 16, 3, 4, 15) + ); } static { - RecipesTransmutationStone.philStone = new ItemStack(ModItems.stonePhilosophers, 1, 32767); - RecipesTransmutationStone.miniumStone = new ItemStack(ModItems.stoneMinium, 1, 32767); - RecipesTransmutationStone.transmutationStones = Arrays.asList(RecipesTransmutationStone.miniumStone, RecipesTransmutationStone.philStone); + RecipesTransmutationStone.philStone + = new ItemStack(ModItems.stonePhilosophers, 1, 32767); + RecipesTransmutationStone.miniumStone + = new ItemStack(ModItems.stoneMinium, 1, 32767); + RecipesTransmutationStone.transmutationStones = Arrays.asList( + RecipesTransmutationStone.miniumStone, RecipesTransmutationStone.philStone + ); RecipesTransmutationStone.anyCoal = new ItemStack(Items.coal, 1, 32767); RecipesTransmutationStone.anyWood = new ItemStack(Blocks.log, 1, 32767); RecipesTransmutationStone.anyPlank = new ItemStack(Blocks.planks, 1, 32767); - RecipesTransmutationStone.anySandStone = new ItemStack(Blocks.sandstone, 1, 32767); + RecipesTransmutationStone.anySandStone + = new ItemStack(Blocks.sandstone, 1, 32767); RecipesTransmutationStone.dyeBoneMeal = new ItemStack(Items.dye, 1, 15); } - } diff --git a/src/main/java/com/pahimar/ee3/init/TileEntities.java b/src/main/java/com/pahimar/ee3/init/TileEntities.java index 78f73c13..13c0d8a6 100644 --- a/src/main/java/com/pahimar/ee3/init/TileEntities.java +++ b/src/main/java/com/pahimar/ee3/init/TileEntities.java @@ -4,20 +4,52 @@ import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.tileentity.*; import cpw.mods.fml.common.registry.GameRegistry; -public class TileEntities -{ - public static void init() - { - GameRegistry.registerTileEntityWithAlternatives(TileEntityAlchemicalChest.class, Names.Blocks.ALCHEMICAL_CHEST, "tile." + Names.Blocks.ALCHEMICAL_CHEST); - GameRegistry.registerTileEntityWithAlternatives(TileEntityAlchemicalChestSmall.class, Names.Blocks.ALCHEMICAL_CHEST + "Small", "tile." + Names.Blocks.ALCHEMICAL_CHEST + "Small"); - GameRegistry.registerTileEntityWithAlternatives(TileEntityAlchemicalChestMedium.class, Names.Blocks.ALCHEMICAL_CHEST + "Medium", "tile." + Names.Blocks.ALCHEMICAL_CHEST + "Medium"); - GameRegistry.registerTileEntityWithAlternatives(TileEntityAlchemicalChestLarge.class, Names.Blocks.ALCHEMICAL_CHEST + "Large", "tile." + Names.Blocks.ALCHEMICAL_CHEST + "Large"); - GameRegistry.registerTileEntityWithAlternatives(TileEntityAludel.class, Names.Blocks.ALUDEL, "tile." + Names.Blocks.ALUDEL); - GameRegistry.registerTileEntityWithAlternatives(TileEntityCalcinator.class, Names.Blocks.CALCINATOR, "tile." + Names.Blocks.CALCINATOR); - GameRegistry.registerTileEntityWithAlternatives(TileEntityGlassBell.class, Names.Blocks.GLASS_BELL, "tile." + Names.Blocks.GLASS_BELL); - GameRegistry.registerTileEntity(TileEntityResearchStation.class, Names.Blocks.RESEARCH_STATION); - GameRegistry.registerTileEntity(TileEntityAlchemyArray.class, Names.Blocks.ALCHEMY_ARRAY); - GameRegistry.registerTileEntity(TileEntityDummyArray.class, Names.Blocks.DUMMY_ARRAY); - GameRegistry.registerTileEntity(TileEntityTransmutationTablet.class, Names.Blocks.TRANSMUTATION_TABLET); +public class TileEntities { + public static void init() { + GameRegistry.registerTileEntityWithAlternatives( + TileEntityAlchemicalChest.class, + Names.Blocks.ALCHEMICAL_CHEST, + "tile." + Names.Blocks.ALCHEMICAL_CHEST + ); + GameRegistry.registerTileEntityWithAlternatives( + TileEntityAlchemicalChestSmall.class, + Names.Blocks.ALCHEMICAL_CHEST + "Small", + "tile." + Names.Blocks.ALCHEMICAL_CHEST + "Small" + ); + GameRegistry.registerTileEntityWithAlternatives( + TileEntityAlchemicalChestMedium.class, + Names.Blocks.ALCHEMICAL_CHEST + "Medium", + "tile." + Names.Blocks.ALCHEMICAL_CHEST + "Medium" + ); + GameRegistry.registerTileEntityWithAlternatives( + TileEntityAlchemicalChestLarge.class, + Names.Blocks.ALCHEMICAL_CHEST + "Large", + "tile." + Names.Blocks.ALCHEMICAL_CHEST + "Large" + ); + GameRegistry.registerTileEntityWithAlternatives( + TileEntityAludel.class, Names.Blocks.ALUDEL, "tile." + Names.Blocks.ALUDEL + ); + GameRegistry.registerTileEntityWithAlternatives( + TileEntityCalcinator.class, + Names.Blocks.CALCINATOR, + "tile." + Names.Blocks.CALCINATOR + ); + GameRegistry.registerTileEntityWithAlternatives( + TileEntityGlassBell.class, + Names.Blocks.GLASS_BELL, + "tile." + Names.Blocks.GLASS_BELL + ); + GameRegistry.registerTileEntity( + TileEntityResearchStation.class, Names.Blocks.RESEARCH_STATION + ); + GameRegistry.registerTileEntity( + TileEntityAlchemyArray.class, Names.Blocks.ALCHEMY_ARRAY + ); + GameRegistry.registerTileEntity( + TileEntityDummyArray.class, Names.Blocks.DUMMY_ARRAY + ); + GameRegistry.registerTileEntity( + TileEntityTransmutationTablet.class, Names.Blocks.TRANSMUTATION_TABLET + ); } } diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerAdminPanel.java b/src/main/java/com/pahimar/ee3/inventory/ContainerAdminPanel.java index 66586105..08a18853 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerAdminPanel.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerAdminPanel.java @@ -5,30 +5,19 @@ import com.pahimar.ee3.inventory.element.IElementTextFieldHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; -public class ContainerAdminPanel extends ContainerEE implements IElementButtonHandler, IElementTextFieldHandler -{ - - public ContainerAdminPanel(InventoryPlayer inventoryPlayer) - { - - } +public class ContainerAdminPanel + extends ContainerEE implements IElementButtonHandler, IElementTextFieldHandler { + public ContainerAdminPanel(InventoryPlayer inventoryPlayer) {} @Override - public boolean canInteractWith(EntityPlayer entityPlayer) - { + public boolean canInteractWith(EntityPlayer entityPlayer) { // TODO Check if the player is Admin return true; } @Override - public void handleElementButtonClick(String elementName, int mouseButton) - { - - } + public void handleElementButtonClick(String elementName, int mouseButton) {} @Override - public void handleElementTextFieldUpdate(String elementName, String updatedText) - { - - } + public void handleElementTextFieldUpdate(String elementName, String updatedText) {} } diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerAlchemicalBag.java b/src/main/java/com/pahimar/ee3/inventory/ContainerAlchemicalBag.java index b1521c6c..68c25422 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerAlchemicalBag.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerAlchemicalBag.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.inventory; +import java.util.UUID; + import com.pahimar.ee3.item.ItemAlchemicalBag; import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.util.NBTHelper; @@ -10,10 +12,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import java.util.UUID; - -public class ContainerAlchemicalBag extends ContainerEE -{ +public class ContainerAlchemicalBag extends ContainerEE { // Small Bag public static final int SMALL_BAG_INVENTORY_ROWS = 4; public static final int SMALL_BAG_INVENTORY_COLUMNS = 12; @@ -29,139 +28,170 @@ public class ContainerAlchemicalBag extends ContainerEE private int bagInventoryRows; private int bagInventoryColumns; - public ContainerAlchemicalBag(EntityPlayer entityPlayer, InventoryAlchemicalBag inventoryAlchemicalBag) - { + public ContainerAlchemicalBag( + EntityPlayer entityPlayer, InventoryAlchemicalBag inventoryAlchemicalBag + ) { this.entityPlayer = entityPlayer; this.inventoryAlchemicalBag = inventoryAlchemicalBag; - if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 0) - { + if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 0) { bagInventoryRows = SMALL_BAG_INVENTORY_ROWS; bagInventoryColumns = SMALL_BAG_INVENTORY_COLUMNS; - } - else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 1) - { + } else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 1) { bagInventoryRows = MEDIUM_BAG_INVENTORY_ROWS; bagInventoryColumns = MEDIUM_BAG_INVENTORY_COLUMNS; - } - else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 2) - { + } else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 2) { bagInventoryRows = LARGE_BAG_INVENTORY_ROWS; bagInventoryColumns = LARGE_BAG_INVENTORY_COLUMNS; } // Add the Alchemical Chest slots to the container - for (int bagRowIndex = 0; bagRowIndex < bagInventoryRows; ++bagRowIndex) - { - for (int bagColumnIndex = 0; bagColumnIndex < bagInventoryColumns; ++bagColumnIndex) - { - if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 0) - { - this.addSlotToContainer(new SlotAlchemicalBag(this, inventoryAlchemicalBag, entityPlayer, bagColumnIndex + bagRowIndex * bagInventoryColumns, 8 + bagColumnIndex * 18, 18 + bagRowIndex * 18)); - } - else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 1) - { - this.addSlotToContainer(new SlotAlchemicalBag(this, inventoryAlchemicalBag, entityPlayer, bagColumnIndex + bagRowIndex * bagInventoryColumns, 8 + bagColumnIndex * 18, 18 + bagRowIndex * 18)); - } - else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 2) - { - this.addSlotToContainer(new SlotAlchemicalBag(this, inventoryAlchemicalBag, entityPlayer, bagColumnIndex + bagRowIndex * bagInventoryColumns, 8 + bagColumnIndex * 18, 8 + bagRowIndex * 18)); + for (int bagRowIndex = 0; bagRowIndex < bagInventoryRows; ++bagRowIndex) { + for (int bagColumnIndex = 0; bagColumnIndex < bagInventoryColumns; + ++bagColumnIndex) { + if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 0) { + this.addSlotToContainer(new SlotAlchemicalBag( + this, + inventoryAlchemicalBag, + entityPlayer, + bagColumnIndex + bagRowIndex * bagInventoryColumns, + 8 + bagColumnIndex * 18, + 18 + bagRowIndex * 18 + )); + } else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 1) { + this.addSlotToContainer(new SlotAlchemicalBag( + this, + inventoryAlchemicalBag, + entityPlayer, + bagColumnIndex + bagRowIndex * bagInventoryColumns, + 8 + bagColumnIndex * 18, + 18 + bagRowIndex * 18 + )); + } else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 2) { + this.addSlotToContainer(new SlotAlchemicalBag( + this, + inventoryAlchemicalBag, + entityPlayer, + bagColumnIndex + bagRowIndex * bagInventoryColumns, + 8 + bagColumnIndex * 18, + 8 + bagRowIndex * 18 + )); } } } // Add the player's inventory slots to the container - for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex) - { - for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex) - { - if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 0) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 35 + inventoryColumnIndex * 18, 104 + inventoryRowIndex * 18)); - } - else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 1) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 35 + inventoryColumnIndex * 18, 158 + inventoryRowIndex * 18)); - } - else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 2) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 44 + inventoryColumnIndex * 18, 174 + inventoryRowIndex * 18)); + for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; + ++inventoryRowIndex) { + for (int inventoryColumnIndex = 0; + inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; + ++inventoryColumnIndex) { + if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 0) { + this.addSlotToContainer(new Slot( + entityPlayer.inventory, + inventoryColumnIndex + inventoryRowIndex * 9 + 9, + 35 + inventoryColumnIndex * 18, + 104 + inventoryRowIndex * 18 + )); + } else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 1) { + this.addSlotToContainer(new Slot( + entityPlayer.inventory, + inventoryColumnIndex + inventoryRowIndex * 9 + 9, + 35 + inventoryColumnIndex * 18, + 158 + inventoryRowIndex * 18 + )); + } else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 2) { + this.addSlotToContainer(new Slot( + entityPlayer.inventory, + inventoryColumnIndex + inventoryRowIndex * 9 + 9, + 44 + inventoryColumnIndex * 18, + 174 + inventoryRowIndex * 18 + )); } } } // Add the player's action bar slots to the container - for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex) - { - if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 0) - { - if(!(entityPlayer.inventory.getStackInSlot(actionBarSlotIndex)==inventoryAlchemicalBag.parentItemStack)) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 162)); - } - else - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 162) - { - public boolean canTakeStack(EntityPlayer p_82869_1_) - { - return false; - } - }); - } - } - else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 1) - { - if(!(entityPlayer.inventory.getStackInSlot(actionBarSlotIndex)==inventoryAlchemicalBag.parentItemStack)) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 216)); - } - else - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 216) - { - public boolean canTakeStack(EntityPlayer p_82869_1_) - { - return false; - } - }); - } - } - else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 2) - { - if(!(entityPlayer.inventory.getStackInSlot(actionBarSlotIndex)==inventoryAlchemicalBag.parentItemStack)) - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 232)); - } - else - { - this.addSlotToContainer(new Slot(entityPlayer.inventory, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 232) - { - public boolean canTakeStack(EntityPlayer p_82869_1_) - { - return false; - } - }); - } + for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; + ++actionBarSlotIndex) { + if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 0) { + if (!(entityPlayer.inventory.getStackInSlot(actionBarSlotIndex) + == inventoryAlchemicalBag.parentItemStack)) { + this.addSlotToContainer(new Slot( + entityPlayer.inventory, + actionBarSlotIndex, + 35 + actionBarSlotIndex * 18, + 162 + )); + } else { + this.addSlotToContainer(new Slot( + entityPlayer.inventory, + actionBarSlotIndex, + 35 + actionBarSlotIndex * 18, + 162 + ) { + public boolean canTakeStack(EntityPlayer p_82869_1_) { + return false; + } + }); + } + } else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 1) { + if (!(entityPlayer.inventory.getStackInSlot(actionBarSlotIndex) + == inventoryAlchemicalBag.parentItemStack)) { + this.addSlotToContainer(new Slot( + entityPlayer.inventory, + actionBarSlotIndex, + 35 + actionBarSlotIndex * 18, + 216 + )); + } else { + this.addSlotToContainer(new Slot( + entityPlayer.inventory, + actionBarSlotIndex, + 35 + actionBarSlotIndex * 18, + 216 + ) { + public boolean canTakeStack(EntityPlayer p_82869_1_) { + return false; + } + }); + } + } else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 2) { + if (!(entityPlayer.inventory.getStackInSlot(actionBarSlotIndex) + == inventoryAlchemicalBag.parentItemStack)) { + this.addSlotToContainer(new Slot( + entityPlayer.inventory, + actionBarSlotIndex, + 44 + actionBarSlotIndex * 18, + 232 + )); + } else { + this.addSlotToContainer(new Slot( + entityPlayer.inventory, + actionBarSlotIndex, + 44 + actionBarSlotIndex * 18, + 232 + ) { + public boolean canTakeStack(EntityPlayer p_82869_1_) { + return false; + } + }); + } } } } @Override - public void onContainerClosed(EntityPlayer entityPlayer) - { + public void onContainerClosed(EntityPlayer entityPlayer) { super.onContainerClosed(entityPlayer); - if (!entityPlayer.worldObj.isRemote) - { - // We can probably do this better now considering the InventoryAlchemicalBag has a findParent method + if (!entityPlayer.worldObj.isRemote) { + // We can probably do this better now considering the InventoryAlchemicalBag + // has a findParent method InventoryPlayer invPlayer = entityPlayer.inventory; - for (ItemStack itemStack : invPlayer.mainInventory) - { - if (itemStack != null) - { - if (NBTHelper.hasKey(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN)) - { + for (ItemStack itemStack : invPlayer.mainInventory) { + if (itemStack != null) { + if (NBTHelper.hasKey(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN)) { NBTHelper.removeTag(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN); } } @@ -172,70 +202,80 @@ public class ContainerAlchemicalBag extends ContainerEE } @Override - public boolean canInteractWith(EntityPlayer entityPlayer) - { + public boolean canInteractWith(EntityPlayer entityPlayer) { return true; } - public boolean isItemStackParent(ItemStack itemStack) - { - if (NBTHelper.hasUUID(itemStack)) - { - UUID stackUUID = new UUID(itemStack.getTagCompound().getLong(Names.NBT.UUID_MOST_SIG), itemStack.getTagCompound().getLong(Names.NBT.UUID_LEAST_SIG)); + public boolean isItemStackParent(ItemStack itemStack) { + if (NBTHelper.hasUUID(itemStack)) { + UUID stackUUID = new UUID( + itemStack.getTagCompound().getLong(Names.NBT.UUID_MOST_SIG), + itemStack.getTagCompound().getLong(Names.NBT.UUID_LEAST_SIG) + ); return inventoryAlchemicalBag.matchesUUID(stackUUID); } return false; } @Override - public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) - { + public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { ItemStack newItemStack = null; Slot slot = (Slot) inventorySlots.get(slotIndex); - if (slot != null && slot.getHasStack()) - { + if (slot != null && slot.getHasStack()) { ItemStack itemStack = slot.getStack(); newItemStack = itemStack.copy(); - // Attempt to shift click something from the bag inventory into the player inventory - if (slotIndex < bagInventoryRows * bagInventoryColumns) - { - if (!this.mergeItemStack(itemStack, bagInventoryRows * bagInventoryColumns, inventorySlots.size(), false)) - { + // Attempt to shift click something from the bag inventory into the player + // inventory + if (slotIndex < bagInventoryRows * bagInventoryColumns) { + if (!this.mergeItemStack( + itemStack, + bagInventoryRows * bagInventoryColumns, + inventorySlots.size(), + false + )) { return null; } } // Special case if we are dealing with an Alchemical Bag being shift clicked - else if (itemStack.getItem() instanceof ItemAlchemicalBag) - { - // Attempt to shift click a bag from the player inventory into the hot bar inventory - if (slotIndex < (bagInventoryRows * bagInventoryColumns) + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS)) - { - if (!this.mergeItemStack(itemStack, (bagInventoryRows * bagInventoryColumns) + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), inventorySlots.size(), false)) - { + else if (itemStack.getItem() instanceof ItemAlchemicalBag) { + // Attempt to shift click a bag from the player inventory into the hot bar + // inventory + if (slotIndex < (bagInventoryRows * bagInventoryColumns) + + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS)) { + if (!this.mergeItemStack( + itemStack, + (bagInventoryRows * bagInventoryColumns) + + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), + inventorySlots.size(), + false + )) { return null; } } - // Attempt to shift click a bag from the hot bar inventory into the player inventory - else if (!this.mergeItemStack(itemStack, bagInventoryRows * bagInventoryColumns, (bagInventoryRows * bagInventoryColumns) + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), false)) - { + // Attempt to shift click a bag from the hot bar inventory into the player + // inventory + else if (!this.mergeItemStack( + itemStack, + bagInventoryRows * bagInventoryColumns, + (bagInventoryRows * bagInventoryColumns) + + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), + false + )) { return null; } } // Attempt to shift click a non-Alchemical Bag into the bag inventory - else if (!this.mergeItemStack(itemStack, 0, bagInventoryRows * bagInventoryColumns, false)) - { + else if (!this.mergeItemStack( + itemStack, 0, bagInventoryRows * bagInventoryColumns, false + )) { return null; } - - if (itemStack.stackSize == 0) - { + if (itemStack.stackSize == 0) { slot.putStack(null); - } - else - { + } else { slot.onSlotChanged(); } } @@ -243,40 +283,42 @@ public class ContainerAlchemicalBag extends ContainerEE return newItemStack; } - public void saveInventory(EntityPlayer entityPlayer) - { + public void saveInventory(EntityPlayer entityPlayer) { inventoryAlchemicalBag.onGuiSaved(entityPlayer); } - private class SlotAlchemicalBag extends Slot - { + private class SlotAlchemicalBag extends Slot { private final EntityPlayer entityPlayer; private ContainerAlchemicalBag containerAlchemicalBag; - public SlotAlchemicalBag(ContainerAlchemicalBag containerAlchemicalBag, IInventory inventory, EntityPlayer entityPlayer, int slotIndex, int x, int y) - { + public SlotAlchemicalBag( + ContainerAlchemicalBag containerAlchemicalBag, + IInventory inventory, + EntityPlayer entityPlayer, + int slotIndex, + int x, + int y + ) { super(inventory, slotIndex, x, y); this.entityPlayer = entityPlayer; this.containerAlchemicalBag = containerAlchemicalBag; } @Override - public void onSlotChanged() - { + public void onSlotChanged() { super.onSlotChanged(); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) - { + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { containerAlchemicalBag.saveInventory(entityPlayer); } } /** - * Check if the stack is a valid item for this slot. Always true beside for the armor slots. + * Check if the stack is a valid item for this slot. Always true beside for the + * armor slots. */ @Override - public boolean isItemValid(ItemStack itemStack) - { + public boolean isItemValid(ItemStack itemStack) { return !(itemStack.getItem() instanceof ItemAlchemicalBag); } } diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerAlchemicalChest.java b/src/main/java/com/pahimar/ee3/inventory/ContainerAlchemicalChest.java index b76b4081..fa74230e 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerAlchemicalChest.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerAlchemicalChest.java @@ -6,100 +6,120 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerAlchemicalChest extends ContainerEE -{ +public class ContainerAlchemicalChest extends ContainerEE { // Small Chest public static final int SMALL_CHEST_INVENTORY_ROWS = 4; public static final int SMALL_CHEST_INVENTORY_COLUMNS = 12; - public static final int SMALL_INVENTORY_SIZE = SMALL_CHEST_INVENTORY_ROWS * SMALL_CHEST_INVENTORY_COLUMNS; + public static final int SMALL_INVENTORY_SIZE + = SMALL_CHEST_INVENTORY_ROWS * SMALL_CHEST_INVENTORY_COLUMNS; // Medium Chest public static final int MEDIUM_CHEST_INVENTORY_ROWS = 7; public static final int MEDIUM_CHEST_INVENTORY_COLUMNS = 12; - public static final int MEDIUM_INVENTORY_SIZE = MEDIUM_CHEST_INVENTORY_ROWS * MEDIUM_CHEST_INVENTORY_COLUMNS; + public static final int MEDIUM_INVENTORY_SIZE + = MEDIUM_CHEST_INVENTORY_ROWS * MEDIUM_CHEST_INVENTORY_COLUMNS; // Large Chest public static final int LARGE_CHEST_INVENTORY_ROWS = 9; public static final int LARGE_CHEST_INVENTORY_COLUMNS = 13; - public static final int LARGE_INVENTORY_SIZE = LARGE_CHEST_INVENTORY_ROWS * LARGE_CHEST_INVENTORY_COLUMNS; + public static final int LARGE_INVENTORY_SIZE + = LARGE_CHEST_INVENTORY_ROWS * LARGE_CHEST_INVENTORY_COLUMNS; private TileEntityAlchemicalChest tileEntityAlchemicalChest; private int chestInventoryRows; private int chestInventoryColumns; - public ContainerAlchemicalChest(InventoryPlayer inventoryPlayer, TileEntityAlchemicalChest tileEntityAlchemicalChest) - { + public ContainerAlchemicalChest( + InventoryPlayer inventoryPlayer, + TileEntityAlchemicalChest tileEntityAlchemicalChest + ) { this.tileEntityAlchemicalChest = tileEntityAlchemicalChest; tileEntityAlchemicalChest.openInventory(); - if (this.tileEntityAlchemicalChest.getState() == 0) - { + if (this.tileEntityAlchemicalChest.getState() == 0) { chestInventoryRows = SMALL_CHEST_INVENTORY_ROWS; chestInventoryColumns = SMALL_CHEST_INVENTORY_COLUMNS; - } - else if (this.tileEntityAlchemicalChest.getState() == 1) - { + } else if (this.tileEntityAlchemicalChest.getState() == 1) { chestInventoryRows = MEDIUM_CHEST_INVENTORY_ROWS; chestInventoryColumns = MEDIUM_CHEST_INVENTORY_COLUMNS; - } - else if (this.tileEntityAlchemicalChest.getState() == 2) - { + } else if (this.tileEntityAlchemicalChest.getState() == 2) { chestInventoryRows = LARGE_CHEST_INVENTORY_ROWS; chestInventoryColumns = LARGE_CHEST_INVENTORY_COLUMNS; } // Add the Alchemical Chest slots to the container - for (int chestRowIndex = 0; chestRowIndex < chestInventoryRows; ++chestRowIndex) - { - for (int chestColumnIndex = 0; chestColumnIndex < chestInventoryColumns; ++chestColumnIndex) - { - if (this.tileEntityAlchemicalChest.getState() == 0) - { - this.addSlotToContainer(new Slot(tileEntityAlchemicalChest, chestColumnIndex + chestRowIndex * chestInventoryColumns, 8 + chestColumnIndex * 18, 18 + chestRowIndex * 18)); - } - else if (this.tileEntityAlchemicalChest.getState() == 1) - { - this.addSlotToContainer(new Slot(tileEntityAlchemicalChest, chestColumnIndex + chestRowIndex * chestInventoryColumns, 8 + chestColumnIndex * 18, 18 + chestRowIndex * 18)); - } - else if (this.tileEntityAlchemicalChest.getState() == 2) - { - this.addSlotToContainer(new Slot(tileEntityAlchemicalChest, chestColumnIndex + chestRowIndex * chestInventoryColumns, 8 + chestColumnIndex * 18, 8 + chestRowIndex * 18)); + for (int chestRowIndex = 0; chestRowIndex < chestInventoryRows; ++chestRowIndex) { + for (int chestColumnIndex = 0; chestColumnIndex < chestInventoryColumns; + ++chestColumnIndex) { + if (this.tileEntityAlchemicalChest.getState() == 0) { + this.addSlotToContainer(new Slot( + tileEntityAlchemicalChest, + chestColumnIndex + chestRowIndex * chestInventoryColumns, + 8 + chestColumnIndex * 18, + 18 + chestRowIndex * 18 + )); + } else if (this.tileEntityAlchemicalChest.getState() == 1) { + this.addSlotToContainer(new Slot( + tileEntityAlchemicalChest, + chestColumnIndex + chestRowIndex * chestInventoryColumns, + 8 + chestColumnIndex * 18, + 18 + chestRowIndex * 18 + )); + } else if (this.tileEntityAlchemicalChest.getState() == 2) { + this.addSlotToContainer(new Slot( + tileEntityAlchemicalChest, + chestColumnIndex + chestRowIndex * chestInventoryColumns, + 8 + chestColumnIndex * 18, + 8 + chestRowIndex * 18 + )); } } } // Add the player's inventory slots to the container - for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex) - { - for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex) - { - if (this.tileEntityAlchemicalChest.getState() == 0) - { - this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 35 + inventoryColumnIndex * 18, 104 + inventoryRowIndex * 18)); - } - else if (this.tileEntityAlchemicalChest.getState() == 1) - { - this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 35 + inventoryColumnIndex * 18, 158 + inventoryRowIndex * 18)); - } - else if (this.tileEntityAlchemicalChest.getState() == 2) - { - this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 44 + inventoryColumnIndex * 18, 174 + inventoryRowIndex * 18)); + for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; + ++inventoryRowIndex) { + for (int inventoryColumnIndex = 0; + inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; + ++inventoryColumnIndex) { + if (this.tileEntityAlchemicalChest.getState() == 0) { + this.addSlotToContainer(new Slot( + inventoryPlayer, + inventoryColumnIndex + inventoryRowIndex * 9 + 9, + 35 + inventoryColumnIndex * 18, + 104 + inventoryRowIndex * 18 + )); + } else if (this.tileEntityAlchemicalChest.getState() == 1) { + this.addSlotToContainer(new Slot( + inventoryPlayer, + inventoryColumnIndex + inventoryRowIndex * 9 + 9, + 35 + inventoryColumnIndex * 18, + 158 + inventoryRowIndex * 18 + )); + } else if (this.tileEntityAlchemicalChest.getState() == 2) { + this.addSlotToContainer(new Slot( + inventoryPlayer, + inventoryColumnIndex + inventoryRowIndex * 9 + 9, + 44 + inventoryColumnIndex * 18, + 174 + inventoryRowIndex * 18 + )); } } } // Add the player's action bar slots to the container - for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex) - { - if (this.tileEntityAlchemicalChest.getState() == 0) - { - this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 162)); - } - else if (this.tileEntityAlchemicalChest.getState() == 1) - { - this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 216)); - } - else if (this.tileEntityAlchemicalChest.getState() == 2) - { - this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 232)); + for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; + ++actionBarSlotIndex) { + if (this.tileEntityAlchemicalChest.getState() == 0) { + this.addSlotToContainer(new Slot( + inventoryPlayer, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 162 + )); + } else if (this.tileEntityAlchemicalChest.getState() == 1) { + this.addSlotToContainer(new Slot( + inventoryPlayer, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 216 + )); + } else if (this.tileEntityAlchemicalChest.getState() == 2) { + this.addSlotToContainer(new Slot( + inventoryPlayer, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 232 + )); } } } @@ -108,47 +128,43 @@ public class ContainerAlchemicalChest extends ContainerEE * Callback for when the crafting gui is closed. */ @Override - public void onContainerClosed(EntityPlayer entityPlayer) - { + public void onContainerClosed(EntityPlayer entityPlayer) { super.onContainerClosed(entityPlayer); tileEntityAlchemicalChest.closeInventory(); } @Override - public boolean canInteractWith(EntityPlayer entityPlayer) - { + public boolean canInteractWith(EntityPlayer entityPlayer) { return this.tileEntityAlchemicalChest.isUseableByPlayer(entityPlayer); } @Override - public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) - { + public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { ItemStack newItemStack = null; Slot slot = (Slot) inventorySlots.get(slotIndex); - if (slot != null && slot.getHasStack()) - { + if (slot != null && slot.getHasStack()) { ItemStack itemStack = slot.getStack(); newItemStack = itemStack.copy(); - if (slotIndex < chestInventoryRows * chestInventoryColumns) - { - if (!this.mergeItemStack(itemStack, chestInventoryRows * chestInventoryColumns, inventorySlots.size(), false)) - { + if (slotIndex < chestInventoryRows * chestInventoryColumns) { + if (!this.mergeItemStack( + itemStack, + chestInventoryRows * chestInventoryColumns, + inventorySlots.size(), + false + )) { return null; } - } - else if (!this.mergeItemStack(itemStack, 0, chestInventoryRows * chestInventoryColumns, false)) - { + } else if (!this.mergeItemStack( + itemStack, 0, chestInventoryRows * chestInventoryColumns, false + )) { return null; } - if (itemStack.stackSize == 0) - { + if (itemStack.stackSize == 0) { slot.putStack(null); - } - else - { + } else { slot.onSlotChanged(); } } diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerAlchenomicon.java b/src/main/java/com/pahimar/ee3/inventory/ContainerAlchenomicon.java index 2e28c91b..627fdce6 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerAlchenomicon.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerAlchenomicon.java @@ -1,5 +1,9 @@ package com.pahimar.ee3.inventory; +import java.util.ArrayList; +import java.util.List; +import java.util.TreeSet; + import com.pahimar.ee3.api.knowledge.PlayerKnowledgeRegistryProxy; import com.pahimar.ee3.inventory.element.IElementButtonHandler; import com.pahimar.ee3.inventory.element.IElementTextFieldHandler; @@ -14,12 +18,8 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import java.util.ArrayList; -import java.util.List; -import java.util.TreeSet; - -public class ContainerAlchenomicon extends ContainerEE implements IElementButtonHandler, IElementTextFieldHandler -{ +public class ContainerAlchenomicon + extends ContainerEE implements IElementButtonHandler, IElementTextFieldHandler { private final InventoryAlchenomicon inventoryAlchenomicon; private int pageOffset, maxPageOffset; private String searchTerm; @@ -28,13 +28,16 @@ public class ContainerAlchenomicon extends ContainerEE implements IElementButton private final static int MAX_ROW_INDEX = 8; private final static int MAX_COLUMN_INDEX = 5; - public ContainerAlchenomicon(EntityPlayer entityPlayer, ItemStack itemStack) - { - TreeSet knownTransmutations = new TreeSet<>(Comparators.DISPLAY_NAME_COMPARATOR); + public ContainerAlchenomicon(EntityPlayer entityPlayer, ItemStack itemStack) { + TreeSet knownTransmutations + = new TreeSet<>(Comparators.DISPLAY_NAME_COMPARATOR); - if (itemStack.getItem() instanceof ItemAlchenomicon && ItemStackUtils.getOwnerName(itemStack) != null) { + if (itemStack.getItem() instanceof ItemAlchenomicon + && ItemStackUtils.getOwnerName(itemStack) != null) { String playerName = ItemStackUtils.getOwnerName(itemStack); - knownTransmutations.addAll(PlayerKnowledgeRegistryProxy.getKnownItemStacks(playerName)); + knownTransmutations.addAll( + PlayerKnowledgeRegistryProxy.getKnownItemStacks(playerName) + ); } inventoryAlchenomicon = new InventoryAlchenomicon(knownTransmutations); @@ -42,22 +45,19 @@ public class ContainerAlchenomicon extends ContainerEE implements IElementButton maxPageOffset = knownTransmutations.size() / 80; int i = 0; - for (int rowIndex = 0; rowIndex < MAX_ROW_INDEX; ++rowIndex) - { - for (int columnIndex = 0; columnIndex < MAX_COLUMN_INDEX; ++columnIndex) - { - this.addSlotToContainer(new Slot(inventoryAlchenomicon, i, 18 + columnIndex * 20, 18 + rowIndex * 19) - { + for (int rowIndex = 0; rowIndex < MAX_ROW_INDEX; ++rowIndex) { + for (int columnIndex = 0; columnIndex < MAX_COLUMN_INDEX; ++columnIndex) { + this.addSlotToContainer(new Slot( + inventoryAlchenomicon, i, 18 + columnIndex * 20, 18 + rowIndex * 19 + ) { @Override - public boolean canTakeStack(EntityPlayer player) - { + public boolean canTakeStack(EntityPlayer player) { return false; } @Override @SideOnly(Side.CLIENT) - public boolean func_111238_b() - { + public boolean func_111238_b() { return false; } }); @@ -66,22 +66,19 @@ public class ContainerAlchenomicon extends ContainerEE implements IElementButton } i = 40; - for (int rowIndex = 0; rowIndex < MAX_ROW_INDEX; ++rowIndex) - { - for (int columnIndex = 0; columnIndex < MAX_COLUMN_INDEX; ++columnIndex) - { - this.addSlotToContainer(new Slot(inventoryAlchenomicon, i, 140 + columnIndex * 20, 18 + rowIndex * 19) - { + for (int rowIndex = 0; rowIndex < MAX_ROW_INDEX; ++rowIndex) { + for (int columnIndex = 0; columnIndex < MAX_COLUMN_INDEX; ++columnIndex) { + this.addSlotToContainer(new Slot( + inventoryAlchenomicon, i, 140 + columnIndex * 20, 18 + rowIndex * 19 + ) { @Override - public boolean canTakeStack(EntityPlayer player) - { + public boolean canTakeStack(EntityPlayer player) { return false; } @Override @SideOnly(Side.CLIENT) - public boolean func_111238_b() - { + public boolean func_111238_b() { return false; } }); @@ -91,22 +88,18 @@ public class ContainerAlchenomicon extends ContainerEE implements IElementButton } @Override - public void addCraftingToCrafters(ICrafting iCrafting) - { + public void addCraftingToCrafters(ICrafting iCrafting) { super.addCraftingToCrafters(iCrafting); iCrafting.sendProgressBarUpdate(this, 0, this.pageOffset); iCrafting.sendProgressBarUpdate(this, 1, this.maxPageOffset); } @Override - public void detectAndSendChanges() - { + public void detectAndSendChanges() { super.detectAndSendChanges(); - if (requiresUpdate) - { - for (Object crafter : this.crafters) - { + if (requiresUpdate) { + for (Object crafter : this.crafters) { ICrafting icrafting = (ICrafting) crafter; icrafting.sendProgressBarUpdate(this, 0, this.pageOffset); icrafting.sendProgressBarUpdate(this, 1, this.maxPageOffset); @@ -117,111 +110,92 @@ public class ContainerAlchenomicon extends ContainerEE implements IElementButton } @SideOnly(Side.CLIENT) - public void updateProgressBar(int valueType, int updatedValue) - { - if (valueType == 0) - { + public void updateProgressBar(int valueType, int updatedValue) { + if (valueType == 0) { this.pageOffset = updatedValue; - } - else if (valueType == 1) - { + } else if (valueType == 1) { this.maxPageOffset = updatedValue; } } @Override - public boolean canInteractWith(EntityPlayer entityPlayer) - { + public boolean canInteractWith(EntityPlayer entityPlayer) { return true; } - public int getInventorySize() - { + public int getInventorySize() { return inventoryAlchenomicon.getSizeInventory(); } - public int getKnownTransmutationsCount() - { + public int getKnownTransmutationsCount() { return inventoryAlchenomicon.getKnownTransmutations().size(); } - public int getPageOffset() - { + public int getPageOffset() { return this.pageOffset; } - public int getMaxPageOffset() - { + public int getMaxPageOffset() { return this.maxPageOffset; } @Override - public void handleElementButtonClick(String elementName, int mouseButton) - { - if (elementName.equalsIgnoreCase("prev") && mouseButton == 0 && this.pageOffset > 0) - { + public void handleElementButtonClick(String elementName, int mouseButton) { + if (elementName.equalsIgnoreCase("prev") && mouseButton == 0 + && this.pageOffset > 0) { this.pageOffset--; updateInventory(); - } - else if (elementName.equalsIgnoreCase("next") && mouseButton == 0 && this.pageOffset < this.maxPageOffset) - { + } else if (elementName.equalsIgnoreCase("next") && mouseButton == 0 && this.pageOffset < this.maxPageOffset) { this.pageOffset++; updateInventory(); } } @Override - public void handleElementTextFieldUpdate(String elementName, String updatedText) - { - if (elementName.equalsIgnoreCase("searchField")) - { + public void handleElementTextFieldUpdate(String elementName, String updatedText) { + if (elementName.equalsIgnoreCase("searchField")) { this.searchTerm = updatedText; pageOffset = 0; updateInventory(); } } - private void updateInventory() - { + private void updateInventory() { this.requiresUpdate = true; boolean shouldUpdateInventory = false; ItemStack[] newInventory = new ItemStack[80]; - List filteredList = new ArrayList<>(FilterUtils.filterByDisplayName(inventoryAlchenomicon.getKnownTransmutations(), searchTerm, FilterUtils.NameFilterType.CONTAINS, Comparators.DISPLAY_NAME_COMPARATOR)); + List filteredList = new ArrayList<>(FilterUtils.filterByDisplayName( + inventoryAlchenomicon.getKnownTransmutations(), + searchTerm, + FilterUtils.NameFilterType.CONTAINS, + Comparators.DISPLAY_NAME_COMPARATOR + )); maxPageOffset = filteredList.size() / 80; - if (pageOffset > maxPageOffset) - { + if (pageOffset > maxPageOffset) { pageOffset = 0; } - if (pageOffset == 0) - { - if (filteredList.size() <= 80) - { + if (pageOffset == 0) { + if (filteredList.size() <= 80) { newInventory = filteredList.toArray(newInventory); shouldUpdateInventory = true; - } - else - { + } else { newInventory = filteredList.subList(0, 80).toArray(newInventory); shouldUpdateInventory = true; } - } - else if (pageOffset < maxPageOffset) - { - newInventory = filteredList.subList(pageOffset * 80, (pageOffset + 1) * 80).toArray(newInventory); + } else if (pageOffset < maxPageOffset) { + newInventory = filteredList.subList(pageOffset * 80, (pageOffset + 1) * 80) + .toArray(newInventory); shouldUpdateInventory = true; - } - else if (pageOffset == maxPageOffset) - { - newInventory = filteredList.subList(pageOffset * 80, filteredList.size() - 1).toArray(newInventory); + } else if (pageOffset == maxPageOffset) { + newInventory = filteredList.subList(pageOffset * 80, filteredList.size() - 1) + .toArray(newInventory); shouldUpdateInventory = true; } - if (shouldUpdateInventory) - { - for (int i = 0; i < 80; i++) - { + if (shouldUpdateInventory) { + for (int i = 0; i < 80; i++) { inventoryAlchenomicon.setInventorySlotContents(i, newInventory[i]); inventoryAlchenomicon.markDirty(); } diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerAludel.java b/src/main/java/com/pahimar/ee3/inventory/ContainerAludel.java index f1ec4c6a..67463d69 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerAludel.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerAludel.java @@ -12,55 +12,69 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntityFurnace; -public class ContainerAludel extends ContainerEE -{ +public class ContainerAludel extends ContainerEE { private TileEntityAludel tileEntityAludel; private int lastDeviceCookTime; private int lastFuelBurnTime; private int lastItemCookTime; - public ContainerAludel(InventoryPlayer inventoryPlayer, TileEntityAludel tileEntityAludel) - { + public ContainerAludel( + InventoryPlayer inventoryPlayer, TileEntityAludel tileEntityAludel + ) { this.tileEntityAludel = tileEntityAludel; - this.addSlotToContainer(new Slot(tileEntityAludel, TileEntityAludel.FUEL_INVENTORY_INDEX, 44, 74)); - this.addSlotToContainer(new Slot(tileEntityAludel, TileEntityAludel.INPUT_INVENTORY_INDEX, 44, 18)); - this.addSlotToContainer(new Slot(tileEntityAludel, TileEntityAludel.DUST_INVENTORY_INDEX, 44, 39)); - this.addSlotToContainer(new Slot(tileEntityAludel, TileEntityAludel.OUTPUT_INVENTORY_INDEX, 120, 39) - { + this.addSlotToContainer( + new Slot(tileEntityAludel, TileEntityAludel.FUEL_INVENTORY_INDEX, 44, 74) + ); + this.addSlotToContainer( + new Slot(tileEntityAludel, TileEntityAludel.INPUT_INVENTORY_INDEX, 44, 18) + ); + this.addSlotToContainer( + new Slot(tileEntityAludel, TileEntityAludel.DUST_INVENTORY_INDEX, 44, 39) + ); + this.addSlotToContainer(new Slot( + tileEntityAludel, TileEntityAludel.OUTPUT_INVENTORY_INDEX, 120, 39 + ) { @Override - public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack) - { + public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack) { super.onPickupFromSlot(entityPlayer, itemStack); - FMLCommonHandler.instance().firePlayerCraftingEvent(entityPlayer, itemStack, inventory); + FMLCommonHandler.instance().firePlayerCraftingEvent( + entityPlayer, itemStack, inventory + ); } @Override - public boolean isItemValid(ItemStack itemStack) - { + public boolean isItemValid(ItemStack itemStack) { return false; } }); // Add the player's inventory slots to the container - for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex) - { - for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex) - { - this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 8 + inventoryColumnIndex * 18, 106 + inventoryRowIndex * 18)); + for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; + ++inventoryRowIndex) { + for (int inventoryColumnIndex = 0; + inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; + ++inventoryColumnIndex) { + this.addSlotToContainer(new Slot( + inventoryPlayer, + inventoryColumnIndex + inventoryRowIndex * 9 + 9, + 8 + inventoryColumnIndex * 18, + 106 + inventoryRowIndex * 18 + )); } } // Add the player's action bar slots to the container - for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex) - { - this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 164)); + for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; + ++actionBarSlotIndex) { + this.addSlotToContainer(new Slot( + inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 164 + )); } } @Override - public void addCraftingToCrafters(ICrafting iCrafting) - { + public void addCraftingToCrafters(ICrafting iCrafting) { super.addCraftingToCrafters(iCrafting); iCrafting.sendProgressBarUpdate(this, 0, this.tileEntityAludel.deviceCookTime); iCrafting.sendProgressBarUpdate(this, 1, this.tileEntityAludel.fuelBurnTime); @@ -68,27 +82,28 @@ public class ContainerAludel extends ContainerEE } @Override - public void detectAndSendChanges() - { + public void detectAndSendChanges() { super.detectAndSendChanges(); - for (Object crafter : this.crafters) - { + for (Object crafter : this.crafters) { ICrafting icrafting = (ICrafting) crafter; - if (this.lastDeviceCookTime != this.tileEntityAludel.deviceCookTime) - { - icrafting.sendProgressBarUpdate(this, 0, this.tileEntityAludel.deviceCookTime); + if (this.lastDeviceCookTime != this.tileEntityAludel.deviceCookTime) { + icrafting.sendProgressBarUpdate( + this, 0, this.tileEntityAludel.deviceCookTime + ); } - if (this.lastFuelBurnTime != this.tileEntityAludel.fuelBurnTime) - { - icrafting.sendProgressBarUpdate(this, 1, this.tileEntityAludel.fuelBurnTime); + if (this.lastFuelBurnTime != this.tileEntityAludel.fuelBurnTime) { + icrafting.sendProgressBarUpdate( + this, 1, this.tileEntityAludel.fuelBurnTime + ); } - if (this.lastItemCookTime != this.tileEntityAludel.itemCookTime) - { - icrafting.sendProgressBarUpdate(this, 2, this.tileEntityAludel.itemCookTime); + if (this.lastItemCookTime != this.tileEntityAludel.itemCookTime) { + icrafting.sendProgressBarUpdate( + this, 2, this.tileEntityAludel.itemCookTime + ); } } @@ -98,13 +113,11 @@ public class ContainerAludel extends ContainerEE } @Override - public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) - { + public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { ItemStack itemStack = null; Slot slot = (Slot) inventorySlots.get(slotIndex); - if (slot != null && slot.getHasStack()) - { + if (slot != null && slot.getHasStack()) { ItemStack slotItemStack = slot.getStack(); itemStack = slotItemStack.copy(); @@ -113,25 +126,29 @@ public class ContainerAludel extends ContainerEE * attempt to put it in the first available slot in the player's * inventory */ - if (slotIndex < TileEntityAludel.INVENTORY_SIZE) - { - if (!this.mergeItemStack(slotItemStack, TileEntityAludel.INVENTORY_SIZE, inventorySlots.size(), false)) - { + if (slotIndex < TileEntityAludel.INVENTORY_SIZE) { + if (!this.mergeItemStack( + slotItemStack, + TileEntityAludel.INVENTORY_SIZE, + inventorySlots.size(), + false + )) { return null; } - } - else - { + } else { /** * If the stack being shift-clicked into the Aludel's container * is a fuel, first try to put it in the fuel slot. If it cannot * be merged into the fuel slot, try to put it in the input * slot. */ - if (TileEntityFurnace.isItemFuel(slotItemStack)) - { - if (!this.mergeItemStack(slotItemStack, TileEntityAludel.FUEL_INVENTORY_INDEX, TileEntityAludel.OUTPUT_INVENTORY_INDEX, false)) - { + if (TileEntityFurnace.isItemFuel(slotItemStack)) { + if (!this.mergeItemStack( + slotItemStack, + TileEntityAludel.FUEL_INVENTORY_INDEX, + TileEntityAludel.OUTPUT_INVENTORY_INDEX, + false + )) { return null; } } @@ -142,10 +159,13 @@ public class ContainerAludel extends ContainerEE * be merged into the dust slot, try to put it in the input * slot. */ - else if (slotItemStack.getItem() instanceof ItemAlchemicalDust) - { - if (!this.mergeItemStack(slotItemStack, TileEntityAludel.DUST_INVENTORY_INDEX, TileEntityAludel.OUTPUT_INVENTORY_INDEX, false)) - { + else if (slotItemStack.getItem() instanceof ItemAlchemicalDust) { + if (!this.mergeItemStack( + slotItemStack, + TileEntityAludel.DUST_INVENTORY_INDEX, + TileEntityAludel.OUTPUT_INVENTORY_INDEX, + false + )) { return null; } } @@ -153,18 +173,19 @@ public class ContainerAludel extends ContainerEE /** * Finally, attempt to put stack into the input slot */ - else if (!this.mergeItemStack(slotItemStack, TileEntityAludel.INPUT_INVENTORY_INDEX, TileEntityAludel.DUST_INVENTORY_INDEX, false)) - { + else if (!this.mergeItemStack( + slotItemStack, + TileEntityAludel.INPUT_INVENTORY_INDEX, + TileEntityAludel.DUST_INVENTORY_INDEX, + false + )) { return null; } } - if (slotItemStack.stackSize == 0) - { + if (slotItemStack.stackSize == 0) { slot.putStack(null); - } - else - { + } else { slot.onSlotChanged(); } } @@ -173,27 +194,22 @@ public class ContainerAludel extends ContainerEE } @SideOnly(Side.CLIENT) - public void updateProgressBar(int valueType, int updatedValue) - { - if (valueType == 0) - { + public void updateProgressBar(int valueType, int updatedValue) { + if (valueType == 0) { this.tileEntityAludel.deviceCookTime = updatedValue; } - if (valueType == 1) - { + if (valueType == 1) { this.tileEntityAludel.fuelBurnTime = updatedValue; } - if (valueType == 2) - { + if (valueType == 2) { this.tileEntityAludel.itemCookTime = updatedValue; } } @Override - public boolean canInteractWith(EntityPlayer entityPlayer) - { + public boolean canInteractWith(EntityPlayer entityPlayer) { return this.tileEntityAludel.isUseableByPlayer(entityPlayer); } } diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerCalcinator.java b/src/main/java/com/pahimar/ee3/inventory/ContainerCalcinator.java index 8a105c00..1ce80ac1 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerCalcinator.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerCalcinator.java @@ -12,74 +12,97 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntityFurnace; -public class ContainerCalcinator extends ContainerEE -{ +public class ContainerCalcinator extends ContainerEE { private TileEntityCalcinator tileEntityCalcinator; - private int lastCookTime; // How much longer the Calcinator will burn - private int lastBurnTime; // The fuel value for the currently burning fuel - private int lastItemCookTime; // How long the current item has been "cooking" + private int lastCookTime; // How much longer the Calcinator will burn + private int lastBurnTime; // The fuel value for the currently burning fuel + private int lastItemCookTime; // How long the current item has been "cooking" - public ContainerCalcinator(InventoryPlayer inventoryPlayer, TileEntityCalcinator tileEntityCalcinator) - { + public ContainerCalcinator( + InventoryPlayer inventoryPlayer, TileEntityCalcinator tileEntityCalcinator + ) { this.tileEntityCalcinator = tileEntityCalcinator; // Add the fuel slot to the container - this.addSlotToContainer(new Slot(tileEntityCalcinator, TileEntityCalcinator.FUEL_INVENTORY_INDEX, 45, 55)); + this.addSlotToContainer(new Slot( + tileEntityCalcinator, TileEntityCalcinator.FUEL_INVENTORY_INDEX, 45, 55 + )); // Add the input slot to the container - this.addSlotToContainer(new Slot(tileEntityCalcinator, TileEntityCalcinator.INPUT_INVENTORY_INDEX, 45, 10)); + this.addSlotToContainer(new Slot( + tileEntityCalcinator, TileEntityCalcinator.INPUT_INVENTORY_INDEX, 45, 10 + )); // Add the output results slot to the container - this.addSlotToContainer(new SlotCalcinator(tileEntityCalcinator, TileEntityCalcinator.OUTPUT_LEFT_INVENTORY_INDEX, 105, 29)); - this.addSlotToContainer(new SlotCalcinator(tileEntityCalcinator, TileEntityCalcinator.OUTPUT_RIGHT_INVENTORY_INDEX, 125, 29)); + this.addSlotToContainer(new SlotCalcinator( + tileEntityCalcinator, + TileEntityCalcinator.OUTPUT_LEFT_INVENTORY_INDEX, + 105, + 29 + )); + this.addSlotToContainer(new SlotCalcinator( + tileEntityCalcinator, + TileEntityCalcinator.OUTPUT_RIGHT_INVENTORY_INDEX, + 125, + 29 + )); // Add the player's inventory slots to the container - for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex) - { - for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex) - { - this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 8 + inventoryColumnIndex * 18, 94 + inventoryRowIndex * 18)); + for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; + ++inventoryRowIndex) { + for (int inventoryColumnIndex = 0; + inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; + ++inventoryColumnIndex) { + this.addSlotToContainer(new Slot( + inventoryPlayer, + inventoryColumnIndex + inventoryRowIndex * 9 + 9, + 8 + inventoryColumnIndex * 18, + 94 + inventoryRowIndex * 18 + )); } } // Add the player's action bar slots to the container - for (int actionBarSlotIndex = 0; actionBarSlotIndex < 9; ++actionBarSlotIndex) - { - this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 152)); + for (int actionBarSlotIndex = 0; actionBarSlotIndex < 9; ++actionBarSlotIndex) { + this.addSlotToContainer(new Slot( + inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 152 + )); } } @Override - public void addCraftingToCrafters(ICrafting iCrafting) - { + public void addCraftingToCrafters(ICrafting iCrafting) { super.addCraftingToCrafters(iCrafting); - iCrafting.sendProgressBarUpdate(this, 0, this.tileEntityCalcinator.deviceCookTime); + iCrafting.sendProgressBarUpdate( + this, 0, this.tileEntityCalcinator.deviceCookTime + ); iCrafting.sendProgressBarUpdate(this, 1, this.tileEntityCalcinator.fuelBurnTime); iCrafting.sendProgressBarUpdate(this, 2, this.tileEntityCalcinator.itemCookTime); } @Override - public void detectAndSendChanges() - { + public void detectAndSendChanges() { super.detectAndSendChanges(); - for (Object crafter : this.crafters) - { + for (Object crafter : this.crafters) { ICrafting icrafting = (ICrafting) crafter; - if (this.lastCookTime != this.tileEntityCalcinator.deviceCookTime) - { - icrafting.sendProgressBarUpdate(this, 0, this.tileEntityCalcinator.deviceCookTime); + if (this.lastCookTime != this.tileEntityCalcinator.deviceCookTime) { + icrafting.sendProgressBarUpdate( + this, 0, this.tileEntityCalcinator.deviceCookTime + ); } - if (this.lastBurnTime != this.tileEntityCalcinator.fuelBurnTime) - { - icrafting.sendProgressBarUpdate(this, 1, this.tileEntityCalcinator.fuelBurnTime); + if (this.lastBurnTime != this.tileEntityCalcinator.fuelBurnTime) { + icrafting.sendProgressBarUpdate( + this, 1, this.tileEntityCalcinator.fuelBurnTime + ); } - if (this.lastItemCookTime != this.tileEntityCalcinator.itemCookTime) - { - icrafting.sendProgressBarUpdate(this, 2, this.tileEntityCalcinator.itemCookTime); + if (this.lastItemCookTime != this.tileEntityCalcinator.itemCookTime) { + icrafting.sendProgressBarUpdate( + this, 2, this.tileEntityCalcinator.itemCookTime + ); } } @@ -89,14 +112,11 @@ public class ContainerCalcinator extends ContainerEE } @Override - public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) - { + public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { ItemStack itemStack = null; Slot slot = (Slot) inventorySlots.get(slotIndex); - if (slot != null && slot.getHasStack()) - { - + if (slot != null && slot.getHasStack()) { ItemStack slotItemStack = slot.getStack(); itemStack = slotItemStack.copy(); @@ -105,25 +125,29 @@ public class ContainerCalcinator extends ContainerEE * attempt to put it in the first available slot in the player's * inventory */ - if (slotIndex < TileEntityCalcinator.INVENTORY_SIZE) - { - if (!this.mergeItemStack(slotItemStack, TileEntityCalcinator.INVENTORY_SIZE, inventorySlots.size(), false)) - { + if (slotIndex < TileEntityCalcinator.INVENTORY_SIZE) { + if (!this.mergeItemStack( + slotItemStack, + TileEntityCalcinator.INVENTORY_SIZE, + inventorySlots.size(), + false + )) { return null; } - } - else - { + } else { /** * If the stack being shift-clicked into the Aludel's container * is a fuel, first try to put it in the fuel slot. If it cannot * be merged into the fuel slot, try to put it in the input * slot. */ - if (TileEntityFurnace.isItemFuel(slotItemStack)) - { - if (!this.mergeItemStack(slotItemStack, TileEntityCalcinator.FUEL_INVENTORY_INDEX, TileEntityCalcinator.OUTPUT_LEFT_INVENTORY_INDEX, false)) - { + if (TileEntityFurnace.isItemFuel(slotItemStack)) { + if (!this.mergeItemStack( + slotItemStack, + TileEntityCalcinator.FUEL_INVENTORY_INDEX, + TileEntityCalcinator.OUTPUT_LEFT_INVENTORY_INDEX, + false + )) { return null; } } @@ -131,18 +155,19 @@ public class ContainerCalcinator extends ContainerEE /** * Finally, attempt to put stack into the input slot */ - else if (!this.mergeItemStack(slotItemStack, TileEntityCalcinator.INPUT_INVENTORY_INDEX, TileEntityCalcinator.OUTPUT_LEFT_INVENTORY_INDEX, false)) - { + else if (!this.mergeItemStack( + slotItemStack, + TileEntityCalcinator.INPUT_INVENTORY_INDEX, + TileEntityCalcinator.OUTPUT_LEFT_INVENTORY_INDEX, + false + )) { return null; } } - if (slotItemStack.stackSize == 0) - { + if (slotItemStack.stackSize == 0) { slot.putStack(null); - } - else - { + } else { slot.onSlotChanged(); } } @@ -151,47 +176,40 @@ public class ContainerCalcinator extends ContainerEE } @SideOnly(Side.CLIENT) - public void updateProgressBar(int valueType, int updatedValue) - { - if (valueType == 0) - { + public void updateProgressBar(int valueType, int updatedValue) { + if (valueType == 0) { this.tileEntityCalcinator.deviceCookTime = updatedValue; } - if (valueType == 1) - { + if (valueType == 1) { this.tileEntityCalcinator.fuelBurnTime = updatedValue; } - if (valueType == 2) - { + if (valueType == 2) { this.tileEntityCalcinator.itemCookTime = updatedValue; } } @Override - public boolean canInteractWith(EntityPlayer entityPlayer) - { + public boolean canInteractWith(EntityPlayer entityPlayer) { return this.tileEntityCalcinator.isUseableByPlayer(entityPlayer); } - private class SlotCalcinator extends Slot - { - public SlotCalcinator(IInventory inventory, int slotIndex, int x, int y) - { + private class SlotCalcinator extends Slot { + public SlotCalcinator(IInventory inventory, int slotIndex, int x, int y) { super(inventory, slotIndex, x, y); } @Override - public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack) - { + public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack) { super.onPickupFromSlot(entityPlayer, itemStack); - FMLCommonHandler.instance().firePlayerCraftingEvent(entityPlayer, itemStack, inventory); + FMLCommonHandler.instance().firePlayerCraftingEvent( + entityPlayer, itemStack, inventory + ); } @Override - public boolean isItemValid(ItemStack itemStack) - { + public boolean isItemValid(ItemStack itemStack) { return false; } } diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerEE.java b/src/main/java/com/pahimar/ee3/inventory/ContainerEE.java index 7cf35810..0fd885fe 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerEE.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerEE.java @@ -5,41 +5,39 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public abstract class ContainerEE extends Container -{ +public abstract class ContainerEE extends Container { protected final int PLAYER_INVENTORY_ROWS = 3; protected final int PLAYER_INVENTORY_COLUMNS = 9; @Override - protected boolean mergeItemStack(ItemStack itemStack, int slotMin, int slotMax, boolean ascending) - { + protected boolean + mergeItemStack(ItemStack itemStack, int slotMin, int slotMax, boolean ascending) { boolean slotFound = false; int currentSlotIndex = ascending ? slotMax - 1 : slotMin; Slot slot; ItemStack stackInSlot; - if (itemStack.isStackable()) - { - while (itemStack.stackSize > 0 && (!ascending && currentSlotIndex < slotMax || ascending && currentSlotIndex >= slotMin)) - { + if (itemStack.isStackable()) { + while (itemStack.stackSize > 0 + && (!ascending && currentSlotIndex < slotMax + || ascending && currentSlotIndex >= slotMin)) { slot = (Slot) this.inventorySlots.get(currentSlotIndex); stackInSlot = slot.getStack(); - if (slot.isItemValid(itemStack) && ItemStackUtils.equalsIgnoreStackSize(itemStack, stackInSlot)) - { + if (slot.isItemValid(itemStack) + && ItemStackUtils.equalsIgnoreStackSize(itemStack, stackInSlot)) { int combinedStackSize = stackInSlot.stackSize + itemStack.stackSize; - int slotStackSizeLimit = Math.min(stackInSlot.getMaxStackSize(), slot.getSlotStackLimit()); + int slotStackSizeLimit = Math.min( + stackInSlot.getMaxStackSize(), slot.getSlotStackLimit() + ); - if (combinedStackSize <= slotStackSizeLimit) - { + if (combinedStackSize <= slotStackSizeLimit) { itemStack.stackSize = 0; stackInSlot.stackSize = combinedStackSize; slot.onSlotChanged(); slotFound = true; - } - else if (stackInSlot.stackSize < slotStackSizeLimit) - { + } else if (stackInSlot.stackSize < slotStackSizeLimit) { itemStack.stackSize -= slotStackSizeLimit - stackInSlot.stackSize; stackInSlot.stackSize = slotStackSizeLimit; slot.onSlotChanged(); @@ -51,22 +49,21 @@ public abstract class ContainerEE extends Container } } - if (itemStack.stackSize > 0) - { + if (itemStack.stackSize > 0) { currentSlotIndex = ascending ? slotMax - 1 : slotMin; - while (!ascending && currentSlotIndex < slotMax || ascending && currentSlotIndex >= slotMin) - { + while (!ascending && currentSlotIndex < slotMax + || ascending && currentSlotIndex >= slotMin) { slot = (Slot) this.inventorySlots.get(currentSlotIndex); stackInSlot = slot.getStack(); - if (slot.isItemValid(itemStack) && stackInSlot == null) - { - slot.putStack(ItemStackUtils.clone(itemStack, Math.min(itemStack.stackSize, slot.getSlotStackLimit()))); + if (slot.isItemValid(itemStack) && stackInSlot == null) { + slot.putStack(ItemStackUtils.clone( + itemStack, Math.min(itemStack.stackSize, slot.getSlotStackLimit()) + )); slot.onSlotChanged(); - if (slot.getStack() != null) - { + if (slot.getStack() != null) { itemStack.stackSize -= slot.getStack().stackSize; slotFound = true; } diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerGlassBell.java b/src/main/java/com/pahimar/ee3/inventory/ContainerGlassBell.java index 4015a442..763a5ec6 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerGlassBell.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerGlassBell.java @@ -6,64 +6,65 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerGlassBell extends ContainerEE -{ +public class ContainerGlassBell extends ContainerEE { private TileEntityGlassBell tileGlassBell; - public ContainerGlassBell(InventoryPlayer inventoryPlayer, TileEntityGlassBell tileGlassBell) - { + public ContainerGlassBell( + InventoryPlayer inventoryPlayer, TileEntityGlassBell tileGlassBell + ) { this.tileGlassBell = tileGlassBell; - this.addSlotToContainer(new Slot(tileGlassBell, TileEntityGlassBell.DISPLAY_SLOT_INVENTORY_INDEX, 80, 26)); + this.addSlotToContainer(new Slot( + tileGlassBell, TileEntityGlassBell.DISPLAY_SLOT_INVENTORY_INDEX, 80, 26 + )); // Add the player's inventory slots to the container - for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex) - { - for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex) - { - this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 8 + inventoryColumnIndex * 18, 79 + inventoryRowIndex * 18)); + for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; + ++inventoryRowIndex) { + for (int inventoryColumnIndex = 0; + inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; + ++inventoryColumnIndex) { + this.addSlotToContainer(new Slot( + inventoryPlayer, + inventoryColumnIndex + inventoryRowIndex * 9 + 9, + 8 + inventoryColumnIndex * 18, + 79 + inventoryRowIndex * 18 + )); } } // Add the player's action bar slots to the container - for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex) - { - this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 137)); + for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; + ++actionBarSlotIndex) { + this.addSlotToContainer(new Slot( + inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 137 + )); } } @Override - public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) - { + public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { ItemStack itemStack = null; Slot slot = (Slot) inventorySlots.get(slotIndex); - if (slot != null && slot.getHasStack()) - { + if (slot != null && slot.getHasStack()) { ItemStack slotItemStack = slot.getStack(); itemStack = slotItemStack.copy(); - if (slotIndex < TileEntityGlassBell.INVENTORY_SIZE) - { - - if (!this.mergeItemStack(slotItemStack, 1, inventorySlots.size(), true)) - { + if (slotIndex < TileEntityGlassBell.INVENTORY_SIZE) { + if (!this.mergeItemStack(slotItemStack, 1, inventorySlots.size(), true)) { return null; } - } - else - { - if (!this.mergeItemStack(slotItemStack, 0, TileEntityGlassBell.INVENTORY_SIZE, false)) - { + } else { + if (!this.mergeItemStack( + slotItemStack, 0, TileEntityGlassBell.INVENTORY_SIZE, false + )) { return null; } } - if (slotItemStack.stackSize == 0) - { + if (slotItemStack.stackSize == 0) { slot.putStack(null); - } - else - { + } else { slot.onSlotChanged(); } } @@ -72,8 +73,7 @@ public class ContainerGlassBell extends ContainerEE } @Override - public boolean canInteractWith(EntityPlayer entityPlayer) - { + public boolean canInteractWith(EntityPlayer entityPlayer) { return this.tileGlassBell.isUseableByPlayer(entityPlayer); } } diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerPortableCrafting.java b/src/main/java/com/pahimar/ee3/inventory/ContainerPortableCrafting.java index a41026c6..baeb73d7 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerPortableCrafting.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerPortableCrafting.java @@ -2,7 +2,6 @@ package com.pahimar.ee3.inventory; import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.util.NBTHelper; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ContainerWorkbench; @@ -10,11 +9,12 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ContainerPortableCrafting extends ContainerWorkbench { - - public ContainerPortableCrafting(InventoryPlayer inv, World world, int x, int y, int z) { + public ContainerPortableCrafting( + InventoryPlayer inv, World world, int x, int y, int z + ) { super(inv, world, x, y, z); } - + @Override public boolean canInteractWith(EntityPlayer player) { return true; @@ -26,10 +26,11 @@ public class ContainerPortableCrafting extends ContainerWorkbench { if (!player.worldObj.isRemote) { InventoryPlayer invPlayer = player.inventory; for (ItemStack itemStack : invPlayer.mainInventory) { - if (itemStack == null || !NBTHelper.hasKey(itemStack, Names.NBT.CRAFTING_GUI_OPEN)) continue; + if (itemStack == null + || !NBTHelper.hasKey(itemStack, Names.NBT.CRAFTING_GUI_OPEN)) + continue; NBTHelper.removeTag(itemStack, Names.NBT.CRAFTING_GUI_OPEN); } } } - } diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerPortableTransmutation.java b/src/main/java/com/pahimar/ee3/inventory/ContainerPortableTransmutation.java index 49d2d56c..b8c9ac52 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerPortableTransmutation.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerPortableTransmutation.java @@ -3,11 +3,10 @@ package com.pahimar.ee3.inventory; import com.pahimar.ee3.inventory.element.IElementButtonHandler; import com.pahimar.ee3.inventory.element.IElementSliderHandler; import com.pahimar.ee3.inventory.element.IElementTextFieldHandler; - import net.minecraft.entity.player.EntityPlayer; -public class ContainerPortableTransmutation extends ContainerEE implements IElementTextFieldHandler, IElementSliderHandler, IElementButtonHandler { - +public class ContainerPortableTransmutation extends ContainerEE + implements IElementTextFieldHandler, IElementSliderHandler, IElementButtonHandler { @Override public boolean canInteractWith(EntityPlayer arg0) { // TODO Auto-generated method stub @@ -17,19 +16,15 @@ public class ContainerPortableTransmutation extends ContainerEE implements IElem @Override public void handleElementButtonClick(String elementName, int mouseButton) { // TODO Auto-generated method stub - } @Override public void handleElementSliderUpdate(String elementName, int elementValue) { // TODO Auto-generated method stub - } @Override public void handleElementTextFieldUpdate(String elementName, String updatedText) { // TODO Auto-generated method stub - } - } diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerResearchStation.java b/src/main/java/com/pahimar/ee3/inventory/ContainerResearchStation.java index b2d1bd14..40256da0 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerResearchStation.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerResearchStation.java @@ -11,99 +11,105 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerResearchStation extends ContainerEE -{ +public class ContainerResearchStation extends ContainerEE { private TileEntityResearchStation tileEntityResearchStation; private int lastItemLearnTime; private boolean isItemStackKnown; - public ContainerResearchStation(InventoryPlayer inventoryPlayer, TileEntityResearchStation tileEntityResearchStation) - { + public ContainerResearchStation( + InventoryPlayer inventoryPlayer, + TileEntityResearchStation tileEntityResearchStation + ) { this.tileEntityResearchStation = tileEntityResearchStation; - this.addSlotToContainer(new Slot(tileEntityResearchStation, TileEntityResearchStation.ITEM_SLOT_INVENTORY_INDEX, 79, 84) - { + this.addSlotToContainer(new Slot( + tileEntityResearchStation, + TileEntityResearchStation.ITEM_SLOT_INVENTORY_INDEX, + 79, + 84 + ) { @Override - public int getSlotStackLimit() - { + public int getSlotStackLimit() { return 1; } @Override - public boolean isItemValid(ItemStack itemStack) - { + public boolean isItemValid(ItemStack itemStack) { return BlacklistRegistryProxy.isLearnable(itemStack); } }); - this.addSlotToContainer(new Slot(tileEntityResearchStation, TileEntityResearchStation.ALCHENOMICON_SLOT_INVENTORY_INDEX, 161, 84) - { + this.addSlotToContainer(new Slot( + tileEntityResearchStation, + TileEntityResearchStation.ALCHENOMICON_SLOT_INVENTORY_INDEX, + 161, + 84 + ) { @Override - public int getSlotStackLimit() - { + public int getSlotStackLimit() { return 1; } @Override - public boolean isItemValid(ItemStack itemStack) - { + public boolean isItemValid(ItemStack itemStack) { return itemStack.getItem() instanceof ItemAlchenomicon; } }); // Add the entityPlayer's inventory slots to the container - for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex) - { - for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex) - { - this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 50 + inventoryColumnIndex * 18, 152 + inventoryRowIndex * 18)); + for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; + ++inventoryRowIndex) { + for (int inventoryColumnIndex = 0; + inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; + ++inventoryColumnIndex) { + this.addSlotToContainer(new Slot( + inventoryPlayer, + inventoryColumnIndex + inventoryRowIndex * 9 + 9, + 50 + inventoryColumnIndex * 18, + 152 + inventoryRowIndex * 18 + )); } } // Add the entityPlayer's action bar slots to the container - for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex) - { - this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 50 + actionBarSlotIndex * 18, 210)); + for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; + ++actionBarSlotIndex) { + this.addSlotToContainer(new Slot( + inventoryPlayer, actionBarSlotIndex, 50 + actionBarSlotIndex * 18, 210 + )); } } @Override - public void addCraftingToCrafters(ICrafting iCrafting) - { + public void addCraftingToCrafters(ICrafting iCrafting) { super.addCraftingToCrafters(iCrafting); - iCrafting.sendProgressBarUpdate(this, 0, this.tileEntityResearchStation.itemLearnTime); - if (this.tileEntityResearchStation.isItemKnown) - { + iCrafting.sendProgressBarUpdate( + this, 0, this.tileEntityResearchStation.itemLearnTime + ); + if (this.tileEntityResearchStation.isItemKnown) { iCrafting.sendProgressBarUpdate(this, 1, 1); - } - else - { + } else { iCrafting.sendProgressBarUpdate(this, 1, 0); } } @Override - public void detectAndSendChanges() - { + public void detectAndSendChanges() { super.detectAndSendChanges(); - for (Object crafter : this.crafters) - { + for (Object crafter : this.crafters) { ICrafting iCrafting = (ICrafting) crafter; - if (this.lastItemLearnTime != this.tileEntityResearchStation.itemLearnTime) - { - iCrafting.sendProgressBarUpdate(this, 0, this.tileEntityResearchStation.itemLearnTime); + if (this.lastItemLearnTime != this.tileEntityResearchStation.itemLearnTime) { + iCrafting.sendProgressBarUpdate( + this, 0, this.tileEntityResearchStation.itemLearnTime + ); } - if (this.isItemStackKnown != this.tileEntityResearchStation.isItemKnown) - { - if (this.tileEntityResearchStation.isItemKnown) - { + if (this.isItemStackKnown != this.tileEntityResearchStation.isItemKnown) { + if (this.tileEntityResearchStation.isItemKnown) { iCrafting.sendProgressBarUpdate(this, 1, 1); - } - else - { + } else { iCrafting.sendProgressBarUpdate(this, 1, 0); } } @@ -114,39 +120,29 @@ public class ContainerResearchStation extends ContainerEE } @SideOnly(Side.CLIENT) - public void updateProgressBar(int valueType, int updatedValue) - { - if (valueType == 0) - { + public void updateProgressBar(int valueType, int updatedValue) { + if (valueType == 0) { this.tileEntityResearchStation.itemLearnTime = updatedValue; - } - else if (valueType == 1) - { - if (updatedValue == 1) - { + } else if (valueType == 1) { + if (updatedValue == 1) { this.tileEntityResearchStation.isItemKnown = true; - } - else - { + } else { this.tileEntityResearchStation.isItemKnown = false; } } } @Override - public boolean canInteractWith(EntityPlayer entityPlayer) - { + public boolean canInteractWith(EntityPlayer entityPlayer) { return this.tileEntityResearchStation.isUseableByPlayer(entityPlayer); } @Override - public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) - { + public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { ItemStack itemStack = null; Slot slot = (Slot) inventorySlots.get(slotIndex); - if (slot != null && slot.getHasStack()) - { + if (slot != null && slot.getHasStack()) { ItemStack slotItemStack = slot.getStack(); itemStack = slotItemStack.copy(); @@ -155,43 +151,46 @@ public class ContainerResearchStation extends ContainerEE * attempt to put it in the first available slot in the entityPlayer's * inventory */ - if (slotIndex < TileEntityResearchStation.INVENTORY_SIZE) - { - if (!this.mergeItemStack(slotItemStack, TileEntityResearchStation.INVENTORY_SIZE, inventorySlots.size(), false)) - { + if (slotIndex < TileEntityResearchStation.INVENTORY_SIZE) { + if (!this.mergeItemStack( + slotItemStack, + TileEntityResearchStation.INVENTORY_SIZE, + inventorySlots.size(), + false + )) { return null; } - } - else - { + } else { /** * If the stack being shift-clicked into the Research Table's container * is a fuel, first try to put it in the fuel slot. If it cannot * be merged into the fuel slot, try to put it in the input * slot. */ - if (slotItemStack.getItem() instanceof ItemAlchenomicon) - { - if (!this.mergeItemStack(slotItemStack, TileEntityResearchStation.ALCHENOMICON_SLOT_INVENTORY_INDEX, TileEntityResearchStation.INVENTORY_SIZE, false)) - { + if (slotItemStack.getItem() instanceof ItemAlchenomicon) { + if (!this.mergeItemStack( + slotItemStack, + TileEntityResearchStation.ALCHENOMICON_SLOT_INVENTORY_INDEX, + TileEntityResearchStation.INVENTORY_SIZE, + false + )) { return null; } - } - else - { - if (!this.mergeItemStack(slotItemStack, TileEntityResearchStation.ITEM_SLOT_INVENTORY_INDEX, TileEntityResearchStation.ALCHENOMICON_SLOT_INVENTORY_INDEX, false)) - { + } else { + if (!this.mergeItemStack( + slotItemStack, + TileEntityResearchStation.ITEM_SLOT_INVENTORY_INDEX, + TileEntityResearchStation.ALCHENOMICON_SLOT_INVENTORY_INDEX, + false + )) { return null; } } } - if (slotItemStack.stackSize == 0) - { + if (slotItemStack.stackSize == 0) { slot.putStack(null); - } - else - { + } else { slot.onSlotChanged(); } } diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerSymbolSelection.java b/src/main/java/com/pahimar/ee3/inventory/ContainerSymbolSelection.java index 416ed200..84024780 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerSymbolSelection.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerSymbolSelection.java @@ -2,11 +2,9 @@ package com.pahimar.ee3.inventory; import net.minecraft.entity.player.EntityPlayer; -public class ContainerSymbolSelection extends ContainerEE -{ +public class ContainerSymbolSelection extends ContainerEE { @Override - public boolean canInteractWith(EntityPlayer entityPlayer) - { + public boolean canInteractWith(EntityPlayer entityPlayer) { return true; } } diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerTransmutationArray.java b/src/main/java/com/pahimar/ee3/inventory/ContainerTransmutationArray.java index 8f61c8f2..9959bfc3 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerTransmutationArray.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerTransmutationArray.java @@ -7,50 +7,52 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -public class ContainerTransmutationArray extends ContainerEE -{ +public class ContainerTransmutationArray extends ContainerEE { private TileEntityAlchemyArray tileEntityAlchemyArray; - public ContainerTransmutationArray(InventoryPlayer inventoryPlayer, TileEntityAlchemyArray tileEntityAlchemyArray) - { + public ContainerTransmutationArray( + InventoryPlayer inventoryPlayer, TileEntityAlchemyArray tileEntityAlchemyArray + ) { this.tileEntityAlchemyArray = tileEntityAlchemyArray; int maxArrayRowCount = (2 * (tileEntityAlchemyArray.getSize() - 1)) + 1; int maxArrayColumnCount = maxArrayRowCount; - for (int rowIndex = 0; rowIndex < maxArrayRowCount; rowIndex++) - { - for (int columnIndex = 0; columnIndex < maxArrayColumnCount; columnIndex++) - { - if (tileEntityAlchemyArray.getSize() == 1) - { - this.addSlotToContainer(new Slot(tileEntityAlchemyArray, columnIndex + rowIndex * maxArrayRowCount, 120 + columnIndex * 18, 69 + rowIndex * 18) - { + for (int rowIndex = 0; rowIndex < maxArrayRowCount; rowIndex++) { + for (int columnIndex = 0; columnIndex < maxArrayColumnCount; columnIndex++) { + if (tileEntityAlchemyArray.getSize() == 1) { + this.addSlotToContainer(new Slot( + tileEntityAlchemyArray, + columnIndex + rowIndex * maxArrayRowCount, + 120 + columnIndex * 18, + 69 + rowIndex * 18 + ) { @Override - public boolean isItemValid(ItemStack itemStack) - { + public boolean isItemValid(ItemStack itemStack) { return itemStack.getItem() instanceof ItemBlock; } }); - } - else if (tileEntityAlchemyArray.getSize() == 2) - { - this.addSlotToContainer(new Slot(tileEntityAlchemyArray, columnIndex + rowIndex * maxArrayRowCount, 102 + columnIndex * 18, 51 + rowIndex * 18) - { + } else if (tileEntityAlchemyArray.getSize() == 2) { + this.addSlotToContainer(new Slot( + tileEntityAlchemyArray, + columnIndex + rowIndex * maxArrayRowCount, + 102 + columnIndex * 18, + 51 + rowIndex * 18 + ) { @Override - public boolean isItemValid(ItemStack itemStack) - { + public boolean isItemValid(ItemStack itemStack) { return itemStack.getItem() instanceof ItemBlock; } }); - } - else if (tileEntityAlchemyArray.getSize() == 3) - { - this.addSlotToContainer(new Slot(tileEntityAlchemyArray, columnIndex + rowIndex * maxArrayRowCount, 84 + columnIndex * 18, 33 + rowIndex * 18) - { + } else if (tileEntityAlchemyArray.getSize() == 3) { + this.addSlotToContainer(new Slot( + tileEntityAlchemyArray, + columnIndex + rowIndex * maxArrayRowCount, + 84 + columnIndex * 18, + 33 + rowIndex * 18 + ) { @Override - public boolean isItemValid(ItemStack itemStack) - { + public boolean isItemValid(ItemStack itemStack) { return itemStack.getItem() instanceof ItemBlock; } }); @@ -59,31 +61,37 @@ public class ContainerTransmutationArray extends ContainerEE } // Add the player's inventory slots to the container - for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex) - { - for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex) - { - this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 47 + inventoryColumnIndex * 18, 173 + inventoryRowIndex * 18)); + for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; + ++inventoryRowIndex) { + for (int inventoryColumnIndex = 0; + inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; + ++inventoryColumnIndex) { + this.addSlotToContainer(new Slot( + inventoryPlayer, + inventoryColumnIndex + inventoryRowIndex * 9 + 9, + 47 + inventoryColumnIndex * 18, + 173 + inventoryRowIndex * 18 + )); } } // Add the player's action bar slots to the container - for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex) - { - this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 47 + actionBarSlotIndex * 18, 231)); + for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; + ++actionBarSlotIndex) { + this.addSlotToContainer(new Slot( + inventoryPlayer, actionBarSlotIndex, 47 + actionBarSlotIndex * 18, 231 + )); } } @Override - public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) - { + public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { ItemStack itemStack = null; Slot slot = (Slot) inventorySlots.get(slotIndex); int inventorySize = ((2 * (this.tileEntityAlchemyArray.getSize() - 1)) + 1); inventorySize *= inventorySize; - if (slot != null && slot.getHasStack()) - { + if (slot != null && slot.getHasStack()) { ItemStack slotItemStack = slot.getStack(); itemStack = slotItemStack.copy(); @@ -92,27 +100,21 @@ public class ContainerTransmutationArray extends ContainerEE * attempt to put it in the first available slot in the entityPlayer's * inventory */ - if (slotIndex < inventorySize) - { - if (!this.mergeItemStack(slotItemStack, inventorySize, inventorySlots.size(), false)) - { + if (slotIndex < inventorySize) { + if (!this.mergeItemStack( + slotItemStack, inventorySize, inventorySlots.size(), false + )) { return null; } - } - else - { - if (!this.mergeItemStack(slotItemStack, 0, inventorySize, false)) - { + } else { + if (!this.mergeItemStack(slotItemStack, 0, inventorySize, false)) { return null; } } - if (slotItemStack.stackSize == 0) - { + if (slotItemStack.stackSize == 0) { slot.putStack(null); - } - else - { + } else { slot.onSlotChanged(); } } @@ -121,8 +123,7 @@ public class ContainerTransmutationArray extends ContainerEE } @Override - public boolean canInteractWith(EntityPlayer entityPlayer) - { + public boolean canInteractWith(EntityPlayer entityPlayer) { return this.tileEntityAlchemyArray.isUseableByPlayer(entityPlayer); } } diff --git a/src/main/java/com/pahimar/ee3/inventory/ContainerTransmutationTablet.java b/src/main/java/com/pahimar/ee3/inventory/ContainerTransmutationTablet.java index 1611f01e..dbda84bd 100644 --- a/src/main/java/com/pahimar/ee3/inventory/ContainerTransmutationTablet.java +++ b/src/main/java/com/pahimar/ee3/inventory/ContainerTransmutationTablet.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.inventory; +import java.util.*; + import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.api.exchange.EnergyValue; import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; @@ -29,13 +31,11 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import java.util.*; - /** * FIXME Continue integrating PR#881 */ -public class ContainerTransmutationTablet extends ContainerEE implements IElementTextFieldHandler, IElementSliderHandler, IElementButtonHandler { - +public class ContainerTransmutationTablet extends ContainerEE + implements IElementTextFieldHandler, IElementSliderHandler, IElementButtonHandler { private InventoryTransmutationTablet inventoryTransmutationTablet; private final ITransmutationContainer transmutationTablet; private final World world; @@ -43,26 +43,47 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen private String searchTerm; private int sortOption, sortOrder, scrollBarPosition; - public ContainerTransmutationTablet(InventoryPlayer inventoryPlayer, TileEntityTransmutationTablet transmutationTablet) { - + public ContainerTransmutationTablet( + InventoryPlayer inventoryPlayer, TileEntityTransmutationTablet transmutationTablet + ) { this.transmutationTablet = transmutationTablet; this.world = transmutationTablet.getWorldObj(); - handleTomeSync(transmutationTablet.getStackInSlot(TileEntityTransmutationTablet.ALCHENOMICON_INDEX)); + handleTomeSync(transmutationTablet.getStackInSlot( + TileEntityTransmutationTablet.ALCHENOMICON_INDEX + )); this.sortOption = 0; this.scrollBarPosition = 0; this.energyValue = transmutationTablet.getAvailableEnergy(); - this.addSlotToContainer(new SlotTabletInput(this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_1, 62, 24)); - this.addSlotToContainer(new SlotTabletInput(this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_2, 35, 35)); - this.addSlotToContainer(new SlotTabletInput(this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_3, 26, 61)); - this.addSlotToContainer(new SlotTabletInput(this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_4, 35, 87)); - this.addSlotToContainer(new SlotTabletInput(this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_5, 62, 99)); - this.addSlotToContainer(new SlotTabletInput(this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_6, 89, 87)); - this.addSlotToContainer(new SlotTabletInput(this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_7, 98, 61)); - this.addSlotToContainer(new SlotTabletInput(this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_8, 89, 35)); - this.addSlotToContainer(new Slot(transmutationTablet, TileEntityTransmutationTablet.STONE_INDEX, 62, 61) { + this.addSlotToContainer(new SlotTabletInput( + this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_1, 62, 24 + )); + this.addSlotToContainer(new SlotTabletInput( + this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_2, 35, 35 + )); + this.addSlotToContainer(new SlotTabletInput( + this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_3, 26, 61 + )); + this.addSlotToContainer(new SlotTabletInput( + this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_4, 35, 87 + )); + this.addSlotToContainer(new SlotTabletInput( + this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_5, 62, 99 + )); + this.addSlotToContainer(new SlotTabletInput( + this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_6, 89, 87 + )); + this.addSlotToContainer(new SlotTabletInput( + this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_7, 98, 61 + )); + this.addSlotToContainer(new SlotTabletInput( + this, transmutationTablet, TileEntityTransmutationTablet.ITEM_INPUT_8, 89, 35 + )); + this.addSlotToContainer(new Slot( + transmutationTablet, TileEntityTransmutationTablet.STONE_INDEX, 62, 61 + ) { @Override public int getSlotStackLimit() { return 1; @@ -70,27 +91,47 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen @Override public boolean isItemValid(ItemStack itemStack) { - return itemStack.getItem() instanceof ItemMiniumStone || itemStack.getItem() instanceof ItemPhilosophersStone; + return itemStack.getItem() instanceof ItemMiniumStone + || itemStack.getItem() instanceof ItemPhilosophersStone; } }); - this.addSlotToContainer(new SlotAlchenomicon(transmutationTablet, TileEntityTransmutationTablet.ALCHENOMICON_INDEX, 152, 15)); + this.addSlotToContainer(new SlotAlchenomicon( + transmutationTablet, TileEntityTransmutationTablet.ALCHENOMICON_INDEX, 152, 15 + )); for (int i = 0; i < 10; i++) { for (int j = 0; j < 3; j++) { - this.addSlotToContainer(new SlotTabletOutput(this, inventoryTransmutationTablet, i * 3 + j, 175 + j * 20, 38 + i * 20)); + this.addSlotToContainer(new SlotTabletOutput( + this, + inventoryTransmutationTablet, + i * 3 + j, + 175 + j * 20, + 38 + i * 20 + )); } } // Add the player's inventory slots to the container - for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex) { - for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex) { - this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 8 + inventoryColumnIndex * 18, 164 + inventoryRowIndex * 18)); + for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; + ++inventoryRowIndex) { + for (int inventoryColumnIndex = 0; + inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; + ++inventoryColumnIndex) { + this.addSlotToContainer(new Slot( + inventoryPlayer, + inventoryColumnIndex + inventoryRowIndex * 9 + 9, + 8 + inventoryColumnIndex * 18, + 164 + inventoryRowIndex * 18 + )); } } // Add the player's action bar slots to the container - for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex) { - this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 222)); + for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; + ++actionBarSlotIndex) { + this.addSlotToContainer(new Slot( + inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 222 + )); } updateInventory(); @@ -102,23 +143,23 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen @Override public boolean canInteractWith(EntityPlayer entityPlayer) { - return transmutationTablet != null && transmutationTablet.isUseableByPlayer(entityPlayer); + return transmutationTablet != null + && transmutationTablet.isUseableByPlayer(entityPlayer); } @Override public void detectAndSendChanges() { - super.detectAndSendChanges(); EnergyValue tileEnergyValue = transmutationTablet.getAvailableEnergy(); for (Object crafter : this.crafters) { - ICrafting iCrafting = (ICrafting) crafter; if (energyValue.compareTo(tileEnergyValue) != 0) { energyValue = tileEnergyValue; - int energyValueAsInt = Float.floatToRawIntBits(tileEnergyValue.getValue()); + int energyValueAsInt + = Float.floatToRawIntBits(tileEnergyValue.getValue()); iCrafting.sendProgressBarUpdate(this, 0, energyValueAsInt & 0xffff); iCrafting.sendProgressBarUpdate(this, 1, energyValueAsInt >>> 16); } @@ -129,24 +170,19 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen @SideOnly(Side.CLIENT) public void updateProgressBar(int valueType, int updatedValue) { - if (valueType == 0) { int energyValueAsInt = Float.floatToRawIntBits(energyValue.getValue()); energyValueAsInt = (energyValueAsInt & 0xffff0000) | updatedValue; energyValue = new EnergyValue(Float.intBitsToFloat(energyValueAsInt)); - } - else if (valueType == 1) { + } else if (valueType == 1) { int energyValueAsInt = Float.floatToRawIntBits(energyValue.getValue()); energyValueAsInt = (energyValueAsInt & 0xffff) | (updatedValue << 16); energyValue = new EnergyValue(Float.intBitsToFloat(energyValueAsInt)); - } - else if (valueType == 2) { + } else if (valueType == 2) { sortOption = updatedValue; - } - else if (valueType == 3) { + } else if (valueType == 3) { scrollBarPosition = updatedValue; - } - else if (valueType == 4) { + } else if (valueType == 4) { sortOrder = updatedValue; } @@ -156,29 +192,35 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen } private void sendKnowledgeToClient(Collection knownItemStacks) { - PacketHandler.INSTANCE.sendToAllAround( - new MessagePlayerKnowledge(transmutationTablet, knownItemStacks), - new NetworkRegistry.TargetPoint(world.provider.dimensionId, transmutationTablet.getXCoord(), transmutationTablet.getYCoord(), transmutationTablet.getZCoord(), 5d) + new MessagePlayerKnowledge(transmutationTablet, knownItemStacks), + new NetworkRegistry.TargetPoint( + world.provider.dimensionId, + transmutationTablet.getXCoord(), + transmutationTablet.getYCoord(), + transmutationTablet.getZCoord(), + 5d + ) ); } private void handleTomeSync(ItemStack itemStack) { - - if (itemStack != null && itemStack.getItem() instanceof ItemAlchenomicon && ItemStackUtils.getOwnerName(itemStack) != null) { - + if (itemStack != null && itemStack.getItem() instanceof ItemAlchenomicon + && ItemStackUtils.getOwnerName(itemStack) != null) { if (!world.isRemote) { - - Set knownItemStacks = PlayerKnowledgeRegistryProxy.getKnownItemStacks(ItemStackUtils.getOwnerName(itemStack)); - inventoryTransmutationTablet = new InventoryTransmutationTablet(knownItemStacks); + Set knownItemStacks + = PlayerKnowledgeRegistryProxy.getKnownItemStacks( + ItemStackUtils.getOwnerName(itemStack) + ); + inventoryTransmutationTablet + = new InventoryTransmutationTablet(knownItemStacks); sendKnowledgeToClient(knownItemStacks); + } else { + this.inventoryTransmutationTablet = new InventoryTransmutationTablet( + transmutationTablet.getPlayerKnowledge() + ); } - else { - this.inventoryTransmutationTablet = new InventoryTransmutationTablet(transmutationTablet.getPlayerKnowledge()); - } - } - else { - + } else { this.inventoryTransmutationTablet = new InventoryTransmutationTablet(); if (!world.isRemote) { sendKnowledgeToClient(null); @@ -188,7 +230,6 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen @Override public void handleElementTextFieldUpdate(String elementName, String updatedText) { - if (elementName.equalsIgnoreCase("searchField")) { searchTerm = updatedText; updateInventory(); @@ -197,7 +238,6 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen @Override public void handleElementSliderUpdate(String elementName, int elementValue) { - if (elementName.equals("scrollBar")) { scrollBarPosition = elementValue; updateInventory(); @@ -205,28 +245,33 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen } private void updateInventory() { - ItemStack[] newInventory = new ItemStack[30]; - Set filteredSet = FilterUtils.filterByDisplayName(inventoryTransmutationTablet.getKnownTransmutations(), searchTerm, FilterUtils.NameFilterType.CONTAINS); - List filteredList = new ArrayList<>(FilterUtils.filterByEnergyValue(filteredSet, energyValue)); + Set filteredSet = FilterUtils.filterByDisplayName( + inventoryTransmutationTablet.getKnownTransmutations(), + searchTerm, + FilterUtils.NameFilterType.CONTAINS + ); + List filteredList + = new ArrayList<>(FilterUtils.filterByEnergyValue(filteredSet, energyValue)); if (sortOption == 0 && sortOrder == 0) { Collections.sort(filteredList, Comparators.DISPLAY_NAME_COMPARATOR); - } - else if (sortOption == 0 && sortOrder == 1) { - Collections.sort(filteredList, Comparators.DISPLAY_NAME_COMPARATOR.reversed()); - } - else if (sortOption == 1 && sortOrder == 0) { - Collections.sort(filteredList, Comparators.ENERGY_VALUE_ITEM_STACK_COMPARATOR); - } - else if (sortOption == 1 && sortOrder == 1) { - Collections.sort(filteredList, Comparators.ENERGY_VALUE_ITEM_STACK_COMPARATOR.reversed()); - } - else if (sortOption == 2 && sortOrder == 0) { + } else if (sortOption == 0 && sortOrder == 1) { + Collections.sort( + filteredList, Comparators.DISPLAY_NAME_COMPARATOR.reversed() + ); + } else if (sortOption == 1 && sortOrder == 0) { + Collections.sort( + filteredList, Comparators.ENERGY_VALUE_ITEM_STACK_COMPARATOR + ); + } else if (sortOption == 1 && sortOrder == 1) { + Collections.sort( + filteredList, Comparators.ENERGY_VALUE_ITEM_STACK_COMPARATOR.reversed() + ); + } else if (sortOption == 2 && sortOrder == 0) { Collections.sort(filteredList, Comparators.ID_COMPARATOR); - } - else if (sortOption == 2 && sortOrder == 1) { + } else if (sortOption == 2 && sortOrder == 1) { Collections.sort(filteredList, Comparators.ID_COMPARATOR.reversed()); } @@ -237,7 +282,8 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen int adjustedStartIndex = (int) ((scrollBarPosition / 187f) * filteredList.size()); adjustedStartIndex -= adjustedStartIndex % 3; // Paginate by 3 elements. - int startIndex = Math.max(0, Math.min(adjustedStartIndex, filteredList.size() - 30)); + int startIndex + = Math.max(0, Math.min(adjustedStartIndex, filteredList.size() - 30)); int endIndex = Math.min(adjustedStartIndex + 30, filteredList.size()); filteredList.subList(startIndex, endIndex).toArray(newInventory); @@ -249,49 +295,65 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen @Override public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { - ItemStack itemStack = null; Slot slot = (Slot) inventorySlots.get(slotIndex); if (slot != null && slot.getHasStack()) { - ItemStack slotItemStack = slot.getStack(); itemStack = slotItemStack.copy(); /** - * If we are shift-clicking an item out of the Transmutation Tablet's container, - * attempt to put it in the first available slot in the entityPlayer's - * inventory + * If we are shift-clicking an item out of the Transmutation Tablet's + * container, attempt to put it in the first available slot in the + * entityPlayer's inventory */ if (slotIndex < TileEntityTransmutationTablet.INVENTORY_SIZE) { - - if (!this.mergeItemStack(slotItemStack, TileEntityTransmutationTablet.INVENTORY_SIZE, inventorySlots.size(), false)) { + if (!this.mergeItemStack( + slotItemStack, + TileEntityTransmutationTablet.INVENTORY_SIZE, + inventorySlots.size(), + false + )) { return null; } - } - else if (slotIndex >= TileEntityTransmutationTablet.INVENTORY_SIZE && slotIndex < 40) { - - if (!this.mergeTransmutedItemStack(entityPlayer, slot, slotItemStack, 40, inventorySlots.size(), false)) { + } else if (slotIndex >= TileEntityTransmutationTablet.INVENTORY_SIZE && slotIndex < 40) { + if (!this.mergeTransmutedItemStack( + entityPlayer, + slot, + slotItemStack, + 40, + inventorySlots.size(), + false + )) { return null; } - } - else { - + } else { if (slotItemStack.getItem() instanceof ItemAlchenomicon) { - - if (!this.mergeItemStack(slotItemStack, TileEntityTransmutationTablet.ALCHENOMICON_INDEX, TileEntityTransmutationTablet.INVENTORY_SIZE, false)) { + if (!this.mergeItemStack( + slotItemStack, + TileEntityTransmutationTablet.ALCHENOMICON_INDEX, + TileEntityTransmutationTablet.INVENTORY_SIZE, + false + )) { return null; } } else if (slotItemStack.getItem() instanceof ItemMiniumStone || slotItemStack.getItem() instanceof ItemPhilosophersStone) { - - if (!this.mergeItemStack(slotItemStack, TileEntityTransmutationTablet.STONE_INDEX, TileEntityTransmutationTablet.INVENTORY_SIZE, false)) { + if (!this.mergeItemStack( + slotItemStack, + TileEntityTransmutationTablet.STONE_INDEX, + TileEntityTransmutationTablet.INVENTORY_SIZE, + false + )) { return null; } - } - else { - - if (!this.mergeItemStack(slotItemStack, TileEntityTransmutationTablet.ITEM_INPUT_1, TileEntityTransmutationTablet.INVENTORY_SIZE, false)) { + } else { + if (!this.mergeItemStack( + slotItemStack, + TileEntityTransmutationTablet.ITEM_INPUT_1, + TileEntityTransmutationTablet.INVENTORY_SIZE, + false + )) { return null; } } @@ -299,8 +361,7 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen if (slotItemStack.stackSize == 0) { slot.putStack(null); - } - else { + } else { slot.onSlotChanged(); } } @@ -308,10 +369,19 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen return itemStack; } - private boolean mergeTransmutedItemStack(EntityPlayer entityPlayer, Slot transmutationOutputSlot, ItemStack itemStack, int slotMin, int slotMax, boolean ascending) { - + private boolean mergeTransmutedItemStack( + EntityPlayer entityPlayer, + Slot transmutationOutputSlot, + ItemStack itemStack, + int slotMin, + int slotMax, + boolean ascending + ) { // Calculate how many items can be transmuted - int numCanTransmute = MathHelper.floor(this.transmutationTablet.getAvailableEnergy().getValue() / EnergyValueRegistryProxy.getEnergyValue(itemStack).getValue()); + int numCanTransmute = MathHelper.floor( + this.transmutationTablet.getAvailableEnergy().getValue() + / EnergyValueRegistryProxy.getEnergyValue(itemStack).getValue() + ); int numTransmuted = 0; ItemStack itemStack1 = itemStack.copy(); @@ -326,34 +396,30 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen Slot slot; ItemStack stackInSlot; - while (itemStack1.stackSize > 0 && (!ascending && currentSlotIndex < slotMax || ascending && currentSlotIndex >= slotMin)) { - + while (itemStack1.stackSize > 0 + && (!ascending && currentSlotIndex < slotMax + || ascending && currentSlotIndex >= slotMin)) { slot = (Slot) this.inventorySlots.get(currentSlotIndex); stackInSlot = slot.getStack(); if (stackInSlot == null) { - stackInSlot = itemStack1.copy(); stackInSlot.stackSize = itemStack1.stackSize; slot.putStack(stackInSlot); numTransmuted = itemStack1.stackSize; itemStack1.stackSize = 0; slot.onSlotChanged(); - } - else if (slot.isItemValid(itemStack1) && ItemStackUtils.equalsIgnoreStackSize(itemStack1, stackInSlot)) { - - int slotStackSizeLimit = Math.min(stackInSlot.getMaxStackSize(), slot.getSlotStackLimit()); + } else if (slot.isItemValid(itemStack1) && ItemStackUtils.equalsIgnoreStackSize(itemStack1, stackInSlot)) { + int slotStackSizeLimit + = Math.min(stackInSlot.getMaxStackSize(), slot.getSlotStackLimit()); int combinedStackSize = stackInSlot.stackSize + itemStack1.stackSize; if (combinedStackSize <= slotStackSizeLimit) { - stackInSlot.stackSize = combinedStackSize; numTransmuted = itemStack1.stackSize; itemStack1.stackSize = 0; slot.onSlotChanged(); - } - else if (stackInSlot.stackSize < slotStackSizeLimit) { - + } else if (stackInSlot.stackSize < slotStackSizeLimit) { itemStack1.stackSize = slotStackSizeLimit - stackInSlot.stackSize; stackInSlot.stackSize = slotStackSizeLimit; numTransmuted = itemStack1.stackSize; @@ -365,28 +431,27 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen currentSlotIndex += ascending ? -1 : 1; } - ((SlotTabletOutput) transmutationOutputSlot).onShiftPickupFromSlot(entityPlayer, ItemStackUtils.clone(itemStack, numTransmuted)); + ((SlotTabletOutput) transmutationOutputSlot) + .onShiftPickupFromSlot( + entityPlayer, ItemStackUtils.clone(itemStack, numTransmuted) + ); return false; } @Override public void handleElementButtonClick(String elementName, int mouseButton) { - if (elementName.equals("sortOption")) { if (mouseButton == 0) { sortOption = (sortOption + 1) % 3; - } - else if (mouseButton == 1) { + } else if (mouseButton == 1) { sortOption = (sortOption + (3 - 1)) % 3; } - } - else if (elementName.equals("sortOrder")) { + } else if (elementName.equals("sortOrder")) { sortOrder = 1 - sortOrder; // Toggle between 0 and 1 } for (Object crafter : this.crafters) { - ICrafting iCrafting = (ICrafting) crafter; iCrafting.sendProgressBarUpdate(this, 2, sortOption); iCrafting.sendProgressBarUpdate(this, 4, sortOrder); @@ -395,16 +460,14 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen @Override public ItemStack slotClick(int slot, int button, int flag, EntityPlayer player) { + if (button == 0 && flag == 6) { + return null; + } - if (button == 0 && flag == 6) { - return null; - } - - return super.slotClick(slot, button, flag, player); + return super.slotClick(slot, button, flag, player); } private class SlotAlchenomicon extends Slot { - public SlotAlchenomicon(IInventory iInventory, int slotIndex, int x, int y) { super(iInventory, slotIndex, x, y); } @@ -421,7 +484,6 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen @Override public void onSlotChanged() { - super.onSlotChanged(); handleTomeSync(getStack()); updateInventory(); @@ -429,11 +491,15 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen } private class SlotTabletOutput extends Slot { - private ContainerTransmutationTablet containerTransmutationTablet; - public SlotTabletOutput(ContainerTransmutationTablet containerTransmutationTablet, IInventory iInventory, int slotIndex, int x, int y) { - + public SlotTabletOutput( + ContainerTransmutationTablet containerTransmutationTablet, + IInventory iInventory, + int slotIndex, + int x, + int y + ) { super(iInventory, slotIndex, x, y); this.containerTransmutationTablet = containerTransmutationTablet; } @@ -450,7 +516,6 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen @Override public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack) { - super.onPickupFromSlot(entityPlayer, itemStack); if (getHasStack()) { @@ -461,8 +526,8 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen updateInventory(); } - public void onShiftPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack) { - + public void + onShiftPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack) { super.onPickupFromSlot(entityPlayer, itemStack); if (getHasStack()) { @@ -474,7 +539,6 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen @Override public void onSlotChanged() { - super.onSlotChanged(); transmutationTablet.updateEnergyValueFromInventory(); } @@ -487,33 +551,38 @@ public class ContainerTransmutationTablet extends ContainerEE implements IElemen } private class SlotTabletInput extends Slot { - private ContainerTransmutationTablet containerTransmutationTablet; - public SlotTabletInput(ContainerTransmutationTablet containerTransmutationTablet, IInventory iInventory, int slotIndex, int x, int y) { - + public SlotTabletInput( + ContainerTransmutationTablet containerTransmutationTablet, + IInventory iInventory, + int slotIndex, + int x, + int y + ) { super(iInventory, slotIndex, x, y); this.containerTransmutationTablet = containerTransmutationTablet; } @Override public boolean isItemValid(ItemStack itemStack) { - return EnergyValueRegistryProxy.hasEnergyValue(itemStack) && BlacklistRegistryProxy.isExchangeable(itemStack); + return EnergyValueRegistryProxy.hasEnergyValue(itemStack) + && BlacklistRegistryProxy.isExchangeable(itemStack); } @Override public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack itemStack) { - super.onPickupFromSlot(entityPlayer, itemStack); - this.containerTransmutationTablet.transmutationTablet.updateEnergyValueFromInventory(); + this.containerTransmutationTablet.transmutationTablet + .updateEnergyValueFromInventory(); this.containerTransmutationTablet.updateInventory(); } @Override public void putStack(ItemStack itemStack) { - super.putStack(itemStack); - this.containerTransmutationTablet.transmutationTablet.updateEnergyValueFromInventory(); + this.containerTransmutationTablet.transmutationTablet + .updateEnergyValueFromInventory(); this.containerTransmutationTablet.updateInventory(); } } diff --git a/src/main/java/com/pahimar/ee3/inventory/InventoryAlchemicalBag.java b/src/main/java/com/pahimar/ee3/inventory/InventoryAlchemicalBag.java index 7086acd2..59bb9d1c 100644 --- a/src/main/java/com/pahimar/ee3/inventory/InventoryAlchemicalBag.java +++ b/src/main/java/com/pahimar/ee3/inventory/InventoryAlchemicalBag.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.inventory; +import java.util.UUID; + import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.util.INBTTaggable; import com.pahimar.ee3.util.NBTHelper; @@ -9,30 +11,24 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import java.util.UUID; - -public class InventoryAlchemicalBag implements IInventory, INBTTaggable -{ +public class InventoryAlchemicalBag implements IInventory, INBTTaggable { public ItemStack parentItemStack; protected ItemStack[] inventory; protected String customName; - public InventoryAlchemicalBag(ItemStack itemStack) - { + public InventoryAlchemicalBag(ItemStack itemStack) { parentItemStack = itemStack; int size; - if (itemStack.getItemDamage() == 1) - { - size = ContainerAlchemicalBag.MEDIUM_BAG_INVENTORY_ROWS * ContainerAlchemicalBag.MEDIUM_BAG_INVENTORY_COLUMNS; - } - else if (itemStack.getItemDamage() == 2) - { - size = ContainerAlchemicalBag.LARGE_BAG_INVENTORY_ROWS * ContainerAlchemicalBag.LARGE_BAG_INVENTORY_COLUMNS; - } - else - { - size = ContainerAlchemicalBag.SMALL_BAG_INVENTORY_ROWS * ContainerAlchemicalBag.SMALL_BAG_INVENTORY_COLUMNS; + if (itemStack.getItemDamage() == 1) { + size = ContainerAlchemicalBag.MEDIUM_BAG_INVENTORY_ROWS + * ContainerAlchemicalBag.MEDIUM_BAG_INVENTORY_COLUMNS; + } else if (itemStack.getItemDamage() == 2) { + size = ContainerAlchemicalBag.LARGE_BAG_INVENTORY_ROWS + * ContainerAlchemicalBag.LARGE_BAG_INVENTORY_COLUMNS; + } else { + size = ContainerAlchemicalBag.SMALL_BAG_INVENTORY_ROWS + * ContainerAlchemicalBag.SMALL_BAG_INVENTORY_COLUMNS; } inventory = new ItemStack[size]; @@ -41,7 +37,6 @@ public class InventoryAlchemicalBag implements IInventory, INBTTaggable } public void onGuiSaved(EntityPlayer entityPlayer) { - parentItemStack = findParentItemStack(entityPlayer); if (parentItemStack != null) { @@ -50,17 +45,20 @@ public class InventoryAlchemicalBag implements IInventory, INBTTaggable } public ItemStack findParentItemStack(EntityPlayer entityPlayer) { - if (NBTHelper.hasUUID(parentItemStack)) { - - UUID parentItemStackUUID = new UUID(parentItemStack.getTagCompound().getLong(Names.NBT.UUID_MOST_SIG), parentItemStack.getTagCompound().getLong(Names.NBT.UUID_LEAST_SIG)); + UUID parentItemStackUUID = new UUID( + parentItemStack.getTagCompound().getLong(Names.NBT.UUID_MOST_SIG), + parentItemStack.getTagCompound().getLong(Names.NBT.UUID_LEAST_SIG) + ); for (int i = 0; i < entityPlayer.inventory.getSizeInventory(); i++) { - ItemStack itemStack = entityPlayer.inventory.getStackInSlot(i); if (NBTHelper.hasUUID(itemStack)) { - if (itemStack.getTagCompound().getLong(Names.NBT.UUID_MOST_SIG) == parentItemStackUUID.getMostSignificantBits() && itemStack.getTagCompound().getLong(Names.NBT.UUID_LEAST_SIG) == parentItemStackUUID.getLeastSignificantBits()) { + if (itemStack.getTagCompound().getLong(Names.NBT.UUID_MOST_SIG) + == parentItemStackUUID.getMostSignificantBits() + && itemStack.getTagCompound().getLong(Names.NBT.UUID_LEAST_SIG) + == parentItemStackUUID.getLeastSignificantBits()) { return itemStack; } } @@ -71,20 +69,26 @@ public class InventoryAlchemicalBag implements IInventory, INBTTaggable } public boolean matchesUUID(UUID uuid) { - return NBTHelper.hasUUID(parentItemStack) && parentItemStack.getTagCompound().getLong(Names.NBT.UUID_LEAST_SIG) == uuid.getLeastSignificantBits() && parentItemStack.getTagCompound().getLong(Names.NBT.UUID_MOST_SIG) == uuid.getMostSignificantBits(); + return NBTHelper.hasUUID(parentItemStack) + && parentItemStack.getTagCompound().getLong(Names.NBT.UUID_LEAST_SIG) + == uuid.getLeastSignificantBits() + && parentItemStack.getTagCompound().getLong(Names.NBT.UUID_MOST_SIG) + == uuid.getMostSignificantBits(); } public void save() { - NBTTagCompound nbtTagCompound = parentItemStack.getTagCompound(); if (nbtTagCompound == null) { - nbtTagCompound = new NBTTagCompound(); UUID uuid = UUID.randomUUID(); - nbtTagCompound.setLong(Names.NBT.UUID_MOST_SIG, uuid.getMostSignificantBits()); - nbtTagCompound.setLong(Names.NBT.UUID_LEAST_SIG, uuid.getLeastSignificantBits()); + nbtTagCompound.setLong( + Names.NBT.UUID_MOST_SIG, uuid.getMostSignificantBits() + ); + nbtTagCompound.setLong( + Names.NBT.UUID_LEAST_SIG, uuid.getLeastSignificantBits() + ); } writeToNBT(nbtTagCompound); @@ -92,32 +96,24 @@ public class InventoryAlchemicalBag implements IInventory, INBTTaggable } @Override - public int getSizeInventory() - { + public int getSizeInventory() { return inventory.length; } @Override - public ItemStack getStackInSlot(int slotIndex) - { + public ItemStack getStackInSlot(int slotIndex) { return inventory[slotIndex]; } @Override - public ItemStack decrStackSize(int slotIndex, int decrementAmount) - { + public ItemStack decrStackSize(int slotIndex, int decrementAmount) { ItemStack itemStack = getStackInSlot(slotIndex); - if (itemStack != null) - { - if (itemStack.stackSize <= decrementAmount) - { + if (itemStack != null) { + if (itemStack.stackSize <= decrementAmount) { setInventorySlotContents(slotIndex, null); - } - else - { + } else { itemStack = itemStack.splitStack(decrementAmount); - if (itemStack.stackSize == 0) - { + if (itemStack.stackSize == 0) { setInventorySlotContents(slotIndex, null); } } @@ -127,115 +123,97 @@ public class InventoryAlchemicalBag implements IInventory, INBTTaggable } @Override - public ItemStack getStackInSlotOnClosing(int slotIndex) - { - if (inventory[slotIndex] != null) - { + public ItemStack getStackInSlotOnClosing(int slotIndex) { + if (inventory[slotIndex] != null) { ItemStack itemStack = inventory[slotIndex]; inventory[slotIndex] = null; return itemStack; - } - else - { + } else { return null; } } @Override - public void setInventorySlotContents(int slotIndex, ItemStack itemStack) - { + public void setInventorySlotContents(int slotIndex, ItemStack itemStack) { inventory[slotIndex] = itemStack; } @Override - public String getInventoryName() - { - return this.hasCustomName() ? this.getCustomName() : Names.Containers.ALCHEMICAL_BAG; + public String getInventoryName() { + return this.hasCustomName() ? this.getCustomName() + : Names.Containers.ALCHEMICAL_BAG; } @Override - public boolean hasCustomInventoryName() - { + public boolean hasCustomInventoryName() { return false; } @Override - public int getInventoryStackLimit() - { + public int getInventoryStackLimit() { return 64; } @Override - public void markDirty() - { + public void markDirty() { // NOOP } @Override - public boolean isUseableByPlayer(EntityPlayer entityPlayer) - { + public boolean isUseableByPlayer(EntityPlayer entityPlayer) { return true; } @Override - public void openInventory() - { + public void openInventory() { // NOOP } @Override - public void closeInventory() - { + public void closeInventory() { // NOOP } @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) - { + public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { return true; } @Override - public void readFromNBT(NBTTagCompound nbtTagCompound) - { - if (nbtTagCompound != null && nbtTagCompound.hasKey(Names.NBT.ITEMS)) - { + public void readFromNBT(NBTTagCompound nbtTagCompound) { + if (nbtTagCompound != null && nbtTagCompound.hasKey(Names.NBT.ITEMS)) { // Read in the ItemStacks in the inventory from NBT - if (nbtTagCompound.hasKey(Names.NBT.ITEMS)) - { + if (nbtTagCompound.hasKey(Names.NBT.ITEMS)) { NBTTagList tagList = nbtTagCompound.getTagList(Names.NBT.ITEMS, 10); inventory = new ItemStack[this.getSizeInventory()]; - for (int i = 0; i < tagList.tagCount(); ++i) - { + for (int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slotIndex = tagCompound.getByte("Slot"); - if (slotIndex >= 0 && slotIndex < inventory.length) - { - inventory[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); + if (slotIndex >= 0 && slotIndex < inventory.length) { + inventory[slotIndex] + = ItemStack.loadItemStackFromNBT(tagCompound); } } } // Read in any custom name for the inventory - if (nbtTagCompound.hasKey("display") && nbtTagCompound.getTag("display").getClass().equals(NBTTagCompound.class)) - { - if (nbtTagCompound.getCompoundTag("display").hasKey("Name")) - { - customName = nbtTagCompound.getCompoundTag("display").getString("Name"); + if (nbtTagCompound.hasKey("display") + && nbtTagCompound.getTag("display").getClass().equals(NBTTagCompound + .class)) { + if (nbtTagCompound.getCompoundTag("display").hasKey("Name")) { + customName + = nbtTagCompound.getCompoundTag("display").getString("Name"); } } } } @Override - public void writeToNBT(NBTTagCompound nbtTagCompound) - { + public void writeToNBT(NBTTagCompound nbtTagCompound) { // Write the ItemStacks in the inventory to NBT NBTTagList tagList = new NBTTagList(); - for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) - { - if (inventory[currentIndex] != null) - { + for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) { + if (inventory[currentIndex] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte) currentIndex); inventory[currentIndex].writeToNBT(tagCompound); @@ -246,18 +224,15 @@ public class InventoryAlchemicalBag implements IInventory, INBTTaggable } @Override - public String getTagLabel() - { + public String getTagLabel() { return "InventoryAlchemicalBag"; } - public boolean hasCustomName() - { + public boolean hasCustomName() { return customName != null && customName.length() > 0; } - public String getCustomName() - { + public String getCustomName() { return customName; } } diff --git a/src/main/java/com/pahimar/ee3/inventory/InventoryAlchenomicon.java b/src/main/java/com/pahimar/ee3/inventory/InventoryAlchenomicon.java index 4920d4ce..b98ae631 100644 --- a/src/main/java/com/pahimar/ee3/inventory/InventoryAlchenomicon.java +++ b/src/main/java/com/pahimar/ee3/inventory/InventoryAlchenomicon.java @@ -1,44 +1,36 @@ package com.pahimar.ee3.inventory; +import java.util.Set; +import java.util.TreeSet; + import com.pahimar.ee3.reference.Comparators; import com.pahimar.ee3.reference.Names; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import java.util.Set; -import java.util.TreeSet; - -public class InventoryAlchenomicon implements IInventory -{ +public class InventoryAlchenomicon implements IInventory { private ItemStack[] inventory; private Set knownTransmutations; - public InventoryAlchenomicon(Set knownTransmutations) - { + public InventoryAlchenomicon(Set knownTransmutations) { inventory = new ItemStack[80]; - if (knownTransmutations != null) - { + if (knownTransmutations != null) { this.knownTransmutations = knownTransmutations; - } - else - { + } else { this.knownTransmutations = new TreeSet(Comparators.ID_COMPARATOR); } inventory = knownTransmutations.toArray(inventory); } @Override - public int getSizeInventory() - { + public int getSizeInventory() { return inventory.length; } @Override - public ItemStack getStackInSlot(int slotIndex) - { - if (slotIndex < getSizeInventory()) - { + public ItemStack getStackInSlot(int slotIndex) { + if (slotIndex < getSizeInventory()) { return inventory[slotIndex]; } @@ -46,20 +38,14 @@ public class InventoryAlchenomicon implements IInventory } @Override - public ItemStack decrStackSize(int slotIndex, int decrementAmount) - { + public ItemStack decrStackSize(int slotIndex, int decrementAmount) { ItemStack itemStack = getStackInSlot(slotIndex); - if (itemStack != null) - { - if (itemStack.stackSize <= decrementAmount) - { + if (itemStack != null) { + if (itemStack.stackSize <= decrementAmount) { setInventorySlotContents(slotIndex, null); - } - else - { + } else { itemStack = itemStack.splitStack(decrementAmount); - if (itemStack.stackSize == 0) - { + if (itemStack.stackSize == 0) { setInventorySlotContents(slotIndex, null); } } @@ -69,79 +55,64 @@ public class InventoryAlchenomicon implements IInventory } @Override - public ItemStack getStackInSlotOnClosing(int slotIndex) - { - if (getStackInSlot(slotIndex) != null) - { + public ItemStack getStackInSlotOnClosing(int slotIndex) { + if (getStackInSlot(slotIndex) != null) { ItemStack itemStack = inventory[slotIndex]; inventory[slotIndex] = null; return itemStack; - } - else - { + } else { return null; } } @Override - public void setInventorySlotContents(int slotIndex, ItemStack itemStack) - { - if (slotIndex < inventory.length) - { + public void setInventorySlotContents(int slotIndex, ItemStack itemStack) { + if (slotIndex < inventory.length) { inventory[slotIndex] = itemStack; } } @Override - public String getInventoryName() - { + public String getInventoryName() { return Names.Containers.ALCHENOMICON; } @Override - public boolean hasCustomInventoryName() - { + public boolean hasCustomInventoryName() { return false; } @Override - public int getInventoryStackLimit() - { + public int getInventoryStackLimit() { return 64; } @Override - public void markDirty() - { + public void markDirty() { // NOOP } @Override - public boolean isUseableByPlayer(EntityPlayer entityPlayer) - { + public boolean isUseableByPlayer(EntityPlayer entityPlayer) { return true; } @Override - public void openInventory() - { + public void openInventory() { // NOOP } @Override - public void closeInventory() - { + public void closeInventory() { // NOOP } @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) - { + public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { return false; } - public Set getKnownTransmutations() - { + public Set getKnownTransmutations() { return knownTransmutations; } } diff --git a/src/main/java/com/pahimar/ee3/inventory/InventoryTransmutationTablet.java b/src/main/java/com/pahimar/ee3/inventory/InventoryTransmutationTablet.java index f79c27a4..563952c5 100644 --- a/src/main/java/com/pahimar/ee3/inventory/InventoryTransmutationTablet.java +++ b/src/main/java/com/pahimar/ee3/inventory/InventoryTransmutationTablet.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.inventory; +import java.util.*; + import com.pahimar.ee3.knowledge.PlayerKnowledge; import com.pahimar.ee3.reference.Comparators; import com.pahimar.ee3.reference.Names; @@ -7,15 +9,11 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import java.util.*; - public class InventoryTransmutationTablet implements IInventory { - private ItemStack[] inventory; private Set knownTransmutations; - public InventoryTransmutationTablet() - { + public InventoryTransmutationTablet() { this(Collections.emptySet()); } @@ -24,7 +22,6 @@ public class InventoryTransmutationTablet implements IInventory { } public InventoryTransmutationTablet(Collection knownTransmutations) { - inventory = new ItemStack[30]; this.knownTransmutations = new TreeSet<>(Comparators.ID_COMPARATOR); @@ -33,12 +30,12 @@ public class InventoryTransmutationTablet implements IInventory { this.knownTransmutations.addAll(knownTransmutations); } - List knownTransmutationsList = new ArrayList<>(this.knownTransmutations); + List knownTransmutationsList + = new ArrayList<>(this.knownTransmutations); if (knownTransmutationsList.size() <= 30) { inventory = knownTransmutationsList.toArray(inventory); - } - else { + } else { inventory = knownTransmutationsList.subList(0, 30).toArray(inventory); } @@ -56,7 +53,6 @@ public class InventoryTransmutationTablet implements IInventory { @Override public ItemStack getStackInSlot(int slotIndex) { - if (slotIndex < getSizeInventory()) { return inventory[slotIndex]; } @@ -65,19 +61,17 @@ public class InventoryTransmutationTablet implements IInventory { } /** - * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a - * new stack. + * Removes from an inventory slot (first arg) up to a specified number (second arg) of + * items and returns them in a new stack. */ @Override public ItemStack decrStackSize(int slotIndex, int decrementAmount) { - ItemStack itemStack = getStackInSlot(slotIndex); if (itemStack != null) { if (itemStack.stackSize <= decrementAmount) { setInventorySlotContents(slotIndex, null); - } - else { + } else { itemStack = itemStack.splitStack(decrementAmount); if (itemStack.stackSize == 0) { @@ -93,30 +87,23 @@ public class InventoryTransmutationTablet implements IInventory { @Override public ItemStack getStackInSlotOnClosing(int slotIndex) { - if (getStackInSlot(slotIndex) != null) { - ItemStack itemStack = inventory[slotIndex]; inventory[slotIndex] = null; return itemStack; - } - else { + } else { return null; } } @Override public void setInventorySlotContents(int slotIndex, ItemStack itemStack) { - if (slotIndex < inventory.length) { - if (itemStack != null) { - ItemStack copiedItemStack = itemStack.copy(); copiedItemStack.stackSize = 1; inventory[slotIndex] = copiedItemStack; - } - else { + } else { inventory[slotIndex] = itemStack; } } diff --git a/src/main/java/com/pahimar/ee3/inventory/element/IElementButtonHandler.java b/src/main/java/com/pahimar/ee3/inventory/element/IElementButtonHandler.java index daacaa9f..5db6c754 100644 --- a/src/main/java/com/pahimar/ee3/inventory/element/IElementButtonHandler.java +++ b/src/main/java/com/pahimar/ee3/inventory/element/IElementButtonHandler.java @@ -1,6 +1,5 @@ package com.pahimar.ee3.inventory.element; -public interface IElementButtonHandler -{ +public interface IElementButtonHandler { public abstract void handleElementButtonClick(String elementName, int mouseButton); } diff --git a/src/main/java/com/pahimar/ee3/inventory/element/IElementSliderHandler.java b/src/main/java/com/pahimar/ee3/inventory/element/IElementSliderHandler.java index e57aa4cd..7da619a5 100644 --- a/src/main/java/com/pahimar/ee3/inventory/element/IElementSliderHandler.java +++ b/src/main/java/com/pahimar/ee3/inventory/element/IElementSliderHandler.java @@ -1,6 +1,5 @@ package com.pahimar.ee3.inventory.element; -public interface IElementSliderHandler -{ +public interface IElementSliderHandler { public abstract void handleElementSliderUpdate(String elementName, int elementValue); } diff --git a/src/main/java/com/pahimar/ee3/inventory/element/IElementTextFieldHandler.java b/src/main/java/com/pahimar/ee3/inventory/element/IElementTextFieldHandler.java index 679bce9e..072549d5 100644 --- a/src/main/java/com/pahimar/ee3/inventory/element/IElementTextFieldHandler.java +++ b/src/main/java/com/pahimar/ee3/inventory/element/IElementTextFieldHandler.java @@ -1,6 +1,6 @@ package com.pahimar.ee3.inventory.element; -public interface IElementTextFieldHandler -{ - public abstract void handleElementTextFieldUpdate(String elementName, String updatedText); +public interface IElementTextFieldHandler { + public abstract void + handleElementTextFieldUpdate(String elementName, String updatedText); } diff --git a/src/main/java/com/pahimar/ee3/item/ITransmutationStone.java b/src/main/java/com/pahimar/ee3/item/ITransmutationStone.java index 33646036..95297e94 100644 --- a/src/main/java/com/pahimar/ee3/item/ITransmutationStone.java +++ b/src/main/java/com/pahimar/ee3/item/ITransmutationStone.java @@ -4,11 +4,18 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public interface ITransmutationStone -{ +public interface ITransmutationStone { void openPortableCraftingGUI(final EntityPlayer p0, final ItemStack p1); - + void openPortableTransmutationGUI(final EntityPlayer p0, final ItemStack p1); - - void transmuteBlock(final ItemStack p0, final EntityPlayer p1, final World p2, final int p3, final int p4, final int p5, final int p6); + + void transmuteBlock( + final ItemStack p0, + final EntityPlayer p1, + final World p2, + final int p3, + final int p4, + final int p5, + final int p6 + ); } diff --git a/src/main/java/com/pahimar/ee3/item/ItemAlchemicalBag.java b/src/main/java/com/pahimar/ee3/item/ItemAlchemicalBag.java index a24b4e8f..f0bbad9a 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemAlchemicalBag.java +++ b/src/main/java/com/pahimar/ee3/item/ItemAlchemicalBag.java @@ -1,5 +1,8 @@ package com.pahimar.ee3.item; +import java.util.List; +import java.util.UUID; + import com.pahimar.ee3.EquivalentExchange3; import com.pahimar.ee3.reference.Colors; import com.pahimar.ee3.reference.GUIs; @@ -21,18 +24,14 @@ import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; -import java.util.List; -import java.util.UUID; - -public class ItemAlchemicalBag extends ItemEE implements IOwnable -{ - private static final String[] ALCHEMICAL_BAG_ICONS = {"open", "closed", "symbolTier1", "symbolTier2", "symbolTier3"}; +public class ItemAlchemicalBag extends ItemEE implements IOwnable { + private static final String[] ALCHEMICAL_BAG_ICONS + = { "open", "closed", "symbolTier1", "symbolTier2", "symbolTier3" }; @SideOnly(Side.CLIENT) private IIcon[] icons; - public ItemAlchemicalBag() - { + public ItemAlchemicalBag() { super(); this.setHasSubtypes(true); this.setUnlocalizedName(Names.Items.ALCHEMICAL_BAG); @@ -40,64 +39,53 @@ public class ItemAlchemicalBag extends ItemEE implements IOwnable @Override @SideOnly(Side.CLIENT) - public boolean requiresMultipleRenderPasses() - { + public boolean requiresMultipleRenderPasses() { return true; } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister iconRegister) - { + public void registerIcons(IIconRegister iconRegister) { icons = new IIcon[ALCHEMICAL_BAG_ICONS.length]; - for (int i = 0; i < ALCHEMICAL_BAG_ICONS.length; i++) - { - icons[i] = iconRegister.registerIcon(Textures.RESOURCE_PREFIX + Names.Items.ALCHEMICAL_BAG + "." + ALCHEMICAL_BAG_ICONS[i]); + for (int i = 0; i < ALCHEMICAL_BAG_ICONS.length; i++) { + icons[i] = iconRegister.registerIcon( + Textures.RESOURCE_PREFIX + Names.Items.ALCHEMICAL_BAG + "." + + ALCHEMICAL_BAG_ICONS[i] + ); } } @Override - public IIcon getIcon(ItemStack itemStack, int renderPass) - { - if (renderPass == 0) - { - if (NBTHelper.hasKey(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN)) - { + public IIcon getIcon(ItemStack itemStack, int renderPass) { + if (renderPass == 0) { + if (NBTHelper.hasKey(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN)) { return icons[0]; - } - else - { + } else { return icons[1]; } - } - else - { + } else { return icons[2 + MathHelper.clamp_int(itemStack.getItemDamage(), 0, 3)]; } } @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs creativeTab, List list) - { - for (int meta = 0; meta < 3; ++meta) - { + public void getSubItems(Item item, CreativeTabs creativeTab, List list) { + for (int meta = 0; meta < 3; ++meta) { list.add(new ItemStack(this, 1, meta)); } } @Override - public boolean getShareTag() - { + public boolean getShareTag() { return true; } @Override - public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) { - + public ItemStack + onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) { if (!world.isRemote) { - // Set the owner of the bag if one doesn't exist already if (ItemStackUtils.getOwnerUUID(itemStack) == null) { ItemStackUtils.setOwner(itemStack, entityPlayer); @@ -108,13 +96,17 @@ public class ItemAlchemicalBag extends ItemEE implements IOwnable NBTHelper.setUUID(itemStack, UUID.randomUUID()); } - // TODO Do a scan of inventory and if we find a bag with the same UUID, change it's UUID + // TODO Do a scan of inventory and if we find a bag with the same UUID, change + // it's UUID for (int i = 0; i < entityPlayer.inventory.getSizeInventory(); i++) { if (entityPlayer.inventory.getStackInSlot(i) != null) { ItemStack itemStack1 = entityPlayer.inventory.getStackInSlot(i); if (itemStack1.getItem() instanceof ItemAlchemicalBag) { - if (NBTHelper.hasUUID(itemStack1) && NBTHelper.getUUID(itemStack).equals(NBTHelper.getUUID(itemStack1))) { + if (NBTHelper.hasUUID(itemStack1) + && NBTHelper.getUUID(itemStack).equals( + NBTHelper.getUUID(itemStack1) + )) { NBTHelper.setUUID(itemStack1, UUID.randomUUID()); } } @@ -122,7 +114,14 @@ public class ItemAlchemicalBag extends ItemEE implements IOwnable } NBTHelper.setBoolean(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN, true); - entityPlayer.openGui(EquivalentExchange3.instance, GUIs.ALCHEMICAL_BAG.ordinal(), entityPlayer.worldObj, (int) entityPlayer.posX, (int) entityPlayer.posY, (int) entityPlayer.posZ); + entityPlayer.openGui( + EquivalentExchange3.instance, + GUIs.ALCHEMICAL_BAG.ordinal(), + entityPlayer.worldObj, + (int) entityPlayer.posX, + (int) entityPlayer.posY, + (int) entityPlayer.posZ + ); } return itemStack; @@ -130,51 +129,41 @@ public class ItemAlchemicalBag extends ItemEE implements IOwnable @Override @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack itemStack, int renderPass) - { + public int getColorFromItemStack(ItemStack itemStack, int renderPass) { int bagColor = this.getColor(itemStack); - if (bagColor < 0) - { + if (bagColor < 0) { bagColor = Integer.parseInt(Colors.PURE_WHITE, 16); } return bagColor; } - public boolean hasColor(ItemStack itemStack) - { + public boolean hasColor(ItemStack itemStack) { return ColorHelper.hasColor(itemStack); } - public int getColor(ItemStack itemStack) - { + public int getColor(ItemStack itemStack) { return ColorHelper.getColor(itemStack); } - public void setColor(ItemStack itemStack, int color) - { - if (itemStack != null) - { - if (itemStack.getItem() instanceof ItemAlchemicalBag) - { + public void setColor(ItemStack itemStack, int color) { + if (itemStack != null) { + if (itemStack.getItem() instanceof ItemAlchemicalBag) { ColorHelper.setColor(itemStack, color); } } } - public void removeColor(ItemStack itemStack) - { - if (itemStack != null) - { + public void removeColor(ItemStack itemStack) { + if (itemStack != null) { NBTTagCompound nbtTagCompound = itemStack.getTagCompound(); - if (nbtTagCompound != null) - { - NBTTagCompound displayTagCompound = nbtTagCompound.getCompoundTag(Names.NBT.DISPLAY); + if (nbtTagCompound != null) { + NBTTagCompound displayTagCompound + = nbtTagCompound.getCompoundTag(Names.NBT.DISPLAY); - if (displayTagCompound.hasKey(Names.NBT.COLOR)) - { + if (displayTagCompound.hasKey(Names.NBT.COLOR)) { displayTagCompound.removeTag(Names.NBT.COLOR); } } diff --git a/src/main/java/com/pahimar/ee3/item/ItemAlchemicalDust.java b/src/main/java/com/pahimar/ee3/item/ItemAlchemicalDust.java index 73ad54f9..588745aa 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemAlchemicalDust.java +++ b/src/main/java/com/pahimar/ee3/item/ItemAlchemicalDust.java @@ -1,5 +1,8 @@ package com.pahimar.ee3.item; +import java.util.ArrayList; +import java.util.List; + import com.pahimar.ee3.init.ModItems; import com.pahimar.ee3.reference.Colors; import com.pahimar.ee3.reference.Names; @@ -11,25 +14,18 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; -import java.util.ArrayList; -import java.util.List; - -public class ItemAlchemicalDust extends ItemEE -{ - public ItemAlchemicalDust() - { +public class ItemAlchemicalDust extends ItemEE { + public ItemAlchemicalDust() { super(); this.setMaxStackSize(64); this.setHasSubtypes(true); this.setUnlocalizedName(Names.Items.ALCHEMICAL_DUST); } - public static List getAlchemicalDusts() - { + public static List getAlchemicalDusts() { List alchemicalDustStacks = new ArrayList(); - for (int meta = 0; meta < Names.Items.ALCHEMICAL_DUST_SUBTYPES.length; meta++) - { + for (int meta = 0; meta < Names.Items.ALCHEMICAL_DUST_SUBTYPES.length; meta++) { alchemicalDustStacks.add(new ItemStack(ModItems.alchemicalDust, 1, meta)); } @@ -38,22 +34,14 @@ public class ItemAlchemicalDust extends ItemEE @Override @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack itemStack, int renderPass) - { - if (itemStack.getItemDamage() == 0) - { + public int getColorFromItemStack(ItemStack itemStack, int renderPass) { + if (itemStack.getItemDamage() == 0) { return Integer.parseInt(Colors.DUST_ASH, 16); - } - else if (itemStack.getItemDamage() == 1) - { + } else if (itemStack.getItemDamage() == 1) { return Integer.parseInt(Colors.DUST_VERDANT, 16); - } - else if (itemStack.getItemDamage() == 2) - { + } else if (itemStack.getItemDamage() == 2) { return Integer.parseInt(Colors.DUST_AZURE, 16); - } - else if (itemStack.getItemDamage() == 3) - { + } else if (itemStack.getItemDamage() == 3) { return Integer.parseInt(Colors.DUST_MINIUM, 16); } @@ -61,21 +49,29 @@ public class ItemAlchemicalDust extends ItemEE } @Override - public String getUnlocalizedName() - { - return String.format("item.%s%s", Textures.RESOURCE_PREFIX, Names.Items.ALCHEMICAL_DUST); + public String getUnlocalizedName() { + return String.format( + "item.%s%s", Textures.RESOURCE_PREFIX, Names.Items.ALCHEMICAL_DUST + ); } @Override - public String getUnlocalizedName(ItemStack itemStack) - { - return String.format("item.%s%s.%s", Textures.RESOURCE_PREFIX, Names.Items.ALCHEMICAL_DUST, Names.Items.ALCHEMICAL_DUST_SUBTYPES[MathHelper.clamp_int(itemStack.getItemDamage(), 0, Names.Items.ALCHEMICAL_DUST_SUBTYPES.length - 1)]); + public String getUnlocalizedName(ItemStack itemStack) { + return String.format( + "item.%s%s.%s", + Textures.RESOURCE_PREFIX, + Names.Items.ALCHEMICAL_DUST, + Names.Items.ALCHEMICAL_DUST_SUBTYPES[MathHelper.clamp_int( + itemStack.getItemDamage(), + 0, + Names.Items.ALCHEMICAL_DUST_SUBTYPES.length - 1 + )] + ); } @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs creativeTab, List list) - { + public void getSubItems(Item item, CreativeTabs creativeTab, List list) { list.add(new ItemStack(this, 1, 0)); list.add(new ItemStack(this, 1, 3)); } diff --git a/src/main/java/com/pahimar/ee3/item/ItemAlchemicalFuel.java b/src/main/java/com/pahimar/ee3/item/ItemAlchemicalFuel.java index 8c4edc12..bac9fb92 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemAlchemicalFuel.java +++ b/src/main/java/com/pahimar/ee3/item/ItemAlchemicalFuel.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.item; +import java.util.List; + import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.reference.Textures; import cpw.mods.fml.relauncher.Side; @@ -11,15 +13,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; -import java.util.List; - -public class ItemAlchemicalFuel extends ItemEE -{ +public class ItemAlchemicalFuel extends ItemEE { @SideOnly(Side.CLIENT) private IIcon[] icons; - public ItemAlchemicalFuel() - { + public ItemAlchemicalFuel() { super(); this.setMaxStackSize(64); this.setHasSubtypes(true); @@ -27,43 +25,52 @@ public class ItemAlchemicalFuel extends ItemEE } @Override - public String getUnlocalizedName() - { - return String.format("item.%s%s", Textures.RESOURCE_PREFIX, Names.Items.ALCHEMICAL_FUEL); + public String getUnlocalizedName() { + return String.format( + "item.%s%s", Textures.RESOURCE_PREFIX, Names.Items.ALCHEMICAL_FUEL + ); } @Override - public String getUnlocalizedName(ItemStack itemStack) - { - return String.format("item.%s%s.%s", Textures.RESOURCE_PREFIX, Names.Items.ALCHEMICAL_FUEL, Names.Items.ALCHEMICAL_FUEL_SUBTYPES[MathHelper.clamp_int(itemStack.getItemDamage(), 0, Names.Items.ALCHEMICAL_FUEL_SUBTYPES.length - 1)]); + public String getUnlocalizedName(ItemStack itemStack) { + return String.format( + "item.%s%s.%s", + Textures.RESOURCE_PREFIX, + Names.Items.ALCHEMICAL_FUEL, + Names.Items.ALCHEMICAL_FUEL_SUBTYPES[MathHelper.clamp_int( + itemStack.getItemDamage(), + 0, + Names.Items.ALCHEMICAL_FUEL_SUBTYPES.length - 1 + )] + ); } @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs creativeTab, List list) - { - for (int meta = 0; meta < Names.Items.ALCHEMICAL_FUEL_SUBTYPES.length; ++meta) - { + public void getSubItems(Item item, CreativeTabs creativeTab, List list) { + for (int meta = 0; meta < Names.Items.ALCHEMICAL_FUEL_SUBTYPES.length; ++meta) { list.add(new ItemStack(this, 1, meta)); } } @Override @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int meta) - { - return icons[MathHelper.clamp_int(meta, 0, Names.Items.ALCHEMICAL_FUEL_SUBTYPES.length - 1)]; + public IIcon getIconFromDamage(int meta) { + return icons[MathHelper.clamp_int( + meta, 0, Names.Items.ALCHEMICAL_FUEL_SUBTYPES.length - 1 + )]; } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister iconRegister) - { + public void registerIcons(IIconRegister iconRegister) { icons = new IIcon[Names.Items.ALCHEMICAL_FUEL_SUBTYPES.length]; - for (int i = 0; i < Names.Items.ALCHEMICAL_FUEL_SUBTYPES.length; i++) - { - icons[i] = iconRegister.registerIcon(Textures.RESOURCE_PREFIX + Names.Items.ALCHEMICAL_FUEL + "." + Names.Items.ALCHEMICAL_FUEL_SUBTYPES[i]); + for (int i = 0; i < Names.Items.ALCHEMICAL_FUEL_SUBTYPES.length; i++) { + icons[i] = iconRegister.registerIcon( + Textures.RESOURCE_PREFIX + Names.Items.ALCHEMICAL_FUEL + "." + + Names.Items.ALCHEMICAL_FUEL_SUBTYPES[i] + ); } } } diff --git a/src/main/java/com/pahimar/ee3/item/ItemAlchemicalInventoryUpgrade.java b/src/main/java/com/pahimar/ee3/item/ItemAlchemicalInventoryUpgrade.java index f1dc9b41..5041ffb6 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemAlchemicalInventoryUpgrade.java +++ b/src/main/java/com/pahimar/ee3/item/ItemAlchemicalInventoryUpgrade.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.item; +import java.util.List; + import com.pahimar.ee3.reference.Colors; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; @@ -14,12 +16,8 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraft.util.StatCollector; -import java.util.List; - -public class ItemAlchemicalInventoryUpgrade extends ItemEE -{ - public ItemAlchemicalInventoryUpgrade() - { +public class ItemAlchemicalInventoryUpgrade extends ItemEE { + public ItemAlchemicalInventoryUpgrade() { super(); this.setMaxStackSize(64); this.setUnlocalizedName(Names.Items.ALCHEMICAL_UPGRADE); @@ -27,41 +25,43 @@ public class ItemAlchemicalInventoryUpgrade extends ItemEE } @Override - public String getUnlocalizedName() - { - return String.format("item.%s%s", Textures.RESOURCE_PREFIX, Names.Items.ALCHEMICAL_UPGRADE); + public String getUnlocalizedName() { + return String.format( + "item.%s%s", Textures.RESOURCE_PREFIX, Names.Items.ALCHEMICAL_UPGRADE + ); } @Override - public String getUnlocalizedName(ItemStack itemStack) - { - return String.format("item.%s%s.%s", Textures.RESOURCE_PREFIX, Names.Items.ALCHEMICAL_UPGRADE, Names.Items.ALCHEMICAL_UPGRADE_SUBTYPES[MathHelper.clamp_int(itemStack.getItemDamage(), 0, Names.Items.ALCHEMICAL_UPGRADE_SUBTYPES.length - 1)]); + public String getUnlocalizedName(ItemStack itemStack) { + return String.format( + "item.%s%s.%s", + Textures.RESOURCE_PREFIX, + Names.Items.ALCHEMICAL_UPGRADE, + Names.Items.ALCHEMICAL_UPGRADE_SUBTYPES[MathHelper.clamp_int( + itemStack.getItemDamage(), + 0, + Names.Items.ALCHEMICAL_UPGRADE_SUBTYPES.length - 1 + )] + ); } @Override @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs creativeTab, List list) - { - for (int meta = 0; meta < Names.Items.ALCHEMICAL_UPGRADE_SUBTYPES.length; ++meta) - { + public void getSubItems(Item item, CreativeTabs creativeTab, List list) { + for (int meta = 0; meta < Names.Items.ALCHEMICAL_UPGRADE_SUBTYPES.length; + ++meta) { list.add(new ItemStack(this, 1, meta)); } } @Override @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack itemStack, int renderPass) - { - if (itemStack.getItemDamage() == 0) - { + public int getColorFromItemStack(ItemStack itemStack, int renderPass) { + if (itemStack.getItemDamage() == 0) { return Integer.parseInt(Colors.DUST_VERDANT, 16); - } - else if (itemStack.getItemDamage() == 1) - { + } else if (itemStack.getItemDamage() == 1) { return Integer.parseInt(Colors.DUST_AZURE, 16); - } - else if (itemStack.getItemDamage() == 2) - { + } else if (itemStack.getItemDamage() == 2) { return Integer.parseInt(Colors.DUST_MINIUM, 16); } @@ -70,31 +70,32 @@ public class ItemAlchemicalInventoryUpgrade extends ItemEE @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean flag) - { + public void addInformation( + ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean flag + ) { list.add(StatCollector.translateToLocal(Messages.Tooltips.UPGRADES_CHESTS)); } @Override - public String getItemStackDisplayName(ItemStack itemStack) - { - switch (MathHelper.clamp_int(itemStack.getItemDamage(), 0, Names.Items.ALCHEMICAL_UPGRADE_SUBTYPES.length - 1)) - { - case 0: - { - return EnumChatFormatting.GREEN + super.getItemStackDisplayName(itemStack); + public String getItemStackDisplayName(ItemStack itemStack) { + switch (MathHelper.clamp_int( + itemStack.getItemDamage(), + 0, + Names.Items.ALCHEMICAL_UPGRADE_SUBTYPES.length - 1 + )) { + case 0: { + return EnumChatFormatting.GREEN + + super.getItemStackDisplayName(itemStack); } - case 1: - { + case 1: { return EnumChatFormatting.BLUE + super.getItemStackDisplayName(itemStack); } - case 2: - { + case 2: { return EnumChatFormatting.RED + super.getItemStackDisplayName(itemStack); } - default: - { - return EnumChatFormatting.WHITE + super.getItemStackDisplayName(itemStack); + default: { + return EnumChatFormatting.WHITE + + super.getItemStackDisplayName(itemStack); } } } diff --git a/src/main/java/com/pahimar/ee3/item/ItemAlchenomicon.java b/src/main/java/com/pahimar/ee3/item/ItemAlchenomicon.java index 2235f7ee..fd69a583 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemAlchenomicon.java +++ b/src/main/java/com/pahimar/ee3/item/ItemAlchenomicon.java @@ -15,33 +15,35 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.world.World; -public class ItemAlchenomicon extends ItemEE implements IOwnable, IEnergyValueProvider -{ - public ItemAlchenomicon() - { +public class ItemAlchenomicon extends ItemEE implements IOwnable, IEnergyValueProvider { + public ItemAlchenomicon() { super(); this.setUnlocalizedName(Names.Items.ALCHENOMICON); } @Override - public boolean getShareTag() - { + public boolean getShareTag() { return true; } @Override - public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) - { - if (!world.isRemote) - { - if (ItemStackUtils.getOwnerUUID(itemStack) == null) - { + public ItemStack + onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) { + if (!world.isRemote) { + if (ItemStackUtils.getOwnerUUID(itemStack) == null) { ItemStackUtils.setOwner(itemStack, entityPlayer); - entityPlayer.addChatComponentMessage(new ChatComponentTranslation(Messages.OWNER_SET_TO_SELF, new Object[]{itemStack.func_151000_E()})); - } - else - { - entityPlayer.openGui(EquivalentExchange3.instance, GUIs.ALCHENOMICON.ordinal(), entityPlayer.worldObj, (int) entityPlayer.posX, (int) entityPlayer.posY, (int) entityPlayer.posZ); + entityPlayer.addChatComponentMessage(new ChatComponentTranslation( + Messages.OWNER_SET_TO_SELF, new Object[] { itemStack.func_151000_E() } + )); + } else { + entityPlayer.openGui( + EquivalentExchange3.instance, + GUIs.ALCHENOMICON.ordinal(), + entityPlayer.worldObj, + (int) entityPlayer.posX, + (int) entityPlayer.posY, + (int) entityPlayer.posZ + ); } } @@ -49,8 +51,7 @@ public class ItemAlchenomicon extends ItemEE implements IOwnable, IEnergyValuePr } @Override - public EnergyValue getEnergyValue(ItemStack itemStack) - { + public EnergyValue getEnergyValue(ItemStack itemStack) { return EnergyValueRegistryProxy.getEnergyValue(ModItems.alchenomicon, true); } } diff --git a/src/main/java/com/pahimar/ee3/item/ItemBlockAlchemicalChest.java b/src/main/java/com/pahimar/ee3/item/ItemBlockAlchemicalChest.java index 9c50e38e..c6ca1423 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemBlockAlchemicalChest.java +++ b/src/main/java/com/pahimar/ee3/item/ItemBlockAlchemicalChest.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.item; +import java.util.List; + import com.pahimar.ee3.reference.Messages; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -9,38 +11,35 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; -import java.util.List; - -public class ItemBlockAlchemicalChest extends ItemBlock -{ - public ItemBlockAlchemicalChest(Block block) - { +public class ItemBlockAlchemicalChest extends ItemBlock { + public ItemBlockAlchemicalChest(Block block) { super(block); this.setHasSubtypes(true); } @Override - public int getMetadata(int meta) - { + public int getMetadata(int meta) { return meta; } @SideOnly(Side.CLIENT) - public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean flag) - { + public void addInformation( + ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean flag + ) { int metaData = itemStack.getItemDamage(); - if (metaData == 0) - { - list.add(StatCollector.translateToLocal(StatCollector.translateToLocal(Messages.Tooltips.SMALL))); - } - else if (metaData == 1) - { - list.add(StatCollector.translateToLocal(StatCollector.translateToLocal(Messages.Tooltips.MEDIUM))); - } - else if (metaData == 2) - { - list.add(StatCollector.translateToLocal(StatCollector.translateToLocal(Messages.Tooltips.LARGE))); + if (metaData == 0) { + list.add(StatCollector.translateToLocal( + StatCollector.translateToLocal(Messages.Tooltips.SMALL) + )); + } else if (metaData == 1) { + list.add(StatCollector.translateToLocal( + StatCollector.translateToLocal(Messages.Tooltips.MEDIUM) + )); + } else if (metaData == 2) { + list.add(StatCollector.translateToLocal( + StatCollector.translateToLocal(Messages.Tooltips.LARGE) + )); } } } diff --git a/src/main/java/com/pahimar/ee3/item/ItemBlockAlchemicalFuel.java b/src/main/java/com/pahimar/ee3/item/ItemBlockAlchemicalFuel.java index 3d33a75b..268cdc1a 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemBlockAlchemicalFuel.java +++ b/src/main/java/com/pahimar/ee3/item/ItemBlockAlchemicalFuel.java @@ -5,10 +5,12 @@ import com.pahimar.ee3.reference.Names; import net.minecraft.block.Block; import net.minecraft.item.ItemMultiTexture; -public class ItemBlockAlchemicalFuel extends ItemMultiTexture -{ - public ItemBlockAlchemicalFuel(Block block) - { - super(ModBlocks.alchemicalFuelBlock, ModBlocks.alchemicalFuelBlock, Names.Items.ALCHEMICAL_FUEL_SUBTYPES); +public class ItemBlockAlchemicalFuel extends ItemMultiTexture { + public ItemBlockAlchemicalFuel(Block block) { + super( + ModBlocks.alchemicalFuelBlock, + ModBlocks.alchemicalFuelBlock, + Names.Items.ALCHEMICAL_FUEL_SUBTYPES + ); } } diff --git a/src/main/java/com/pahimar/ee3/item/ItemChalk.java b/src/main/java/com/pahimar/ee3/item/ItemChalk.java index 3fe10fa1..1d5bf8d6 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemChalk.java +++ b/src/main/java/com/pahimar/ee3/item/ItemChalk.java @@ -19,10 +19,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public class ItemChalk extends ItemEE implements IKeyBound -{ - public ItemChalk() - { +public class ItemChalk extends ItemEE implements IKeyBound { + public ItemChalk() { super(); this.setUnlocalizedName(Names.Items.CHALK); this.setMaxDamage(80); @@ -30,41 +28,39 @@ public class ItemChalk extends ItemEE implements IKeyBound } /** - * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return - * True if something happen and false if it don't. This is for ITEMS, not BLOCKS + * Callback for item usage. If the item does something special on right clicking, he + * will have one of those. Return True if something happen and false if it don't. This + * is for ITEMS, not BLOCKS */ @Override - public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { - if (!world.isRemote) - { - if (side == 0) - { + public boolean onItemUse( + ItemStack itemStack, + EntityPlayer entityPlayer, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ + ) { + if (!world.isRemote) { + if (side == 0) { --y; - } - else if (side == 1) - { + } else if (side == 1) { ++y; - } - else if (side == 2) - { + } else if (side == 2) { --z; - } - else if (side == 3) - { + } else if (side == 3) { ++z; - } - else if (side == 4) - { + } else if (side == 4) { --x; - } - else if (side == 5) - { + } else if (side == 5) { ++x; } - if (canPlaceAlchemyArray(itemStack, entityPlayer, world, x, y, z, side)) - { + if (canPlaceAlchemyArray(itemStack, entityPlayer, world, x, y, z, side)) { placeAlchemyArray(itemStack, entityPlayer, world, x, y, z, side); return true; } @@ -73,23 +69,35 @@ public class ItemChalk extends ItemEE implements IKeyBound return false; } - private boolean canPlaceAlchemyArray(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int side) - { - if (!world.isRemote) - { - NBTTagCompound playerCustomData = EntityHelper.getCustomEntityData(entityPlayer); + private boolean canPlaceAlchemyArray( + ItemStack itemStack, + EntityPlayer entityPlayer, + World world, + int x, + int y, + int z, + int side + ) { + if (!world.isRemote) { + NBTTagCompound playerCustomData + = EntityHelper.getCustomEntityData(entityPlayer); ChalkSettings chalkSettings = new ChalkSettings(); chalkSettings.readFromNBT(playerCustomData); - AlchemyArray alchemyArray = AlchemyArrayRegistry.getInstance().getAlchemyArray(chalkSettings.getIndex()); + AlchemyArray alchemyArray + = AlchemyArrayRegistry.getInstance().getAlchemyArray( + chalkSettings.getIndex() + ); int coordOffset = chalkSettings.getSize() - 1; ForgeDirection orientation = ForgeDirection.getOrientation(side); - boolean canPlaceAlchemyArray = ModBlocks.alchemyArray.canPlaceBlockOnSide(world, x, y, z, side); + boolean canPlaceAlchemyArray + = ModBlocks.alchemyArray.canPlaceBlockOnSide(world, x, y, z, side); int chargeLevel = ((chalkSettings.getSize() - 1) * 2) + 1; - if (itemStack.getItemDamage() == itemStack.getMaxDamage() && (chargeLevel * chargeLevel) * alchemyArray.getChalkCostPerBlock() == 1) - { + if (itemStack.getItemDamage() == itemStack.getMaxDamage() + && (chargeLevel * chargeLevel) * alchemyArray.getChalkCostPerBlock() + == 1) { canPlaceAlchemyArray = true; } else if (itemStack.getMaxDamage() - itemStack.getItemDamage() + 1 < (chargeLevel * chargeLevel) * alchemyArray.getChalkCostPerBlock()) @@ -97,16 +105,17 @@ public class ItemChalk extends ItemEE implements IKeyBound canPlaceAlchemyArray = false; } - if (canPlaceAlchemyArray) - { - if (orientation == ForgeDirection.UP || orientation == ForgeDirection.DOWN) - { - for (int i = x - coordOffset; i <= x + coordOffset; i++) - { - for (int j = z - coordOffset; j <= z + coordOffset; j++) - { - if ((i != x || j != z) && (!ModBlocks.dummyArray.canPlaceBlockOnSide(world, i, y, j, side) || world.getTileEntity(i, y, j) instanceof TileEntityDummyArray)) - { + if (canPlaceAlchemyArray) { + if (orientation == ForgeDirection.UP + || orientation == ForgeDirection.DOWN) { + for (int i = x - coordOffset; i <= x + coordOffset; i++) { + for (int j = z - coordOffset; j <= z + coordOffset; j++) { + if ((i != x || j != z) + && (!ModBlocks.dummyArray.canPlaceBlockOnSide( + world, i, y, j, side + ) + || world.getTileEntity(i, y, j) + instanceof TileEntityDummyArray)) { canPlaceAlchemyArray = false; } } @@ -114,12 +123,14 @@ public class ItemChalk extends ItemEE implements IKeyBound } else if (orientation == ForgeDirection.NORTH || orientation == ForgeDirection.SOUTH) { - for (int i = x - coordOffset; i <= x + coordOffset; i++) - { - for (int j = y - coordOffset; j <= y + coordOffset; j++) - { - if ((i != x || j != y) && (!ModBlocks.dummyArray.canPlaceBlockOnSide(world, i, j, z, side) || world.getTileEntity(i, j, z) instanceof TileEntityDummyArray)) - { + for (int i = x - coordOffset; i <= x + coordOffset; i++) { + for (int j = y - coordOffset; j <= y + coordOffset; j++) { + if ((i != x || j != y) + && (!ModBlocks.dummyArray.canPlaceBlockOnSide( + world, i, j, z, side + ) + || world.getTileEntity(i, j, z) + instanceof TileEntityDummyArray)) { canPlaceAlchemyArray = false; } } @@ -127,12 +138,14 @@ public class ItemChalk extends ItemEE implements IKeyBound } else if (orientation == ForgeDirection.EAST || orientation == ForgeDirection.WEST) { - for (int i = y - coordOffset; i <= y + coordOffset; i++) - { - for (int j = z - coordOffset; j <= z + coordOffset; j++) - { - if ((i != y || j != z) && (!ModBlocks.dummyArray.canPlaceBlockOnSide(world, x, i, j, side) || world.getTileEntity(x, i, j) instanceof TileEntityDummyArray)) - { + for (int i = y - coordOffset; i <= y + coordOffset; i++) { + for (int j = z - coordOffset; j <= z + coordOffset; j++) { + if ((i != y || j != z) + && (!ModBlocks.dummyArray.canPlaceBlockOnSide( + world, x, i, j, side + ) + || world.getTileEntity(x, i, j) + instanceof TileEntityDummyArray)) { canPlaceAlchemyArray = false; } } @@ -146,33 +159,49 @@ public class ItemChalk extends ItemEE implements IKeyBound return true; } - private void placeAlchemyArray(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int side) - { - if (!world.isRemote) - { - NBTTagCompound playerCustomData = EntityHelper.getCustomEntityData(entityPlayer); + private void placeAlchemyArray( + ItemStack itemStack, + EntityPlayer entityPlayer, + World world, + int x, + int y, + int z, + int side + ) { + if (!world.isRemote) { + NBTTagCompound playerCustomData + = EntityHelper.getCustomEntityData(entityPlayer); ChalkSettings chalkSettings = new ChalkSettings(); chalkSettings.readFromNBT(playerCustomData); int coordOffset = chalkSettings.getSize() - 1; ForgeDirection orientation = ForgeDirection.getOrientation(side); - boolean canPlaceAlchemyArray = ModBlocks.alchemyArray.canPlaceBlockOnSide(world, x, y, z, side); + boolean canPlaceAlchemyArray + = ModBlocks.alchemyArray.canPlaceBlockOnSide(world, x, y, z, side); - placeBlockAt(entityPlayer, itemStack, world, x, y, z, ModBlocks.alchemyArray, side); + placeBlockAt( + entityPlayer, itemStack, world, x, y, z, ModBlocks.alchemyArray, side + ); - if (canPlaceAlchemyArray) - { - if (orientation == ForgeDirection.UP || orientation == ForgeDirection.DOWN) - { - for (int i = x - coordOffset; i <= x + coordOffset; i++) - { - for (int j = z - coordOffset; j <= z + coordOffset; j++) - { - if (i != x || j != z) - { - placeBlockAt(entityPlayer, itemStack, world, i, y, j, ModBlocks.dummyArray, side); - if (world.getTileEntity(i, y, j) instanceof TileEntityDummyArray) - { - ((TileEntityDummyArray) world.getTileEntity(i, y, j)).setTrueCoords(x, y, z); + if (canPlaceAlchemyArray) { + if (orientation == ForgeDirection.UP + || orientation == ForgeDirection.DOWN) { + for (int i = x - coordOffset; i <= x + coordOffset; i++) { + for (int j = z - coordOffset; j <= z + coordOffset; j++) { + if (i != x || j != z) { + placeBlockAt( + entityPlayer, + itemStack, + world, + i, + y, + j, + ModBlocks.dummyArray, + side + ); + if (world.getTileEntity(i, y, j) + instanceof TileEntityDummyArray) { + ((TileEntityDummyArray) world.getTileEntity(i, y, j)) + .setTrueCoords(x, y, z); } } } @@ -180,15 +209,22 @@ public class ItemChalk extends ItemEE implements IKeyBound } else if (orientation == ForgeDirection.NORTH || orientation == ForgeDirection.SOUTH) { - for (int i = x - coordOffset; i <= x + coordOffset; i++) - { - for (int j = y - coordOffset; j <= y + coordOffset; j++) - { - if (i != x || j != y) - { - placeBlockAt(entityPlayer, itemStack, world, i, j, z, ModBlocks.dummyArray, side); + for (int i = x - coordOffset; i <= x + coordOffset; i++) { + for (int j = y - coordOffset; j <= y + coordOffset; j++) { + if (i != x || j != y) { + placeBlockAt( + entityPlayer, + itemStack, + world, + i, + j, + z, + ModBlocks.dummyArray, + side + ); { - ((TileEntityDummyArray) world.getTileEntity(i, j, z)).setTrueCoords(x, y, z); + ((TileEntityDummyArray) world.getTileEntity(i, j, z)) + .setTrueCoords(x, y, z); } } } @@ -196,15 +232,22 @@ public class ItemChalk extends ItemEE implements IKeyBound } else if (orientation == ForgeDirection.EAST || orientation == ForgeDirection.WEST) { - for (int i = y - coordOffset; i <= y + coordOffset; i++) - { - for (int j = z - coordOffset; j <= z + coordOffset; j++) - { - if (i != y || j != z) - { - placeBlockAt(entityPlayer, itemStack, world, x, i, j, ModBlocks.dummyArray, side); + for (int i = y - coordOffset; i <= y + coordOffset; i++) { + for (int j = z - coordOffset; j <= z + coordOffset; j++) { + if (i != y || j != z) { + placeBlockAt( + entityPlayer, + itemStack, + world, + x, + i, + j, + ModBlocks.dummyArray, + side + ); { - ((TileEntityDummyArray) world.getTileEntity(x, i, j)).setTrueCoords(x, y, z); + ((TileEntityDummyArray) world.getTileEntity(x, i, j)) + .setTrueCoords(x, y, z); } } } @@ -215,30 +258,43 @@ public class ItemChalk extends ItemEE implements IKeyBound } /** - * Called to actually place the block, after the location is determined and all permission checks have been made. + * Called to actually place the block, after the location is determined and all + * permission checks have been made. * - * @param itemStack The item stack that was used to place the block. This can be changed inside the method. - * @param entityPlayer The entityPlayer who is placing the block. Can be null if the block is not being placed by a entityPlayer. + * @param itemStack The item stack that was used to place the block. This can be + * changed inside the method. + * @param entityPlayer The entityPlayer who is placing the block. Can be null if the + * block is not being placed by a entityPlayer. */ - private boolean placeBlockAt(EntityPlayer entityPlayer, ItemStack itemStack, World world, int x, int y, int z, Block block, int metadata) - { - if (!world.isRemote) - { - if (!world.setBlock(x, y, z, block, metadata, 3)) - { + private boolean placeBlockAt( + EntityPlayer entityPlayer, + ItemStack itemStack, + World world, + int x, + int y, + int z, + Block block, + int metadata + ) { + if (!world.isRemote) { + if (!world.setBlock(x, y, z, block, metadata, 3)) { return false; } - if (world.getBlock(x, y, z) == block) - { - NBTTagCompound playerCustomData = EntityHelper.getCustomEntityData(entityPlayer); + if (world.getBlock(x, y, z) == block) { + NBTTagCompound playerCustomData + = EntityHelper.getCustomEntityData(entityPlayer); ChalkSettings chalkSettings = new ChalkSettings(); chalkSettings.readFromNBT(playerCustomData); - AlchemyArray alchemyArray = AlchemyArrayRegistry.getInstance().getAlchemyArray(chalkSettings.getIndex()); + AlchemyArray alchemyArray + = AlchemyArrayRegistry.getInstance().getAlchemyArray( + chalkSettings.getIndex() + ); - if (alchemyArray != null) - { - itemStack.damageItem(alchemyArray.getChalkCostPerBlock(), entityPlayer); + if (alchemyArray != null) { + itemStack.damageItem( + alchemyArray.getChalkCostPerBlock(), entityPlayer + ); block.onBlockPlacedBy(world, x, y, z, entityPlayer, itemStack); block.onPostBlockPlaced(world, x, y, z, metadata); } @@ -249,51 +305,39 @@ public class ItemChalk extends ItemEE implements IKeyBound } @Override - public void doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key) - { - if (key != Key.UNKNOWN) - { - NBTTagCompound playerCustomData = EntityHelper.getCustomEntityData(entityPlayer); + public void + doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key) { + if (key != Key.UNKNOWN) { + NBTTagCompound playerCustomData + = EntityHelper.getCustomEntityData(entityPlayer); ChalkSettings chalkSettings = new ChalkSettings(); chalkSettings.readFromNBT(playerCustomData); - if (key == Key.CHARGE) - { - if (!entityPlayer.isSneaking()) - { + if (key == Key.CHARGE) { + if (!entityPlayer.isSneaking()) { chalkSettings.incrementSize(); - } - else - { + } else { chalkSettings.decrementSize(); } - } - else if (key == Key.TOGGLE) - { - if (!entityPlayer.isSneaking()) - { + } else if (key == Key.TOGGLE) { + if (!entityPlayer.isSneaking()) { chalkSettings.incrementIndex(); - } - else - { + } else { chalkSettings.decrementIndex(); } - } - else if (key == Key.RELEASE) - { - if (!entityPlayer.isSneaking()) - { + } else if (key == Key.RELEASE) { + if (!entityPlayer.isSneaking()) { chalkSettings.rotateClockwise(); - } - else - { + } else { chalkSettings.rotateCounterClockwise(); } } chalkSettings.writeToNBT(playerCustomData); EntityHelper.saveCustomEntityData(entityPlayer, playerCustomData); - PacketHandler.INSTANCE.sendTo(new MessageChalkSettings(chalkSettings), (EntityPlayerMP) entityPlayer); + PacketHandler.INSTANCE.sendTo( + new MessageChalkSettings(chalkSettings), (EntityPlayerMP) entityPlayer + ); } } } \ No newline at end of file diff --git a/src/main/java/com/pahimar/ee3/item/ItemEE.java b/src/main/java/com/pahimar/ee3/item/ItemEE.java index 097dcf44..fef9df84 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemEE.java +++ b/src/main/java/com/pahimar/ee3/item/ItemEE.java @@ -8,10 +8,8 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -public class ItemEE extends Item -{ - public ItemEE() - { +public class ItemEE extends Item { + public ItemEE() { super(); this.maxStackSize = 1; this.setCreativeTab(CreativeTab.EE3_TAB); @@ -19,26 +17,32 @@ public class ItemEE extends Item } @Override - public String getUnlocalizedName() - { - return String.format("item.%s%s", Textures.RESOURCE_PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + public String getUnlocalizedName() { + return String.format( + "item.%s%s", + Textures.RESOURCE_PREFIX, + getUnwrappedUnlocalizedName(super.getUnlocalizedName()) + ); } @Override - public String getUnlocalizedName(ItemStack itemStack) - { - return String.format("item.%s%s", Textures.RESOURCE_PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + public String getUnlocalizedName(ItemStack itemStack) { + return String.format( + "item.%s%s", + Textures.RESOURCE_PREFIX, + getUnwrappedUnlocalizedName(super.getUnlocalizedName()) + ); } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister iconRegister) - { - itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1)); + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().substring( + this.getUnlocalizedName().indexOf(".") + 1 + )); } - protected String getUnwrappedUnlocalizedName(String unlocalizedName) - { + protected String getUnwrappedUnlocalizedName(String unlocalizedName) { return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); } } diff --git a/src/main/java/com/pahimar/ee3/item/ItemInertStone.java b/src/main/java/com/pahimar/ee3/item/ItemInertStone.java index d46570d9..cf4a9926 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemInertStone.java +++ b/src/main/java/com/pahimar/ee3/item/ItemInertStone.java @@ -2,10 +2,8 @@ package com.pahimar.ee3.item; import com.pahimar.ee3.reference.Names; -public class ItemInertStone extends ItemEE -{ - public ItemInertStone() - { +public class ItemInertStone extends ItemEE { + public ItemInertStone() { super(); this.setUnlocalizedName(Names.Items.INERT_STONE); } diff --git a/src/main/java/com/pahimar/ee3/item/ItemMiniumShard.java b/src/main/java/com/pahimar/ee3/item/ItemMiniumShard.java index 0cf51371..119186be 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemMiniumShard.java +++ b/src/main/java/com/pahimar/ee3/item/ItemMiniumShard.java @@ -5,10 +5,8 @@ import com.pahimar.ee3.api.exchange.IEnergyValueProvider; import com.pahimar.ee3.reference.Names; import net.minecraft.item.ItemStack; -public class ItemMiniumShard extends ItemEE implements IEnergyValueProvider -{ - public ItemMiniumShard() - { +public class ItemMiniumShard extends ItemEE implements IEnergyValueProvider { + public ItemMiniumShard() { super(); this.setMaxStackSize(64); this.setUnlocalizedName(Names.Items.MINIUM_SHARD); @@ -16,11 +14,15 @@ public class ItemMiniumShard extends ItemEE implements IEnergyValueProvider @Override public EnergyValue getEnergyValue(ItemStack itemStack) { - if (itemStack != null && itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey(Names.NBT.ENERGY_VALUE)) - { - if (Float.compare(itemStack.getTagCompound().getFloat(Names.NBT.ENERGY_VALUE), 0) > 0) - { - return new EnergyValue(itemStack.getTagCompound().getFloat(Names.NBT.ENERGY_VALUE)); + if (itemStack != null && itemStack.hasTagCompound() + && itemStack.getTagCompound().hasKey(Names.NBT.ENERGY_VALUE)) { + if (Float.compare( + itemStack.getTagCompound().getFloat(Names.NBT.ENERGY_VALUE), 0 + ) + > 0) { + return new EnergyValue( + itemStack.getTagCompound().getFloat(Names.NBT.ENERGY_VALUE) + ); } } return null; diff --git a/src/main/java/com/pahimar/ee3/item/ItemMiniumStone.java b/src/main/java/com/pahimar/ee3/item/ItemMiniumStone.java index af80c23b..1c982767 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemMiniumStone.java +++ b/src/main/java/com/pahimar/ee3/item/ItemMiniumStone.java @@ -8,7 +8,6 @@ import com.pahimar.ee3.util.IKeyBound; import com.pahimar.ee3.util.IOverlayItem; import com.pahimar.ee3.util.NBTHelper; import com.pahimar.ee3.util.TransmutationHelper; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; @@ -16,30 +15,26 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public class ItemMiniumStone extends ItemEE implements IKeyBound, IOverlayItem, ITransmutationStone -{ - public ItemMiniumStone() - { +public class ItemMiniumStone + extends ItemEE implements IKeyBound, IOverlayItem, ITransmutationStone { + public ItemMiniumStone() { super(); this.setUnlocalizedName(Names.Items.MINIUM_STONE); this.setMaxDamage(1000); // TODO Get this from configs } @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack) - { + public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack) { return false; } @Override - public boolean getShareTag() - { + public boolean getShareTag() { return true; } @Override - public ItemStack getContainerItem(ItemStack itemStack) - { + public ItemStack getContainerItem(ItemStack itemStack) { ItemStack copiedStack = itemStack.copy(); copiedStack.setItemDamage(copiedStack.getItemDamage() + 1); @@ -51,18 +46,18 @@ public class ItemMiniumStone extends ItemEE implements IKeyBound, IOverlayItem, @Override public boolean hasContainerItem() { return true; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean hasEffect(ItemStack itemStack, int renderPass) - { - return NBTHelper.hasKey(itemStack, Names.NBT.CRAFTING_GUI_OPEN) || NBTHelper.hasKey(itemStack, Names.NBT.TRANSMUTATION_GUI_OPEN); } @Override - public void doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key) - { + @SideOnly(Side.CLIENT) + public boolean hasEffect(ItemStack itemStack, int renderPass) { + return NBTHelper.hasKey(itemStack, Names.NBT.CRAFTING_GUI_OPEN) + || NBTHelper.hasKey(itemStack, Names.NBT.TRANSMUTATION_GUI_OPEN); + } + + @Override + public void + doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key) { if (key == Key.EXTRA) { if (!entityPlayer.isSneaking()) { openPortableCraftingGUI(entityPlayer, itemStack); @@ -71,16 +66,33 @@ public class ItemMiniumStone extends ItemEE implements IKeyBound, IOverlayItem, } } else if (key == Key.TOGGLE && TransmutationHelper.targetBlockStack != null) { if (!entityPlayer.isSneaking()) { - TransmutationHelper.targetBlockStack = TransmutationHelper.getNextBlock(TransmutationHelper.targetBlockStack.getItem(), TransmutationHelper.targetBlockStack.getItemDamage()); - } - else { - TransmutationHelper.targetBlockStack = TransmutationHelper.getPreviousBlock(TransmutationHelper.targetBlockStack.getItem(), TransmutationHelper.targetBlockStack.getItemDamage()); + TransmutationHelper.targetBlockStack = TransmutationHelper.getNextBlock( + TransmutationHelper.targetBlockStack.getItem(), + TransmutationHelper.targetBlockStack.getItemDamage() + ); + } else { + TransmutationHelper.targetBlockStack + = TransmutationHelper.getPreviousBlock( + TransmutationHelper.targetBlockStack.getItem(), + TransmutationHelper.targetBlockStack.getItemDamage() + ); } } } @Override - public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int x, int y, int z, int sideHit, float hitVecX, float hitVecY, float hitVecZ) { + public boolean onItemUse( + ItemStack itemStack, + EntityPlayer entityPlayer, + World world, + int x, + int y, + int z, + int sideHit, + float hitVecX, + float hitVecY, + float hitVecZ + ) { if (world.isRemote) { this.transmuteBlock(itemStack, entityPlayer, world, x, y, z, sideHit); } @@ -88,20 +100,38 @@ public class ItemMiniumStone extends ItemEE implements IKeyBound, IOverlayItem, } @Override - public void transmuteBlock(final ItemStack itemStack, final EntityPlayer player, final World world, final int x, final int y, final int z, final int sideHit) { - EquivalentExchange3.proxy.transmuteBlock(itemStack, player, world, x, y, z, ForgeDirection.getOrientation(sideHit)); + public void transmuteBlock( + final ItemStack itemStack, + final EntityPlayer player, + final World world, + final int x, + final int y, + final int z, + final int sideHit + ) { + EquivalentExchange3.proxy.transmuteBlock( + itemStack, player, world, x, y, z, ForgeDirection.getOrientation(sideHit) + ); } @Override public void openPortableCraftingGUI(EntityPlayer thePlayer, ItemStack itemStack) { NBTHelper.setBoolean(itemStack, Names.NBT.CRAFTING_GUI_OPEN, true); - thePlayer.openGui((Object)EquivalentExchange3.instance, GUIs.PORTABLE_CRAFTING.ordinal(), thePlayer.worldObj, (int)thePlayer.posX, (int)thePlayer.posY, (int)thePlayer.posZ); + thePlayer.openGui( + (Object) EquivalentExchange3.instance, + GUIs.PORTABLE_CRAFTING.ordinal(), + thePlayer.worldObj, + (int) thePlayer.posX, + (int) thePlayer.posY, + (int) thePlayer.posZ + ); } @Override - public void openPortableTransmutationGUI(EntityPlayer thePlayer, ItemStack itemStack) { + public void + openPortableTransmutationGUI(EntityPlayer thePlayer, ItemStack itemStack) { NBTHelper.setBoolean(itemStack, Names.NBT.TRANSMUTATION_GUI_OPEN, true); - //thePlayer.openGui((Object)EquivalentExchange3.instance, 1, thePlayer.worldObj, (int)thePlayer.posX, (int)thePlayer.posY, (int)thePlayer.posZ); + //thePlayer.openGui((Object)EquivalentExchange3.instance, 1, thePlayer.worldObj, + //(int)thePlayer.posX, (int)thePlayer.posY, (int)thePlayer.posZ); } - } diff --git a/src/main/java/com/pahimar/ee3/item/ItemPhilosophersStone.java b/src/main/java/com/pahimar/ee3/item/ItemPhilosophersStone.java index 5872cdb5..21b1be5c 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemPhilosophersStone.java +++ b/src/main/java/com/pahimar/ee3/item/ItemPhilosophersStone.java @@ -9,12 +9,11 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public class ItemPhilosophersStone extends ItemEE implements IKeyBound, IOverlayItem, ITransmutationStone -{ +public class ItemPhilosophersStone + extends ItemEE implements IKeyBound, IOverlayItem, ITransmutationStone { private int maxChargeLevel; - public ItemPhilosophersStone() - { + public ItemPhilosophersStone() { super(); this.setUnlocalizedName(Names.Items.PHILOSOPHERS_STONE); this.setMaxDamage(1000); @@ -22,20 +21,17 @@ public class ItemPhilosophersStone extends ItemEE implements IKeyBound, IOverlay } @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack) - { + public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack) { return false; } @Override - public boolean getShareTag() - { + public boolean getShareTag() { return true; } @Override - public ItemStack getContainerItem(ItemStack itemStack) - { + public ItemStack getContainerItem(ItemStack itemStack) { ItemStack copiedStack = itemStack.copy(); copiedStack.setItemDamage(copiedStack.getItemDamage() + 1); @@ -45,23 +41,21 @@ public class ItemPhilosophersStone extends ItemEE implements IKeyBound, IOverlay } @Override - public void doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key) - { - LogHelper.info("{} {} {}", entityPlayer.toString(), itemStack.toString(), key.toString()); + public void + doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key) { + LogHelper.info( + "{} {} {}", entityPlayer.toString(), itemStack.toString(), key.toString() + ); } @Override - public void openPortableCraftingGUI(EntityPlayer p0, ItemStack p1) { - - } + public void openPortableCraftingGUI(EntityPlayer p0, ItemStack p1) {} @Override - public void openPortableTransmutationGUI(EntityPlayer p0, ItemStack p1) { - - } + public void openPortableTransmutationGUI(EntityPlayer p0, ItemStack p1) {} @Override - public void transmuteBlock(ItemStack p0, EntityPlayer p1, World p2, int p3, int p4, int p5, int p6) { - - } + public void transmuteBlock( + ItemStack p0, EntityPlayer p1, World p2, int p3, int p4, int p5, int p6 + ) {} } diff --git a/src/main/java/com/pahimar/ee3/item/ItemToolEE.java b/src/main/java/com/pahimar/ee3/item/ItemToolEE.java index 7b4a3db0..54e5e6da 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemToolEE.java +++ b/src/main/java/com/pahimar/ee3/item/ItemToolEE.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.item; +import java.util.Set; + import com.pahimar.ee3.creativetab.CreativeTab; import com.pahimar.ee3.reference.Textures; import com.pahimar.ee3.util.IChargeable; @@ -10,12 +12,10 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; -import java.util.Set; - -public class ItemToolEE extends ItemTool -{ - public ItemToolEE(float damageVsEntity, Item.ToolMaterial toolMaterial, Set blocksEffectiveAgainst) - { +public class ItemToolEE extends ItemTool { + public ItemToolEE( + float damageVsEntity, Item.ToolMaterial toolMaterial, Set blocksEffectiveAgainst + ) { super(damageVsEntity, toolMaterial, blocksEffectiveAgainst); this.setCreativeTab(CreativeTab.EE3_TAB); this.setNoRepair(); @@ -23,40 +23,43 @@ public class ItemToolEE extends ItemTool } @Override - public String getUnlocalizedName() - { - return String.format("item.%s%s", Textures.RESOURCE_PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + public String getUnlocalizedName() { + return String.format( + "item.%s%s", + Textures.RESOURCE_PREFIX, + getUnwrappedUnlocalizedName(super.getUnlocalizedName()) + ); } @Override - public String getUnlocalizedName(ItemStack itemStack) - { - return String.format("item.%s%s", Textures.RESOURCE_PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + public String getUnlocalizedName(ItemStack itemStack) { + return String.format( + "item.%s%s", + Textures.RESOURCE_PREFIX, + getUnwrappedUnlocalizedName(super.getUnlocalizedName()) + ); } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister iconRegister) - { - itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1)); + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().substring( + this.getUnlocalizedName().indexOf(".") + 1 + )); } - protected String getUnwrappedUnlocalizedName(String unlocalizedName) - { + protected String getUnwrappedUnlocalizedName(String unlocalizedName) { return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); } @Override - public boolean getShareTag() - { + public boolean getShareTag() { return true; } @Override - public boolean showDurabilityBar(ItemStack itemStack) - { - if (itemStack.getItem() instanceof IChargeable) - { + public boolean showDurabilityBar(ItemStack itemStack) { + if (itemStack.getItem() instanceof IChargeable) { return ((IChargeable) itemStack.getItem()).getChargeLevel(itemStack) > 0; } @@ -64,11 +67,12 @@ public class ItemToolEE extends ItemTool } @Override - public double getDurabilityForDisplay(ItemStack itemStack) - { - if (itemStack.getItem() instanceof IChargeable) - { - return (double) (((IChargeable) itemStack.getItem()).getMaxChargeLevel() - ((IChargeable) itemStack.getItem()).getChargeLevel(itemStack)) / (double) ((IChargeable) itemStack.getItem()).getMaxChargeLevel(); + public double getDurabilityForDisplay(ItemStack itemStack) { + if (itemStack.getItem() instanceof IChargeable) { + return (double + ) (((IChargeable) itemStack.getItem()).getMaxChargeLevel() + - ((IChargeable) itemStack.getItem()).getChargeLevel(itemStack)) + / (double) ((IChargeable) itemStack.getItem()).getMaxChargeLevel(); } return 1d; diff --git a/src/main/java/com/pahimar/ee3/item/ItemToolModalEE.java b/src/main/java/com/pahimar/ee3/item/ItemToolModalEE.java index 0e6bf048..578c31a9 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemToolModalEE.java +++ b/src/main/java/com/pahimar/ee3/item/ItemToolModalEE.java @@ -1,33 +1,31 @@ package com.pahimar.ee3.item; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.reference.ToolMode; import com.pahimar.ee3.util.IModalTool; import com.pahimar.ee3.util.NBTHelper; import net.minecraft.item.ItemStack; -import java.util.Arrays; -import java.util.List; -import java.util.Set; - -public class ItemToolModalEE extends ItemToolEE implements IModalTool -{ - public ItemToolModalEE(float damageVsEntity, ToolMaterial toolMaterial, Set blocksEffectiveAgainst) - { +public class ItemToolModalEE extends ItemToolEE implements IModalTool { + public ItemToolModalEE( + float damageVsEntity, ToolMaterial toolMaterial, Set blocksEffectiveAgainst + ) { super(damageVsEntity, toolMaterial, blocksEffectiveAgainst); } @Override - public List getAvailableToolModes() - { + public List getAvailableToolModes() { return Arrays.asList(ToolMode.UNKNOWN); } @Override - public ToolMode getCurrentToolMode(ItemStack itemStack) - { - if (NBTHelper.getShort(itemStack, Names.NBT.MODE) != null && NBTHelper.getShort(itemStack, Names.NBT.MODE) < ToolMode.TYPES.length) - { + public ToolMode getCurrentToolMode(ItemStack itemStack) { + if (NBTHelper.getShort(itemStack, Names.NBT.MODE) != null + && NBTHelper.getShort(itemStack, Names.NBT.MODE) < ToolMode.TYPES.length) { return ToolMode.TYPES[NBTHelper.getShort(itemStack, Names.NBT.MODE)]; } @@ -35,36 +33,31 @@ public class ItemToolModalEE extends ItemToolEE implements IModalTool } @Override - public void setToolMode(ItemStack itemStack, ToolMode toolMode) - { + public void setToolMode(ItemStack itemStack, ToolMode toolMode) { NBTHelper.setShort(itemStack, Names.NBT.MODE, (short) toolMode.ordinal()); } @Override - public void changeToolMode(ItemStack itemStack) - { + public void changeToolMode(ItemStack itemStack) { ToolMode currentToolMode = getCurrentToolMode(itemStack); - if (getAvailableToolModes().size() > 0) - { - if (getAvailableToolModes().contains(currentToolMode)) - { - if (getAvailableToolModes().indexOf(currentToolMode) == getAvailableToolModes().size() - 1) - { + if (getAvailableToolModes().size() > 0) { + if (getAvailableToolModes().contains(currentToolMode)) { + if (getAvailableToolModes().indexOf(currentToolMode) + == getAvailableToolModes().size() - 1) { setToolMode(itemStack, getAvailableToolModes().get(0)); + } else { + setToolMode( + itemStack, + getAvailableToolModes().get( + getAvailableToolModes().indexOf(currentToolMode) + 1 + ) + ); } - else - { - setToolMode(itemStack, getAvailableToolModes().get(getAvailableToolModes().indexOf(currentToolMode) + 1)); - } - } - else - { + } else { setToolMode(itemStack, getAvailableToolModes().get(0)); } - } - else - { + } else { setToolMode(itemStack, ToolMode.UNKNOWN); } } diff --git a/src/main/java/com/pahimar/ee3/item/crafting/RecipeAludel.java b/src/main/java/com/pahimar/ee3/item/crafting/RecipeAludel.java index 463bc795..a40a265e 100644 --- a/src/main/java/com/pahimar/ee3/item/crafting/RecipeAludel.java +++ b/src/main/java/com/pahimar/ee3/item/crafting/RecipeAludel.java @@ -1,42 +1,40 @@ package com.pahimar.ee3.item.crafting; +import java.util.ArrayList; +import java.util.List; import com.pahimar.ee3.exchange.WrappedStack; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; -import java.util.ArrayList; -import java.util.List; - -public class RecipeAludel -{ +public class RecipeAludel { private ItemStack recipeOutput; private WrappedStack inputStack; private ItemStack dustStack; - public RecipeAludel(ItemStack recipeOutput, ItemStack inputStack, ItemStack dustStack) - { + public RecipeAludel( + ItemStack recipeOutput, ItemStack inputStack, ItemStack dustStack + ) { this.recipeOutput = recipeOutput.copy(); this.inputStack = WrappedStack.wrap(inputStack); this.dustStack = dustStack.copy(); } - public boolean matches(ItemStack inputStack, ItemStack dustStack) - { + public boolean matches(ItemStack inputStack, ItemStack dustStack) { return matches(WrappedStack.wrap(inputStack), dustStack); } - public boolean matches(WrappedStack inputStack, ItemStack dustStack) - { - return compareStacks(this.inputStack, inputStack) && compareItemStacks(this.dustStack, dustStack); + public boolean matches(WrappedStack inputStack, ItemStack dustStack) { + return compareStacks(this.inputStack, inputStack) + && compareItemStacks(this.dustStack, dustStack); } - private static boolean compareStacks(WrappedStack wrappedStack1, WrappedStack wrappedStack2) - { - if (wrappedStack1 != null && wrappedStack1.getWrappedObject() != null && wrappedStack2 != null && wrappedStack2.getWrappedObject() != null) - { - if (wrappedStack1.getWrappedObject() instanceof ItemStack && wrappedStack2.getWrappedObject() instanceof ItemStack) - { + private static boolean + compareStacks(WrappedStack wrappedStack1, WrappedStack wrappedStack2) { + if (wrappedStack1 != null && wrappedStack1.getWrappedObject() != null + && wrappedStack2 != null && wrappedStack2.getWrappedObject() != null) { + if (wrappedStack1.getWrappedObject() instanceof ItemStack + && wrappedStack2.getWrappedObject() instanceof ItemStack) { ItemStack itemStack1 = (ItemStack) wrappedStack1.getWrappedObject(); itemStack1.stackSize = wrappedStack1.getStackSize(); ItemStack itemStack2 = (ItemStack) wrappedStack2.getWrappedObject(); @@ -49,23 +47,19 @@ public class RecipeAludel return false; } - private static boolean compareItemStacks(ItemStack itemStack1, ItemStack itemStack2) - { - if (itemStack1 != null && itemStack2 != null) - { - if (itemStack1.getItem().getIdFromItem(itemStack1.getItem()) == itemStack2.getItem().getIdFromItem(itemStack2.getItem())) - { - if (itemStack1.getItemDamage() == itemStack2.getItemDamage() || itemStack1.getItemDamage() == OreDictionary.WILDCARD_VALUE || itemStack2.getItemDamage() == OreDictionary.WILDCARD_VALUE) - { - if (itemStack1.hasTagCompound() && itemStack2.hasTagCompound()) - { - if (itemStack1.getTagCompound().hashCode() == itemStack2.getTagCompound().hashCode()) - { + private static boolean compareItemStacks(ItemStack itemStack1, ItemStack itemStack2) { + if (itemStack1 != null && itemStack2 != null) { + if (itemStack1.getItem().getIdFromItem(itemStack1.getItem()) + == itemStack2.getItem().getIdFromItem(itemStack2.getItem())) { + if (itemStack1.getItemDamage() == itemStack2.getItemDamage() + || itemStack1.getItemDamage() == OreDictionary.WILDCARD_VALUE + || itemStack2.getItemDamage() == OreDictionary.WILDCARD_VALUE) { + if (itemStack1.hasTagCompound() && itemStack2.hasTagCompound()) { + if (itemStack1.getTagCompound().hashCode() + == itemStack2.getTagCompound().hashCode()) { return itemStack2.stackSize >= itemStack1.stackSize; } - } - else if (!itemStack1.hasTagCompound() && !itemStack2.hasTagCompound()) - { + } else if (!itemStack1.hasTagCompound() && !itemStack2.hasTagCompound()) { return itemStack2.stackSize >= itemStack1.stackSize; } } @@ -75,18 +69,15 @@ public class RecipeAludel return false; } - public ItemStack getRecipeOutput() - { + public ItemStack getRecipeOutput() { return this.recipeOutput; } - public WrappedStack[] getRecipeInputs() - { - return new WrappedStack[]{inputStack, WrappedStack.wrap(dustStack)}; + public WrappedStack[] getRecipeInputs() { + return new WrappedStack[] { inputStack, WrappedStack.wrap(dustStack) }; } - public List getRecipeInputsAsWrappedStacks() - { + public List getRecipeInputsAsWrappedStacks() { List recipeInputs = new ArrayList(); recipeInputs.add(WrappedStack.wrap(inputStack)); recipeInputs.add(WrappedStack.wrap(dustStack)); @@ -94,24 +85,23 @@ public class RecipeAludel } @Override - public boolean equals(Object object) - { - if (object instanceof RecipeAludel) - { + public boolean equals(Object object) { + if (object instanceof RecipeAludel) { return matches((RecipeAludel) object); } return false; } - public boolean matches(RecipeAludel recipeAludel) - { - return compareItemStacks(this.recipeOutput, recipeAludel.recipeOutput) && matches(recipeAludel.inputStack, recipeAludel.dustStack); + public boolean matches(RecipeAludel recipeAludel) { + return compareItemStacks(this.recipeOutput, recipeAludel.recipeOutput) + && matches(recipeAludel.inputStack, recipeAludel.dustStack); } @Override - public String toString() - { - return String.format("Output: %s, Input: %s, Dust: %s", recipeOutput, inputStack, dustStack); + public String toString() { + return String.format( + "Output: %s, Input: %s, Dust: %s", recipeOutput, inputStack, dustStack + ); } } diff --git a/src/main/java/com/pahimar/ee3/item/crafting/RecipesAlchemicalBagDyes.java b/src/main/java/com/pahimar/ee3/item/crafting/RecipesAlchemicalBagDyes.java index 65f5acb0..74174f52 100644 --- a/src/main/java/com/pahimar/ee3/item/crafting/RecipesAlchemicalBagDyes.java +++ b/src/main/java/com/pahimar/ee3/item/crafting/RecipesAlchemicalBagDyes.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.item.crafting; +import java.util.ArrayList; + import com.pahimar.ee3.item.ItemAlchemicalBag; import net.minecraft.block.BlockColored; import net.minecraft.entity.passive.EntitySheep; @@ -9,35 +11,24 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.world.World; -import java.util.ArrayList; - -public class RecipesAlchemicalBagDyes implements IRecipe -{ +public class RecipesAlchemicalBagDyes implements IRecipe { @Override - public boolean matches(InventoryCrafting inventoryCrafting, World world) - { + public boolean matches(InventoryCrafting inventoryCrafting, World world) { ItemStack itemStack = null; ArrayList arrayList = new ArrayList(); - for (int i = 0; i < inventoryCrafting.getSizeInventory(); ++i) - { + for (int i = 0; i < inventoryCrafting.getSizeInventory(); ++i) { ItemStack currentStack = inventoryCrafting.getStackInSlot(i); - if (currentStack != null) - { - if (currentStack.getItem() instanceof ItemAlchemicalBag) - { - if (itemStack != null) - { + if (currentStack != null) { + if (currentStack.getItem() instanceof ItemAlchemicalBag) { + if (itemStack != null) { return false; } itemStack = currentStack; - } - else - { - if (currentStack.getItem() != Items.dye) - { + } else { + if (currentStack.getItem() != Items.dye) { return false; } @@ -50,8 +41,7 @@ public class RecipesAlchemicalBagDyes implements IRecipe } @Override - public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) - { + public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) { ItemStack itemStack = null; ItemAlchemicalBag itemAlchemicalBag = null; int[] colorChannels = new int[3]; @@ -61,26 +51,21 @@ public class RecipesAlchemicalBagDyes implements IRecipe int currentColor, newColor; float red, green, blue; - for (k = 0; k < inventoryCrafting.getSizeInventory(); ++k) - { + for (k = 0; k < inventoryCrafting.getSizeInventory(); ++k) { ItemStack currentStack = inventoryCrafting.getStackInSlot(k); - if (currentStack != null) - { - if (currentStack.getItem() instanceof ItemAlchemicalBag) - { + if (currentStack != null) { + if (currentStack.getItem() instanceof ItemAlchemicalBag) { itemAlchemicalBag = (ItemAlchemicalBag) currentStack.getItem(); - if (itemStack != null) - { + if (itemStack != null) { return null; } itemStack = currentStack.copy(); itemStack.stackSize = 1; - if (itemAlchemicalBag.hasColor(currentStack)) - { + if (itemAlchemicalBag.hasColor(currentStack)) { currentColor = itemAlchemicalBag.getColor(itemStack); red = (currentColor >> 16 & 255) / 255.0F; green = (currentColor >> 8 & 255) / 255.0F; @@ -91,15 +76,15 @@ public class RecipesAlchemicalBagDyes implements IRecipe colorChannels[2] = (int) (colorChannels[2] + blue * 255.0F); ++j; } - } - else - { - if (currentStack.getItem() != Items.dye) - { + } else { + if (currentStack.getItem() != Items.dye) { return null; } - float[] dyeColorChannels = EntitySheep.fleeceColorTable[BlockColored.func_150032_b(currentStack.getItemDamage())]; + float[] dyeColorChannels + = EntitySheep.fleeceColorTable[BlockColored.func_150032_b( + currentStack.getItemDamage() + )]; j1 = (int) (dyeColorChannels[0] * 255.0F); k1 = (int) (dyeColorChannels[1] * 255.0F); newColor = (int) (dyeColorChannels[2] * 255.0F); @@ -112,12 +97,9 @@ public class RecipesAlchemicalBagDyes implements IRecipe } } - if (itemAlchemicalBag == null) - { + if (itemAlchemicalBag == null) { return null; - } - else - { + } else { k = colorChannels[0] / j; l1 = colorChannels[1] / j; currentColor = colorChannels[2] / j; @@ -134,14 +116,12 @@ public class RecipesAlchemicalBagDyes implements IRecipe } @Override - public int getRecipeSize() - { + public int getRecipeSize() { return 10; } @Override - public ItemStack getRecipeOutput() - { + public ItemStack getRecipeOutput() { return null; } } diff --git a/src/main/java/com/pahimar/ee3/knowledge/PlayerKnowledge.java b/src/main/java/com/pahimar/ee3/knowledge/PlayerKnowledge.java index d3fb8fa1..9c5886c4 100644 --- a/src/main/java/com/pahimar/ee3/knowledge/PlayerKnowledge.java +++ b/src/main/java/com/pahimar/ee3/knowledge/PlayerKnowledge.java @@ -1,16 +1,15 @@ package com.pahimar.ee3.knowledge; -import com.pahimar.ee3.reference.Comparators; -import com.pahimar.ee3.util.ItemStackUtils; -import net.minecraft.item.ItemStack; - import java.util.Collection; import java.util.Collections; import java.util.Set; import java.util.TreeSet; -public class PlayerKnowledge { +import com.pahimar.ee3.reference.Comparators; +import com.pahimar.ee3.util.ItemStackUtils; +import net.minecraft.item.ItemStack; +public class PlayerKnowledge { private Set knownItemStacks; public PlayerKnowledge() { @@ -22,7 +21,6 @@ public class PlayerKnowledge { } public PlayerKnowledge(Collection objects) { - knownItemStacks = new TreeSet<>(Comparators.ID_COMPARATOR); if (objects != null) { @@ -33,7 +31,6 @@ public class PlayerKnowledge { } public boolean isKnown(Object object) { - if (object instanceof ItemStack) { return knownItemStacks.contains(ItemStackUtils.clone((ItemStack) object, 1)); } @@ -46,7 +43,6 @@ public class PlayerKnowledge { } public void learn(Object object) { - if (object instanceof ItemStack) { ItemStack unitItemStack = ItemStackUtils.clone((ItemStack) object, 1); knownItemStacks.add(unitItemStack); @@ -54,7 +50,6 @@ public class PlayerKnowledge { } public void learn(Collection objects) { - if (objects != null) { for (Object object : objects) { learn(object); @@ -63,7 +58,6 @@ public class PlayerKnowledge { } public void forget(Object object) { - if (object instanceof ItemStack) { ItemStack unitItemStack = ItemStackUtils.clone((ItemStack) object, 1); knownItemStacks.remove(unitItemStack); @@ -71,7 +65,6 @@ public class PlayerKnowledge { } public void forget(Collection objects) { - if (objects != null) { for (Object object : objects) { forget(object); @@ -85,12 +78,12 @@ public class PlayerKnowledge { @Override public String toString() { - StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("["); for (ItemStack itemStack : knownItemStacks) { - stringBuilder.append(String.format("%s, ", ItemStackUtils.toString(itemStack))); + stringBuilder.append(String.format("%s, ", ItemStackUtils.toString(itemStack)) + ); } stringBuilder.append("]"); diff --git a/src/main/java/com/pahimar/ee3/knowledge/PlayerKnowledgeRegistry.java b/src/main/java/com/pahimar/ee3/knowledge/PlayerKnowledgeRegistry.java index 414d4704..5d37f068 100644 --- a/src/main/java/com/pahimar/ee3/knowledge/PlayerKnowledgeRegistry.java +++ b/src/main/java/com/pahimar/ee3/knowledge/PlayerKnowledgeRegistry.java @@ -1,5 +1,12 @@ package com.pahimar.ee3.knowledge; +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Collection; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; + import com.google.gson.JsonSyntaxException; import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.handler.ConfigurationHandler; @@ -14,15 +21,7 @@ import net.minecraft.item.ItemStack; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; -import java.io.File; -import java.io.FileNotFoundException; -import java.util.Collection; -import java.util.Set; -import java.util.TreeMap; -import java.util.TreeSet; - public class PlayerKnowledgeRegistry { - public static final PlayerKnowledgeRegistry INSTANCE = new PlayerKnowledgeRegistry(); private final TreeMap playerKnowledgeMap; @@ -30,13 +29,18 @@ public class PlayerKnowledgeRegistry { public static File templatePlayerKnowledgeFile; - public static final Marker PLAYER_KNOWLEDGE_MARKER = MarkerManager.getMarker("EE3_PLAYER_KNOWLEDGE", LogHelper.MOD_MARKER); - public static final Marker PLAYER_LEARN_KNOWLEDGE = MarkerManager.getMarker("EE3_PLAYER_TEACH_KNOWLEDGE", PLAYER_KNOWLEDGE_MARKER); - public static final Marker PLAYER_FORGET_KNOWLEDGE_MARKER = MarkerManager.getMarker("EE3_PLAYER_FORGET_KNOWLEDGE", PLAYER_KNOWLEDGE_MARKER); - public static final Marker PLAYER_FORGET_ALL_KNOWLEDGE_MARKER = MarkerManager.getMarker("EE3_PLAYER_FORGET_ALL_KNOWLEDGE", PLAYER_FORGET_KNOWLEDGE_MARKER); + public static final Marker PLAYER_KNOWLEDGE_MARKER + = MarkerManager.getMarker("EE3_PLAYER_KNOWLEDGE", LogHelper.MOD_MARKER); + public static final Marker PLAYER_LEARN_KNOWLEDGE + = MarkerManager.getMarker("EE3_PLAYER_TEACH_KNOWLEDGE", PLAYER_KNOWLEDGE_MARKER); + public static final Marker PLAYER_FORGET_KNOWLEDGE_MARKER + = MarkerManager.getMarker("EE3_PLAYER_FORGET_KNOWLEDGE", PLAYER_KNOWLEDGE_MARKER); + public static final Marker PLAYER_FORGET_ALL_KNOWLEDGE_MARKER + = MarkerManager.getMarker( + "EE3_PLAYER_FORGET_ALL_KNOWLEDGE", PLAYER_FORGET_KNOWLEDGE_MARKER + ); private PlayerKnowledgeRegistry() { - playerKnowledgeMap = new TreeMap<>(Comparators.STRING_COMPARATOR); templatePlayerKnowledge = new PlayerKnowledge(); } @@ -60,7 +64,6 @@ public class PlayerKnowledgeRegistry { * @return */ public boolean doesPlayerKnow(String playerName, Object object) { - if (getPlayerKnowledge(playerName) != null) { return getPlayerKnowledge(playerName).isKnown(object); } @@ -76,7 +79,6 @@ public class PlayerKnowledgeRegistry { * @return */ public boolean canPlayerLearn(EntityPlayer entityPlayer, Object object) { - if (entityPlayer != null) { return canPlayerLearn(entityPlayer.getDisplayName(), object); } @@ -92,9 +94,9 @@ public class PlayerKnowledgeRegistry { * @return */ public boolean canPlayerLearn(String playerName, Object object) { - if (getPlayerKnowledge(playerName) != null) { - return !getPlayerKnowledge(playerName).isKnown(object) && BlacklistRegistryProxy.isLearnable(object); + return !getPlayerKnowledge(playerName).isKnown(object) + && BlacklistRegistryProxy.isLearnable(object); } return false; @@ -107,7 +109,6 @@ public class PlayerKnowledgeRegistry { * @param object */ public void teachPlayer(EntityPlayer entityPlayer, Object object) { - if (entityPlayer != null) { teachPlayer(entityPlayer.getDisplayName(), object); } @@ -120,10 +121,11 @@ public class PlayerKnowledgeRegistry { * @param object */ public void teachPlayer(String playerName, Object object) { - if (getPlayerKnowledge(playerName) != null) { getPlayerKnowledge(playerName).learn(object); - LogHelper.trace(PLAYER_LEARN_KNOWLEDGE, "Player {} learned {}", playerName, object); + LogHelper.trace( + PLAYER_LEARN_KNOWLEDGE, "Player {} learned {}", playerName, object + ); save(playerName); } } @@ -135,7 +137,6 @@ public class PlayerKnowledgeRegistry { * @param objects */ public void teachPlayer(EntityPlayer entityPlayer, Collection objects) { - if (entityPlayer != null) { teachPlayer(entityPlayer.getDisplayName(), objects); } @@ -148,15 +149,15 @@ public class PlayerKnowledgeRegistry { * @param objects */ public void teachPlayer(String playerName, Collection objects) { - if (objects != null) { - PlayerKnowledge playerKnowledge = getPlayerKnowledge(playerName); if (playerKnowledge != null) { - for (Object object : objects){ + for (Object object : objects) { getPlayerKnowledge(playerName).learn(object); - LogHelper.trace(PLAYER_LEARN_KNOWLEDGE, "Player {} learned {}", playerName, object); + LogHelper.trace( + PLAYER_LEARN_KNOWLEDGE, "Player {} learned {}", playerName, object + ); } save(playerName); } @@ -170,7 +171,6 @@ public class PlayerKnowledgeRegistry { * @param object */ public void makePlayerForget(EntityPlayer entityPlayer, Object object) { - if (entityPlayer != null) { makePlayerForget(entityPlayer.getDisplayName(), object); } @@ -183,10 +183,11 @@ public class PlayerKnowledgeRegistry { * @param object */ public void makePlayerForget(String playerName, Object object) { - if (getPlayerKnowledge(playerName) != null) { getPlayerKnowledge(playerName).forget(object); - LogHelper.trace(PLAYER_FORGET_KNOWLEDGE_MARKER, "Player {} forgot {}", playerName, object); + LogHelper.trace( + PLAYER_FORGET_KNOWLEDGE_MARKER, "Player {} forgot {}", playerName, object + ); save(playerName); } } @@ -198,7 +199,6 @@ public class PlayerKnowledgeRegistry { * @param objects */ public void makePlayerForget(EntityPlayer entityPlayer, Collection objects) { - if (entityPlayer != null) { makePlayerForget(entityPlayer.getDisplayName(), objects); } @@ -211,15 +211,18 @@ public class PlayerKnowledgeRegistry { * @param objects */ public void makePlayerForget(String playerName, Collection objects) { - if (objects != null) { - PlayerKnowledge playerKnowledge = getPlayerKnowledge(playerName); if (playerKnowledge != null) { for (Object object : objects) { getPlayerKnowledge(playerName).forget(object); - LogHelper.trace(PLAYER_FORGET_KNOWLEDGE_MARKER, "Player {} forgot {}", playerName, object); + LogHelper.trace( + PLAYER_FORGET_KNOWLEDGE_MARKER, + "Player {} forgot {}", + playerName, + object + ); } save(playerName); } @@ -232,7 +235,6 @@ public class PlayerKnowledgeRegistry { * @param entityPlayer */ public void makePlayerForgetAll(EntityPlayer entityPlayer) { - if (entityPlayer != null) { makePlayerForgetAll(entityPlayer.getDisplayName()); } @@ -244,11 +246,14 @@ public class PlayerKnowledgeRegistry { * @param playerName */ public void makePlayerForgetAll(String playerName) { - if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { if (playerName != null && !playerName.isEmpty()) { playerKnowledgeMap.put(playerName, new PlayerKnowledge()); - LogHelper.trace(PLAYER_FORGET_ALL_KNOWLEDGE_MARKER, "Player {} forget everything", playerName); + LogHelper.trace( + PLAYER_FORGET_ALL_KNOWLEDGE_MARKER, + "Player {} forget everything", + playerName + ); save(playerName); } } @@ -261,7 +266,6 @@ public class PlayerKnowledgeRegistry { * @return */ public Set getKnownItemStacks(EntityPlayer entityPlayer) { - if (entityPlayer != null) { return getKnownItemStacks(entityPlayer.getDisplayName()); } @@ -276,7 +280,6 @@ public class PlayerKnowledgeRegistry { * @return */ public Set getKnownItemStacks(String playerName) { - if (getPlayerKnowledge(playerName) != null) { return getPlayerKnowledge(playerName).getKnownItemStacks(); } @@ -291,7 +294,6 @@ public class PlayerKnowledgeRegistry { * @return */ protected PlayerKnowledge getPlayerKnowledge(EntityPlayer entityPlayer) { - if (entityPlayer != null) { return getPlayerKnowledge(entityPlayer.getDisplayName()); } @@ -306,10 +308,12 @@ public class PlayerKnowledgeRegistry { * @return */ private PlayerKnowledge getPlayerKnowledge(String playerName) { - - if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && playerName != null && !playerName.isEmpty()) { + if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER + && playerName != null && !playerName.isEmpty()) { if (!playerKnowledgeMap.containsKey(playerName)) { - playerKnowledgeMap.put(playerName, load(getPlayerKnowledgeFile(playerName), false)); + playerKnowledgeMap.put( + playerName, load(getPlayerKnowledgeFile(playerName), false) + ); } return playerKnowledgeMap.get(playerName); @@ -322,11 +326,12 @@ public class PlayerKnowledgeRegistry { * TODO Finish JavaDoc */ public void saveAll() { - if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { - // Save the template to file - SerializationHelper.writeJsonFile(templatePlayerKnowledgeFile, SerializationHelper.GSON.toJson(templatePlayerKnowledge)); + SerializationHelper.writeJsonFile( + templatePlayerKnowledgeFile, + SerializationHelper.GSON.toJson(templatePlayerKnowledge) + ); // Save every currently loaded player knowledge to file for (String playerName : playerKnowledgeMap.keySet()) { @@ -341,12 +346,15 @@ public class PlayerKnowledgeRegistry { * @param playerName */ private void save(String playerName) { - if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { if (playerName != null && !playerName.isEmpty()) { File playerKnowledgeFile = getPlayerKnowledgeFile(playerName); if (playerKnowledgeFile != null) { - SerializationHelper.writeJsonFile(playerKnowledgeFile, SerializationHelper.GSON.toJson(playerKnowledgeMap.get(playerName))); + SerializationHelper.writeJsonFile( + playerKnowledgeFile, + SerializationHelper.GSON.toJson(playerKnowledgeMap.get(playerName) + ) + ); } } } @@ -356,12 +364,12 @@ public class PlayerKnowledgeRegistry { * TODO Finish JavaDoc */ public void load() { - // Load template knowledge if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) { - templatePlayerKnowledge.forgetAll(); - templatePlayerKnowledge.learn(load(templatePlayerKnowledgeFile, true).getKnownItemStacks()); + templatePlayerKnowledge.learn( + load(templatePlayerKnowledgeFile, true).getKnownItemStacks() + ); // Reset the player knowledge map playerKnowledgeMap.clear(); @@ -375,30 +383,38 @@ public class PlayerKnowledgeRegistry { * @return */ private PlayerKnowledge load(File file, boolean isTemplate) { - - if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && file != null) { + if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER + && file != null) { try { String jsonString = SerializationHelper.readJsonFile(file); - PlayerKnowledge playerKnowledge = SerializationHelper.GSON.fromJson(jsonString, PlayerKnowledge.class); + PlayerKnowledge playerKnowledge + = SerializationHelper.GSON + .fromJson(jsonString, PlayerKnowledge.class); if (playerKnowledge != null) { return playerKnowledge; } - } - catch (JsonSyntaxException e) { - LogHelper.error("Unable to read player knowledge from file '{}'", file.getAbsoluteFile()); - } - catch (FileNotFoundException e) { + } catch (JsonSyntaxException e) { + LogHelper.error( + "Unable to read player knowledge from file '{}'", + file.getAbsoluteFile() + ); + } catch (FileNotFoundException e) { LogHelper.warn("Unable to find file '{}'", file.getAbsoluteFile()); } } if (ConfigurationHandler.Settings.playerKnowledgeTemplateEnabled && !isTemplate) { - LogHelper.info("Unable to read player knowledge from {}, initializing a new one with template data", file.getName()); + LogHelper.info( + "Unable to read player knowledge from {}, initializing a new one with template data", + file.getName() + ); return new PlayerKnowledge(templatePlayerKnowledge); - } - else { - LogHelper.info("Unable to read player knowledge from {}, initializing a new empty one", file.getName()); + } else { + LogHelper.info( + "Unable to read player knowledge from {}, initializing a new empty one", + file.getName() + ); return new PlayerKnowledge(); } } @@ -410,9 +426,12 @@ public class PlayerKnowledgeRegistry { * @return */ private static File getPlayerKnowledgeFile(String playerName) { - if (playerName != null && !playerName.isEmpty()) { - return new File(Files.playerDataDirectory, "knowledge" + File.separator + "transmutation" + File.separator + playerName + ".json"); + return new File( + Files.playerDataDirectory, + "knowledge" + File.separator + "transmutation" + File.separator + + playerName + ".json" + ); } return null; diff --git a/src/main/java/com/pahimar/ee3/nei/AludelRecipeHandler.java b/src/main/java/com/pahimar/ee3/nei/AludelRecipeHandler.java index a5a5395c..186c07df 100644 --- a/src/main/java/com/pahimar/ee3/nei/AludelRecipeHandler.java +++ b/src/main/java/com/pahimar/ee3/nei/AludelRecipeHandler.java @@ -1,5 +1,12 @@ package com.pahimar.ee3.nei; +import static codechicken.lib.gui.GuiDraw.changeTexture; +import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect; + +import java.awt.*; +import java.util.Arrays; +import java.util.List; + import codechicken.nei.NEIServerUtils; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.FurnaceRecipeHandler; @@ -16,131 +23,129 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import org.lwjgl.opengl.GL11; -import java.awt.*; -import java.util.Arrays; -import java.util.List; - -import static codechicken.lib.gui.GuiDraw.changeTexture; -import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect; - -public class AludelRecipeHandler extends TemplateRecipeHandler -{ - public class CachedAludelRecipe extends CachedRecipe - { +public class AludelRecipeHandler extends TemplateRecipeHandler { + public class CachedAludelRecipe extends CachedRecipe { public List inputs; public PositionedStack output; - public CachedAludelRecipe(RecipeAludel recipe) - { + public CachedAludelRecipe(RecipeAludel recipe) { WrappedStack[] wrappedInputs = recipe.getRecipeInputs(); - inputs = Arrays.asList(new PositionedStack(new ItemStack(((ItemStack) wrappedInputs[0].getWrappedObject()).getItem(), wrappedInputs[0].getStackSize(), ((ItemStack) wrappedInputs[0].getWrappedObject()).getItemDamage()), 37, 7), new PositionedStack(new ItemStack(((ItemStack) wrappedInputs[1].getWrappedObject()).getItem(), wrappedInputs[1].getStackSize(), ((ItemStack) wrappedInputs[1].getWrappedObject()).getItemDamage()), 37, 28)); + inputs = Arrays.asList( + new PositionedStack( + new ItemStack( + ((ItemStack) wrappedInputs[0].getWrappedObject()).getItem(), + wrappedInputs[0].getStackSize(), + ((ItemStack) wrappedInputs[0].getWrappedObject()).getItemDamage() + ), + 37, + 7 + ), + new PositionedStack( + new ItemStack( + ((ItemStack) wrappedInputs[1].getWrappedObject()).getItem(), + wrappedInputs[1].getStackSize(), + ((ItemStack) wrappedInputs[1].getWrappedObject()).getItemDamage() + ), + 37, + 28 + ) + ); output = new PositionedStack(recipe.getRecipeOutput(), 113, 28); - } @Override - public List getIngredients() - { + public List getIngredients() { return inputs; } - public PositionedStack getOtherStack() - { - return new PositionedStack(FurnaceRecipeHandler.afuels.get((cycleticks / 48) % FurnaceRecipeHandler.afuels.size()).stack.item, 37, 63); + public PositionedStack getOtherStack() { + return new PositionedStack( + FurnaceRecipeHandler.afuels + .get((cycleticks / 48) % FurnaceRecipeHandler.afuels.size()) + .stack.item, + 37, + 63 + ); } @Override - public PositionedStack getResult() - { + public PositionedStack getResult() { return output; } } @Override - public void drawBackground(int recipe) - { + public void drawBackground(int recipe) { GL11.glColor4f(1, 1, 1, 1); changeTexture(getGuiTexture()); drawTexturedModalRect(1, -1, 8, 10, 164, 91); } @Override - public void drawExtras(int recipe) - { + public void drawExtras(int recipe) { drawProgressBar(37, 46, 176, 0, 14, 14, 48, 7); drawProgressBar(73, 29, 176, 14, 24, 16, 48, 0); } @Override - public Class getGuiClass() - { + public Class getGuiClass() { return GuiAludel.class; } @Override - public String getGuiTexture() - { + public String getGuiTexture() { return Textures.Gui.ALUDEL.toString(); } - public String getRecipeID() - { + public String getRecipeID() { return Reference.MOD_ID + ":" + Names.Blocks.ALUDEL; } @Override - public String getRecipeName() - { + public String getRecipeName() { return StatCollector.translateToLocal("gui.nei.ee3:aludel"); } @Override - public void loadCraftingRecipes(ItemStack result) - { - for (RecipeAludel recipe : AludelRecipeManager.getInstance().getRecipes()) - { - if (NEIServerUtils.areStacksSameTypeCrafting(recipe.getRecipeOutput(), result)) - { + public void loadCraftingRecipes(ItemStack result) { + for (RecipeAludel recipe : AludelRecipeManager.getInstance().getRecipes()) { + if (NEIServerUtils.areStacksSameTypeCrafting( + recipe.getRecipeOutput(), result + )) { arecipes.add(new CachedAludelRecipe(recipe)); } } } @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if (outputId.equals(getRecipeID())) - { - for (RecipeAludel recipe : AludelRecipeManager.getInstance().getRecipes()) - { + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeID())) { + for (RecipeAludel recipe : AludelRecipeManager.getInstance().getRecipes()) { arecipes.add(new CachedAludelRecipe(recipe)); } - } - else - { + } else { super.loadCraftingRecipes(outputId, results); } } @Override - public void loadTransferRects() - { + public void loadTransferRects() { transferRects.add(new RecipeTransferRect(new Rectangle(36, 44, 18, 18), "fuel")); - transferRects.add(new RecipeTransferRect(new Rectangle(74, 28, 24, 16), getRecipeID())); + transferRects.add( + new RecipeTransferRect(new Rectangle(74, 28, 24, 16), getRecipeID()) + ); } @Override - public void loadUsageRecipes(ItemStack ingredient) - { - for (RecipeAludel recipe : AludelRecipeManager.getInstance().getRecipes()) - { - for (WrappedStack wrappedStack : recipe.getRecipeInputs()) - { - if (NEIServerUtils.areStacksSameTypeCrafting((ItemStack) wrappedStack.getWrappedObject(), ingredient)) - { + public void loadUsageRecipes(ItemStack ingredient) { + for (RecipeAludel recipe : AludelRecipeManager.getInstance().getRecipes()) { + for (WrappedStack wrappedStack : recipe.getRecipeInputs()) { + if (NEIServerUtils.areStacksSameTypeCrafting( + (ItemStack) wrappedStack.getWrappedObject(), ingredient + )) { arecipes.add(new CachedAludelRecipe(recipe)); } } @@ -148,8 +153,7 @@ public class AludelRecipeHandler extends TemplateRecipeHandler } @Override - public int recipiesPerPage() - { + public int recipiesPerPage() { return 1; } } diff --git a/src/main/java/com/pahimar/ee3/nei/NEIConfig.java b/src/main/java/com/pahimar/ee3/nei/NEIConfig.java index 73fbdc5a..b68fa913 100644 --- a/src/main/java/com/pahimar/ee3/nei/NEIConfig.java +++ b/src/main/java/com/pahimar/ee3/nei/NEIConfig.java @@ -6,23 +6,19 @@ import com.pahimar.ee3.init.ModBlocks; import com.pahimar.ee3.reference.Reference; import net.minecraft.item.ItemStack; -public class NEIConfig implements IConfigureNEI -{ +public class NEIConfig implements IConfigureNEI { @Override - public String getName() - { + public String getName() { return Reference.MOD_NAME; } @Override - public String getVersion() - { + public String getVersion() { return Reference.MOD_VERSION; } @Override - public void loadConfig() - { + public void loadConfig() { AludelRecipeHandler aludelRecipeHandler = new AludelRecipeHandler(); API.registerRecipeHandler(aludelRecipeHandler); diff --git a/src/main/java/com/pahimar/ee3/network/PacketHandler.java b/src/main/java/com/pahimar/ee3/network/PacketHandler.java index 27823256..123a8370 100644 --- a/src/main/java/com/pahimar/ee3/network/PacketHandler.java +++ b/src/main/java/com/pahimar/ee3/network/PacketHandler.java @@ -7,30 +7,96 @@ import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; public class PacketHandler { - - public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.LOWERCASE_MOD_ID); + public static final SimpleNetworkWrapper INSTANCE + = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.LOWERCASE_MOD_ID); public static void init() { - INSTANCE.registerMessage(MessageTileEntityEE.class, MessageTileEntityEE.class, 0, Side.CLIENT); - INSTANCE.registerMessage(MessageTileCalcinator.class, MessageTileCalcinator.class, 1, Side.CLIENT); - INSTANCE.registerMessage(MessageTileEntityAludel.class, MessageTileEntityAludel.class, 2, Side.CLIENT); - INSTANCE.registerMessage(MessageTileEntityGlassBell.class, MessageTileEntityGlassBell.class, 3, Side.CLIENT); - INSTANCE.registerMessage(MessageKeyPressed.class, MessageKeyPressed.class, 4, Side.SERVER); - INSTANCE.registerMessage(MessageSoundEvent.class, MessageSoundEvent.class, 5, Side.CLIENT); - INSTANCE.registerMessage(MessageSyncEnergyValues.class, MessageSyncEnergyValues.class, 6, Side.CLIENT); - INSTANCE.registerMessage(MessageSetEnergyValue.class, MessageSetEnergyValue.class, 7, Side.CLIENT); - INSTANCE.registerMessage(MessageGuiElementClicked.class, MessageGuiElementClicked.class, 8, Side.SERVER); - INSTANCE.registerMessage(MessageGuiElementTextFieldUpdate.class, MessageGuiElementTextFieldUpdate.class, 9, Side.SERVER); - INSTANCE.registerMessage(MessageChalkSettings.class, MessageChalkSettings.class, 10, Side.CLIENT); - INSTANCE.registerMessage(MessageTileEntityDummy.class, MessageTileEntityDummy.class, 11, Side.CLIENT); - INSTANCE.registerMessage(MessageTileEntityAlchemyArray.class, MessageTileEntityAlchemyArray.class, 12, Side.CLIENT); - INSTANCE.registerMessage(MessageTileEntityTransmutationTablet.class, MessageTileEntityTransmutationTablet.class, 13, Side.CLIENT); - INSTANCE.registerMessage(MessageSingleParticleEvent.class, MessageSingleParticleEvent.class, 14, Side.CLIENT); - INSTANCE.registerMessage(MessageSliderElementUpdated.class, MessageSliderElementUpdated.class, 15, Side.SERVER); - INSTANCE.registerMessage(MessagePlayerKnowledge.class, MessagePlayerKnowledge.class, 16, Side.CLIENT); - INSTANCE.registerMessage(MessageTileEntityResearchStation.class, MessageTileEntityResearchStation.class, 17, Side.CLIENT); - INSTANCE.registerMessage(MessageSyncBlacklist.class, MessageSyncBlacklist.class, 18, Side.CLIENT); - INSTANCE.registerMessage(MessageSetBlacklistEntry.class, MessageSetBlacklistEntry.class, 19, Side.CLIENT); - INSTANCE.registerMessage(MessageTransmutateEvent.class, MessageTransmutateEvent.class, 20, Side.SERVER); + INSTANCE.registerMessage( + MessageTileEntityEE.class, MessageTileEntityEE.class, 0, Side.CLIENT + ); + INSTANCE.registerMessage( + MessageTileCalcinator.class, MessageTileCalcinator.class, 1, Side.CLIENT + ); + INSTANCE.registerMessage( + MessageTileEntityAludel.class, MessageTileEntityAludel.class, 2, Side.CLIENT + ); + INSTANCE.registerMessage( + MessageTileEntityGlassBell.class, + MessageTileEntityGlassBell.class, + 3, + Side.CLIENT + ); + INSTANCE.registerMessage( + MessageKeyPressed.class, MessageKeyPressed.class, 4, Side.SERVER + ); + INSTANCE.registerMessage( + MessageSoundEvent.class, MessageSoundEvent.class, 5, Side.CLIENT + ); + INSTANCE.registerMessage( + MessageSyncEnergyValues.class, MessageSyncEnergyValues.class, 6, Side.CLIENT + ); + INSTANCE.registerMessage( + MessageSetEnergyValue.class, MessageSetEnergyValue.class, 7, Side.CLIENT + ); + INSTANCE.registerMessage( + MessageGuiElementClicked.class, MessageGuiElementClicked.class, 8, Side.SERVER + ); + INSTANCE.registerMessage( + MessageGuiElementTextFieldUpdate.class, + MessageGuiElementTextFieldUpdate.class, + 9, + Side.SERVER + ); + INSTANCE.registerMessage( + MessageChalkSettings.class, MessageChalkSettings.class, 10, Side.CLIENT + ); + INSTANCE.registerMessage( + MessageTileEntityDummy.class, MessageTileEntityDummy.class, 11, Side.CLIENT + ); + INSTANCE.registerMessage( + MessageTileEntityAlchemyArray.class, + MessageTileEntityAlchemyArray.class, + 12, + Side.CLIENT + ); + INSTANCE.registerMessage( + MessageTileEntityTransmutationTablet.class, + MessageTileEntityTransmutationTablet.class, + 13, + Side.CLIENT + ); + INSTANCE.registerMessage( + MessageSingleParticleEvent.class, + MessageSingleParticleEvent.class, + 14, + Side.CLIENT + ); + INSTANCE.registerMessage( + MessageSliderElementUpdated.class, + MessageSliderElementUpdated.class, + 15, + Side.SERVER + ); + INSTANCE.registerMessage( + MessagePlayerKnowledge.class, MessagePlayerKnowledge.class, 16, Side.CLIENT + ); + INSTANCE.registerMessage( + MessageTileEntityResearchStation.class, + MessageTileEntityResearchStation.class, + 17, + Side.CLIENT + ); + INSTANCE.registerMessage( + MessageSyncBlacklist.class, MessageSyncBlacklist.class, 18, Side.CLIENT + ); + INSTANCE.registerMessage( + MessageSetBlacklistEntry.class, + MessageSetBlacklistEntry.class, + 19, + Side.CLIENT + ); + INSTANCE.registerMessage( + MessageTransmutateEvent.class, MessageTransmutateEvent.class, 20, Side.SERVER + ); } } diff --git a/src/main/java/com/pahimar/ee3/network/message/MessageChalkSettings.java b/src/main/java/com/pahimar/ee3/network/message/MessageChalkSettings.java index e860e725..e9fdb065 100644 --- a/src/main/java/com/pahimar/ee3/network/message/MessageChalkSettings.java +++ b/src/main/java/com/pahimar/ee3/network/message/MessageChalkSettings.java @@ -7,17 +7,13 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -public class MessageChalkSettings implements IMessage, IMessageHandler -{ +public class MessageChalkSettings + implements IMessage, IMessageHandler { private int index, size, rotation; - public MessageChalkSettings() - { + public MessageChalkSettings() {} - } - - public MessageChalkSettings(ChalkSettings chalkSettings) - { + public MessageChalkSettings(ChalkSettings chalkSettings) { this.index = chalkSettings.getIndex(); this.size = chalkSettings.getSize(); this.rotation = chalkSettings.getRotation(); @@ -29,8 +25,7 @@ public class MessageChalkSettings implements IMessage, IMessageHandler { - +public class MessageGuiElementClicked + implements IMessage, IMessageHandler { public String elementName; public int buttonPressed; - public MessageGuiElementClicked(){ - } + public MessageGuiElementClicked() {} public MessageGuiElementClicked(String elementName, int buttonPressed) { - this.elementName = elementName; this.buttonPressed = buttonPressed; } @Override public void fromBytes(ByteBuf buf) { - int elementNameLength = buf.readInt(); this.elementName = new String(buf.readBytes(elementNameLength).array()); this.buttonPressed = buf.readInt(); @@ -31,7 +28,6 @@ public class MessageGuiElementClicked implements IMessage, IMessageHandler -{ +public class MessageGuiElementTextFieldUpdate + implements IMessage, IMessageHandler { public String elementName; public String elementText; - public MessageGuiElementTextFieldUpdate() - { + public MessageGuiElementTextFieldUpdate() {} - } - - public MessageGuiElementTextFieldUpdate(ElementTextField elementTextField) - { + public MessageGuiElementTextFieldUpdate(ElementTextField elementTextField) { this(elementTextField.getName(), elementTextField.getText()); } - public MessageGuiElementTextFieldUpdate(String elementName, String elementText) - { + public MessageGuiElementTextFieldUpdate(String elementName, String elementText) { this.elementName = elementName; this.elementText = elementText; } @Override - public void fromBytes(ByteBuf buf) - { + public void fromBytes(ByteBuf buf) { int elementNameLength = buf.readInt(); this.elementName = new String(buf.readBytes(elementNameLength).array()); int elementTextLength = buf.readInt(); @@ -39,8 +33,7 @@ public class MessageGuiElementTextFieldUpdate implements IMessage, IMessageHandl } @Override - public void toBytes(ByteBuf buf) - { + public void toBytes(ByteBuf buf) { buf.writeInt(elementName.length()); buf.writeBytes(elementName.getBytes()); buf.writeInt(elementText.length()); @@ -48,15 +41,16 @@ public class MessageGuiElementTextFieldUpdate implements IMessage, IMessageHandl } @Override - public IMessage onMessage(MessageGuiElementTextFieldUpdate message, MessageContext ctx) - { + public IMessage + onMessage(MessageGuiElementTextFieldUpdate message, MessageContext ctx) { EntityPlayer entityPlayer = ctx.getServerHandler().playerEntity; - if (entityPlayer != null) - { - if (entityPlayer.openContainer instanceof IElementTextFieldHandler) - { - ((IElementTextFieldHandler) entityPlayer.openContainer).handleElementTextFieldUpdate(message.elementName, message.elementText); + if (entityPlayer != null) { + if (entityPlayer.openContainer instanceof IElementTextFieldHandler) { + ((IElementTextFieldHandler) entityPlayer.openContainer) + .handleElementTextFieldUpdate( + message.elementName, message.elementText + ); } } diff --git a/src/main/java/com/pahimar/ee3/network/message/MessageKeyPressed.java b/src/main/java/com/pahimar/ee3/network/message/MessageKeyPressed.java index 4abb2e8b..8bdaa55f 100644 --- a/src/main/java/com/pahimar/ee3/network/message/MessageKeyPressed.java +++ b/src/main/java/com/pahimar/ee3/network/message/MessageKeyPressed.java @@ -8,72 +8,62 @@ import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; -public class MessageKeyPressed implements IMessage, IMessageHandler -{ +public class MessageKeyPressed + implements IMessage, IMessageHandler { private byte keyPressed; - public MessageKeyPressed() - { - } + public MessageKeyPressed() {} - public MessageKeyPressed(Key key) - { - if (key == Key.CHARGE) - { + public MessageKeyPressed(Key key) { + if (key == Key.CHARGE) { this.keyPressed = (byte) Key.CHARGE.ordinal(); - } - else if (key == Key.EXTRA) - { + } else if (key == Key.EXTRA) { this.keyPressed = (byte) Key.EXTRA.ordinal(); - } - else if (key == Key.RELEASE) - { + } else if (key == Key.RELEASE) { this.keyPressed = (byte) Key.RELEASE.ordinal(); - } - else if (key == Key.TOGGLE) - { + } else if (key == Key.TOGGLE) { this.keyPressed = (byte) Key.TOGGLE.ordinal(); - } - else - { + } else { this.keyPressed = (byte) Key.UNKNOWN.ordinal(); } } @Override - public void fromBytes(ByteBuf buf) - { + public void fromBytes(ByteBuf buf) { this.keyPressed = buf.readByte(); } @Override - public void toBytes(ByteBuf buf) - { + public void toBytes(ByteBuf buf) { buf.writeByte(keyPressed); } @Override - public IMessage onMessage(MessageKeyPressed message, MessageContext ctx) - { + public IMessage onMessage(MessageKeyPressed message, MessageContext ctx) { EntityPlayer entityPlayer = ctx.getServerHandler().playerEntity; - if (entityPlayer != null && entityPlayer.getCurrentEquippedItem() != null && entityPlayer.getCurrentEquippedItem().getItem() instanceof IKeyBound) - { - if (message.keyPressed == Key.CHARGE.ordinal()) - { - ((IKeyBound) entityPlayer.getCurrentEquippedItem().getItem()).doKeyBindingAction(entityPlayer, entityPlayer.getCurrentEquippedItem(), Key.CHARGE); - } - else if (message.keyPressed == Key.EXTRA.ordinal()) - { - ((IKeyBound) entityPlayer.getCurrentEquippedItem().getItem()).doKeyBindingAction(entityPlayer, entityPlayer.getCurrentEquippedItem(), Key.EXTRA); - } - else if (message.keyPressed == Key.RELEASE.ordinal()) - { - ((IKeyBound) entityPlayer.getCurrentEquippedItem().getItem()).doKeyBindingAction(entityPlayer, entityPlayer.getCurrentEquippedItem(), Key.RELEASE); - } - else if (message.keyPressed == Key.TOGGLE.ordinal()) - { - ((IKeyBound) entityPlayer.getCurrentEquippedItem().getItem()).doKeyBindingAction(entityPlayer, entityPlayer.getCurrentEquippedItem(), Key.TOGGLE); + if (entityPlayer != null && entityPlayer.getCurrentEquippedItem() != null + && entityPlayer.getCurrentEquippedItem().getItem() instanceof IKeyBound) { + if (message.keyPressed == Key.CHARGE.ordinal()) { + ((IKeyBound) entityPlayer.getCurrentEquippedItem().getItem()) + .doKeyBindingAction( + entityPlayer, entityPlayer.getCurrentEquippedItem(), Key.CHARGE + ); + } else if (message.keyPressed == Key.EXTRA.ordinal()) { + ((IKeyBound) entityPlayer.getCurrentEquippedItem().getItem()) + .doKeyBindingAction( + entityPlayer, entityPlayer.getCurrentEquippedItem(), Key.EXTRA + ); + } else if (message.keyPressed == Key.RELEASE.ordinal()) { + ((IKeyBound) entityPlayer.getCurrentEquippedItem().getItem()) + .doKeyBindingAction( + entityPlayer, entityPlayer.getCurrentEquippedItem(), Key.RELEASE + ); + } else if (message.keyPressed == Key.TOGGLE.ordinal()) { + ((IKeyBound) entityPlayer.getCurrentEquippedItem().getItem()) + .doKeyBindingAction( + entityPlayer, entityPlayer.getCurrentEquippedItem(), Key.TOGGLE + ); } } diff --git a/src/main/java/com/pahimar/ee3/network/message/MessagePlayerKnowledge.java b/src/main/java/com/pahimar/ee3/network/message/MessagePlayerKnowledge.java index 16a91e1a..b23c81c9 100644 --- a/src/main/java/com/pahimar/ee3/network/message/MessagePlayerKnowledge.java +++ b/src/main/java/com/pahimar/ee3/network/message/MessagePlayerKnowledge.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.network.message; +import java.util.Collection; + import com.google.gson.JsonSyntaxException; import com.pahimar.ee3.api.exchange.ITransmutationContainer; import com.pahimar.ee3.knowledge.PlayerKnowledge; @@ -14,24 +16,21 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import java.util.Collection; - -public class MessagePlayerKnowledge implements IMessage, IMessageHandler { - +public class MessagePlayerKnowledge + implements IMessage, IMessageHandler { public int xCoord, yCoord, zCoord; public PlayerKnowledge playerKnowledge; - public MessagePlayerKnowledge(){ - } - - public MessagePlayerKnowledge(ITransmutationContainer transmutationTablet, Collection knownItemStacks) { + public MessagePlayerKnowledge() {} + public MessagePlayerKnowledge( + ITransmutationContainer transmutationTablet, Collection knownItemStacks + ) { if (transmutationTablet != null) { this.xCoord = transmutationTablet.getXCoord(); this.yCoord = transmutationTablet.getYCoord(); this.zCoord = transmutationTablet.getZCoord(); - } - else { + } else { this.xCoord = 0; this.yCoord = Integer.MIN_VALUE; this.zCoord = 0; @@ -39,15 +38,13 @@ public class MessagePlayerKnowledge implements IMessage, IMessageHandler { - +public class MessageSetBlacklistEntry + implements IMessage, IMessageHandler { public Blacklist blacklist; public boolean isBlacklistAction; public WrappedStack wrappedStack; - public MessageSetBlacklistEntry() { - } + public MessageSetBlacklistEntry() {} public MessageSetBlacklistEntry(Object object, Blacklist blacklist) { this(object, blacklist, true); } - public MessageSetBlacklistEntry(Object object, Blacklist blacklist, boolean isBlacklistAction) { - + public MessageSetBlacklistEntry( + Object object, Blacklist blacklist, boolean isBlacklistAction + ) { if (WrappedStack.canBeWrapped(object)) { this.wrappedStack = WrappedStack.wrap(object, 1); - } - else { + } else { wrappedStack = null; } this.blacklist = blacklist; @@ -41,52 +40,48 @@ public class MessageSetBlacklistEntry implements IMessage, IMessageHandler= 0) { - if (blacklistOrdinal == 0) { blacklist = Blacklist.KNOWLEDGE; - } - else if (blacklistOrdinal == 1) { + } else if (blacklistOrdinal == 1) { blacklist = Blacklist.EXCHANGE; - } - else { + } else { blacklist = null; } if (blacklist != null) { - isBlacklistAction = buf.readBoolean(); int compressedJsonLength = buf.readInt(); if (compressedJsonLength != 0) { - - byte[] compressedWrappedStack = buf.readBytes(compressedJsonLength).array(); + byte[] compressedWrappedStack + = buf.readBytes(compressedJsonLength).array(); if (compressedWrappedStack != null) { - - String jsonWrappedStack = CompressionHelper.decompress(compressedWrappedStack); + String jsonWrappedStack + = CompressionHelper.decompress(compressedWrappedStack); try { - wrappedStack = SerializationHelper.GSON.fromJson(jsonWrappedStack, WrappedStack.class); - } - catch (JsonParseException e) { - LogHelper.warn("Failed to receive {} blacklist data from server", blacklist); + wrappedStack + = SerializationHelper.GSON + .fromJson(jsonWrappedStack, WrappedStack.class); + } catch (JsonParseException e) { + LogHelper.warn( + "Failed to receive {} blacklist data from server", + blacklist + ); wrappedStack = null; } - } - else { + } else { wrappedStack = null; } - } - else { + } else { wrappedStack = null; } } - } - else { + } else { blacklist = null; isBlacklistAction = false; wrappedStack = null; @@ -95,37 +90,35 @@ public class MessageSetBlacklistEntry implements IMessage, IMessageHandler { - +public class MessageSetEnergyValue + implements IMessage, IMessageHandler { public Map energyValueMap; - public MessageSetEnergyValue() { - } + public MessageSetEnergyValue() {} public MessageSetEnergyValue(WrappedStack wrappedStack, EnergyValue energyValue) { - this.energyValueMap = new TreeMap<>(); - if (wrappedStack != null && wrappedStack.getWrappedObject() != null && energyValue != null) { + if (wrappedStack != null && wrappedStack.getWrappedObject() != null + && energyValue != null) { this.energyValueMap.put(wrappedStack, energyValue); } } @@ -37,63 +36,62 @@ public class MessageSetEnergyValue implements IMessage, IMessageHandler -{ +public class MessageSingleParticleEvent + implements IMessage, IMessageHandler { private String particleName; private double xCoord, yCoord, zCoord; private double xVelocity, yVelocity, zVelocity; - public MessageSingleParticleEvent() - { + public MessageSingleParticleEvent() {} - } - - public MessageSingleParticleEvent(String particleName, double xCoord, double yCoord, double zCoord, double xVelocity, double yVelocity, double zVelocity) - { + public MessageSingleParticleEvent( + String particleName, + double xCoord, + double yCoord, + double zCoord, + double xVelocity, + double yVelocity, + double zVelocity + ) { this.particleName = particleName; this.xCoord = xCoord; this.yCoord = yCoord; @@ -29,8 +33,7 @@ public class MessageSingleParticleEvent implements IMessage, IMessageHandler -{ +public class MessageSliderElementUpdated + implements IMessage, IMessageHandler { public String elementName; public int elementValue; - public MessageSliderElementUpdated() - { - } + public MessageSliderElementUpdated() {} - public MessageSliderElementUpdated(ElementSlider elementSlider) - { + public MessageSliderElementUpdated(ElementSlider elementSlider) { this(elementSlider.getName(), elementSlider.getValue()); } - public MessageSliderElementUpdated(String elementName, int elementValue) - { + public MessageSliderElementUpdated(String elementName, int elementValue) { this.elementName = elementName; this.elementValue = elementValue; } @Override - public void fromBytes(ByteBuf buf) - { + public void fromBytes(ByteBuf buf) { int elementNameLength = buf.readInt(); this.elementName = new String(buf.readBytes(elementNameLength).array()); this.elementValue = buf.readInt(); } @Override - public void toBytes(ByteBuf buf) - { - if (elementName != null) - { + public void toBytes(ByteBuf buf) { + if (elementName != null) { buf.writeInt(elementName.length()); buf.writeBytes(elementName.getBytes()); - } - else - { + } else { buf.writeInt(0); } buf.writeInt(elementValue); } @Override - public IMessage onMessage(MessageSliderElementUpdated message, MessageContext ctx) - { + public IMessage onMessage(MessageSliderElementUpdated message, MessageContext ctx) { EntityPlayer entityPlayer = ctx.getServerHandler().playerEntity; - if (entityPlayer != null) - { - if (entityPlayer.openContainer instanceof IElementSliderHandler) - { - ((IElementSliderHandler) entityPlayer.openContainer).handleElementSliderUpdate(message.elementName, message.elementValue); + if (entityPlayer != null) { + if (entityPlayer.openContainer instanceof IElementSliderHandler) { + ((IElementSliderHandler) entityPlayer.openContainer) + .handleElementSliderUpdate(message.elementName, message.elementValue); } } diff --git a/src/main/java/com/pahimar/ee3/network/message/MessageSoundEvent.java b/src/main/java/com/pahimar/ee3/network/message/MessageSoundEvent.java index 2ebff831..7f3c9689 100644 --- a/src/main/java/com/pahimar/ee3/network/message/MessageSoundEvent.java +++ b/src/main/java/com/pahimar/ee3/network/message/MessageSoundEvent.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.network.message; +import java.util.UUID; + import com.pahimar.ee3.EquivalentExchange3; import com.pahimar.ee3.handler.ConfigurationHandler; import cpw.mods.fml.client.FMLClientHandler; @@ -9,22 +11,18 @@ import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; -import java.util.UUID; - -public class MessageSoundEvent implements IMessage, IMessageHandler -{ +public class MessageSoundEvent + implements IMessage, IMessageHandler { private long mostSigUUID, leastSigUUID; private String soundName; private float xCoord, yCoord, zCoord; private float volume, pitch; - public MessageSoundEvent() - { + public MessageSoundEvent() {} - } - - public MessageSoundEvent(EntityPlayer entityPlayer, String soundName, float volume, float pitch) - { + public MessageSoundEvent( + EntityPlayer entityPlayer, String soundName, float volume, float pitch + ) { this.mostSigUUID = entityPlayer.getUniqueID().getMostSignificantBits(); this.leastSigUUID = entityPlayer.getUniqueID().getLeastSignificantBits(); this.soundName = soundName; @@ -35,8 +33,14 @@ public class MessageSoundEvent implements IMessage, IMessageHandler { - +public class MessageSyncBlacklist + implements IMessage, IMessageHandler { public Blacklist blacklist; public Set blacklistSet; - public MessageSyncBlacklist() { - } + public MessageSyncBlacklist() {} public MessageSyncBlacklist(Blacklist blacklist) { - this.blacklist = blacklist; this.blacklistSet = BlacklistRegistryProxy.getBlacklist(blacklist); } @Override public void fromBytes(ByteBuf buf) { - int blacklistOrdinal = buf.readInt(); if (blacklistOrdinal == 0) { blacklist = Blacklist.KNOWLEDGE; - } - else if (blacklistOrdinal == 1) { + } else if (blacklistOrdinal == 1) { blacklist = Blacklist.EXCHANGE; - } - else { + } else { blacklist = null; } if (blacklist != null) { - int compressedJsonLength = buf.readInt(); if (compressedJsonLength != 0) { - byte[] compressedBlacklist = buf.readBytes(compressedJsonLength).array(); if (compressedBlacklist != null) { - - String jsonBlacklist = CompressionHelper.decompress(compressedBlacklist); + String jsonBlacklist + = CompressionHelper.decompress(compressedBlacklist); try { - blacklistSet = SerializationHelper.GSON.fromJson(jsonBlacklist, SerializationHelper.WRAPPED_STACK_SET_TYPE); - } - catch (JsonParseException e) { - LogHelper.warn("Failed to receive {} blacklist data from server", blacklist); + blacklistSet = SerializationHelper.GSON.fromJson( + jsonBlacklist, SerializationHelper.WRAPPED_STACK_SET_TYPE + ); + } catch (JsonParseException e) { + LogHelper.warn( + "Failed to receive {} blacklist data from server", blacklist + ); blacklistSet = null; } - } - else { + } else { blacklistSet = null; } } - } - else { + } else { blacklistSet = null; } } @Override public void toBytes(ByteBuf buf) { - if (blacklist != null) { - buf.writeInt(blacklist.ordinal()); if (blacklistSet != null) { - - byte[] compressedBlacklist = CompressionHelper.compress(SerializationHelper.GSON.toJson(blacklistSet, SerializationHelper.WRAPPED_STACK_SET_TYPE)); + byte[] compressedBlacklist + = CompressionHelper.compress(SerializationHelper.GSON.toJson( + blacklistSet, SerializationHelper.WRAPPED_STACK_SET_TYPE + )); if (compressedBlacklist != null) { buf.writeInt(compressedBlacklist.length); buf.writeBytes(compressedBlacklist); - } - else { + } else { buf.writeInt(0); } - } - else { + } else { buf.writeInt(0); } - } - else { + } else { buf.writeInt(-1); } } @Override public IMessage onMessage(MessageSyncBlacklist message, MessageContext ctx) { - if (message.blacklist != null && message.blacklistSet != null) { BlacklistRegistry.INSTANCE.load(message.blacklistSet, message.blacklist); } diff --git a/src/main/java/com/pahimar/ee3/network/message/MessageSyncEnergyValues.java b/src/main/java/com/pahimar/ee3/network/message/MessageSyncEnergyValues.java index b4b681b7..4b726cf7 100644 --- a/src/main/java/com/pahimar/ee3/network/message/MessageSyncEnergyValues.java +++ b/src/main/java/com/pahimar/ee3/network/message/MessageSyncEnergyValues.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.network.message; +import java.util.Map; + import com.google.gson.JsonParseException; import com.pahimar.ee3.api.exchange.EnergyValue; import com.pahimar.ee3.exchange.EnergyValueRegistry; @@ -12,10 +14,8 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -import java.util.Map; - -public class MessageSyncEnergyValues implements IMessage, IMessageHandler { - +public class MessageSyncEnergyValues + implements IMessage, IMessageHandler { public Map valueMap; public MessageSyncEnergyValues() { @@ -29,29 +29,26 @@ public class MessageSyncEnergyValues implements IMessage, IMessageHandler -{ +public class MessageTileCalcinator + implements IMessage, IMessageHandler { public int x, y, z; public byte orientation, state; public String customName; public UUID ownerUUID; public byte leftStackSize, leftStackMeta, rightStackSize, rightStackMeta; - public MessageTileCalcinator() - { - } + public MessageTileCalcinator() {} - public MessageTileCalcinator(TileEntityCalcinator tileEntityCalcinator) - { + public MessageTileCalcinator(TileEntityCalcinator tileEntityCalcinator) { this.x = tileEntityCalcinator.xCoord; this.y = tileEntityCalcinator.yCoord; this.z = tileEntityCalcinator.zCoord; @@ -39,8 +36,7 @@ public class MessageTileCalcinator implements IMessage, IMessageHandler -{ +public class MessageTileEntityAlchemyArray + implements IMessage, IMessageHandler { public NBTTagCompound tileEntityAlchemyArrayNBT; - public MessageTileEntityAlchemyArray() - { - } + public MessageTileEntityAlchemyArray() {} - public MessageTileEntityAlchemyArray(TileEntityAlchemyArray tileEntityAlchemyArray) - { + public MessageTileEntityAlchemyArray(TileEntityAlchemyArray tileEntityAlchemyArray) { tileEntityAlchemyArrayNBT = new NBTTagCompound(); tileEntityAlchemyArray.writeToNBT(tileEntityAlchemyArrayNBT); } @@ -33,24 +30,20 @@ public class MessageTileEntityAlchemyArray implements IMessage, IMessageHandler< * @param buf */ @Override - public void fromBytes(ByteBuf buf) - { + public void fromBytes(ByteBuf buf) { byte[] compressedNBT = null; int readableBytes = buf.readInt(); - if (readableBytes > 0) - { + if (readableBytes > 0) { compressedNBT = buf.readBytes(readableBytes).array(); } - if (compressedNBT != null) - { - try - { - this.tileEntityAlchemyArrayNBT = CompressedStreamTools.readCompressed(new ByteArrayInputStream(compressedNBT)); - } - catch (IOException e) - { + if (compressedNBT != null) { + try { + this.tileEntityAlchemyArrayNBT = CompressedStreamTools.readCompressed( + new ByteArrayInputStream(compressedNBT) + ); + } catch (IOException e) { e.printStackTrace(); } } @@ -62,56 +55,54 @@ public class MessageTileEntityAlchemyArray implements IMessage, IMessageHandler< * @param buf */ @Override - public void toBytes(ByteBuf buf) - { + public void toBytes(ByteBuf buf) { byte[] compressedNBT = null; - try - { - if (tileEntityAlchemyArrayNBT != null) - { + try { + if (tileEntityAlchemyArrayNBT != null) { compressedNBT = CompressedStreamTools.compress(tileEntityAlchemyArrayNBT); } - } - catch (IOException e) - { + } catch (IOException e) { e.printStackTrace(); } - if (compressedNBT != null) - { + if (compressedNBT != null) { buf.writeInt(compressedNBT.length); buf.writeBytes(compressedNBT); - } - else - { + } else { buf.writeInt(0); } } /** - * Called when a message is received of the appropriate type. You can optionally return a reply message, or null if no reply - * is needed. + * Called when a message is received of the appropriate type. You can optionally + * return a reply message, or null if no reply is needed. * * @param message The message * @param ctx * @return an optional return message */ @Override - public IMessage onMessage(MessageTileEntityAlchemyArray message, MessageContext ctx) - { - if (message.tileEntityAlchemyArrayNBT != null) - { + public IMessage onMessage(MessageTileEntityAlchemyArray message, MessageContext ctx) { + if (message.tileEntityAlchemyArrayNBT != null) { TileEntityAlchemyArray tileEntityAlchemyArray = new TileEntityAlchemyArray(); tileEntityAlchemyArray.readFromNBT(message.tileEntityAlchemyArrayNBT); - TileEntity tileEntity = FMLClientHandler.instance().getClient().theWorld.getTileEntity(tileEntityAlchemyArray.xCoord, tileEntityAlchemyArray.yCoord, tileEntityAlchemyArray.zCoord); + TileEntity tileEntity + = FMLClientHandler.instance().getClient().theWorld.getTileEntity( + tileEntityAlchemyArray.xCoord, + tileEntityAlchemyArray.yCoord, + tileEntityAlchemyArray.zCoord + ); - if (tileEntity instanceof TileEntityAlchemyArray) - { + if (tileEntity instanceof TileEntityAlchemyArray) { tileEntity.readFromNBT(message.tileEntityAlchemyArrayNBT); //NAME UPDATE - FMLClientHandler.instance().getClient().theWorld.func_147451_t(tileEntityAlchemyArray.xCoord, tileEntityAlchemyArray.yCoord, tileEntityAlchemyArray.zCoord); + FMLClientHandler.instance().getClient().theWorld.func_147451_t( + tileEntityAlchemyArray.xCoord, + tileEntityAlchemyArray.yCoord, + tileEntityAlchemyArray.zCoord + ); } } diff --git a/src/main/java/com/pahimar/ee3/network/message/MessageTileEntityAludel.java b/src/main/java/com/pahimar/ee3/network/message/MessageTileEntityAludel.java index e5fe80ef..a531fee3 100644 --- a/src/main/java/com/pahimar/ee3/network/message/MessageTileEntityAludel.java +++ b/src/main/java/com/pahimar/ee3/network/message/MessageTileEntityAludel.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.network.message; +import java.util.UUID; + import com.pahimar.ee3.reference.Colors; import com.pahimar.ee3.tileentity.TileEntityAludel; import com.pahimar.ee3.util.ColorHelper; @@ -12,10 +14,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import java.util.UUID; - -public class MessageTileEntityAludel implements IMessage, IMessageHandler -{ +public class MessageTileEntityAludel + implements IMessage, IMessageHandler { public int x, y, z; public byte orientation; public byte state; @@ -23,12 +23,11 @@ public class MessageTileEntityAludel implements IMessage, IMessageHandler -{ +public class MessageTileEntityDummy + implements IMessage, IMessageHandler { public int x, y, z; public byte orientation; public byte state; @@ -20,13 +20,9 @@ public class MessageTileEntityDummy implements IMessage, IMessageHandler -{ +public class MessageTileEntityEE + implements IMessage, IMessageHandler { public int x, y, z; public byte orientation, state; public String customName; public UUID ownerUUID; - public MessageTileEntityEE() - { - } + public MessageTileEntityEE() {} - public MessageTileEntityEE(TileEntityEE tileEntityEE) - { + public MessageTileEntityEE(TileEntityEE tileEntityEE) { this.x = tileEntityEE.xCoord; this.y = tileEntityEE.yCoord; this.z = tileEntityEE.zCoord; @@ -33,8 +30,7 @@ public class MessageTileEntityEE implements IMessage, IMessageHandler -{ +public class MessageTileEntityGlassBell + implements IMessage, IMessageHandler { public int x, y, z; public byte orientation; public byte state; @@ -21,12 +21,11 @@ public class MessageTileEntityGlassBell implements IMessage, IMessageHandler -{ +public class MessageTileEntityResearchStation + implements IMessage, IMessageHandler { public int x, y, z; public ItemStack alchenomiconItemStack; - public MessageTileEntityResearchStation() - { - } + public MessageTileEntityResearchStation() {} - public MessageTileEntityResearchStation(TileEntityResearchStation tileEntityResearchStation) - { + public MessageTileEntityResearchStation( + TileEntityResearchStation tileEntityResearchStation + ) { this.x = tileEntityResearchStation.xCoord; this.y = tileEntityResearchStation.yCoord; this.z = tileEntityResearchStation.zCoord; - this.alchenomiconItemStack = tileEntityResearchStation.getStackInSlot(TileEntityResearchStation.ALCHENOMICON_SLOT_INVENTORY_INDEX); + this.alchenomiconItemStack = tileEntityResearchStation.getStackInSlot( + TileEntityResearchStation.ALCHENOMICON_SLOT_INVENTORY_INDEX + ); } @Override - public void fromBytes(ByteBuf buf) - { + public void fromBytes(ByteBuf buf) { this.x = buf.readInt(); this.y = buf.readInt(); this.z = buf.readInt(); @@ -37,8 +37,7 @@ public class MessageTileEntityResearchStation implements IMessage, IMessageHandl } @Override - public void toBytes(ByteBuf buf) - { + public void toBytes(ByteBuf buf) { buf.writeInt(x); buf.writeInt(y); buf.writeInt(z); @@ -46,21 +45,32 @@ public class MessageTileEntityResearchStation implements IMessage, IMessageHandl } @Override - public IMessage onMessage(MessageTileEntityResearchStation message, MessageContext ctx) - { - TileEntity tileEntity = FMLClientHandler.instance().getClient().theWorld.getTileEntity(message.x, message.y, message.z); + public IMessage + onMessage(MessageTileEntityResearchStation message, MessageContext ctx) { + TileEntity tileEntity + = FMLClientHandler.instance().getClient().theWorld.getTileEntity( + message.x, message.y, message.z + ); - if (tileEntity instanceof TileEntityResearchStation) - { - ((TileEntityResearchStation) tileEntity).setInventorySlotContents(TileEntityResearchStation.ALCHENOMICON_SLOT_INVENTORY_INDEX, message.alchenomiconItemStack); + if (tileEntity instanceof TileEntityResearchStation) { + ((TileEntityResearchStation) tileEntity) + .setInventorySlotContents( + TileEntityResearchStation.ALCHENOMICON_SLOT_INVENTORY_INDEX, + message.alchenomiconItemStack + ); } return null; } @Override - public String toString() - { - return String.format("MessageTileEntityResearchStation - x:%s, y:%s, z:%s, tome:%s", x, y, z, alchenomiconItemStack.toString()); + public String toString() { + return String.format( + "MessageTileEntityResearchStation - x:%s, y:%s, z:%s, tome:%s", + x, + y, + z, + alchenomiconItemStack.toString() + ); } } diff --git a/src/main/java/com/pahimar/ee3/network/message/MessageTileEntityTransmutationTablet.java b/src/main/java/com/pahimar/ee3/network/message/MessageTileEntityTransmutationTablet.java index da09b930..7fa56ee5 100644 --- a/src/main/java/com/pahimar/ee3/network/message/MessageTileEntityTransmutationTablet.java +++ b/src/main/java/com/pahimar/ee3/network/message/MessageTileEntityTransmutationTablet.java @@ -1,5 +1,8 @@ package com.pahimar.ee3.network.message; +import java.io.ByteArrayInputStream; +import java.io.IOException; + import com.pahimar.ee3.tileentity.TileEntityTransmutationTablet; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.network.simpleimpl.IMessage; @@ -10,25 +13,21 @@ import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import java.io.ByteArrayInputStream; -import java.io.IOException; - -public class MessageTileEntityTransmutationTablet implements IMessage, IMessageHandler { - +public class MessageTileEntityTransmutationTablet + implements IMessage, IMessageHandler { public NBTTagCompound tileEntityTransmutationTabletNBT; - public MessageTileEntityTransmutationTablet() { - } - - public MessageTileEntityTransmutationTablet(TileEntityTransmutationTablet tileEntityTransmutationTablet) { + public MessageTileEntityTransmutationTablet() {} + public MessageTileEntityTransmutationTablet( + TileEntityTransmutationTablet tileEntityTransmutationTablet + ) { tileEntityTransmutationTabletNBT = new NBTTagCompound(); tileEntityTransmutationTablet.writeToNBT(tileEntityTransmutationTabletNBT); } @Override public void fromBytes(ByteBuf buf) { - byte[] compressedNBT = null; int readableBytes = buf.readInt(); @@ -37,11 +36,12 @@ public class MessageTileEntityTransmutationTablet implements IMessage, IMessageH } if (compressedNBT != null) { - try { - this.tileEntityTransmutationTabletNBT = CompressedStreamTools.readCompressed(new ByteArrayInputStream(compressedNBT)); - } - catch (IOException e) { + this.tileEntityTransmutationTabletNBT + = CompressedStreamTools.readCompressed( + new ByteArrayInputStream(compressedNBT) + ); + } catch (IOException e) { e.printStackTrace(); } } @@ -49,41 +49,50 @@ public class MessageTileEntityTransmutationTablet implements IMessage, IMessageH @Override public void toBytes(ByteBuf buf) { - byte[] compressedNBT = null; try { if (tileEntityTransmutationTabletNBT != null) { - compressedNBT = CompressedStreamTools.compress(tileEntityTransmutationTabletNBT); + compressedNBT + = CompressedStreamTools.compress(tileEntityTransmutationTabletNBT); } - } - catch (IOException e) { + } catch (IOException e) { e.printStackTrace(); } if (compressedNBT != null) { buf.writeInt(compressedNBT.length); buf.writeBytes(compressedNBT); - } - else { + } else { buf.writeInt(0); } } @Override - public IMessage onMessage(MessageTileEntityTransmutationTablet message, MessageContext ctx) { - + public IMessage + onMessage(MessageTileEntityTransmutationTablet message, MessageContext ctx) { if (message.tileEntityTransmutationTabletNBT != null) { + TileEntityTransmutationTablet tileEntityTransmutationTablet + = new TileEntityTransmutationTablet(); + tileEntityTransmutationTablet.readFromNBT( + message.tileEntityTransmutationTabletNBT + ); - TileEntityTransmutationTablet tileEntityTransmutationTablet = new TileEntityTransmutationTablet(); - tileEntityTransmutationTablet.readFromNBT(message.tileEntityTransmutationTabletNBT); - - TileEntity tileEntity = FMLClientHandler.instance().getClient().theWorld.getTileEntity(tileEntityTransmutationTablet.xCoord, tileEntityTransmutationTablet.yCoord, tileEntityTransmutationTablet.zCoord); + TileEntity tileEntity + = FMLClientHandler.instance().getClient().theWorld.getTileEntity( + tileEntityTransmutationTablet.xCoord, + tileEntityTransmutationTablet.yCoord, + tileEntityTransmutationTablet.zCoord + ); if (tileEntity instanceof TileEntityTransmutationTablet) { tileEntity.readFromNBT(message.tileEntityTransmutationTabletNBT); //NAME UPDATE - FMLClientHandler.instance().getClient().theWorld.func_147451_t(tileEntityTransmutationTablet.xCoord, tileEntityTransmutationTablet.yCoord, tileEntityTransmutationTablet.zCoord); + FMLClientHandler.instance().getClient().theWorld.func_147451_t( + tileEntityTransmutationTablet.xCoord, + tileEntityTransmutationTablet.yCoord, + tileEntityTransmutationTablet.zCoord + ); } } diff --git a/src/main/java/com/pahimar/ee3/network/message/MessageTransmutateEvent.java b/src/main/java/com/pahimar/ee3/network/message/MessageTransmutateEvent.java index 894b235e..b4de4dfd 100644 --- a/src/main/java/com/pahimar/ee3/network/message/MessageTransmutateEvent.java +++ b/src/main/java/com/pahimar/ee3/network/message/MessageTransmutateEvent.java @@ -1,7 +1,6 @@ package com.pahimar.ee3.network.message; import com.pahimar.ee3.handler.WorldTransmutationHandler; - import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; @@ -10,8 +9,8 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.common.util.ForgeDirection; -public class MessageTransmutateEvent implements IMessage, IMessageHandler { - +public class MessageTransmutateEvent + implements IMessage, IMessageHandler { public int originX; public int originY; public int originZ; @@ -24,7 +23,14 @@ public class MessageTransmutateEvent implements IMessage, IMessageHandler aludelRecipes; - private AludelRecipeManager() - { + private AludelRecipeManager() { aludelRecipes = new ArrayList(); } - public static AludelRecipeManager getInstance() - { - if (aludelRegistry == null) - { + public static AludelRecipeManager getInstance() { + if (aludelRegistry == null) { aludelRegistry = new AludelRecipeManager(); } @@ -34,30 +30,35 @@ public class AludelRecipeManager public static void registerRecipes() { for (RecipeAludel recipeAludel : AludelRecipeManager.getInstance().getRecipes()) { - RecipeRegistryProxy.addRecipe(recipeAludel.getRecipeOutput(), recipeAludel.getRecipeInputsAsWrappedStacks()); + RecipeRegistryProxy.addRecipe( + recipeAludel.getRecipeOutput(), + recipeAludel.getRecipeInputsAsWrappedStacks() + ); } } - public void addRecipe(ItemStack recipeOutput, ItemStack recipeInputStack, ItemStack recipeInputDust) - { + public void addRecipe( + ItemStack recipeOutput, ItemStack recipeInputStack, ItemStack recipeInputDust + ) { addRecipe(new RecipeAludel(recipeOutput, recipeInputStack, recipeInputDust)); } - public void addRecipe(RecipeAludel recipeAludel) - { - if (!aludelRecipes.contains(recipeAludel)) - { - LogHelper.trace(RecipeRegistry.RECIPE_MARKER, "[{}] Mod with ID '{}' added Aludel recipe '{}'", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), recipeAludel); + public void addRecipe(RecipeAludel recipeAludel) { + if (!aludelRecipes.contains(recipeAludel)) { + LogHelper.trace( + RecipeRegistry.RECIPE_MARKER, + "[{}] Mod with ID '{}' added Aludel recipe '{}'", + LoaderHelper.getLoaderState(), + Loader.instance().activeModContainer().getModId(), + recipeAludel + ); aludelRecipes.add(recipeAludel); } } - public ItemStack getResult(ItemStack recipeInputStack, ItemStack recipeInputDust) - { - for (RecipeAludel recipeAludel : aludelRecipes) - { - if (recipeAludel.matches(recipeInputStack, recipeInputDust)) - { + public ItemStack getResult(ItemStack recipeInputStack, ItemStack recipeInputDust) { + for (RecipeAludel recipeAludel : aludelRecipes) { + if (recipeAludel.matches(recipeInputStack, recipeInputDust)) { return recipeAludel.getRecipeOutput(); } } @@ -65,12 +66,9 @@ public class AludelRecipeManager return null; } - public RecipeAludel getRecipe(ItemStack recipeInputStack, ItemStack recipeInputDust) - { - for (RecipeAludel recipeAludel : aludelRecipes) - { - if (recipeAludel.matches(recipeInputStack, recipeInputDust)) - { + public RecipeAludel getRecipe(ItemStack recipeInputStack, ItemStack recipeInputDust) { + for (RecipeAludel recipeAludel : aludelRecipes) { + if (recipeAludel.matches(recipeInputStack, recipeInputDust)) { return recipeAludel; } } @@ -78,8 +76,7 @@ public class AludelRecipeManager return null; } - public List getRecipes() - { + public List getRecipes() { return ImmutableList.copyOf(aludelRecipes); } } diff --git a/src/main/java/com/pahimar/ee3/recipe/RecipeRegistry.java b/src/main/java/com/pahimar/ee3/recipe/RecipeRegistry.java index 9ae99c7d..faf54662 100644 --- a/src/main/java/com/pahimar/ee3/recipe/RecipeRegistry.java +++ b/src/main/java/com/pahimar/ee3/recipe/RecipeRegistry.java @@ -1,5 +1,9 @@ package com.pahimar.ee3.recipe; +import java.util.Collection; +import java.util.Set; +import java.util.TreeSet; + import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Multimap; import com.google.common.collect.TreeMultimap; @@ -11,24 +15,21 @@ import cpw.mods.fml.common.Loader; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; -import java.util.Collection; -import java.util.Set; -import java.util.TreeSet; - public class RecipeRegistry { - - public static final Marker RECIPE_MARKER = MarkerManager.getMarker("EE3_RECIPE", LogHelper.MOD_MARKER); + public static final Marker RECIPE_MARKER + = MarkerManager.getMarker("EE3_RECIPE", LogHelper.MOD_MARKER); public static final RecipeRegistry INSTANCE = new RecipeRegistry(); private Multimap> recipeMap; private ImmutableMultimap> immutableRecipeMap; private RecipeRegistry() { - recipeMap = TreeMultimap.create(WrappedStack.COMPARATOR, Comparators.WRAPPED_STACK_SET_COMPARATOR); + recipeMap = TreeMultimap.create( + WrappedStack.COMPARATOR, Comparators.WRAPPED_STACK_SET_COMPARATOR + ); } public void addRecipe(Object recipeOutput, Collection recipeInputList) { - // Wrap the recipe output WrappedStack wrappedRecipeOutput = WrappedStack.wrap(recipeOutput); if (wrappedRecipeOutput == null) { @@ -39,15 +40,13 @@ public class RecipeRegistry { StringBuilder stringBuilder = new StringBuilder(); for (Object recipeInputObject : recipeInputList) { - WrappedStack wrappedInputObject = WrappedStack.wrap(recipeInputObject); if (wrappedInputObject != null) { wrappedRecipeInputList.add(wrappedInputObject); stringBuilder.append(wrappedInputObject); stringBuilder.append(" "); - } - else { + } else { return; } } @@ -55,27 +54,33 @@ public class RecipeRegistry { // Check to see if we already have this recipe in the map boolean existsAlready = false; for (Set recipeInputs : recipeMap.get(wrappedRecipeOutput)) { - if (recipeInputs.containsAll(wrappedRecipeInputList) && wrappedRecipeInputList.containsAll(recipeInputs)) { + if (recipeInputs.containsAll(wrappedRecipeInputList) + && wrappedRecipeInputList.containsAll(recipeInputs)) { existsAlready = true; } } // Add the recipe mapping only if we don't already have it if (!existsAlready) { - LogHelper.trace(RECIPE_MARKER, "[{}] Mod with ID '{}' added recipe (Output: {}, Inputs: {})", LoaderHelper.getLoaderState(), Loader.instance().activeModContainer().getModId(), wrappedRecipeOutput, stringBuilder.toString().trim()); + LogHelper.trace( + RECIPE_MARKER, + "[{}] Mod with ID '{}' added recipe (Output: {}, Inputs: {})", + LoaderHelper.getLoaderState(), + Loader.instance().activeModContainer().getModId(), + wrappedRecipeOutput, + stringBuilder.toString().trim() + ); recipeMap.put(wrappedRecipeOutput, wrappedRecipeInputList); } } public void registerVanillaRecipes() { - new RecipesVanilla().registerRecipes(); new RecipesFluidContainers().registerRecipes(); new RecipesPotions().registerRecipes(); } public Multimap> getRecipeMappings() { - if (immutableRecipeMap == null) { immutableRecipeMap = ImmutableMultimap.copyOf(INSTANCE.recipeMap); } @@ -84,10 +89,11 @@ public class RecipeRegistry { } public void dumpRecipeRegistryToLog() { - for (WrappedStack wrappedStack : getRecipeMappings().keySet()) { StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(String.format("Output: %s, Inputs: ", wrappedStack.toString())); + stringBuilder.append( + String.format("Output: %s, Inputs: ", wrappedStack.toString()) + ); for (Set listStacks : getRecipeMappings().get(wrappedStack)) { for (WrappedStack listStack : listStacks) { stringBuilder.append(listStack.toString() + " "); diff --git a/src/main/java/com/pahimar/ee3/recipe/RecipesFluidContainers.java b/src/main/java/com/pahimar/ee3/recipe/RecipesFluidContainers.java index 428e4e4d..1801e91f 100644 --- a/src/main/java/com/pahimar/ee3/recipe/RecipesFluidContainers.java +++ b/src/main/java/com/pahimar/ee3/recipe/RecipesFluidContainers.java @@ -5,12 +5,17 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; public class RecipesFluidContainers { - public void registerRecipes() { - - for (FluidContainerData fluidContainerData : FluidContainerRegistry.getRegisteredFluidContainerData()) { - if (fluidContainerData.fluid != null && fluidContainerData.filledContainer != null && fluidContainerData.emptyContainer != null) { - RecipeRegistryProxy.addRecipe(fluidContainerData.filledContainer.copy(), fluidContainerData.fluid.copy(), fluidContainerData.emptyContainer.copy()); + for (FluidContainerData fluidContainerData : + FluidContainerRegistry.getRegisteredFluidContainerData()) { + if (fluidContainerData.fluid != null + && fluidContainerData.filledContainer != null + && fluidContainerData.emptyContainer != null) { + RecipeRegistryProxy.addRecipe( + fluidContainerData.filledContainer.copy(), + fluidContainerData.fluid.copy(), + fluidContainerData.emptyContainer.copy() + ); } } } diff --git a/src/main/java/com/pahimar/ee3/recipe/RecipesPotions.java b/src/main/java/com/pahimar/ee3/recipe/RecipesPotions.java index b18cd4f4..e74a0d03 100644 --- a/src/main/java/com/pahimar/ee3/recipe/RecipesPotions.java +++ b/src/main/java/com/pahimar/ee3/recipe/RecipesPotions.java @@ -6,327 +6,822 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -public class RecipesPotions -{ - private static WrappedStack reagentWater = WrappedStack.wrap(new ItemStack(Blocks.water)); - private static WrappedStack reagentNetherWart = WrappedStack.wrap(new ItemStack(Items.nether_wart)); - private static WrappedStack reagentGlowstoneDust = WrappedStack.wrap(new ItemStack(Items.glowstone_dust)); - private static WrappedStack reagentRedstoneDust = WrappedStack.wrap(new ItemStack(Items.redstone)); - private static WrappedStack reagentGunpowder = WrappedStack.wrap(new ItemStack(Items.gunpowder)); - private static WrappedStack reagentGoldenCarrot = WrappedStack.wrap(new ItemStack(Items.golden_carrot)); - private static WrappedStack reagentMagmaCream = WrappedStack.wrap(new ItemStack(Items.magma_cream)); - private static WrappedStack reagentSugar = WrappedStack.wrap(new ItemStack(Items.sugar)); - private static WrappedStack reagentGlisteringMelon = WrappedStack.wrap(new ItemStack(Items.speckled_melon)); - private static WrappedStack reagentSpiderEye = WrappedStack.wrap(new ItemStack(Items.spider_eye)); - private static WrappedStack reagentGhastTear = WrappedStack.wrap(new ItemStack(Items.ghast_tear)); - private static WrappedStack reagentFermentedSpiderEye = WrappedStack.wrap(new ItemStack(Items.fermented_spider_eye)); - private static WrappedStack reagentBlazePowder = WrappedStack.wrap(new ItemStack(Items.blaze_powder)); +public class RecipesPotions { + private static WrappedStack reagentWater + = WrappedStack.wrap(new ItemStack(Blocks.water)); + private static WrappedStack reagentNetherWart + = WrappedStack.wrap(new ItemStack(Items.nether_wart)); + private static WrappedStack reagentGlowstoneDust + = WrappedStack.wrap(new ItemStack(Items.glowstone_dust)); + private static WrappedStack reagentRedstoneDust + = WrappedStack.wrap(new ItemStack(Items.redstone)); + private static WrappedStack reagentGunpowder + = WrappedStack.wrap(new ItemStack(Items.gunpowder)); + private static WrappedStack reagentGoldenCarrot + = WrappedStack.wrap(new ItemStack(Items.golden_carrot)); + private static WrappedStack reagentMagmaCream + = WrappedStack.wrap(new ItemStack(Items.magma_cream)); + private static WrappedStack reagentSugar + = WrappedStack.wrap(new ItemStack(Items.sugar)); + private static WrappedStack reagentGlisteringMelon + = WrappedStack.wrap(new ItemStack(Items.speckled_melon)); + private static WrappedStack reagentSpiderEye + = WrappedStack.wrap(new ItemStack(Items.spider_eye)); + private static WrappedStack reagentGhastTear + = WrappedStack.wrap(new ItemStack(Items.ghast_tear)); + private static WrappedStack reagentFermentedSpiderEye + = WrappedStack.wrap(new ItemStack(Items.fermented_spider_eye)); + private static WrappedStack reagentBlazePowder + = WrappedStack.wrap(new ItemStack(Items.blaze_powder)); private static WrappedStack bottleEmpty = WrappedStack.wrap(Items.glass_bottle); - private static WrappedStack bottleWater = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 0)); + private static WrappedStack bottleWater + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 0)); - private static WrappedStack potionAwkward = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16)); - private static WrappedStack potionAwkwardOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16)); - private static WrappedStack potionThickOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 32)); - private static WrappedStack potionMundane = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 128)); - private static WrappedStack potionMundaneOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 128)); - private static WrappedStack potionMundaneExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 64)); - private static WrappedStack potionMundaneExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 64)); - private static WrappedStack potionMundaneSplash = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16512)); - private static WrappedStack potionMundaneSplashOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16512)); - private static WrappedStack potionMundaneSplashExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16448)); - private static WrappedStack potionMundaneSplashExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16448)); + private static WrappedStack potionAwkward + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16)); + private static WrappedStack potionAwkwardOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16)); + private static WrappedStack potionThickOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 32)); + private static WrappedStack potionMundane + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 128)); + private static WrappedStack potionMundaneOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 128)); + private static WrappedStack potionMundaneExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 64)); + private static WrappedStack potionMundaneExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 64)); + private static WrappedStack potionMundaneSplash + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16512)); + private static WrappedStack potionMundaneSplashOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16512)); + private static WrappedStack potionMundaneSplashExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16448)); + private static WrappedStack potionMundaneSplashExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16448)); - private static WrappedStack potionRegeneration = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8193)); - private static WrappedStack potionRegenerationOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8193)); - private static WrappedStack potionRegenerationEnhanced = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8225)); - private static WrappedStack potionRegenerationEnhancedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8225)); - private static WrappedStack potionRegenerationExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8257)); - private static WrappedStack potionRegenerationExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8257)); - private static WrappedStack potionRegenerationSplash = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16385)); - private static WrappedStack potionRegenerationSplashOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16385)); - private static WrappedStack potionRegenerationSplashEnhanced = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16417)); - private static WrappedStack potionRegenerationSplashEnhancedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16417)); - private static WrappedStack potionRegenerationSplashExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16449)); - private static WrappedStack potionRegenerationSplashExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16449)); + private static WrappedStack potionRegeneration + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8193)); + private static WrappedStack potionRegenerationOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8193)); + private static WrappedStack potionRegenerationEnhanced + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8225)); + private static WrappedStack potionRegenerationEnhancedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8225)); + private static WrappedStack potionRegenerationExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8257)); + private static WrappedStack potionRegenerationExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8257)); + private static WrappedStack potionRegenerationSplash + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16385)); + private static WrappedStack potionRegenerationSplashOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16385)); + private static WrappedStack potionRegenerationSplashEnhanced + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16417)); + private static WrappedStack potionRegenerationSplashEnhancedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16417)); + private static WrappedStack potionRegenerationSplashExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16449)); + private static WrappedStack potionRegenerationSplashExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16449)); - private static WrappedStack potionSwiftness = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8194)); - private static WrappedStack potionSwiftnessOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8194)); - private static WrappedStack potionSwiftnessEnhanced = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8226)); - private static WrappedStack potionSwiftnessEnhancedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8226)); - private static WrappedStack potionSwiftnessExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8258)); - private static WrappedStack potionSwiftnessExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8258)); - private static WrappedStack potionSwiftnessSplash = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16386)); - private static WrappedStack potionSwiftnessSplashOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16386)); - private static WrappedStack potionSwiftnessSplashEnhanced = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16418)); - private static WrappedStack potionSwiftnessSplashEnhancedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16418)); - private static WrappedStack potionSwiftnessSplashExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16450)); - private static WrappedStack potionSwiftnessSplashExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16450)); + private static WrappedStack potionSwiftness + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8194)); + private static WrappedStack potionSwiftnessOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8194)); + private static WrappedStack potionSwiftnessEnhanced + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8226)); + private static WrappedStack potionSwiftnessEnhancedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8226)); + private static WrappedStack potionSwiftnessExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8258)); + private static WrappedStack potionSwiftnessExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8258)); + private static WrappedStack potionSwiftnessSplash + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16386)); + private static WrappedStack potionSwiftnessSplashOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16386)); + private static WrappedStack potionSwiftnessSplashEnhanced + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16418)); + private static WrappedStack potionSwiftnessSplashEnhancedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16418)); + private static WrappedStack potionSwiftnessSplashExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16450)); + private static WrappedStack potionSwiftnessSplashExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16450)); - private static WrappedStack potionFireResist = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8195)); - private static WrappedStack potionFireResistOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8195)); - private static WrappedStack potionFireResistExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8259)); - private static WrappedStack potionFireResistExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8259)); - private static WrappedStack potionFireResistSplash = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16387)); - private static WrappedStack potionFireResistSplashOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16387)); - private static WrappedStack potionFireResistSplashExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16451)); - private static WrappedStack potionFireResistSplashExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16451)); + private static WrappedStack potionFireResist + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8195)); + private static WrappedStack potionFireResistOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8195)); + private static WrappedStack potionFireResistExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8259)); + private static WrappedStack potionFireResistExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8259)); + private static WrappedStack potionFireResistSplash + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16387)); + private static WrappedStack potionFireResistSplashOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16387)); + private static WrappedStack potionFireResistSplashExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16451)); + private static WrappedStack potionFireResistSplashExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16451)); - private static WrappedStack potionPoison = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8196)); - private static WrappedStack potionPoisonOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8196)); - private static WrappedStack potionPoisonEnhanced = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8228)); - private static WrappedStack potionPoisonEnhancedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8228)); - private static WrappedStack potionPoisonExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8260)); - private static WrappedStack potionPoisonExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8260)); - private static WrappedStack potionPoisonSplash = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16388)); - private static WrappedStack potionPoisonSplashOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16388)); - private static WrappedStack potionPoisonSplashEnhanced = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16420)); - private static WrappedStack potionPoisonSplashEnhancedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16420)); - private static WrappedStack potionPoisonSplashExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16452)); - private static WrappedStack potionPoisonSplashExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16452)); + private static WrappedStack potionPoison + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8196)); + private static WrappedStack potionPoisonOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8196)); + private static WrappedStack potionPoisonEnhanced + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8228)); + private static WrappedStack potionPoisonEnhancedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8228)); + private static WrappedStack potionPoisonExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8260)); + private static WrappedStack potionPoisonExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8260)); + private static WrappedStack potionPoisonSplash + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16388)); + private static WrappedStack potionPoisonSplashOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16388)); + private static WrappedStack potionPoisonSplashEnhanced + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16420)); + private static WrappedStack potionPoisonSplashEnhancedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16420)); + private static WrappedStack potionPoisonSplashExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16452)); + private static WrappedStack potionPoisonSplashExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16452)); - private static WrappedStack potionHealing = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8197)); - private static WrappedStack potionHealingOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8197)); - private static WrappedStack potionHealingEnhanced = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8229)); - private static WrappedStack potionHealingEnhancedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8229)); - private static WrappedStack potionHealingSplash = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16389)); - private static WrappedStack potionHealingSplashOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16389)); - private static WrappedStack potionHealingSplashEnhanced = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16421)); - private static WrappedStack potionHealingSplashEnhancedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16421)); + private static WrappedStack potionHealing + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8197)); + private static WrappedStack potionHealingOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8197)); + private static WrappedStack potionHealingEnhanced + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8229)); + private static WrappedStack potionHealingEnhancedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8229)); + private static WrappedStack potionHealingSplash + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16389)); + private static WrappedStack potionHealingSplashOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16389)); + private static WrappedStack potionHealingSplashEnhanced + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16421)); + private static WrappedStack potionHealingSplashEnhancedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16421)); - private static WrappedStack potionNightVision = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8198)); - private static WrappedStack potionNightVisionOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8198)); - private static WrappedStack potionNightVisionExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8262)); - private static WrappedStack potionNightVisionExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8262)); - private static WrappedStack potionNightVisionSplash = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16390)); - private static WrappedStack potionNightVisionSplashOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16390)); - private static WrappedStack potionNightVisionSplashExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16454)); - private static WrappedStack potionNightVisionSplashExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16454)); + private static WrappedStack potionNightVision + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8198)); + private static WrappedStack potionNightVisionOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8198)); + private static WrappedStack potionNightVisionExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8262)); + private static WrappedStack potionNightVisionExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8262)); + private static WrappedStack potionNightVisionSplash + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16390)); + private static WrappedStack potionNightVisionSplashOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16390)); + private static WrappedStack potionNightVisionSplashExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16454)); + private static WrappedStack potionNightVisionSplashExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16454)); - private static WrappedStack potionWeakness = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8200)); - private static WrappedStack potionWeaknessOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8200)); - private static WrappedStack potionWeaknessExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8264)); - private static WrappedStack potionWeaknessExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8264)); - private static WrappedStack potionWeaknessSplash = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16392)); - private static WrappedStack potionWeaknessSplashOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16392)); - private static WrappedStack potionWeaknessSplashExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16456)); - private static WrappedStack potionWeaknessSplashExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16456)); + private static WrappedStack potionWeakness + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8200)); + private static WrappedStack potionWeaknessOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8200)); + private static WrappedStack potionWeaknessExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8264)); + private static WrappedStack potionWeaknessExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8264)); + private static WrappedStack potionWeaknessSplash + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16392)); + private static WrappedStack potionWeaknessSplashOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16392)); + private static WrappedStack potionWeaknessSplashExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16456)); + private static WrappedStack potionWeaknessSplashExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16456)); - private static WrappedStack potionStrength = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8201)); - private static WrappedStack potionStrengthOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8201)); - private static WrappedStack potionStrengthEnhanced = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8233)); - private static WrappedStack potionStrengthEnhancedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8233)); - private static WrappedStack potionStrengthExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8265)); - private static WrappedStack potionStrengthExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8265)); - private static WrappedStack potionStrengthSplash = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16393)); - private static WrappedStack potionStrengthSplashOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16393)); - private static WrappedStack potionStrengthSplashEnhanced = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16425)); - private static WrappedStack potionStrengthSplashEnhancedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16425)); - private static WrappedStack potionStrengthSplashExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16457)); - private static WrappedStack potionStrengthSplashExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16457)); + private static WrappedStack potionStrength + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8201)); + private static WrappedStack potionStrengthOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8201)); + private static WrappedStack potionStrengthEnhanced + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8233)); + private static WrappedStack potionStrengthEnhancedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8233)); + private static WrappedStack potionStrengthExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8265)); + private static WrappedStack potionStrengthExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8265)); + private static WrappedStack potionStrengthSplash + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16393)); + private static WrappedStack potionStrengthSplashOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16393)); + private static WrappedStack potionStrengthSplashEnhanced + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16425)); + private static WrappedStack potionStrengthSplashEnhancedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16425)); + private static WrappedStack potionStrengthSplashExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16457)); + private static WrappedStack potionStrengthSplashExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16457)); - private static WrappedStack potionSlowness = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8202)); - private static WrappedStack potionSlownessOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8202)); - private static WrappedStack potionSlownessExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8266)); - private static WrappedStack potionSlownessExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8266)); - private static WrappedStack potionSlownessSplash = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16394)); - private static WrappedStack potionSlownessSplashOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16394)); - private static WrappedStack potionSlownessSplashExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16458)); - private static WrappedStack potionSlownessSplashExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16458)); + private static WrappedStack potionSlowness + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8202)); + private static WrappedStack potionSlownessOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8202)); + private static WrappedStack potionSlownessExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8266)); + private static WrappedStack potionSlownessExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8266)); + private static WrappedStack potionSlownessSplash + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16394)); + private static WrappedStack potionSlownessSplashOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16394)); + private static WrappedStack potionSlownessSplashExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16458)); + private static WrappedStack potionSlownessSplashExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16458)); - private static WrappedStack potionHarming = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8204)); - private static WrappedStack potionHarmingOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8204)); - private static WrappedStack potionHarmingEnhanced = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8236)); - private static WrappedStack potionHarmingEnhancedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8236)); - private static WrappedStack potionHarmingSplash = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16396)); - private static WrappedStack potionHarmingSplashOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16396)); - private static WrappedStack potionHarmingSplashEnhanced = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16428)); - private static WrappedStack potionHarmingSplashEnhancedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16428)); + private static WrappedStack potionHarming + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8204)); + private static WrappedStack potionHarmingOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8204)); + private static WrappedStack potionHarmingEnhanced + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8236)); + private static WrappedStack potionHarmingEnhancedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8236)); + private static WrappedStack potionHarmingSplash + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16396)); + private static WrappedStack potionHarmingSplashOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16396)); + private static WrappedStack potionHarmingSplashEnhanced + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16428)); + private static WrappedStack potionHarmingSplashEnhancedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16428)); - private static WrappedStack potionInvisibility = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8206)); - private static WrappedStack potionInvisibilityOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8206)); - private static WrappedStack potionInvisibilityExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8270)); - private static WrappedStack potionInvisibilityExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8270)); - private static WrappedStack potionInvisibilitySplash = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16398)); - private static WrappedStack potionInvisibilitySplashOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16398)); - private static WrappedStack potionInvisibilitySplashExtended = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16462)); - private static WrappedStack potionInvisibilitySplashExtendedOutput = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16462)); + private static WrappedStack potionInvisibility + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8206)); + private static WrappedStack potionInvisibilityOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8206)); + private static WrappedStack potionInvisibilityExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 8270)); + private static WrappedStack potionInvisibilityExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 8270)); + private static WrappedStack potionInvisibilitySplash + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16398)); + private static WrappedStack potionInvisibilitySplashOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16398)); + private static WrappedStack potionInvisibilitySplashExtended + = WrappedStack.wrap(new ItemStack(Items.potionitem, 1, 16462)); + private static WrappedStack potionInvisibilitySplashExtendedOutput + = WrappedStack.wrap(new ItemStack(Items.potionitem, 3, 16462)); public void registerRecipes() { - RecipeRegistryProxy.addRecipe(bottleWater, bottleEmpty, reagentWater); - RecipeRegistryProxy.addRecipe(potionAwkwardOutput, bottleWater, reagentNetherWart); + RecipeRegistryProxy.addRecipe( + potionAwkwardOutput, bottleWater, reagentNetherWart + ); - RecipeRegistryProxy.addRecipe(potionNightVisionOutput, potionAwkward, reagentGoldenCarrot); - RecipeRegistryProxy.addRecipe(potionNightVisionOutput, potionNightVisionExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionNightVisionSplashOutput, potionNightVisionSplashExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionNightVisionSplashOutput, potionNightVision, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionNightVisionOutput, potionAwkward, reagentGoldenCarrot + ); + RecipeRegistryProxy.addRecipe( + potionNightVisionOutput, potionNightVisionExtended, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionNightVisionSplashOutput, + potionNightVisionSplashExtended, + reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionNightVisionSplashOutput, potionNightVision, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionNightVisionExtendedOutput, potionNightVision, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionNightVisionSplashExtendedOutput, potionNightVisionSplash, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionNightVisionSplashExtendedOutput, potionNightVisionExtended, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionNightVisionExtendedOutput, potionNightVision, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionNightVisionSplashExtendedOutput, + potionNightVisionSplash, + reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionNightVisionSplashExtendedOutput, + potionNightVisionExtended, + reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionInvisibilityOutput, potionNightVision, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionInvisibilityOutput, potionInvisibilityExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionInvisibilitySplashOutput, potionNightVisionSplash, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionInvisibilitySplashOutput, potionInvisibilitySplashExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionInvisibilitySplashOutput, potionInvisibility, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionInvisibilityOutput, potionNightVision, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionInvisibilityOutput, potionInvisibilityExtended, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionInvisibilitySplashOutput, + potionNightVisionSplash, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionInvisibilitySplashOutput, + potionInvisibilitySplashExtended, + reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionInvisibilitySplashOutput, potionInvisibility, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionInvisibilityExtendedOutput, potionInvisibility, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionInvisibilityExtendedOutput, potionNightVisionExtended, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionInvisibilitySplashExtendedOutput, potionInvisibilitySplash, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionInvisibilitySplashExtendedOutput, potionNightVisionSplashExtended, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionInvisibilitySplashExtendedOutput, potionInvisibilityExtended, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionInvisibilityExtendedOutput, potionInvisibility, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionInvisibilityExtendedOutput, + potionNightVisionExtended, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionInvisibilitySplashExtendedOutput, + potionInvisibilitySplash, + reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionInvisibilitySplashExtendedOutput, + potionNightVisionSplashExtended, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionInvisibilitySplashExtendedOutput, + potionInvisibilityExtended, + reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionFireResistOutput, potionAwkward, reagentMagmaCream); - RecipeRegistryProxy.addRecipe(potionFireResistOutput, potionFireResistExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionFireResistSplashOutput, potionFireResistSplashExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionFireResistSplashOutput, potionFireResist, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionFireResistOutput, potionAwkward, reagentMagmaCream + ); + RecipeRegistryProxy.addRecipe( + potionFireResistOutput, potionFireResistExtended, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionFireResistSplashOutput, + potionFireResistSplashExtended, + reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionFireResistSplashOutput, potionFireResist, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionFireResistExtendedOutput, potionFireResist, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionFireResistSplashExtendedOutput, potionFireResistSplash, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionFireResistSplashExtendedOutput, potionFireResistExtended, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionFireResistExtendedOutput, potionFireResist, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionFireResistSplashExtendedOutput, + potionFireResistSplash, + reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionFireResistSplashExtendedOutput, + potionFireResistExtended, + reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionSlownessOutput, potionFireResist, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionSlownessOutput, potionSlownessExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionSlownessOutput, potionSwiftness, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionSlownessOutput, potionSwiftnessExtended, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionSlownessSplashOutput, potionFireResistSplash, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionSlownessSplashOutput, potionSlownessSplashExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionSlownessSplashOutput, potionSwiftnessSplash, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionSlownessSplashOutput, potionSwiftnessSplashExtended, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionSlownessSplashOutput, potionSlowness, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionSlownessOutput, potionFireResist, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionSlownessOutput, potionSlownessExtended, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionSlownessOutput, potionSwiftness, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionSlownessOutput, potionSwiftnessExtended, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionSlownessSplashOutput, potionFireResistSplash, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionSlownessSplashOutput, potionSlownessSplashExtended, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionSlownessSplashOutput, potionSwiftnessSplash, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionSlownessSplashOutput, + potionSwiftnessSplashExtended, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionSlownessSplashOutput, potionSlowness, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionSlownessExtendedOutput, potionFireResistExtended, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionSlownessExtendedOutput, potionSwiftnessEnhanced, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionSlownessSplashExtendedOutput, potionFireResistSplashExtended, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionSlownessSplashExtendedOutput, potionSwiftnessSplashEnhanced, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionSlownessSplashExtendedOutput, potionSlownessExtended, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionSlownessExtendedOutput, + potionFireResistExtended, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionSlownessExtendedOutput, + potionSwiftnessEnhanced, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionSlownessSplashExtendedOutput, + potionFireResistSplashExtended, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionSlownessSplashExtendedOutput, + potionSwiftnessSplashEnhanced, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionSlownessSplashExtendedOutput, potionSlownessExtended, reagentGunpowder + ); RecipeRegistryProxy.addRecipe(potionSwiftnessOutput, potionAwkward, reagentSugar); - RecipeRegistryProxy.addRecipe(potionSwiftnessSplashOutput, potionSwiftness, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionSwiftnessSplashOutput, potionSwiftness, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionSwiftnessExtendedOutput, potionSwiftness, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionSwiftnessExtendedOutput, potionSwiftnessEnhanced, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionSwiftnessSplashExtendedOutput, potionSwiftnessSplash, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionSwiftnessSplashExtendedOutput, potionSwiftnessSplashEnhanced, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionSwiftnessSplashExtendedOutput, potionSwiftnessExtended, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionSwiftnessExtendedOutput, potionSwiftness, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionSwiftnessExtendedOutput, potionSwiftnessEnhanced, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionSwiftnessSplashExtendedOutput, + potionSwiftnessSplash, + reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionSwiftnessSplashExtendedOutput, + potionSwiftnessSplashEnhanced, + reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionSwiftnessSplashExtendedOutput, potionSwiftnessExtended, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionSwiftnessEnhancedOutput, potionSwiftness, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionSwiftnessEnhancedOutput, potionSwiftnessExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionSwiftnessSplashEnhancedOutput, potionSwiftnessSplash, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionSwiftnessSplashEnhancedOutput, potionSwiftnessSplashExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionSwiftnessSplashEnhancedOutput, potionSwiftnessEnhanced, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionSwiftnessEnhancedOutput, potionSwiftness, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionSwiftnessEnhancedOutput, potionSwiftnessExtended, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionSwiftnessSplashEnhancedOutput, + potionSwiftnessSplash, + reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionSwiftnessSplashEnhancedOutput, + potionSwiftnessSplashExtended, + reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionSwiftnessSplashEnhancedOutput, potionSwiftnessEnhanced, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionHealingOutput, potionAwkward, reagentGlisteringMelon); - RecipeRegistryProxy.addRecipe(potionHealingOutput, potionHealingEnhanced, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionHealingSplashOutput, potionHealingSplashEnhanced, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionHealingSplashOutput, potionHealing, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionHealingOutput, potionAwkward, reagentGlisteringMelon + ); + RecipeRegistryProxy.addRecipe( + potionHealingOutput, potionHealingEnhanced, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionHealingSplashOutput, potionHealingSplashEnhanced, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionHealingSplashOutput, potionHealing, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionHealingEnhancedOutput, potionHealing, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionHealingSplashEnhancedOutput, potionHealingSplash, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionHealingSplashEnhancedOutput, potionHealingEnhanced, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionHealingEnhancedOutput, potionHealing, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionHealingSplashEnhancedOutput, potionHealingSplash, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionHealingSplashEnhancedOutput, potionHealingEnhanced, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionHarmingOutput, potionHealing, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionHarmingOutput, potionPoison, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionHarmingOutput, potionPoisonExtended, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionHarmingOutput, potionHarmingEnhanced, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionHarmingSplashOutput, potionHealingSplash, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionHarmingSplashOutput, potionPoisonSplash, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionHarmingSplashOutput, potionPoisonSplashExtended, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionHarmingSplashOutput, potionHarmingSplashEnhanced, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionHarmingSplashOutput, potionHarming, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionHarmingOutput, potionHealing, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionHarmingOutput, potionPoison, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionHarmingOutput, potionPoisonExtended, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionHarmingOutput, potionHarmingEnhanced, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionHarmingSplashOutput, potionHealingSplash, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionHarmingSplashOutput, potionPoisonSplash, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionHarmingSplashOutput, + potionPoisonSplashExtended, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionHarmingSplashOutput, potionHarmingSplashEnhanced, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionHarmingSplashOutput, potionHarming, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionHarmingEnhancedOutput, potionHealingEnhanced, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionHarmingEnhancedOutput, potionHarming, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionHarmingEnhancedOutput, potionPoisonEnhanced, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionHarmingSplashEnhancedOutput, potionHealingSplashEnhanced, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionHarmingSplashEnhancedOutput, potionHarmingSplash, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionHarmingSplashEnhancedOutput, potionPoisonSplashEnhanced, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionHarmingSplashEnhancedOutput, potionHarmingEnhanced, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionHarmingEnhancedOutput, potionHealingEnhanced, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionHarmingEnhancedOutput, potionHarming, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionHarmingEnhancedOutput, potionPoisonEnhanced, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionHarmingSplashEnhancedOutput, + potionHealingSplashEnhanced, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionHarmingSplashEnhancedOutput, potionHarmingSplash, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionHarmingSplashEnhancedOutput, + potionPoisonSplashEnhanced, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionHarmingSplashEnhancedOutput, potionHarmingEnhanced, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionPoisonOutput, potionAwkward, reagentSpiderEye); - RecipeRegistryProxy.addRecipe(potionPoisonSplashOutput, potionPoison, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionPoisonOutput, potionAwkward, reagentSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionPoisonSplashOutput, potionPoison, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionPoisonExtendedOutput, potionPoisonExtended, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionPoisonExtendedOutput, potionPoisonEnhanced, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionPoisonSplashExtendedOutput, potionPoisonSplashExtended, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionPoisonSplashExtendedOutput, potionPoisonSplashEnhanced, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionPoisonSplashExtendedOutput, potionPoisonExtended, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionPoisonExtendedOutput, potionPoisonExtended, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionPoisonExtendedOutput, potionPoisonEnhanced, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionPoisonSplashExtendedOutput, + potionPoisonSplashExtended, + reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionPoisonSplashExtendedOutput, + potionPoisonSplashEnhanced, + reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionPoisonSplashExtendedOutput, potionPoisonExtended, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionPoisonEnhancedOutput, potionPoison, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionPoisonEnhancedOutput, potionPoisonExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionPoisonSplashEnhancedOutput, potionPoisonSplash, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionPoisonSplashEnhancedOutput, potionPoisonSplashExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionPoisonSplashEnhancedOutput, potionPoisonEnhanced, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionPoisonEnhancedOutput, potionPoison, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionPoisonEnhancedOutput, potionPoisonExtended, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionPoisonSplashEnhancedOutput, potionPoisonSplash, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionPoisonSplashEnhancedOutput, + potionPoisonSplashExtended, + reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionPoisonSplashEnhancedOutput, potionPoisonEnhanced, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionRegenerationOutput, potionAwkward, reagentGhastTear); - RecipeRegistryProxy.addRecipe(potionRegenerationSplashOutput, potionRegeneration, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionRegenerationOutput, potionAwkward, reagentGhastTear + ); + RecipeRegistryProxy.addRecipe( + potionRegenerationSplashOutput, potionRegeneration, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionRegenerationExtendedOutput, potionRegeneration, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionRegenerationExtendedOutput, potionRegenerationEnhanced, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionRegenerationSplashExtendedOutput, potionRegenerationSplash, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionRegenerationSplashExtendedOutput, potionRegenerationSplashEnhanced, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionRegenerationSplashExtendedOutput, potionRegenerationExtended, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionRegenerationExtendedOutput, potionRegeneration, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionRegenerationExtendedOutput, + potionRegenerationEnhanced, + reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionRegenerationSplashExtendedOutput, + potionRegenerationSplash, + reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionRegenerationSplashExtendedOutput, + potionRegenerationSplashEnhanced, + reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionRegenerationSplashExtendedOutput, + potionRegenerationExtended, + reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionRegenerationEnhancedOutput, potionRegeneration, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionRegenerationEnhancedOutput, potionRegenerationExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionRegenerationSplashEnhancedOutput, potionRegenerationSplash, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionRegenerationSplashEnhancedOutput, potionRegenerationSplashExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionRegenerationSplashEnhancedOutput, potionRegenerationEnhanced, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionRegenerationEnhancedOutput, potionRegeneration, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionRegenerationEnhancedOutput, + potionRegenerationExtended, + reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionRegenerationSplashEnhancedOutput, + potionRegenerationSplash, + reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionRegenerationSplashEnhancedOutput, + potionRegenerationSplashExtended, + reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionRegenerationSplashEnhancedOutput, + potionRegenerationEnhanced, + reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionWeaknessOutput, potionAwkward, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionWeaknessOutput, potionRegeneration, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionWeaknessOutput, potionRegenerationEnhanced, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionWeaknessOutput, potionStrength, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionWeaknessOutput, potionStrengthEnhanced, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionWeaknessOutput, potionMundane, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionWeaknessOutput, potionWeaknessExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionWeaknessSplashOutput, potionRegenerationSplash, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionWeaknessSplashOutput, potionRegenerationSplashEnhanced, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionWeaknessSplashOutput, potionStrengthSplash, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionWeaknessSplashOutput, potionStrengthSplashEnhanced, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionWeaknessSplashOutput, potionMundaneSplash, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionWeaknessSplashOutput, potionWeaknessSplashExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionWeaknessSplashOutput, potionWeakness, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionWeaknessOutput, potionAwkward, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessOutput, potionRegeneration, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessOutput, potionRegenerationEnhanced, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessOutput, potionStrength, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessOutput, potionStrengthEnhanced, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessOutput, potionMundane, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessOutput, potionWeaknessExtended, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessSplashOutput, + potionRegenerationSplash, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessSplashOutput, + potionRegenerationSplashEnhanced, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessSplashOutput, potionStrengthSplash, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessSplashOutput, + potionStrengthSplashEnhanced, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessSplashOutput, potionMundaneSplash, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessSplashOutput, potionWeaknessSplashExtended, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessSplashOutput, potionWeakness, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionWeaknessExtendedOutput, potionWeakness, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionWeaknessExtendedOutput, potionRegenerationExtended, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionWeaknessExtendedOutput, potionStrengthExtended, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionWeaknessExtendedOutput, potionMundaneExtended, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionWeaknessSplashExtendedOutput, potionWeaknessSplash, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionWeaknessSplashExtendedOutput, potionRegenerationSplashExtended, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionWeaknessSplashExtendedOutput, potionStrengthSplashExtended, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionWeaknessSplashExtendedOutput, potionMundaneSplashExtended, reagentFermentedSpiderEye); - RecipeRegistryProxy.addRecipe(potionWeaknessSplashExtendedOutput, potionWeaknessExtended, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionWeaknessExtendedOutput, potionWeakness, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessExtendedOutput, + potionRegenerationExtended, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessExtendedOutput, + potionStrengthExtended, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessExtendedOutput, potionMundaneExtended, reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessSplashExtendedOutput, potionWeaknessSplash, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessSplashExtendedOutput, + potionRegenerationSplashExtended, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessSplashExtendedOutput, + potionStrengthSplashExtended, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessSplashExtendedOutput, + potionMundaneSplashExtended, + reagentFermentedSpiderEye + ); + RecipeRegistryProxy.addRecipe( + potionWeaknessSplashExtendedOutput, potionWeaknessExtended, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionStrengthOutput, potionAwkward, reagentBlazePowder); - RecipeRegistryProxy.addRecipe(potionStrengthSplashOutput, potionStrength, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionStrengthOutput, potionAwkward, reagentBlazePowder + ); + RecipeRegistryProxy.addRecipe( + potionStrengthSplashOutput, potionStrength, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionStrengthEnhancedOutput, potionStrength, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionStrengthEnhancedOutput, potionStrengthExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionStrengthSplashEnhancedOutput, potionStrengthSplash, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionStrengthSplashEnhancedOutput, potionStrengthSplashExtended, reagentGlowstoneDust); - RecipeRegistryProxy.addRecipe(potionStrengthSplashEnhancedOutput, potionStrengthEnhanced, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionStrengthEnhancedOutput, potionStrength, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionStrengthEnhancedOutput, potionStrengthExtended, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionStrengthSplashEnhancedOutput, potionStrengthSplash, reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionStrengthSplashEnhancedOutput, + potionStrengthSplashExtended, + reagentGlowstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionStrengthSplashEnhancedOutput, potionStrengthEnhanced, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionStrengthExtendedOutput, potionStrength, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionStrengthExtendedOutput, potionStrengthEnhanced, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionStrengthSplashExtendedOutput, potionStrengthSplash, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionStrengthSplashExtendedOutput, potionStrengthSplashEnhanced, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionStrengthSplashExtendedOutput, potionStrengthExtended, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionStrengthExtendedOutput, potionStrength, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionStrengthExtendedOutput, potionStrengthEnhanced, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionStrengthSplashExtendedOutput, potionStrengthSplash, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionStrengthSplashExtendedOutput, + potionStrengthSplashEnhanced, + reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionStrengthSplashExtendedOutput, potionStrengthExtended, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionThickOutput, bottleWater, reagentGlowstoneDust); + RecipeRegistryProxy.addRecipe( + potionThickOutput, bottleWater, reagentGlowstoneDust + ); RecipeRegistryProxy.addRecipe(potionMundaneOutput, bottleWater, reagentSugar); - RecipeRegistryProxy.addRecipe(potionMundaneOutput, bottleWater, reagentGlisteringMelon); + RecipeRegistryProxy.addRecipe( + potionMundaneOutput, bottleWater, reagentGlisteringMelon + ); RecipeRegistryProxy.addRecipe(potionMundaneOutput, bottleWater, reagentSpiderEye); - RecipeRegistryProxy.addRecipe(potionMundaneOutput, bottleWater, reagentBlazePowder); - RecipeRegistryProxy.addRecipe(potionMundaneOutput, bottleWater, reagentMagmaCream); + RecipeRegistryProxy.addRecipe( + potionMundaneOutput, bottleWater, reagentBlazePowder + ); + RecipeRegistryProxy.addRecipe( + potionMundaneOutput, bottleWater, reagentMagmaCream + ); RecipeRegistryProxy.addRecipe(potionMundaneOutput, bottleWater, reagentGhastTear); - RecipeRegistryProxy.addRecipe(potionMundaneSplashOutput, potionMundane, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionMundaneSplashOutput, potionMundane, reagentGunpowder + ); - RecipeRegistryProxy.addRecipe(potionMundaneExtendedOutput, bottleWater, reagentRedstoneDust); - RecipeRegistryProxy.addRecipe(potionMundaneSplashExtendedOutput, potionMundaneExtended, reagentGunpowder); + RecipeRegistryProxy.addRecipe( + potionMundaneExtendedOutput, bottleWater, reagentRedstoneDust + ); + RecipeRegistryProxy.addRecipe( + potionMundaneSplashExtendedOutput, potionMundaneExtended, reagentGunpowder + ); } } diff --git a/src/main/java/com/pahimar/ee3/recipe/RecipesVanilla.java b/src/main/java/com/pahimar/ee3/recipe/RecipesVanilla.java index 23190b68..5e9813a1 100644 --- a/src/main/java/com/pahimar/ee3/recipe/RecipesVanilla.java +++ b/src/main/java/com/pahimar/ee3/recipe/RecipesVanilla.java @@ -1,5 +1,8 @@ package com.pahimar.ee3.recipe; +import java.util.Arrays; +import java.util.List; + import com.pahimar.ee3.api.recipe.RecipeRegistryProxy; import com.pahimar.ee3.exchange.OreStack; import com.pahimar.ee3.exchange.WrappedStack; @@ -14,23 +17,20 @@ import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; -import java.util.Arrays; -import java.util.List; - public class RecipesVanilla { - public void registerRecipes() { - for (Object recipeObject : CraftingManager.getInstance().getRecipeList()) { - // Vanilla - if (recipeObject instanceof ShapedRecipes || recipeObject instanceof ShapelessRecipes || recipeObject instanceof ShapedOreRecipe || recipeObject instanceof ShapelessOreRecipe) { + if (recipeObject instanceof ShapedRecipes + || recipeObject instanceof ShapelessRecipes + || recipeObject instanceof ShapedOreRecipe + || recipeObject instanceof ShapelessOreRecipe) { IRecipe recipe = (IRecipe) recipeObject; ItemStack recipeOutput = recipe.getRecipeOutput(); if (recipeOutput != null) { - - List recipeInputs = RecipeHelper.getRecipeInputs(recipe); + List recipeInputs + = RecipeHelper.getRecipeInputs(recipe); if (!recipeInputs.isEmpty()) { RecipeRegistryProxy.addRecipe(recipeOutput, recipeInputs); @@ -39,7 +39,15 @@ public class RecipesVanilla { } } - // Fixes for OreDictionary entries that may not exist (because the OreDictionary entry has nothing in it) - RecipeRegistryProxy.addRecipe(new ItemStack(Blocks.daylight_detector), Arrays.asList(new ItemStack(Blocks.glass, 3, OreDictionary.WILDCARD_VALUE), new OreStack("slabWood", 3), new OreStack("gemQuartz", 3))); + // Fixes for OreDictionary entries that may not exist (because the OreDictionary + // entry has nothing in it) + RecipeRegistryProxy.addRecipe( + new ItemStack(Blocks.daylight_detector), + Arrays.asList( + new ItemStack(Blocks.glass, 3, OreDictionary.WILDCARD_VALUE), + new OreStack("slabWood", 3), + new OreStack("gemQuartz", 3) + ) + ); } } diff --git a/src/main/java/com/pahimar/ee3/reference/Colors.java b/src/main/java/com/pahimar/ee3/reference/Colors.java index 60a8dd91..e08f81ed 100644 --- a/src/main/java/com/pahimar/ee3/reference/Colors.java +++ b/src/main/java/com/pahimar/ee3/reference/Colors.java @@ -1,7 +1,6 @@ package com.pahimar.ee3.reference; -public class Colors -{ +public class Colors { public static final String PURE_WHITE = "ffffff"; // Alchemical Dust @@ -9,7 +8,8 @@ public class Colors public static final String DUST_VERDANT = "45CC39"; public static final String DUST_AZURE = "35A6DE"; public static final String DUST_MINIUM = "FF4545"; - public static final String[] DUST_COLOURS = new String[]{DUST_ASH, DUST_VERDANT, DUST_AZURE, DUST_MINIUM}; + public static final String[] DUST_COLOURS + = new String[] { DUST_ASH, DUST_VERDANT, DUST_AZURE, DUST_MINIUM }; // Text public static final String TEXT_COLOUR_PREFIX_YELLOW = "\u00a7e"; diff --git a/src/main/java/com/pahimar/ee3/reference/Comparators.java b/src/main/java/com/pahimar/ee3/reference/Comparators.java index 1d4f06ff..2269846b 100644 --- a/src/main/java/com/pahimar/ee3/reference/Comparators.java +++ b/src/main/java/com/pahimar/ee3/reference/Comparators.java @@ -1,206 +1,204 @@ package com.pahimar.ee3.reference; +import java.util.Collection; +import java.util.Comparator; +import java.util.Set; + import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; import com.pahimar.ee3.exchange.WrappedStack; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; -import java.util.Collection; -import java.util.Comparator; -import java.util.Set; - public class Comparators { + public static final Comparator> ITEM_STACK_COLLECTION_COMPARATOR + = new Comparator>() { + @Override + public int compare(Collection o1, Collection o2) { + if (o1 != null && o2 != null) { + if (o1.size() == o2.size()) { + if (o1.containsAll(o2)) { + if (o2.containsAll(o1)) { + return 0; + } else { + return 1; + } + } else { + return -1; + } + } else { + return o1.size() - o2.size(); + } + } else if (o1 != null) { + return -1; + } else if (o2 != null) { + return 1; + } else { + return 0; + } + } + }; - public static final Comparator> ITEM_STACK_COLLECTION_COMPARATOR = new Comparator>() { - @Override - public int compare(Collection o1, Collection o2) { + public static final Comparator> WRAPPED_STACK_SET_COMPARATOR + = new Comparator>() { + @Override + public int compare( + Set collection1, Set collection2 + ) { + if (collection1 != null && collection2 != null) { + if (collection1.size() == collection2.size()) { + if (collection1.containsAll(collection2)) { + if (collection2.containsAll(collection1)) { + return 0; + } else { + return 1; + } + } else { + return -1; + } + } else { + return collection1.size() - collection2.size(); + } + } else if (collection1 != null) { + return -1; + } else if (collection2 != null) { + return 1; + } else { + return 0; + } + } + }; - if (o1 != null && o2 != null) { - if (o1.size() == o2.size()) { - if (o1.containsAll(o2)) { - if (o2.containsAll(o1)) { - return 0; - } - else { - return 1; - } - } - else { - return -1; - } - } - else { - return o1.size() - o2.size(); - } - } - else if (o1 != null) { - return -1; - } - else if (o2 != null) { - return 1; - } - else { - return 0; - } - } - }; + public static final Comparator STRING_COMPARATOR + = String::compareToIgnoreCase; - public static final Comparator> WRAPPED_STACK_SET_COMPARATOR = new Comparator>() { - @Override - public int compare(Set collection1, Set collection2) { + public static final Comparator ID_COMPARATOR + = new Comparator() { + @Override + public int compare(ItemStack itemStack1, ItemStack itemStack2) { + if (itemStack1 != null && itemStack2 != null) { + if (itemStack1.getItem() != null && itemStack2.getItem() != null) { + // Sort on id + if (Item.getIdFromItem(itemStack1.getItem()) + - Item.getIdFromItem(itemStack2.getItem()) + == 0) { + // Sort on item + if (itemStack1.getItem() == itemStack2.getItem()) { + // Then sort on meta + if ((itemStack1.getItemDamage() + == itemStack2.getItemDamage()) + || itemStack1.getItemDamage() + == OreDictionary.WILDCARD_VALUE + || itemStack2.getItemDamage() + == OreDictionary.WILDCARD_VALUE) { + // Then sort on NBT + if (itemStack1.hasTagCompound() + && itemStack2.hasTagCompound()) { + // Then sort on stack size + if (ItemStack.areItemStackTagsEqual( + itemStack1, itemStack2 + )) { + return ( + itemStack1.stackSize + - itemStack2.stackSize + ); + } else { + return ( + itemStack1.getTagCompound().hashCode() + - itemStack2.getTagCompound().hashCode() + ); + } + } else if (!(itemStack1.hasTagCompound()) && itemStack2.hasTagCompound()) { + return -1; + } else if (itemStack1.hasTagCompound() && !(itemStack2.hasTagCompound())) { + return 1; + } else { + return ( + itemStack1.stackSize - itemStack2.stackSize + ); + } + } else { + return ( + itemStack1.getItemDamage() + - itemStack2.getItemDamage() + ); + } + } else { + return itemStack1.getItem() + .getUnlocalizedName(itemStack1) + .compareToIgnoreCase( + itemStack2.getItem().getUnlocalizedName( + itemStack2 + ) + ); + } + } else { + return Item.getIdFromItem(itemStack1.getItem()) + - Item.getIdFromItem(itemStack2.getItem()); + } + } else if (itemStack1.getItem() != null) { + return -1; + } else if (itemStack2.getItem() != null) { + return 1; + } else { + return 0; + } + } else if (itemStack1 != null) { + return -1; + } else if (itemStack2 != null) { + return 1; + } else { + return 0; + } + } + }; - if (collection1 != null && collection2 != null) { - if (collection1.size() == collection2.size()) { - if (collection1.containsAll(collection2)) { - if (collection2.containsAll(collection1)) { - return 0; - } - else { - return 1; - } - } - else { - return -1; - } - } - else { - return collection1.size() - collection2.size(); - } - } - else if (collection1 != null) { - return -1; - } - else if (collection2 != null) { - return 1; - } - else { - return 0; - } - } - }; + public static final Comparator DISPLAY_NAME_COMPARATOR + = new Comparator() { + @Override + public int compare(ItemStack itemStack1, ItemStack itemStack2) { + if (itemStack1 != null && itemStack2 != null) { + if (itemStack1.getDisplayName().equalsIgnoreCase( + itemStack2.getDisplayName() + )) { + return ID_COMPARATOR.compare(itemStack1, itemStack2); + } else { + return itemStack1.getDisplayName().compareToIgnoreCase( + itemStack2.getDisplayName() + ); + } + } else if (itemStack1 != null) { + return -1; + } else if (itemStack2 != null) { + return 1; + } else { + return 0; + } + } + }; - public static final Comparator STRING_COMPARATOR = String::compareToIgnoreCase; - - public static final Comparator ID_COMPARATOR = new Comparator() { - - @Override - public int compare(ItemStack itemStack1, ItemStack itemStack2) { - - if (itemStack1 != null && itemStack2 != null) { - if (itemStack1.getItem() != null && itemStack2.getItem() != null) { - // Sort on id - if (Item.getIdFromItem(itemStack1.getItem()) - Item.getIdFromItem(itemStack2.getItem()) == 0) { - // Sort on item - if (itemStack1.getItem() == itemStack2.getItem()) { - // Then sort on meta - if ((itemStack1.getItemDamage() == itemStack2.getItemDamage()) || itemStack1.getItemDamage() == OreDictionary.WILDCARD_VALUE || itemStack2.getItemDamage() == OreDictionary.WILDCARD_VALUE) { - // Then sort on NBT - if (itemStack1.hasTagCompound() && itemStack2.hasTagCompound()) { - // Then sort on stack size - if (ItemStack.areItemStackTagsEqual(itemStack1, itemStack2)) { - return (itemStack1.stackSize - itemStack2.stackSize); - } else { - return (itemStack1.getTagCompound().hashCode() - itemStack2.getTagCompound().hashCode()); - } - } else if (!(itemStack1.hasTagCompound()) && itemStack2.hasTagCompound()) { - return -1; - } else if (itemStack1.hasTagCompound() && !(itemStack2.hasTagCompound())) { - return 1; - } else { - return (itemStack1.stackSize - itemStack2.stackSize); - } - } else { - return (itemStack1.getItemDamage() - itemStack2.getItemDamage()); - } - } else { - return itemStack1.getItem().getUnlocalizedName(itemStack1).compareToIgnoreCase(itemStack2.getItem().getUnlocalizedName(itemStack2)); - } + public static final Comparator + ENERGY_VALUE_ITEM_STACK_COMPARATOR = new Comparator() { + @Override + public int compare(ItemStack itemStack1, ItemStack itemStack2) { + if (itemStack1 != null && itemStack2 != null) { + if (EnergyValueRegistryProxy.hasEnergyValue(itemStack1) + && EnergyValueRegistryProxy.hasEnergyValue(itemStack2)) { + return Float.compare( + EnergyValueRegistryProxy.getEnergyValue(itemStack1) + .getValue(), + EnergyValueRegistryProxy.getEnergyValue(itemStack2).getValue() + ); } else { - return Item.getIdFromItem(itemStack1.getItem()) - Item.getIdFromItem(itemStack2.getItem()); + return ID_COMPARATOR.compare(itemStack1, itemStack2); } - } - else if (itemStack1.getItem() != null) { + } else if (itemStack1 != null) { return -1; - } - else if (itemStack2.getItem() != null) { + } else if (itemStack2 != null) { return 1; - } - else { + } else { return 0; } } - else if (itemStack1 != null) { - return -1; - } - else if (itemStack2 != null) { - return 1; - } - else { - return 0; - } - } - }; - - public static final Comparator DISPLAY_NAME_COMPARATOR = new Comparator() { - - @Override - public int compare(ItemStack itemStack1, ItemStack itemStack2) - { - if (itemStack1 != null && itemStack2 != null) - { - if (itemStack1.getDisplayName().equalsIgnoreCase(itemStack2.getDisplayName())) - { - return ID_COMPARATOR.compare(itemStack1, itemStack2); - } - else - { - return itemStack1.getDisplayName().compareToIgnoreCase(itemStack2.getDisplayName()); - } - } - else if (itemStack1 != null) - { - return -1; - } - else if (itemStack2 != null) - { - return 1; - } - else - { - return 0; - } - } - }; - - public static final Comparator ENERGY_VALUE_ITEM_STACK_COMPARATOR = new Comparator() { - - @Override - public int compare(ItemStack itemStack1, ItemStack itemStack2) - { - if (itemStack1 != null && itemStack2 != null) - { - if (EnergyValueRegistryProxy.hasEnergyValue(itemStack1) && EnergyValueRegistryProxy.hasEnergyValue(itemStack2)) - { - return Float.compare(EnergyValueRegistryProxy.getEnergyValue(itemStack1).getValue(), EnergyValueRegistryProxy.getEnergyValue(itemStack2).getValue()); - } - else - { - return ID_COMPARATOR.compare(itemStack1, itemStack2); - } - } - else if (itemStack1 != null) - { - return -1; - } - else if (itemStack2 != null) - { - return 1; - } - else - { - return 0; - } - } - }; + }; } diff --git a/src/main/java/com/pahimar/ee3/reference/Files.java b/src/main/java/com/pahimar/ee3/reference/Files.java index 33725537..f8aad109 100644 --- a/src/main/java/com/pahimar/ee3/reference/Files.java +++ b/src/main/java/com/pahimar/ee3/reference/Files.java @@ -1,54 +1,84 @@ package com.pahimar.ee3.reference; +import java.io.File; + import com.pahimar.ee3.blacklist.BlacklistRegistry; import com.pahimar.ee3.exchange.EnergyValueRegistry; import com.pahimar.ee3.knowledge.PlayerKnowledgeRegistry; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import java.io.File; - public class Files { - public static File globalDataDirectory; public static File globalTestDirectory; public static File playerDataDirectory; private static final String ENERGY_VALUES_JSON_FILENAME = "energy-values.json"; - private static final String PRE_CALCULATION_ENERGY_VALUES_FILENAME = "pre-calculation-energy-values.json"; - private static final String POST_CALCULATION_ENERGY_VALUES_FILENAME = "post-calculation-energy-values.json"; + private static final String PRE_CALCULATION_ENERGY_VALUES_FILENAME + = "pre-calculation-energy-values.json"; + private static final String POST_CALCULATION_ENERGY_VALUES_FILENAME + = "post-calculation-energy-values.json"; - public static final String TEMPLATE_PLAYER_KNOWLEDGE_FILENAME = "template-player-knowledge.json"; + public static final String TEMPLATE_PLAYER_KNOWLEDGE_FILENAME + = "template-player-knowledge.json"; public static final String KNOWLEDGE_BLACKLIST_FILENAME = "knowledge-blacklist.json"; public static final String EXCHANGE_BLACKLIST_FILENAME = "exchange-blacklist.json"; public static void init(FMLPreInitializationEvent event) { - - globalDataDirectory = new File(event.getModConfigurationDirectory().getParentFile(), "data" + File.separator + Reference.LOWERCASE_MOD_ID); + globalDataDirectory = new File( + event.getModConfigurationDirectory().getParentFile(), + "data" + File.separator + Reference.LOWERCASE_MOD_ID + ); globalTestDirectory = new File(globalDataDirectory, "tests"); globalTestDirectory.mkdirs(); - EnergyValueRegistry.energyValuesDirectory = new File(globalDataDirectory, "energy-values"); + EnergyValueRegistry.energyValuesDirectory + = new File(globalDataDirectory, "energy-values"); EnergyValueRegistry.energyValuesDirectory.mkdirs(); - EnergyValueRegistry.energyValuesFile = new File(EnergyValueRegistry.energyValuesDirectory, ENERGY_VALUES_JSON_FILENAME); - EnergyValueRegistry.preCalculationValuesFile = new File(EnergyValueRegistry.energyValuesDirectory, PRE_CALCULATION_ENERGY_VALUES_FILENAME); - EnergyValueRegistry.postCalculationValuesFile = new File(EnergyValueRegistry.energyValuesDirectory, POST_CALCULATION_ENERGY_VALUES_FILENAME); + EnergyValueRegistry.energyValuesFile = new File( + EnergyValueRegistry.energyValuesDirectory, ENERGY_VALUES_JSON_FILENAME + ); + EnergyValueRegistry.preCalculationValuesFile = new File( + EnergyValueRegistry.energyValuesDirectory, + PRE_CALCULATION_ENERGY_VALUES_FILENAME + ); + EnergyValueRegistry.postCalculationValuesFile = new File( + EnergyValueRegistry.energyValuesDirectory, + POST_CALCULATION_ENERGY_VALUES_FILENAME + ); - File templatePlayerKnowledgeDirectory = new File(globalDataDirectory, "knowledge" + File.separator + "transmutation"); + File templatePlayerKnowledgeDirectory = new File( + globalDataDirectory, "knowledge" + File.separator + "transmutation" + ); templatePlayerKnowledgeDirectory.mkdirs(); - PlayerKnowledgeRegistry.templatePlayerKnowledgeFile = new File(templatePlayerKnowledgeDirectory, TEMPLATE_PLAYER_KNOWLEDGE_FILENAME); + PlayerKnowledgeRegistry.templatePlayerKnowledgeFile = new File( + templatePlayerKnowledgeDirectory, TEMPLATE_PLAYER_KNOWLEDGE_FILENAME + ); - BlacklistRegistry.knowledgeBlacklistFile = new File(globalDataDirectory, "blacklist" + File.separator + KNOWLEDGE_BLACKLIST_FILENAME); - BlacklistRegistry.exchangeBlacklistFile = new File(globalDataDirectory, "blacklist" + File.separator + EXCHANGE_BLACKLIST_FILENAME); + BlacklistRegistry.knowledgeBlacklistFile = new File( + globalDataDirectory, + "blacklist" + File.separator + KNOWLEDGE_BLACKLIST_FILENAME + ); + BlacklistRegistry.exchangeBlacklistFile = new File( + globalDataDirectory, + "blacklist" + File.separator + EXCHANGE_BLACKLIST_FILENAME + ); } /** - * Updates the references to the instance specific EE3 data directories, creating them if they don't already exist + * Updates the references to the instance specific EE3 data directories, creating them + * if they don't already exist */ public static void updateFileReferences() { - - playerDataDirectory = new File(FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler().getWorldDirectory(), "playerdata" + File.separator + Reference.LOWERCASE_MOD_ID); + playerDataDirectory = new File( + FMLCommonHandler.instance() + .getMinecraftServerInstance() + .getEntityWorld() + .getSaveHandler() + .getWorldDirectory(), + "playerdata" + File.separator + Reference.LOWERCASE_MOD_ID + ); playerDataDirectory.mkdirs(); } } diff --git a/src/main/java/com/pahimar/ee3/reference/GUIs.java b/src/main/java/com/pahimar/ee3/reference/GUIs.java index f42fa43b..f50c070a 100644 --- a/src/main/java/com/pahimar/ee3/reference/GUIs.java +++ b/src/main/java/com/pahimar/ee3/reference/GUIs.java @@ -1,7 +1,6 @@ package com.pahimar.ee3.reference; -public enum GUIs -{ +public enum GUIs { PORTABLE_CRAFTING, CALCINATOR, ALUDEL, diff --git a/src/main/java/com/pahimar/ee3/reference/Key.java b/src/main/java/com/pahimar/ee3/reference/Key.java index 7ae19bc2..597789f9 100644 --- a/src/main/java/com/pahimar/ee3/reference/Key.java +++ b/src/main/java/com/pahimar/ee3/reference/Key.java @@ -1,6 +1,3 @@ package com.pahimar.ee3.reference; -public enum Key -{ - UNKNOWN, CHARGE, EXTRA, RELEASE, TOGGLE -} +public enum Key { UNKNOWN, CHARGE, EXTRA, RELEASE, TOGGLE } diff --git a/src/main/java/com/pahimar/ee3/reference/Material.java b/src/main/java/com/pahimar/ee3/reference/Material.java index bfed934e..8e213ff0 100644 --- a/src/main/java/com/pahimar/ee3/reference/Material.java +++ b/src/main/java/com/pahimar/ee3/reference/Material.java @@ -4,15 +4,16 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraftforge.common.util.EnumHelper; -public class Material -{ - public static final class Tools - { - public static final Item.ToolMaterial DARK_MATTER = EnumHelper.addToolMaterial(Names.Materials.DARK_MATTER, 3, 0, 14f, 3f, 0); +public class Material { + public static final class Tools { + public static final Item.ToolMaterial DARK_MATTER + = EnumHelper.addToolMaterial(Names.Materials.DARK_MATTER, 3, 0, 14f, 3f, 0); } - public static final class Armor - { - public static final ItemArmor.ArmorMaterial DARK_MATTER = EnumHelper.addArmorMaterial(Names.Materials.DARK_MATTER, 0, new int[]{3, 8, 6, 3}, 0); + public static final class Armor { + public static final ItemArmor.ArmorMaterial DARK_MATTER + = EnumHelper.addArmorMaterial( + Names.Materials.DARK_MATTER, 0, new int[] { 3, 8, 6, 3 }, 0 + ); } } diff --git a/src/main/java/com/pahimar/ee3/reference/Messages.java b/src/main/java/com/pahimar/ee3/reference/Messages.java index dc3c6332..66ad12e4 100644 --- a/src/main/java/com/pahimar/ee3/reference/Messages.java +++ b/src/main/java/com/pahimar/ee3/reference/Messages.java @@ -1,114 +1,161 @@ package com.pahimar.ee3.reference; public final class Messages { - public static final String OWNER_SET_TO_SELF = "misc.ee3:owner-set-to-self"; public static final String ENERGY_VALUE = "misc.ee3:energy-value"; /* Fingerprint check related constants */ - public static final String NO_FINGERPRINT_MESSAGE = "The copy of Equivalent Exchange 3 that you are running is a development version of the mod, and as such may be unstable and/or incomplete."; - public static final String INVALID_FINGERPRINT_MESSAGE = "The copy of Equivalent Exchange 3 that you are running has been modified from the original, and unpredictable things may happen. Please consider re-downloading the original version of the mod."; + public static final String NO_FINGERPRINT_MESSAGE + = "The copy of Equivalent Exchange 3 that you are running is a development version of the mod, and as such may be unstable and/or incomplete."; + public static final String INVALID_FINGERPRINT_MESSAGE + = "The copy of Equivalent Exchange 3 that you are running has been modified from the original, and unpredictable things may happen. Please consider re-downloading the original version of the mod."; public static final class Gui { - private static final String GUI_PREFIX = "container.ee3:"; - public static final String NO_KNOWN_TRANSMUTATIONS = GUI_PREFIX + "alchenomicon.noTransmutationsKnown"; + public static final String NO_KNOWN_TRANSMUTATIONS + = GUI_PREFIX + "alchenomicon.noTransmutationsKnown"; } public static final class Tooltips { - private static final String TOOLTIP_PREFIX = "tooltip.ee3:"; public static final String UPGRADES_CHESTS = TOOLTIP_PREFIX + "upgradesPrefix"; public static final String ITEM_BELONGS_TO = TOOLTIP_PREFIX + "belongsTo"; - public static final String ITEM_BELONGS_TO_NO_ONE = TOOLTIP_PREFIX + "belongsToNoOne"; + public static final String ITEM_BELONGS_TO_NO_ONE + = TOOLTIP_PREFIX + "belongsToNoOne"; public static final String SMALL = TOOLTIP_PREFIX + "small"; public static final String MEDIUM = TOOLTIP_PREFIX + "medium"; public static final String LARGE = TOOLTIP_PREFIX + "large"; - public static final String SORT_BY_DISPLAY_NAME = TOOLTIP_PREFIX + "sortByDisplayName"; - public static final String SORT_BY_ENERGY_VALUE = TOOLTIP_PREFIX + "sortByEnergyValue"; + public static final String SORT_BY_DISPLAY_NAME + = TOOLTIP_PREFIX + "sortByDisplayName"; + public static final String SORT_BY_ENERGY_VALUE + = TOOLTIP_PREFIX + "sortByEnergyValue"; public static final String SORT_BY_ID = TOOLTIP_PREFIX + "sortByID"; public static final String SORT_ASCENDING = TOOLTIP_PREFIX + "sortAscending"; public static final String SORT_DESCENDING = TOOLTIP_PREFIX + "sortDescending"; } public static final class Commands { - private static final String COMMAND_PREFIX = "commands.ee3."; public static final String BASE_COMMAND_USAGE = COMMAND_PREFIX + "usage"; - public static final String PLAYER_NOT_FOUND_ERROR = COMMAND_PREFIX + "player-not-found.error"; - public static final String INVALID_NBT_TAG_ERROR = COMMAND_PREFIX + "invalid-nbt-tag.error"; + public static final String PLAYER_NOT_FOUND_ERROR + = COMMAND_PREFIX + "player-not-found.error"; + public static final String INVALID_NBT_TAG_ERROR + = COMMAND_PREFIX + "invalid-nbt-tag.error"; public static final String NO_ITEM = COMMAND_PREFIX + "no-item.error"; - public static final String SET_ENERGY_VALUE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ENERGY_VALUE + ".usage"; - public static final String SET_ENERGY_VALUE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ENERGY_VALUE + ".success"; + public static final String SET_ENERGY_VALUE_USAGE + = COMMAND_PREFIX + Names.Commands.SET_ENERGY_VALUE + ".usage"; + public static final String SET_ENERGY_VALUE_SUCCESS + = COMMAND_PREFIX + Names.Commands.SET_ENERGY_VALUE + ".success"; - public static final String SET_ENERGY_VALUE_CURRENT_ITEM_USAGE = COMMAND_PREFIX + Names.Commands.SET_ENERGY_VALUE_CURRENT_ITEM + ".usage"; - public static final String SET_ENERGY_VALUE_CURRENT_ITEM_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ENERGY_VALUE_CURRENT_ITEM + ".success"; + public static final String SET_ENERGY_VALUE_CURRENT_ITEM_USAGE + = COMMAND_PREFIX + Names.Commands.SET_ENERGY_VALUE_CURRENT_ITEM + ".usage"; + public static final String SET_ENERGY_VALUE_CURRENT_ITEM_SUCCESS + = COMMAND_PREFIX + Names.Commands.SET_ENERGY_VALUE_CURRENT_ITEM + ".success"; - public static final String REGEN_ENERGY_VALUES_USAGE = COMMAND_PREFIX + Names.Commands.REGEN_ENERGY_VALUES + ".usage"; - public static final String REGEN_ENERGY_VALUES_SUCCESS = COMMAND_PREFIX + Names.Commands.REGEN_ENERGY_VALUES + ".success"; - public static final String REGEN_ENERGY_VALUES_DENIED = COMMAND_PREFIX + Names.Commands.REGEN_ENERGY_VALUES + ".denied"; + public static final String REGEN_ENERGY_VALUES_USAGE + = COMMAND_PREFIX + Names.Commands.REGEN_ENERGY_VALUES + ".usage"; + public static final String REGEN_ENERGY_VALUES_SUCCESS + = COMMAND_PREFIX + Names.Commands.REGEN_ENERGY_VALUES + ".success"; + public static final String REGEN_ENERGY_VALUES_DENIED + = COMMAND_PREFIX + Names.Commands.REGEN_ENERGY_VALUES + ".denied"; - public static final String SYNC_ENERGY_VALUES_USAGE = COMMAND_PREFIX + Names.Commands.SYNC_ENERGY_VALUES + ".usage"; - public static final String SYNC_ENERGY_VALUES_SUCCESS = COMMAND_PREFIX + Names.Commands.SYNC_ENERGY_VALUES + ".success"; - public static final String SYNC_ENERGY_VALUES_DENIED = COMMAND_PREFIX + Names.Commands.SYNC_ENERGY_VALUES + ".denied"; + public static final String SYNC_ENERGY_VALUES_USAGE + = COMMAND_PREFIX + Names.Commands.SYNC_ENERGY_VALUES + ".usage"; + public static final String SYNC_ENERGY_VALUES_SUCCESS + = COMMAND_PREFIX + Names.Commands.SYNC_ENERGY_VALUES + ".success"; + public static final String SYNC_ENERGY_VALUES_DENIED + = COMMAND_PREFIX + Names.Commands.SYNC_ENERGY_VALUES + ".denied"; - public static final String PLAYER_LEARN_ITEM_USAGE = COMMAND_PREFIX + Names.Commands.PLAYER_LEARN_ITEM + ".usage"; - public static final String PLAYER_LEARN_ITEM_SUCCESS = COMMAND_PREFIX + Names.Commands.PLAYER_LEARN_ITEM + ".success"; + public static final String PLAYER_LEARN_ITEM_USAGE + = COMMAND_PREFIX + Names.Commands.PLAYER_LEARN_ITEM + ".usage"; + public static final String PLAYER_LEARN_ITEM_SUCCESS + = COMMAND_PREFIX + Names.Commands.PLAYER_LEARN_ITEM + ".success"; - public static final String PLAYER_LEARN_CURRENT_ITEM_USAGE = COMMAND_PREFIX + Names.Commands.PLAYER_LEARN_CURRENT_ITEM + ".usage"; - public static final String PLAYER_LEARN_CURRENT_ITEM_SUCCESS = COMMAND_PREFIX + Names.Commands.PLAYER_LEARN_CURRENT_ITEM + ".success"; + public static final String PLAYER_LEARN_CURRENT_ITEM_USAGE + = COMMAND_PREFIX + Names.Commands.PLAYER_LEARN_CURRENT_ITEM + ".usage"; + public static final String PLAYER_LEARN_CURRENT_ITEM_SUCCESS + = COMMAND_PREFIX + Names.Commands.PLAYER_LEARN_CURRENT_ITEM + ".success"; - public static final String PLAYER_FORGET_EVERYTHING_USAGE = COMMAND_PREFIX + Names.Commands.PLAYER_FORGET_EVERYTHING + ".usage"; - public static final String PLAYER_FORGET_EVERYTHING_SUCCESS = COMMAND_PREFIX + Names.Commands.PLAYER_FORGET_EVERYTHING + ".success"; + public static final String PLAYER_FORGET_EVERYTHING_USAGE + = COMMAND_PREFIX + Names.Commands.PLAYER_FORGET_EVERYTHING + ".usage"; + public static final String PLAYER_FORGET_EVERYTHING_SUCCESS + = COMMAND_PREFIX + Names.Commands.PLAYER_FORGET_EVERYTHING + ".success"; - public static final String PLAYER_FORGET_ITEM_USAGE = COMMAND_PREFIX + Names.Commands.PLAYER_FORGET_ITEM + ".usage"; - public static final String PLAYER_FORGET_ITEM_SUCCESS = COMMAND_PREFIX + Names.Commands.PLAYER_FORGET_ITEM + ".success"; + public static final String PLAYER_FORGET_ITEM_USAGE + = COMMAND_PREFIX + Names.Commands.PLAYER_FORGET_ITEM + ".usage"; + public static final String PLAYER_FORGET_ITEM_SUCCESS + = COMMAND_PREFIX + Names.Commands.PLAYER_FORGET_ITEM + ".success"; - public static final String PLAYER_FORGET_CURRENT_ITEM_USAGE = COMMAND_PREFIX + Names.Commands.PLAYER_FORGET_CURRENT_ITEM + ".usage"; - public static final String PLAYER_FORGET_CURRENT_ITEM_SUCCESS = COMMAND_PREFIX + Names.Commands.PLAYER_FORGET_CURRENT_ITEM + ".success"; + public static final String PLAYER_FORGET_CURRENT_ITEM_USAGE + = COMMAND_PREFIX + Names.Commands.PLAYER_FORGET_CURRENT_ITEM + ".usage"; + public static final String PLAYER_FORGET_CURRENT_ITEM_SUCCESS + = COMMAND_PREFIX + Names.Commands.PLAYER_FORGET_CURRENT_ITEM + ".success"; - public static final String SET_ITEM_LEARNABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".usage"; - public static final String SET_ITEM_LEARNABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".success"; + public static final String SET_ITEM_LEARNABLE_USAGE + = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".usage"; + public static final String SET_ITEM_LEARNABLE_SUCCESS + = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".success"; - public static final String SET_CURRENT_ITEM_LEARNABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".usage"; - public static final String SET_CURRENT_ITEM_LEARNABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".success"; - public static final String SET_CURRENT_ITEM_LEARNABLE_NO_EFFECT = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".no-effect"; + public static final String SET_CURRENT_ITEM_LEARNABLE_USAGE + = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".usage"; + public static final String SET_CURRENT_ITEM_LEARNABLE_SUCCESS + = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".success"; + public static final String SET_CURRENT_ITEM_LEARNABLE_NO_EFFECT + = COMMAND_PREFIX + Names.Commands.SET_ITEM_LEARNABLE + ".no-effect"; - public static final String SET_ITEM_NOT_LEARNABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".usage"; - public static final String SET_ITEM_NOT_LEARNABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".success"; + public static final String SET_ITEM_NOT_LEARNABLE_USAGE + = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".usage"; + public static final String SET_ITEM_NOT_LEARNABLE_SUCCESS + = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".success"; - public static final String SET_CURRENT_ITEM_NOT_LEARNABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".usage"; - public static final String SET_CURRENT_ITEM_NOT_LEARNABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".success"; - public static final String SET_CURRENT_ITEM_NOT_LEARNABLE_NO_EFFECT = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".no-effect"; + public static final String SET_CURRENT_ITEM_NOT_LEARNABLE_USAGE + = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".usage"; + public static final String SET_CURRENT_ITEM_NOT_LEARNABLE_SUCCESS + = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".success"; + public static final String SET_CURRENT_ITEM_NOT_LEARNABLE_NO_EFFECT + = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_LEARNABLE + ".no-effect"; - public static final String SET_ITEM_RECOVERABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + ".usage"; - public static final String SET_ITEM_RECOVERABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + ".success"; + public static final String SET_ITEM_RECOVERABLE_USAGE + = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + ".usage"; + public static final String SET_ITEM_RECOVERABLE_SUCCESS + = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + ".success"; - public static final String SET_CURRENT_ITEM_RECOVERABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + ".usage"; - public static final String SET_CURRENT_ITEM_RECOVERABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + ".success"; - public static final String SET_CURRENT_ITEM_RECOVERABLE_NO_EFFECT = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + ".no-effect"; + public static final String SET_CURRENT_ITEM_RECOVERABLE_USAGE + = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + ".usage"; + public static final String SET_CURRENT_ITEM_RECOVERABLE_SUCCESS + = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + ".success"; + public static final String SET_CURRENT_ITEM_RECOVERABLE_NO_EFFECT + = COMMAND_PREFIX + Names.Commands.SET_ITEM_RECOVERABLE + ".no-effect"; - public static final String SET_ITEM_NOT_RECOVERABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".usage"; - public static final String SET_ITEM_NOT_RECOVERABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".success"; + public static final String SET_ITEM_NOT_RECOVERABLE_USAGE + = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".usage"; + public static final String SET_ITEM_NOT_RECOVERABLE_SUCCESS + = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".success"; - public static final String SET_CURRENT_ITEM_NOT_RECOVERABLE_USAGE = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".usage"; - public static final String SET_CURRENT_ITEM_NOT_RECOVERABLE_SUCCESS = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".success"; - public static final String SET_CURRENT_ITEM_NOT_RECOVERABLE_NO_EFFECT = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".no-effect"; + public static final String SET_CURRENT_ITEM_NOT_RECOVERABLE_USAGE + = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".usage"; + public static final String SET_CURRENT_ITEM_NOT_RECOVERABLE_SUCCESS + = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".success"; + public static final String SET_CURRENT_ITEM_NOT_RECOVERABLE_NO_EFFECT + = COMMAND_PREFIX + Names.Commands.SET_ITEM_NOT_RECOVERABLE + ".no-effect"; - public static final String RUN_TEST_USAGE = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".usage"; - public static final String RUN_TESTS_SUCCESS = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".success"; - public static final String RUN_TESTS_NOT_FOUND = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".notfound"; - public static final String RUN_TESTS_DIR_NOT_FOUND = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".dir-notfound"; + public static final String RUN_TEST_USAGE + = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".usage"; + public static final String RUN_TESTS_SUCCESS + = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".success"; + public static final String RUN_TESTS_NOT_FOUND + = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".notfound"; + public static final String RUN_TESTS_DIR_NOT_FOUND + = COMMAND_PREFIX + Names.Commands.RUN_TEST + ".dir-notfound"; - public static final String ADMIN_USAGE = COMMAND_PREFIX + Names.Commands.ADMIN_PANEL + ".usage"; + public static final String ADMIN_USAGE + = COMMAND_PREFIX + Names.Commands.ADMIN_PANEL + ".usage"; } - public static final class Configuration { - - } + public static final class Configuration {} } diff --git a/src/main/java/com/pahimar/ee3/reference/Models.java b/src/main/java/com/pahimar/ee3/reference/Models.java index 04a17346..b005d650 100644 --- a/src/main/java/com/pahimar/ee3/reference/Models.java +++ b/src/main/java/com/pahimar/ee3/reference/Models.java @@ -3,13 +3,21 @@ package com.pahimar.ee3.reference; import com.pahimar.ee3.util.ResourceLocationHelper; import net.minecraft.util.ResourceLocation; -public class Models -{ +public class Models { public static final String MODEL_LOCATION = "models/"; - public static final ResourceLocation ALUDEL = ResourceLocationHelper.getResourceLocation(MODEL_LOCATION + "aludel.obj"); - public static final ResourceLocation CALCINATOR = ResourceLocationHelper.getResourceLocation(MODEL_LOCATION + "calcinator.obj"); - public static final ResourceLocation GLASS_BELL = ResourceLocationHelper.getResourceLocation(MODEL_LOCATION + "aludel.obj"); - public static final ResourceLocation RESEARCH_STATION = ResourceLocationHelper.getResourceLocation(MODEL_LOCATION + "researchStation.obj"); - public static final ResourceLocation AUGMENTATION_TABLE = ResourceLocationHelper.getResourceLocation(MODEL_LOCATION + "augmentationTable.obj"); + public static final ResourceLocation ALUDEL + = ResourceLocationHelper.getResourceLocation(MODEL_LOCATION + "aludel.obj"); + public static final ResourceLocation CALCINATOR + = ResourceLocationHelper.getResourceLocation(MODEL_LOCATION + "calcinator.obj"); + public static final ResourceLocation GLASS_BELL + = ResourceLocationHelper.getResourceLocation(MODEL_LOCATION + "aludel.obj"); + public static final ResourceLocation RESEARCH_STATION + = ResourceLocationHelper.getResourceLocation( + MODEL_LOCATION + "researchStation.obj" + ); + public static final ResourceLocation AUGMENTATION_TABLE + = ResourceLocationHelper.getResourceLocation( + MODEL_LOCATION + "augmentationTable.obj" + ); } diff --git a/src/main/java/com/pahimar/ee3/reference/Names.java b/src/main/java/com/pahimar/ee3/reference/Names.java index 4930c3e2..cdb629e6 100644 --- a/src/main/java/com/pahimar/ee3/reference/Names.java +++ b/src/main/java/com/pahimar/ee3/reference/Names.java @@ -1,9 +1,7 @@ package com.pahimar.ee3.reference; -public class Names -{ - public static final class Blocks - { +public class Names { + public static final class Blocks { public static final String CHALK = "chalkBlock"; public static final String ALCHEMICAL_CHEST = "alchemicalChest"; public static final String ALCHEMICAL_FUEL = "alchemicalFuelBlock"; @@ -19,16 +17,17 @@ public class Names public static final String DUMMY_ARRAY = "dummyArray"; } - public static final class Items - { + public static final class Items { public static final String ALCHEMICAL_BAG = "alchemicalBag"; public static final String ALCHEMICAL_DUST = "alchemicalDust"; - public static final String[] ALCHEMICAL_DUST_SUBTYPES = {"ash", "verdant", "azure", "minium"}; + public static final String[] ALCHEMICAL_DUST_SUBTYPES + = { "ash", "verdant", "azure", "minium" }; public static final String ALCHEMICAL_FUEL = "alchemicalFuel"; public static final String ALCHEMICAL_COAL = "alchemicalCoal"; public static final String MOBIUS_FUEL = "mobiusFuel"; public static final String AETERNALIS_FUEL = "aeternalisFuel"; - public static final String[] ALCHEMICAL_FUEL_SUBTYPES = {ALCHEMICAL_COAL, MOBIUS_FUEL, AETERNALIS_FUEL}; + public static final String[] ALCHEMICAL_FUEL_SUBTYPES + = { ALCHEMICAL_COAL, MOBIUS_FUEL, AETERNALIS_FUEL }; public static final String CHALK = "chalk"; public static final String INERT_STONE = "stoneInert"; public static final String LOOT_BALL = "lootBall"; @@ -36,30 +35,29 @@ public class Names public static final String MINIUM_STONE = "stoneMinium"; public static final String PHILOSOPHERS_STONE = "stonePhilosophers"; public static final String ALCHEMICAL_UPGRADE = "alchemicalUpgrade"; - public static final String[] ALCHEMICAL_UPGRADE_SUBTYPES = {"verdant", "azure", "minium"}; + public static final String[] ALCHEMICAL_UPGRADE_SUBTYPES + = { "verdant", "azure", "minium" }; public static final String DIVINING_ROD = "diviningRod"; public static final String ALCHENOMICON = "alchenomicon"; public static final String ALCHEMICAL_TOME = "alchemicalTome"; public static final String MATTER = "matter"; - public static final String[] MATTER_SUBTYPES = {"Proto", "Dark", "Corporeal", "Kinetic", "Temporal", "Essentia", "Amorphous", "Void", "Omni"}; + public static final String[] MATTER_SUBTYPES + = { "Proto", "Dark", "Corporeal", "Kinetic", "Temporal", + "Essentia", "Amorphous", "Void", "Omni" }; public static final String GEM = "gem"; - public static final String[] GEM_SUBTYPES = {"Black", "Blue", "Green", "Grey", "Purple", "Red", "Yellow"}; + public static final String[] GEM_SUBTYPES + = { "Black", "Blue", "Green", "Grey", "Purple", "Red", "Yellow" }; public static final String KNOWLEDGE_SCROLL = "knowledgeScroll"; public static final String POTION_LETHE = "potionLethe"; } - public static final class Fluids - { - public static final String MILK = "ee3.milk"; - } + public static final class Fluids { public static final String MILK = "ee3.milk"; } - public static final class Materials - { + public static final class Materials { public static final String DARK_MATTER = "matterDark"; } - public static final class Tools - { + public static final class Tools { public static final String DARK_MATTER_SHOVEL = "shovelDarkMatter"; public static final String DARK_MATTER_PICKAXE = "pickAxeDarkMatter"; public static final String DARK_MATTER_HAMMER = "hammerDarkMatter"; @@ -69,15 +67,13 @@ public class Names public static final String DARK_MATTER_SHEARS = "shearsDarkMatter"; } - public static final class Weapons - { + public static final class Weapons { public static final String DARK_MATTER_BOW = "bowDarkMatter"; public static final String DARK_MATTER_ARROW = "arrowDarkMatter"; public static final String DARK_MATTER_SWORD = "swordDarkMatter"; } - public static final class Armor - { + public static final class Armor { public static final String DARK_MATTER_ARMOR = "armorDarkMatter"; public static final String CORPOREAL_MATTER_ARMOR = "armorCorporealMatter"; public static final String KINETIC_MATTER_ARMOR = "armorKineticMatter"; @@ -88,10 +84,10 @@ public class Names public static final String OMNI_MATTER_ARMOR = "armorOmniMatter"; } - public static final class NBT - { + public static final class NBT { public static final String ITEMS = "Items"; - public static final String ITEM_TRANSMUTATION_KNOWLEDGE = "transmutationKnowledge"; + public static final String ITEM_TRANSMUTATION_KNOWLEDGE + = "transmutationKnowledge"; public static final String CHARGE_LEVEL = "chargeLevel"; public static final String MODE = "mode"; public static final String CRAFTING_GUI_OPEN = "craftingGuiOpen"; @@ -110,23 +106,26 @@ public class Names public static final String ENERGY_VALUE = "energyValue"; } - public static final class Containers - { + public static final class Containers { public static final String VANILLA_INVENTORY = "container.inventory"; public static final String VANILLA_CRAFTING = "container.crafting"; - public static final String ALCHEMICAL_BAG = "container.ee3:" + Items.ALCHEMICAL_BAG; - public static final String ALCHEMICAL_CHEST = "container.ee3:" + Blocks.ALCHEMICAL_CHEST; + public static final String ALCHEMICAL_BAG + = "container.ee3:" + Items.ALCHEMICAL_BAG; + public static final String ALCHEMICAL_CHEST + = "container.ee3:" + Blocks.ALCHEMICAL_CHEST; public static final String CALCINATOR = "container.ee3:" + Blocks.CALCINATOR; public static final String ALUDEL = "container.ee3:" + Blocks.ALUDEL; - public static final String RESEARCH_STATION = "container.ee3:" + Blocks.RESEARCH_STATION; + public static final String RESEARCH_STATION + = "container.ee3:" + Blocks.RESEARCH_STATION; public static final String GLASS_BELL = "container.ee3:" + Blocks.GLASS_BELL; - public static final String AUGMENTATION_TABLE = "container.ee3:" + Blocks.AUGMENTATION_TABLE; + public static final String AUGMENTATION_TABLE + = "container.ee3:" + Blocks.AUGMENTATION_TABLE; public static final String ALCHENOMICON = "container.ee3:" + Items.ALCHENOMICON; - public static final String TRANSMUTATION_TABLET = "container.ee3:" + Blocks.TRANSMUTATION_TABLET; + public static final String TRANSMUTATION_TABLET + = "container.ee3:" + Blocks.TRANSMUTATION_TABLET; } - public static final class Keys - { + public static final class Keys { public static final String CATEGORY = "key.categories.ee3"; public static final String CHARGE = "key.charge"; public static final String EXTRA = "key.extra"; @@ -134,43 +133,56 @@ public class Names public static final String TOGGLE = "key.toggle"; } - public static final class Commands - { + public static final class Commands { public static final String BASE_COMMAND = Reference.LOWERCASE_MOD_ID; public static final String SET_ENERGY_VALUE = "set-energy-value"; - public static final String SET_ENERGY_VALUE_CURRENT_ITEM = "set-energy-value-current-item"; + public static final String SET_ENERGY_VALUE_CURRENT_ITEM + = "set-energy-value-current-item"; public static final String REGEN_ENERGY_VALUES = "regen-energy-values"; public static final String SYNC_ENERGY_VALUES = "sync-energy-values"; public static final String PLAYER_LEARN_EVERYTHING = "player-learn-everything"; public static final String PLAYER_LEARN_ITEM = "player-learn-item"; - public static final String PLAYER_LEARN_CURRENT_ITEM = "player-learn-current-item"; + public static final String PLAYER_LEARN_CURRENT_ITEM + = "player-learn-current-item"; public static final String PLAYER_FORGET_EVERYTHING = "player-forget-everything"; public static final String PLAYER_FORGET_ITEM = "player-forget-item"; - public static final String PLAYER_FORGET_CURRENT_ITEM = "player-forget-current-item"; + public static final String PLAYER_FORGET_CURRENT_ITEM + = "player-forget-current-item"; public static final String SET_ITEM_LEARNABLE = "set-item-learnable"; - public static final String SET_CURRENT_ITEM_LEARNABLE = "set-current-item-learnable"; + public static final String SET_CURRENT_ITEM_LEARNABLE + = "set-current-item-learnable"; public static final String SET_ITEM_NOT_LEARNABLE = "set-item-not-learnable"; - public static final String SET_CURRENT_ITEM_NOT_LEARNABLE = "set-current-item-not-learnable"; + public static final String SET_CURRENT_ITEM_NOT_LEARNABLE + = "set-current-item-not-learnable"; public static final String SET_ITEM_RECOVERABLE = "set-item-recoverable"; - public static final String SET_CURRENT_ITEM_RECOVERABLE = "set-current-item-recoverable"; + public static final String SET_CURRENT_ITEM_RECOVERABLE + = "set-current-item-recoverable"; public static final String SET_ITEM_NOT_RECOVERABLE = "set-item-not-recoverable"; - public static final String SET_CURRENT_ITEM_NOT_RECOVERABLE = "set-current-item-not-recoverable"; + public static final String SET_CURRENT_ITEM_NOT_RECOVERABLE + = "set-current-item-not-recoverable"; public static final String RUN_TEST = "run-tests"; public static final String DEBUG = "debug"; public static final String ADMIN_PANEL = "admin"; } - public static final class AlchemyArrays - { + public static final class AlchemyArrays { private static final String ALCHEMY_ARRAY_BASE = "arrays.ee3:"; - public static final String ACCELERANT_ALCHEMY_ARRAY = ALCHEMY_ARRAY_BASE + "accelerant"; - public static final String COMBUSTION_ALCHEMY_ARRAY = ALCHEMY_ARRAY_BASE + "combustion"; - public static final String CONSTRUCTION_ALCHEMY_ARRAY = ALCHEMY_ARRAY_BASE + "construction"; - public static final String CONVEYOR_ALCHEMY_ARRAY = ALCHEMY_ARRAY_BASE + "conveyor"; - public static final String DESTRUCTION_ALCHEMY_ARRAY = ALCHEMY_ARRAY_BASE + "destruction"; + public static final String ACCELERANT_ALCHEMY_ARRAY + = ALCHEMY_ARRAY_BASE + "accelerant"; + public static final String COMBUSTION_ALCHEMY_ARRAY + = ALCHEMY_ARRAY_BASE + "combustion"; + public static final String CONSTRUCTION_ALCHEMY_ARRAY + = ALCHEMY_ARRAY_BASE + "construction"; + public static final String CONVEYOR_ALCHEMY_ARRAY + = ALCHEMY_ARRAY_BASE + "conveyor"; + public static final String DESTRUCTION_ALCHEMY_ARRAY + = ALCHEMY_ARRAY_BASE + "destruction"; public static final String GELID_ALCHEMY_ARRAY = ALCHEMY_ARRAY_BASE + "gelid"; - public static final String PARTHENOGENESIS_ALCHEMY_ARRAY = ALCHEMY_ARRAY_BASE + "parthenogenesis"; - public static final String TRANSFIGURATION_ALCHEMY_ARRAY = ALCHEMY_ARRAY_BASE + "transfiguration"; - public static final String TRANSMUTATION_ALCHEMY_ARRAY = ALCHEMY_ARRAY_BASE + "transmutation"; + public static final String PARTHENOGENESIS_ALCHEMY_ARRAY + = ALCHEMY_ARRAY_BASE + "parthenogenesis"; + public static final String TRANSFIGURATION_ALCHEMY_ARRAY + = ALCHEMY_ARRAY_BASE + "transfiguration"; + public static final String TRANSMUTATION_ALCHEMY_ARRAY + = ALCHEMY_ARRAY_BASE + "transmutation"; } } diff --git a/src/main/java/com/pahimar/ee3/reference/Particles.java b/src/main/java/com/pahimar/ee3/reference/Particles.java index a6ed4a96..fd73b5a0 100644 --- a/src/main/java/com/pahimar/ee3/reference/Particles.java +++ b/src/main/java/com/pahimar/ee3/reference/Particles.java @@ -1,7 +1,6 @@ package com.pahimar.ee3.reference; -public final class Particles -{ +public final class Particles { /* Vanilla particle names (not necessarily all of them) */ public static final String NORMAL_SMOKE = "smoke"; public static final String LARGE_SMOKE = "largesmoke"; diff --git a/src/main/java/com/pahimar/ee3/reference/Reference.java b/src/main/java/com/pahimar/ee3/reference/Reference.java index 8340c9e8..10d6913e 100644 --- a/src/main/java/com/pahimar/ee3/reference/Reference.java +++ b/src/main/java/com/pahimar/ee3/reference/Reference.java @@ -1,14 +1,15 @@ package com.pahimar.ee3.reference; -public class Reference -{ +public class Reference { public static final String MOD_ID = "EE3"; public static final String LOWERCASE_MOD_ID = MOD_ID.toLowerCase(); public static final String MOD_NAME = "Equivalent Exchange 3"; public static final String FINGERPRINT = "@FINGERPRINT@"; public static final String MOD_VERSION = "@MOD_VERSION@"; - public static final String DEPENDENCIES = "required-after:Forge@[10.13.3,);after:ProjectE"; + public static final String DEPENDENCIES + = "required-after:Forge@[10.13.3,);after:ProjectE"; public static final String SERVER_PROXY_CLASS = "com.pahimar.ee3.proxy.ServerProxy"; public static final String CLIENT_PROXY_CLASS = "com.pahimar.ee3.proxy.ClientProxy"; - public static final String GUI_FACTORY_CLASS = "com.pahimar.ee3.client.gui.GuiFactory"; + public static final String GUI_FACTORY_CLASS + = "com.pahimar.ee3.client.gui.GuiFactory"; } diff --git a/src/main/java/com/pahimar/ee3/reference/RenderIds.java b/src/main/java/com/pahimar/ee3/reference/RenderIds.java index 96943a8c..779ee550 100644 --- a/src/main/java/com/pahimar/ee3/reference/RenderIds.java +++ b/src/main/java/com/pahimar/ee3/reference/RenderIds.java @@ -1,7 +1,6 @@ package com.pahimar.ee3.reference; -public class RenderIds -{ +public class RenderIds { public static int calcinator; public static int aludel; public static int alchemicalChest; diff --git a/src/main/java/com/pahimar/ee3/reference/Sounds.java b/src/main/java/com/pahimar/ee3/reference/Sounds.java index d5c0546d..5910d6d9 100644 --- a/src/main/java/com/pahimar/ee3/reference/Sounds.java +++ b/src/main/java/com/pahimar/ee3/reference/Sounds.java @@ -2,8 +2,7 @@ package com.pahimar.ee3.reference; import java.util.Random; -public class Sounds -{ +public class Sounds { private static final Random random = new Random(); public static final String CHEST_OPEN = "random.chestopen"; @@ -25,14 +24,14 @@ public class Sounds public static final String WATER_BALL = "waterball"; public static final String WIND = "wind"; - public static final class Chalk - { + public static final class Chalk { private static final String CHALK_PREFIX = "chalk_"; private static final int CHALK_SOUNDS_COUNT = 11; - public static String getRandomChalkSound() - { - return String.format("%s%s", CHALK_PREFIX, random.nextInt(CHALK_SOUNDS_COUNT) + 1); + public static String getRandomChalkSound() { + return String.format( + "%s%s", CHALK_PREFIX, random.nextInt(CHALK_SOUNDS_COUNT) + 1 + ); } } } diff --git a/src/main/java/com/pahimar/ee3/reference/Textures.java b/src/main/java/com/pahimar/ee3/reference/Textures.java index 95479284..bfb55662 100644 --- a/src/main/java/com/pahimar/ee3/reference/Textures.java +++ b/src/main/java/com/pahimar/ee3/reference/Textures.java @@ -3,88 +3,228 @@ package com.pahimar.ee3.reference; import com.pahimar.ee3.util.ResourceLocationHelper; import net.minecraft.util.ResourceLocation; -public final class Textures -{ +public final class Textures { public static final String RESOURCE_PREFIX = Reference.LOWERCASE_MOD_ID + ":"; - public static final class Armor - { + public static final class Armor { private static final String ARMOR_SHEET_LOCATION = "textures/armor/"; } - public static final class Model - { + public static final class Model { private static final String MODEL_TEXTURE_LOCATION = "textures/models/"; - public static final ResourceLocation CALCINATOR_IDLE = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "calcinator_idle.png"); - public static final ResourceLocation CALCINATOR_ACTIVE = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "calcinator_active.png"); - public static final ResourceLocation ALUDEL = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "aludel.png"); - public static final ResourceLocation ALCHEMICAL_CHEST_SMALL = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "alchemicalChest_small.png"); - public static final ResourceLocation ALCHEMICAL_CHEST_MEDIUM = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "alchemicalChest_medium.png"); - public static final ResourceLocation ALCHEMICAL_CHEST_LARGE = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "alchemicalChest_large.png"); - public static final ResourceLocation GLASS_BELL = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "aludel.png"); - public static final ResourceLocation RESEARCH_STATION = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "researchStation.png"); - public static final ResourceLocation AUGMENTATION_TABLE = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "augmentationTable.png"); - public static final ResourceLocation TRANSMUTATION_TABLET = ResourceLocationHelper.getResourceLocation(MODEL_TEXTURE_LOCATION + "transmutationTablet.png"); + public static final ResourceLocation CALCINATOR_IDLE + = ResourceLocationHelper.getResourceLocation( + MODEL_TEXTURE_LOCATION + "calcinator_idle.png" + ); + public static final ResourceLocation CALCINATOR_ACTIVE + = ResourceLocationHelper.getResourceLocation( + MODEL_TEXTURE_LOCATION + "calcinator_active.png" + ); + public static final ResourceLocation ALUDEL + = ResourceLocationHelper.getResourceLocation( + MODEL_TEXTURE_LOCATION + "aludel.png" + ); + public static final ResourceLocation ALCHEMICAL_CHEST_SMALL + = ResourceLocationHelper.getResourceLocation( + MODEL_TEXTURE_LOCATION + "alchemicalChest_small.png" + ); + public static final ResourceLocation ALCHEMICAL_CHEST_MEDIUM + = ResourceLocationHelper.getResourceLocation( + MODEL_TEXTURE_LOCATION + "alchemicalChest_medium.png" + ); + public static final ResourceLocation ALCHEMICAL_CHEST_LARGE + = ResourceLocationHelper.getResourceLocation( + MODEL_TEXTURE_LOCATION + "alchemicalChest_large.png" + ); + public static final ResourceLocation GLASS_BELL + = ResourceLocationHelper.getResourceLocation( + MODEL_TEXTURE_LOCATION + "aludel.png" + ); + public static final ResourceLocation RESEARCH_STATION + = ResourceLocationHelper.getResourceLocation( + MODEL_TEXTURE_LOCATION + "researchStation.png" + ); + public static final ResourceLocation AUGMENTATION_TABLE + = ResourceLocationHelper.getResourceLocation( + MODEL_TEXTURE_LOCATION + "augmentationTable.png" + ); + public static final ResourceLocation TRANSMUTATION_TABLET + = ResourceLocationHelper.getResourceLocation( + MODEL_TEXTURE_LOCATION + "transmutationTablet.png" + ); } - public static final class Gui - { + public static final class Gui { protected static final String GUI_TEXTURE_LOCATION = "textures/gui/"; - public static final ResourceLocation CALCINATOR = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "calcinator.png"); - public static final ResourceLocation ALUDEL = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "aludel.png"); - public static final ResourceLocation ALCHEMICAL_BAG_SMALL = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "alchemicalBag_small.png"); - public static final ResourceLocation ALCHEMICAL_BAG_MEDIUM = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "alchemicalBag_medium.png"); - public static final ResourceLocation ALCHEMICAL_BAG_LARGE = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "alchemicalBag_large.png"); - public static final ResourceLocation ALCHEMICAL_CHEST_SMALL = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "alchemicalChest_small.png"); - public static final ResourceLocation ALCHEMICAL_CHEST_MEDIUM = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "alchemicalChest_medium.png"); - public static final ResourceLocation ALCHEMICAL_CHEST_LARGE = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "alchemicalChest_large.png"); - public static final ResourceLocation GLASS_BELL = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "glassBell.png"); - public static final ResourceLocation RESEARCH_STATION = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "researchStation.png"); - public static final ResourceLocation RESEARCH_STATION_GYLPH_1 = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "researchStation_Glyph1.png"); - public static final ResourceLocation RESEARCH_STATION_GYLPH_2 = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "researchStation_Glyph2.png"); - public static final ResourceLocation AUGMENTATION_TABLE = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "augmentationTable.png"); - public static final ResourceLocation PORTABLE_CRAFTING = new ResourceLocation("textures/gui/container/crafting_table.png"); - public static final ResourceLocation ALCHENOMICON = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "alchenomicon.png"); - public static final ResourceLocation TRANSMUTATION_ARRAY_1 = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "transmutationArray_1.png"); - public static final ResourceLocation TRANSMUTATION_ARRAY_3 = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "transmutationArray_3.png"); - public static final ResourceLocation TRANSMUTATION_ARRAY_5 = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "transmutationArray_5.png"); - public static final ResourceLocation TRANSMUTATION_TABLET = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "transmutationTablet.png"); - public static final ResourceLocation ADMIN_PANEL = ResourceLocationHelper.getResourceLocation(GUI_TEXTURE_LOCATION + "adminPanel.png"); + public static final ResourceLocation CALCINATOR + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "calcinator.png" + ); + public static final ResourceLocation ALUDEL + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "aludel.png" + ); + public static final ResourceLocation ALCHEMICAL_BAG_SMALL + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "alchemicalBag_small.png" + ); + public static final ResourceLocation ALCHEMICAL_BAG_MEDIUM + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "alchemicalBag_medium.png" + ); + public static final ResourceLocation ALCHEMICAL_BAG_LARGE + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "alchemicalBag_large.png" + ); + public static final ResourceLocation ALCHEMICAL_CHEST_SMALL + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "alchemicalChest_small.png" + ); + public static final ResourceLocation ALCHEMICAL_CHEST_MEDIUM + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "alchemicalChest_medium.png" + ); + public static final ResourceLocation ALCHEMICAL_CHEST_LARGE + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "alchemicalChest_large.png" + ); + public static final ResourceLocation GLASS_BELL + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "glassBell.png" + ); + public static final ResourceLocation RESEARCH_STATION + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "researchStation.png" + ); + public static final ResourceLocation RESEARCH_STATION_GYLPH_1 + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "researchStation_Glyph1.png" + ); + public static final ResourceLocation RESEARCH_STATION_GYLPH_2 + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "researchStation_Glyph2.png" + ); + public static final ResourceLocation AUGMENTATION_TABLE + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "augmentationTable.png" + ); + public static final ResourceLocation PORTABLE_CRAFTING + = new ResourceLocation("textures/gui/container/crafting_table.png"); + public static final ResourceLocation ALCHENOMICON + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "alchenomicon.png" + ); + public static final ResourceLocation TRANSMUTATION_ARRAY_1 + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "transmutationArray_1.png" + ); + public static final ResourceLocation TRANSMUTATION_ARRAY_3 + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "transmutationArray_3.png" + ); + public static final ResourceLocation TRANSMUTATION_ARRAY_5 + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "transmutationArray_5.png" + ); + public static final ResourceLocation TRANSMUTATION_TABLET + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "transmutationTablet.png" + ); + public static final ResourceLocation ADMIN_PANEL + = ResourceLocationHelper.getResourceLocation( + GUI_TEXTURE_LOCATION + "adminPanel.png" + ); - public static final class Elements - { - protected static final String ELEMENT_TEXTURE_LOCATION = GUI_TEXTURE_LOCATION + "elements/"; - public static final ResourceLocation ARROW_LEFT = ResourceLocationHelper.getResourceLocation(ELEMENT_TEXTURE_LOCATION + "arrowLeft.png"); - public static final ResourceLocation ARROW_RIGHT = ResourceLocationHelper.getResourceLocation(ELEMENT_TEXTURE_LOCATION + "arrowRight.png"); - public static final ResourceLocation SLIDER_VERTICAL_ENABLED = ResourceLocationHelper.getResourceLocation(ELEMENT_TEXTURE_LOCATION + "sliderVerticalEnabled.png"); - public static final ResourceLocation SLIDER_VERTICAL_DISABLED = ResourceLocationHelper.getResourceLocation(ELEMENT_TEXTURE_LOCATION + "sliderVerticalDisabled.png"); - public static final ResourceLocation BUTTON_ENABLED = ResourceLocationHelper.getResourceLocation(ELEMENT_TEXTURE_LOCATION + "buttonEnabled.png"); - public static final ResourceLocation BUTTON_DISABLED = ResourceLocationHelper.getResourceLocation(ELEMENT_TEXTURE_LOCATION + "buttonDisabled.png"); - public static final ResourceLocation BUTTON_HOVER = ResourceLocationHelper.getResourceLocation(ELEMENT_TEXTURE_LOCATION + "buttonHover.png"); - public static final ResourceLocation BUTTON_SORT_OPTION = ResourceLocationHelper.getResourceLocation(ELEMENT_TEXTURE_LOCATION + "buttonSortOption.png"); - public static final ResourceLocation BUTTON_SORT_ORDER = ResourceLocationHelper.getResourceLocation(ELEMENT_TEXTURE_LOCATION + "buttonSortOrder.png"); - public static final ResourceLocation BUTTON = ResourceLocationHelper.getResourceLocation(ELEMENT_TEXTURE_LOCATION + "button.png"); + public static final class Elements { + protected static final String ELEMENT_TEXTURE_LOCATION + = GUI_TEXTURE_LOCATION + "elements/"; + public static final ResourceLocation ARROW_LEFT + = ResourceLocationHelper.getResourceLocation( + ELEMENT_TEXTURE_LOCATION + "arrowLeft.png" + ); + public static final ResourceLocation ARROW_RIGHT + = ResourceLocationHelper.getResourceLocation( + ELEMENT_TEXTURE_LOCATION + "arrowRight.png" + ); + public static final ResourceLocation SLIDER_VERTICAL_ENABLED + = ResourceLocationHelper.getResourceLocation( + ELEMENT_TEXTURE_LOCATION + "sliderVerticalEnabled.png" + ); + public static final ResourceLocation SLIDER_VERTICAL_DISABLED + = ResourceLocationHelper.getResourceLocation( + ELEMENT_TEXTURE_LOCATION + "sliderVerticalDisabled.png" + ); + public static final ResourceLocation BUTTON_ENABLED + = ResourceLocationHelper.getResourceLocation( + ELEMENT_TEXTURE_LOCATION + "buttonEnabled.png" + ); + public static final ResourceLocation BUTTON_DISABLED + = ResourceLocationHelper.getResourceLocation( + ELEMENT_TEXTURE_LOCATION + "buttonDisabled.png" + ); + public static final ResourceLocation BUTTON_HOVER + = ResourceLocationHelper.getResourceLocation( + ELEMENT_TEXTURE_LOCATION + "buttonHover.png" + ); + public static final ResourceLocation BUTTON_SORT_OPTION + = ResourceLocationHelper.getResourceLocation( + ELEMENT_TEXTURE_LOCATION + "buttonSortOption.png" + ); + public static final ResourceLocation BUTTON_SORT_ORDER + = ResourceLocationHelper.getResourceLocation( + ELEMENT_TEXTURE_LOCATION + "buttonSortOrder.png" + ); + public static final ResourceLocation BUTTON + = ResourceLocationHelper.getResourceLocation( + ELEMENT_TEXTURE_LOCATION + "button.png" + ); } } - public static final class Effect - { + public static final class Effect { private static final String EFFECTS_LOCATION = "textures/effects/"; - public static final ResourceLocation WORLD_TRANSMUTATION = ResourceLocationHelper.getResourceLocation(EFFECTS_LOCATION + "noise.png"); + public static final ResourceLocation WORLD_TRANSMUTATION + = ResourceLocationHelper.getResourceLocation(EFFECTS_LOCATION + "noise.png"); } - public static final class AlchemyArray - { + public static final class AlchemyArray { private static final String SYMBOL_TEXTURE_LOCATION = "textures/arrays/"; - public static final ResourceLocation ACCELERANT_ALCHEMY_ARRAY = ResourceLocationHelper.getResourceLocation(SYMBOL_TEXTURE_LOCATION + "arrayAccelerant.png"); - public static final ResourceLocation COMBUSTION_ALCHEMY_ARRAY = ResourceLocationHelper.getResourceLocation(SYMBOL_TEXTURE_LOCATION + "arrayCombustion.png"); - public static final ResourceLocation CONSTRUCTION_ALCHEMY_ARRAY = ResourceLocationHelper.getResourceLocation(SYMBOL_TEXTURE_LOCATION + "arrayConstruction.png"); - public static final ResourceLocation CONVEYOR_ALCHEMY_ARRAY = ResourceLocationHelper.getResourceLocation(SYMBOL_TEXTURE_LOCATION + "arrayConveyor.png"); - public static final ResourceLocation DESTRUCTION_ALCHEMY_ARRAY = ResourceLocationHelper.getResourceLocation(SYMBOL_TEXTURE_LOCATION + "arrayDestruction.png"); - public static final ResourceLocation GELID_ALCHEMY_ARRAY = ResourceLocationHelper.getResourceLocation(SYMBOL_TEXTURE_LOCATION + "arrayGelid.png"); - public static final ResourceLocation PARTHENOGENESIS_ALCHEMY_ARRAY = ResourceLocationHelper.getResourceLocation(SYMBOL_TEXTURE_LOCATION + "arrayParthenogenesis.png"); - public static final ResourceLocation TRANSFIGURATION_ALCHEMY_ARRAY = ResourceLocationHelper.getResourceLocation(SYMBOL_TEXTURE_LOCATION + "arrayTransfiguration.png"); - public static final ResourceLocation TRANSMUTATION_ALCHEMY_ARRAY = ResourceLocationHelper.getResourceLocation(SYMBOL_TEXTURE_LOCATION + "arrayTransmutation.png"); + public static final ResourceLocation ACCELERANT_ALCHEMY_ARRAY + = ResourceLocationHelper.getResourceLocation( + SYMBOL_TEXTURE_LOCATION + "arrayAccelerant.png" + ); + public static final ResourceLocation COMBUSTION_ALCHEMY_ARRAY + = ResourceLocationHelper.getResourceLocation( + SYMBOL_TEXTURE_LOCATION + "arrayCombustion.png" + ); + public static final ResourceLocation CONSTRUCTION_ALCHEMY_ARRAY + = ResourceLocationHelper.getResourceLocation( + SYMBOL_TEXTURE_LOCATION + "arrayConstruction.png" + ); + public static final ResourceLocation CONVEYOR_ALCHEMY_ARRAY + = ResourceLocationHelper.getResourceLocation( + SYMBOL_TEXTURE_LOCATION + "arrayConveyor.png" + ); + public static final ResourceLocation DESTRUCTION_ALCHEMY_ARRAY + = ResourceLocationHelper.getResourceLocation( + SYMBOL_TEXTURE_LOCATION + "arrayDestruction.png" + ); + public static final ResourceLocation GELID_ALCHEMY_ARRAY + = ResourceLocationHelper.getResourceLocation( + SYMBOL_TEXTURE_LOCATION + "arrayGelid.png" + ); + public static final ResourceLocation PARTHENOGENESIS_ALCHEMY_ARRAY + = ResourceLocationHelper.getResourceLocation( + SYMBOL_TEXTURE_LOCATION + "arrayParthenogenesis.png" + ); + public static final ResourceLocation TRANSFIGURATION_ALCHEMY_ARRAY + = ResourceLocationHelper.getResourceLocation( + SYMBOL_TEXTURE_LOCATION + "arrayTransfiguration.png" + ); + public static final ResourceLocation TRANSMUTATION_ALCHEMY_ARRAY + = ResourceLocationHelper.getResourceLocation( + SYMBOL_TEXTURE_LOCATION + "arrayTransmutation.png" + ); } } diff --git a/src/main/java/com/pahimar/ee3/reference/ToolMode.java b/src/main/java/com/pahimar/ee3/reference/ToolMode.java index bb2e49c8..9a16b34c 100644 --- a/src/main/java/com/pahimar/ee3/reference/ToolMode.java +++ b/src/main/java/com/pahimar/ee3/reference/ToolMode.java @@ -1,8 +1,15 @@ package com.pahimar.ee3.reference; -public enum ToolMode -{ - UNKNOWN, STANDARD, DEEP, WIDE, TALL, SQUARE, CUBE, SLASH, MEGA; +public enum ToolMode { + UNKNOWN, + STANDARD, + DEEP, + WIDE, + TALL, + SQUARE, + CUBE, + SLASH, + MEGA; public static final ToolMode[] TYPES = ToolMode.values(); } diff --git a/src/main/java/com/pahimar/ee3/settings/ChalkSettings.java b/src/main/java/com/pahimar/ee3/settings/ChalkSettings.java index f06e2f88..b29f29ea 100644 --- a/src/main/java/com/pahimar/ee3/settings/ChalkSettings.java +++ b/src/main/java/com/pahimar/ee3/settings/ChalkSettings.java @@ -5,192 +5,148 @@ import com.pahimar.ee3.util.INBTTaggable; import net.minecraft.nbt.NBTTagCompound; // TODO Set the NBT tag names to constants -public class ChalkSettings implements INBTTaggable -{ +public class ChalkSettings implements INBTTaggable { private int index; private int size; private int rotation; private final int MAX_SIZE = 5; - public ChalkSettings() - { + public ChalkSettings() { this(0, 1, 0); } - public ChalkSettings(int index, int size, int rotation) - { + public ChalkSettings(int index, int size, int rotation) { this.index = index; this.size = size; this.rotation = rotation; } - public int getIndex() - { + public int getIndex() { return index; } - public void setIndex(int index) - { + public void setIndex(int index) { this.index = index; - if (this.index < 0) - { + if (this.index < 0) { this.index = 0; - } - else if (this.index >= AlchemyArrayRegistryProxy.getRegisteredAlchemyArrays().size()) - { - this.index = AlchemyArrayRegistryProxy.getRegisteredAlchemyArrays().size() - 1; + } else if (this.index >= AlchemyArrayRegistryProxy.getRegisteredAlchemyArrays().size()) { + this.index + = AlchemyArrayRegistryProxy.getRegisteredAlchemyArrays().size() - 1; } } - public void incrementIndex() - { + public void incrementIndex() { index += 1; - if (index >= AlchemyArrayRegistryProxy.getRegisteredAlchemyArrays().size()) - { + if (index >= AlchemyArrayRegistryProxy.getRegisteredAlchemyArrays().size()) { index = 0; } } - public void decrementIndex() - { + public void decrementIndex() { index -= 1; - if (index < 0) - { - this.index = AlchemyArrayRegistryProxy.getRegisteredAlchemyArrays().size() - 1; + if (index < 0) { + this.index + = AlchemyArrayRegistryProxy.getRegisteredAlchemyArrays().size() - 1; } } - public int getSize() - { + public int getSize() { return size; } - public void setSize(int size) - { - if (size < 1) - { + public void setSize(int size) { + if (size < 1) { this.size = 1; - } - else if (size > MAX_SIZE) - { + } else if (size > MAX_SIZE) { this.size = MAX_SIZE; - } - else - { + } else { this.size = size; } } - public void incrementSize() - { - if (size < MAX_SIZE) - { + public void incrementSize() { + if (size < MAX_SIZE) { size += 1; } } - public void decrementSize() - { - if (size > 1) - { + public void decrementSize() { + if (size > 1) { size -= 1; } } - public int getRotation() - { + public int getRotation() { return rotation; } - public void setRotation(int rotation) - { - if (rotation < 0) - { + public void setRotation(int rotation) { + if (rotation < 0) { this.rotation = 0; - } - else - { + } else { this.rotation = rotation % 4; } } - public void rotateClockwise() - { + public void rotateClockwise() { this.rotation = (rotation + 1) % 4; } - public void rotateCounterClockwise() - { + public void rotateCounterClockwise() { this.rotation -= 1; - if (this.rotation < 0) - { + if (this.rotation < 0) { this.rotation = 3; } } @Override - public void readFromNBT(NBTTagCompound nbtTagCompound) - { - if (nbtTagCompound != null && nbtTagCompound.hasKey("chalk_settings") && nbtTagCompound.getTag("chalk_settings").getId() == (byte) 10) - { - NBTTagCompound chalkSettings = nbtTagCompound.getCompoundTag("chalk_settings"); - if (chalkSettings.hasKey("index")) - { + public void readFromNBT(NBTTagCompound nbtTagCompound) { + if (nbtTagCompound != null && nbtTagCompound.hasKey("chalk_settings") + && nbtTagCompound.getTag("chalk_settings").getId() == (byte) 10) { + NBTTagCompound chalkSettings + = nbtTagCompound.getCompoundTag("chalk_settings"); + if (chalkSettings.hasKey("index")) { this.index = chalkSettings.getInteger("index"); - if (this.index < 0 || this.index >= AlchemyArrayRegistryProxy.getRegisteredAlchemyArrays().size()) - { + if (this.index < 0 + || this.index + >= AlchemyArrayRegistryProxy.getRegisteredAlchemyArrays().size( + )) { this.index = 0; } - } - else - { + } else { this.index = 0; } - if (chalkSettings.hasKey("size")) - { + if (chalkSettings.hasKey("size")) { this.size = chalkSettings.getInteger("size"); - if (this.size < 1) - { + if (this.size < 1) { this.size = 1; - } - else if (this.size > MAX_SIZE) - { + } else if (this.size > MAX_SIZE) { this.size = MAX_SIZE; } - } - else - { + } else { this.size = 1; } - if (chalkSettings.hasKey("rotation")) - { + if (chalkSettings.hasKey("rotation")) { this.rotation = chalkSettings.getInteger("rotation"); - if (this.rotation < 0) - { + if (this.rotation < 0) { this.rotation = 0; - } - else - { + } else { this.rotation = this.rotation % 4; } - } - else - { + } else { this.rotation = 0; } - } - else - { + } else { this.index = 0; this.size = 1; this.rotation = 0; @@ -198,8 +154,7 @@ public class ChalkSettings implements INBTTaggable } @Override - public void writeToNBT(NBTTagCompound nbtTagCompound) - { + public void writeToNBT(NBTTagCompound nbtTagCompound) { NBTTagCompound chalkSettings = new NBTTagCompound(); chalkSettings.setInteger("index", index); chalkSettings.setInteger("size", size); @@ -208,8 +163,7 @@ public class ChalkSettings implements INBTTaggable } @Override - public String getTagLabel() - { + public String getTagLabel() { return this.getClass().getName(); } } diff --git a/src/main/java/com/pahimar/ee3/test/EETestSuite.java b/src/main/java/com/pahimar/ee3/test/EETestSuite.java index 41d84caf..2f66d2cf 100644 --- a/src/main/java/com/pahimar/ee3/test/EETestSuite.java +++ b/src/main/java/com/pahimar/ee3/test/EETestSuite.java @@ -1,20 +1,18 @@ package com.pahimar.ee3.test; +import java.io.File; + import com.pahimar.ee3.init.ModBlocks; import com.pahimar.ee3.init.ModItems; import com.pahimar.ee3.reference.Files; import net.minecraft.item.ItemStack; -import java.io.File; - public class EETestSuite extends EnergyValueTestSuite { - public EETestSuite() { super(); } public EETestSuite build() { - add(ModBlocks.calcinator, 772); add(ModBlocks.aludel, 1794); add(ModBlocks.glassBell, 7); diff --git a/src/main/java/com/pahimar/ee3/test/EnergyValueTestSuite.java b/src/main/java/com/pahimar/ee3/test/EnergyValueTestSuite.java index 8e9b1da3..1fff03b1 100644 --- a/src/main/java/com/pahimar/ee3/test/EnergyValueTestSuite.java +++ b/src/main/java/com/pahimar/ee3/test/EnergyValueTestSuite.java @@ -1,5 +1,12 @@ package com.pahimar.ee3.test; +import java.io.File; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + import com.pahimar.ee3.api.exchange.EnergyValue; import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; import com.pahimar.ee3.exchange.WrappedStack; @@ -8,20 +15,17 @@ import com.pahimar.ee3.util.SerializationHelper; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; -import java.io.File; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - public class EnergyValueTestSuite { - - public static final Marker TEST_MARKER = MarkerManager.getMarker("EE3_ENERGY_VALUE_TEST", LogHelper.MOD_MARKER); - private static final Marker SUCCESS_MARKER = MarkerManager.getMarker("EE3_TEST_SUCCESS", TEST_MARKER); - private static final Marker FAILURE_MARKER = MarkerManager.getMarker("EE3_TEST_FAILURE", TEST_MARKER); - private static final Marker FAILURE_WRONG_VALUE_MARKER = MarkerManager.getMarker("EE3_TEST_FAILURE_WRONG_VALUE", FAILURE_MARKER); - private static final Marker FAILURE_NO_VALUE_MARKER = MarkerManager.getMarker("EE3_TEST_FAILURE_NO_VALUE", FAILURE_MARKER); + public static final Marker TEST_MARKER + = MarkerManager.getMarker("EE3_ENERGY_VALUE_TEST", LogHelper.MOD_MARKER); + private static final Marker SUCCESS_MARKER + = MarkerManager.getMarker("EE3_TEST_SUCCESS", TEST_MARKER); + private static final Marker FAILURE_MARKER + = MarkerManager.getMarker("EE3_TEST_FAILURE", TEST_MARKER); + private static final Marker FAILURE_WRONG_VALUE_MARKER + = MarkerManager.getMarker("EE3_TEST_FAILURE_WRONG_VALUE", FAILURE_MARKER); + private static final Marker FAILURE_NO_VALUE_MARKER + = MarkerManager.getMarker("EE3_TEST_FAILURE_NO_VALUE", FAILURE_MARKER); private Map testSuiteValueMap; @@ -34,17 +38,13 @@ public class EnergyValueTestSuite { } public EnergyValueTestSuite add(Object object, Object value) { - if (WrappedStack.canBeWrapped(object)) { - WrappedStack wrappedStack = WrappedStack.wrap(object, 1); if (value instanceof Number) { testSuiteValueMap.put(wrappedStack, new EnergyValue((Number) value)); - } - else if (value instanceof EnergyValue) { + } else if (value instanceof EnergyValue) { testSuiteValueMap.put(wrappedStack, (EnergyValue) value); - } - else if (value == null) { + } else if (value == null) { testSuiteValueMap.put(wrappedStack, null); } } @@ -53,7 +53,6 @@ public class EnergyValueTestSuite { } public EnergyValueTestSuite remove(Object object) { - if (WrappedStack.canBeWrapped(object)) { testSuiteValueMap.remove(WrappedStack.wrap(object, 1)); } @@ -66,33 +65,51 @@ public class EnergyValueTestSuite { } public void run(boolean strict) { - List successMessages = new ArrayList<>(); List failureMessagesWrongValue = new ArrayList<>(); List failureMessagesNoValue = new ArrayList<>(); for (WrappedStack wrappedStack : testSuiteValueMap.keySet()) { - EnergyValue expectedValue = testSuiteValueMap.get(wrappedStack); - EnergyValue actualValue = EnergyValueRegistryProxy.getEnergyValue(wrappedStack, strict); + EnergyValue actualValue + = EnergyValueRegistryProxy.getEnergyValue(wrappedStack, strict); if (actualValue == null && expectedValue == null) { // Success - anticipated that no value was found and no value was found - successMessages.add(String.format("SUCCESS: Object '%s' had the expected energy value [Expected (%s), Found (%s)]", wrappedStack, expectedValue, actualValue)); - } - else if (actualValue == null) { - // Failure - anticipated that a value would be found but no value was found - failureMessagesNoValue.add(String.format("FAILURE: Object '%s' did not have the expected energy value [Expected (%s), Found (%s)]", wrappedStack, expectedValue, actualValue)); - } - else if (actualValue != null && expectedValue != null) { - + successMessages.add(String.format( + "SUCCESS: Object '%s' had the expected energy value [Expected (%s), Found (%s)]", + wrappedStack, + expectedValue, + actualValue + )); + } else if (actualValue == null) { + // Failure - anticipated that a value would be found but no value was + // found + failureMessagesNoValue.add(String.format( + "FAILURE: Object '%s' did not have the expected energy value [Expected (%s), Found (%s)]", + wrappedStack, + expectedValue, + actualValue + )); + } else if (actualValue != null && expectedValue != null) { if (actualValue.equals(expectedValue)) { - // Success - anticipated that a specific value would be found and the anticipated value was found - successMessages.add(String.format("SUCCESS: Object '%s' had the expected energy value [Expected (%s), Found (%s)]", wrappedStack, expectedValue, actualValue)); - } - else { - // Failure - anticipated that a specific value would be found and while a value was found it was not the anticipated one - failureMessagesWrongValue.add(String.format("FAILURE: Object '%s' did not have the expected energy value [Expected (%s), Found (%s)]", wrappedStack, expectedValue, actualValue)); + // Success - anticipated that a specific value would be found and the + // anticipated value was found + successMessages.add(String.format( + "SUCCESS: Object '%s' had the expected energy value [Expected (%s), Found (%s)]", + wrappedStack, + expectedValue, + actualValue + )); + } else { + // Failure - anticipated that a specific value would be found and + // while a value was found it was not the anticipated one + failureMessagesWrongValue.add(String.format( + "FAILURE: Object '%s' did not have the expected energy value [Expected (%s), Found (%s)]", + wrappedStack, + expectedValue, + actualValue + )); } } } @@ -111,12 +128,12 @@ public class EnergyValueTestSuite { } public EnergyValueTestSuite load(File file) { - try { testSuiteValueMap = SerializationHelper.readMapFromFile(file); - } - catch (FileNotFoundException e) { - LogHelper.warn(TEST_MARKER, "Could not load test file from disk: " + e.getMessage()); + } catch (FileNotFoundException e) { + LogHelper.warn( + TEST_MARKER, "Could not load test file from disk: " + e.getMessage() + ); testSuiteValueMap = new TreeMap<>(); } diff --git a/src/main/java/com/pahimar/ee3/test/VanillaTestSuite.java b/src/main/java/com/pahimar/ee3/test/VanillaTestSuite.java index 585fadc4..8de3a964 100644 --- a/src/main/java/com/pahimar/ee3/test/VanillaTestSuite.java +++ b/src/main/java/com/pahimar/ee3/test/VanillaTestSuite.java @@ -1,21 +1,19 @@ package com.pahimar.ee3.test; +import java.io.File; + import com.pahimar.ee3.reference.Files; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; -import java.io.File; - public class VanillaTestSuite extends EnergyValueTestSuite { - public VanillaTestSuite() { super(); } public VanillaTestSuite build() { - addBuildingBlocksTabTestCases(); addDecorationBlocksTabTestCases(); addRedstoneTabTestCases(); @@ -31,7 +29,6 @@ public class VanillaTestSuite extends EnergyValueTestSuite { } private void addBuildingBlocksTabTestCases() { - add(Blocks.stone, 1); add(Blocks.grass, 1); add(Blocks.dirt, 1); @@ -175,7 +172,6 @@ public class VanillaTestSuite extends EnergyValueTestSuite { } private void addDecorationBlocksTabTestCases() { - add(new ItemStack(Blocks.sapling, 1, 0), 32); add(new ItemStack(Blocks.sapling, 1, 1), 32); add(new ItemStack(Blocks.sapling, 1, 2), 32); @@ -283,7 +279,6 @@ public class VanillaTestSuite extends EnergyValueTestSuite { } private void addRedstoneTabTestCases() { - add(Blocks.dispenser, 87); add(Blocks.noteblock, 96); add(Blocks.sticky_piston, 340); @@ -313,7 +308,6 @@ public class VanillaTestSuite extends EnergyValueTestSuite { } private void addTransportationTabTestCases() { - add(Blocks.golden_rail, 2054); add(Blocks.detector_rail, 261.667); add(Blocks.rail, 96.25); @@ -329,7 +323,6 @@ public class VanillaTestSuite extends EnergyValueTestSuite { } private void addMiscellaneousTabTestCases() { - add(Blocks.beacon, 24773); add(Items.bucket, 768); add(Items.water_bucket, 769); @@ -390,7 +383,6 @@ public class VanillaTestSuite extends EnergyValueTestSuite { } private void addFoodstuffsTabTestCases() { - add(Items.apple, 24); add(Items.mushroom_stew, 70); add(Items.bread, 72); @@ -422,7 +414,6 @@ public class VanillaTestSuite extends EnergyValueTestSuite { } private void addToolsTabTestCases() { - add(Items.iron_shovel, 264); add(Items.iron_pickaxe, 776); add(Items.iron_axe, 776); @@ -454,7 +445,6 @@ public class VanillaTestSuite extends EnergyValueTestSuite { } private void addCombatTabTestCases() { - add(Items.bow, 48); add(Items.arrow, 14); add(Items.iron_sword, 516); @@ -485,7 +475,6 @@ public class VanillaTestSuite extends EnergyValueTestSuite { } private void addBrewingTabTestCases() { - add(Items.ghast_tear, 4096); add(new ItemStack(Items.potionitem, 1, 0), 2); add(new ItemStack(Items.potionitem, 1, 16), 8.667); @@ -554,7 +543,6 @@ public class VanillaTestSuite extends EnergyValueTestSuite { } private void addMaterialsTabTestCases() { - add(new ItemStack(Items.coal, 1, 0), 32); add(new ItemStack(Items.coal, 1, 1), 32); add(Items.diamond, 8192); @@ -603,6 +591,8 @@ public class VanillaTestSuite extends EnergyValueTestSuite { } public void save() { - this.save(new File(Files.globalTestDirectory, "minecraft-v1710-vanilla-test-suite.json")); + this.save( + new File(Files.globalTestDirectory, "minecraft-v1710-vanilla-test-suite.json") + ); } } diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChest.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChest.java index eaf0b677..a0dc369d 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChest.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChest.java @@ -10,8 +10,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class TileEntityAlchemicalChest extends TileEntityEE implements IInventory -{ +public class TileEntityAlchemicalChest extends TileEntityEE implements IInventory { /** * The current angle of the chest lid (between 0 and 1) */ @@ -37,52 +36,38 @@ public class TileEntityAlchemicalChest extends TileEntityEE implements IInventor */ private ItemStack[] inventory; - public TileEntityAlchemicalChest(int metaData) - { + public TileEntityAlchemicalChest(int metaData) { super(); this.state = (byte) metaData; - if (metaData == 0) - { + if (metaData == 0) { inventory = new ItemStack[ContainerAlchemicalChest.SMALL_INVENTORY_SIZE]; - } - else if (metaData == 1) - { + } else if (metaData == 1) { inventory = new ItemStack[ContainerAlchemicalChest.MEDIUM_INVENTORY_SIZE]; - } - else if (metaData == 2) - { + } else if (metaData == 2) { inventory = new ItemStack[ContainerAlchemicalChest.LARGE_INVENTORY_SIZE]; } } @Override - public int getSizeInventory() - { + public int getSizeInventory() { return inventory.length; } @Override - public ItemStack getStackInSlot(int slotIndex) - { + public ItemStack getStackInSlot(int slotIndex) { return inventory[slotIndex]; } @Override - public ItemStack decrStackSize(int slotIndex, int decrementAmount) - { + public ItemStack decrStackSize(int slotIndex, int decrementAmount) { ItemStack itemStack = getStackInSlot(slotIndex); - if (itemStack != null) - { - if (itemStack.stackSize <= decrementAmount) - { + if (itemStack != null) { + if (itemStack.stackSize <= decrementAmount) { setInventorySlotContents(slotIndex, null); - } - else - { + } else { itemStack = itemStack.splitStack(decrementAmount); - if (itemStack.stackSize == 0) - { + if (itemStack.stackSize == 0) { setInventorySlotContents(slotIndex, null); } } @@ -92,187 +77,181 @@ public class TileEntityAlchemicalChest extends TileEntityEE implements IInventor } @Override - public ItemStack getStackInSlotOnClosing(int slotIndex) - { - if (inventory[slotIndex] != null) - { + public ItemStack getStackInSlotOnClosing(int slotIndex) { + if (inventory[slotIndex] != null) { ItemStack itemStack = inventory[slotIndex]; inventory[slotIndex] = null; return itemStack; - } - else - { + } else { return null; } } @Override - public void setInventorySlotContents(int slotIndex, ItemStack itemStack) - { + public void setInventorySlotContents(int slotIndex, ItemStack itemStack) { inventory[slotIndex] = itemStack; - if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit()) - { + if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit()) { itemStack.stackSize = this.getInventoryStackLimit(); } - this.markDirty(); } @Override - public String getInventoryName() - { - return this.hasCustomName() ? this.getCustomName() : Names.Containers.ALCHEMICAL_CHEST; + public String getInventoryName() { + return this.hasCustomName() ? this.getCustomName() + : Names.Containers.ALCHEMICAL_CHEST; } @Override - public boolean hasCustomInventoryName() - { + public boolean hasCustomInventoryName() { return this.hasCustomName(); } @Override - public int getInventoryStackLimit() - { + public int getInventoryStackLimit() { return 64; } /** - * Do not make give this method the name canInteractWith because it clashes with Container + * Do not make give this method the name canInteractWith because it clashes with + * Container * * @param entityplayer The player we are checking to see if they can use this chest */ @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) - { - return this.worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && entityplayer.getDistanceSq((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D; + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return this.worldObj.getTileEntity(xCoord, yCoord, zCoord) == this + && entityplayer.getDistanceSq( + (double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D + ) + <= 64D; } @Override - public void openInventory() - { + public void openInventory() { ++numUsingPlayers; - worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.alchemicalChest, 1, numUsingPlayers); + worldObj.addBlockEvent( + xCoord, yCoord, zCoord, ModBlocks.alchemicalChest, 1, numUsingPlayers + ); } @Override - public void closeInventory() - { + public void closeInventory() { --numUsingPlayers; - worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.alchemicalChest, 1, numUsingPlayers); + worldObj.addBlockEvent( + xCoord, yCoord, zCoord, ModBlocks.alchemicalChest, 1, numUsingPlayers + ); } @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) - { + public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { return true; } /** - * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count - * ticks and creates a new spawn inside its implementation. + * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob + * spawner uses this to count ticks and creates a new spawn inside its implementation. */ @Override - public void updateEntity() - { + public void updateEntity() { super.updateEntity(); - if (++ticksSinceSync % 20 * 4 == 0) - { - worldObj.addBlockEvent(xCoord, yCoord, zCoord, ModBlocks.alchemicalChest, 1, numUsingPlayers); + if (++ticksSinceSync % 20 * 4 == 0) { + worldObj.addBlockEvent( + xCoord, yCoord, zCoord, ModBlocks.alchemicalChest, 1, numUsingPlayers + ); } prevLidAngle = lidAngle; float angleIncrement = 0.1F; double adjustedXCoord, adjustedZCoord; - if (numUsingPlayers > 0 && lidAngle == 0.0F) - { + if (numUsingPlayers > 0 && lidAngle == 0.0F) { adjustedXCoord = xCoord + 0.5D; adjustedZCoord = zCoord + 0.5D; - worldObj.playSoundEffect(adjustedXCoord, yCoord + 0.5D, adjustedZCoord, Sounds.CHEST_OPEN, 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F); + worldObj.playSoundEffect( + adjustedXCoord, + yCoord + 0.5D, + adjustedZCoord, + Sounds.CHEST_OPEN, + 0.5F, + worldObj.rand.nextFloat() * 0.1F + 0.9F + ); } - if (numUsingPlayers == 0 && lidAngle > 0.0F || numUsingPlayers > 0 && lidAngle < 1.0F) - { + if (numUsingPlayers == 0 && lidAngle > 0.0F + || numUsingPlayers > 0 && lidAngle < 1.0F) { float var8 = lidAngle; - if (numUsingPlayers > 0) - { + if (numUsingPlayers > 0) { lidAngle += angleIncrement; - } - else - { + } else { lidAngle -= angleIncrement; } - if (lidAngle > 1.0F) - { + if (lidAngle > 1.0F) { lidAngle = 1.0F; } - if (lidAngle < 0.5F && var8 >= 0.5F) - { + if (lidAngle < 0.5F && var8 >= 0.5F) { adjustedXCoord = xCoord + 0.5D; adjustedZCoord = zCoord + 0.5D; - worldObj.playSoundEffect(adjustedXCoord, yCoord + 0.5D, adjustedZCoord, Sounds.CHEST_CLOSE, 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F); + worldObj.playSoundEffect( + adjustedXCoord, + yCoord + 0.5D, + adjustedZCoord, + Sounds.CHEST_CLOSE, + 0.5F, + worldObj.rand.nextFloat() * 0.1F + 0.9F + ); } - if (lidAngle < 0.0F) - { + if (lidAngle < 0.0F) { lidAngle = 0.0F; } } } /** - * Called when a client event is received with the event number and argument, see World.sendClientEvent + * Called when a client event is received with the event number and argument, see + * World.sendClientEvent */ @Override - public boolean receiveClientEvent(int eventID, int numUsingPlayers) - { - if (eventID == 1) - { + public boolean receiveClientEvent(int eventID, int numUsingPlayers) { + if (eventID == 1) { this.numUsingPlayers = numUsingPlayers; return true; - } - else - { + } else { return super.receiveClientEvent(eventID, numUsingPlayers); } } @Override - public void readFromNBT(NBTTagCompound nbtTagCompound) - { + public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = nbtTagCompound.getTagList(Names.NBT.ITEMS, 10); inventory = new ItemStack[this.getSizeInventory()]; - for (int i = 0; i < tagList.tagCount(); ++i) - { + for (int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slotIndex = tagCompound.getByte("Slot"); - if (slotIndex >= 0 && slotIndex < inventory.length) - { + if (slotIndex >= 0 && slotIndex < inventory.length) { inventory[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); } } } @Override - public void writeToNBT(NBTTagCompound nbtTagCompound) - { + public void writeToNBT(NBTTagCompound nbtTagCompound) { super.writeToNBT(nbtTagCompound); // Write the ItemStacks in the inventory to NBT NBTTagList tagList = new NBTTagList(); - for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) - { - if (inventory[currentIndex] != null) - { + for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) { + if (inventory[currentIndex] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte) currentIndex); inventory[currentIndex].writeToNBT(tagCompound); diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChestLarge.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChestLarge.java index 2d7cb9c8..c45afcf5 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChestLarge.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChestLarge.java @@ -1,9 +1,7 @@ package com.pahimar.ee3.tileentity; -public class TileEntityAlchemicalChestLarge extends TileEntityAlchemicalChest -{ - public TileEntityAlchemicalChestLarge() - { +public class TileEntityAlchemicalChestLarge extends TileEntityAlchemicalChest { + public TileEntityAlchemicalChestLarge() { super(2); } } diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChestMedium.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChestMedium.java index 5f654d5b..0c6fe872 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChestMedium.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChestMedium.java @@ -1,9 +1,7 @@ package com.pahimar.ee3.tileentity; -public class TileEntityAlchemicalChestMedium extends TileEntityAlchemicalChest -{ - public TileEntityAlchemicalChestMedium() - { +public class TileEntityAlchemicalChestMedium extends TileEntityAlchemicalChest { + public TileEntityAlchemicalChestMedium() { super(1); } } diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChestSmall.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChestSmall.java index b28a0c06..d10df60f 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChestSmall.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChestSmall.java @@ -1,9 +1,7 @@ package com.pahimar.ee3.tileentity; -public class TileEntityAlchemicalChestSmall extends TileEntityAlchemicalChest -{ - public TileEntityAlchemicalChestSmall() - { +public class TileEntityAlchemicalChestSmall extends TileEntityAlchemicalChest { + public TileEntityAlchemicalChestSmall() { super(0); } } diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemyArray.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemyArray.java index 8d4a35c2..0fc46799 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemyArray.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemyArray.java @@ -19,208 +19,161 @@ import net.minecraft.world.Explosion; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityAlchemyArray extends TileEntityEE implements ISidedInventory -{ +public class TileEntityAlchemyArray extends TileEntityEE implements ISidedInventory { private AlchemyArray alchemyArray; private ForgeDirection rotation; private int size; private int tickCount; - public TileEntityAlchemyArray() - { + public TileEntityAlchemyArray() { super(); rotation = ForgeDirection.UNKNOWN; size = 0; alchemyArray = null; } - public AlchemyArray getAlchemyArray() - { + public AlchemyArray getAlchemyArray() { return alchemyArray; } - public void setAlchemyArray(AlchemyArray alchemyArray) - { + public void setAlchemyArray(AlchemyArray alchemyArray) { setAlchemyArray(alchemyArray, 1); } - public void setAlchemyArray(AlchemyArray alchemyArray, int size) - { + public void setAlchemyArray(AlchemyArray alchemyArray, int size) { this.alchemyArray = alchemyArray; this.size = size; } - public ForgeDirection getRotation() - { + public ForgeDirection getRotation() { return rotation; } - public void setRotation(ForgeDirection rotation) - { + public void setRotation(ForgeDirection rotation) { this.rotation = rotation; } - public void setRotation(int rotation, int facing) - { - if (this.orientation == ForgeDirection.UP) - { - if ((rotation + facing) % 4 == 0) - { + public void setRotation(int rotation, int facing) { + if (this.orientation == ForgeDirection.UP) { + if ((rotation + facing) % 4 == 0) { this.rotation = ForgeDirection.NORTH; - } - else if ((rotation + facing) % 4 == 1) - { + } else if ((rotation + facing) % 4 == 1) { this.rotation = ForgeDirection.EAST; - } - else if ((rotation + facing) % 4 == 2) - { + } else if ((rotation + facing) % 4 == 2) { this.rotation = ForgeDirection.SOUTH; - } - else if ((rotation + facing) % 4 == 3) - { + } else if ((rotation + facing) % 4 == 3) { this.rotation = ForgeDirection.WEST; } - } - else if (this.orientation == ForgeDirection.DOWN) - { - if ((rotation + facing) % 4 == 0) - { + } else if (this.orientation == ForgeDirection.DOWN) { + if ((rotation + facing) % 4 == 0) { this.rotation = ForgeDirection.NORTH; - } - else if ((rotation + facing) % 4 == 1) - { + } else if ((rotation + facing) % 4 == 1) { this.rotation = ForgeDirection.EAST; - } - else if ((rotation + facing) % 4 == 2) - { + } else if ((rotation + facing) % 4 == 2) { this.rotation = ForgeDirection.SOUTH; - } - else if ((rotation + facing) % 4 == 3) - { + } else if ((rotation + facing) % 4 == 3) { this.rotation = ForgeDirection.WEST; } - } - else if (this.orientation == ForgeDirection.NORTH) - { - if ((rotation + facing) % 4 == 0) - { + } else if (this.orientation == ForgeDirection.NORTH) { + if ((rotation + facing) % 4 == 0) { this.rotation = ForgeDirection.UP; - } - else if ((rotation + facing) % 4 == 1) - { + } else if ((rotation + facing) % 4 == 1) { this.rotation = ForgeDirection.EAST; - } - else if ((rotation + facing) % 4 == 2) - { + } else if ((rotation + facing) % 4 == 2) { this.rotation = ForgeDirection.DOWN; - } - else if ((rotation + facing) % 4 == 3) - { + } else if ((rotation + facing) % 4 == 3) { this.rotation = ForgeDirection.WEST; } - } - else if (this.orientation == ForgeDirection.SOUTH) - { - if ((rotation + facing) % 4 == 0) - { + } else if (this.orientation == ForgeDirection.SOUTH) { + if ((rotation + facing) % 4 == 0) { this.rotation = ForgeDirection.DOWN; - } - else if ((rotation + facing) % 4 == 1) - { + } else if ((rotation + facing) % 4 == 1) { this.rotation = ForgeDirection.EAST; - } - else if ((rotation + facing) % 4 == 2) - { + } else if ((rotation + facing) % 4 == 2) { this.rotation = ForgeDirection.UP; - } - else if ((rotation + facing) % 4 == 3) - { + } else if ((rotation + facing) % 4 == 3) { this.rotation = ForgeDirection.WEST; } - } - else if (this.orientation == ForgeDirection.EAST) - { - if ((rotation + facing) % 4 == 0) - { + } else if (this.orientation == ForgeDirection.EAST) { + if ((rotation + facing) % 4 == 0) { this.rotation = ForgeDirection.NORTH; - } - else if ((rotation + facing) % 4 == 1) - { + } else if ((rotation + facing) % 4 == 1) { this.rotation = ForgeDirection.UP; - } - else if ((rotation + facing) % 4 == 2) - { + } else if ((rotation + facing) % 4 == 2) { this.rotation = ForgeDirection.SOUTH; - } - else if ((rotation + facing) % 4 == 3) - { + } else if ((rotation + facing) % 4 == 3) { this.rotation = ForgeDirection.DOWN; } - } - else if (this.orientation == ForgeDirection.WEST) - { - if ((rotation + facing) % 4 == 0) - { + } else if (this.orientation == ForgeDirection.WEST) { + if ((rotation + facing) % 4 == 0) { this.rotation = ForgeDirection.NORTH; - } - else if ((rotation + facing) % 4 == 1) - { + } else if ((rotation + facing) % 4 == 1) { this.rotation = ForgeDirection.DOWN; - } - else if ((rotation + facing) % 4 == 2) - { + } else if ((rotation + facing) % 4 == 2) { this.rotation = ForgeDirection.SOUTH; - } - else if ((rotation + facing) % 4 == 3) - { + } else if ((rotation + facing) % 4 == 3) { this.rotation = ForgeDirection.UP; } } } - public int getSize() - { + public int getSize() { return size; } - public void setSize(int size) - { + public void setSize(int size) { this.size = size; } @Override @SideOnly(Side.CLIENT) - public AxisAlignedBB getRenderBoundingBox() - { - if (this.orientation == ForgeDirection.UP || this.orientation == ForgeDirection.DOWN) - { - return AxisAlignedBB.getBoundingBox(xCoord - size, yCoord - 1, zCoord - size, xCoord + size, yCoord + 1, zCoord + size); + public AxisAlignedBB getRenderBoundingBox() { + if (this.orientation == ForgeDirection.UP + || this.orientation == ForgeDirection.DOWN) { + return AxisAlignedBB.getBoundingBox( + xCoord - size, + yCoord - 1, + zCoord - size, + xCoord + size, + yCoord + 1, + zCoord + size + ); } else if (this.orientation == ForgeDirection.NORTH || this.orientation == ForgeDirection.SOUTH) { - return AxisAlignedBB.getBoundingBox(xCoord - size, yCoord - size, zCoord - 1, xCoord + size, yCoord + size, zCoord + 1); + return AxisAlignedBB.getBoundingBox( + xCoord - size, + yCoord - size, + zCoord - 1, + xCoord + size, + yCoord + size, + zCoord + 1 + ); } else if (this.orientation == ForgeDirection.EAST || this.orientation == ForgeDirection.WEST) { - return AxisAlignedBB.getBoundingBox(xCoord - 1, yCoord - size, zCoord - size, xCoord + 1, yCoord + size, zCoord + size); + return AxisAlignedBB.getBoundingBox( + xCoord - 1, + yCoord - size, + zCoord - size, + xCoord + 1, + yCoord + size, + zCoord + size + ); } return super.getRenderBoundingBox(); } @Override - public void updateEntity() - { + public void updateEntity() { super.updateEntity(); - if (!worldObj.isRemote) - { + if (!worldObj.isRemote) { ++tickCount; - if (tickCount % 100 == 0) - { - if (!areDummyBlocksValid()) - { + if (tickCount % 100 == 0) { + if (!areDummyBlocksValid()) { this.invalidate(); worldObj.setBlockToAir(xCoord, yCoord, zCoord); } @@ -230,180 +183,304 @@ public class TileEntityAlchemyArray extends TileEntityEE implements ISidedInvent } } - public int getLightLevel() - { - if (alchemyArray != null) - { + public int getLightLevel() { + if (alchemyArray != null) { return alchemyArray.getLightLevel(); } return 0; } - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) - { - onBlockPlacedBy(world, x, y, z, this.xCoord, this.yCoord, this.zCoord, entityLiving, itemStack); + public void onBlockPlacedBy( + World world, + int x, + int y, + int z, + EntityLivingBase entityLiving, + ItemStack itemStack + ) { + onBlockPlacedBy( + world, x, y, z, this.xCoord, this.yCoord, this.zCoord, entityLiving, itemStack + ); } - public void onBlockPlacedBy(World world, int eventX, int eventY, int eventZ, int arrayX, int arrayY, int arrayZ, EntityLivingBase entityLiving, ItemStack itemStack) - { - if (alchemyArray != null) - { - alchemyArray.onArrayPlacedBy(world, eventX, eventY, eventZ, arrayX, arrayY, arrayZ, entityLiving, itemStack); + public void onBlockPlacedBy( + World world, + int eventX, + int eventY, + int eventZ, + int arrayX, + int arrayY, + int arrayZ, + EntityLivingBase entityLiving, + ItemStack itemStack + ) { + if (alchemyArray != null) { + alchemyArray.onArrayPlacedBy( + world, + eventX, + eventY, + eventZ, + arrayX, + arrayY, + arrayZ, + entityLiving, + itemStack + ); } } - public void onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int sideHit, float hitX, float hitY, float hitZ) - { - onBlockActivated(world, x, y, z, this.xCoord, this.yCoord, this.zCoord, entityPlayer, sideHit, hitX, hitY, hitZ); + public void onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer entityPlayer, + int sideHit, + float hitX, + float hitY, + float hitZ + ) { + onBlockActivated( + world, + x, + y, + z, + this.xCoord, + this.yCoord, + this.zCoord, + entityPlayer, + sideHit, + hitX, + hitY, + hitZ + ); } - public void onBlockActivated(World world, int eventX, int eventY, int eventZ, int arrayX, int arrayY, int arrayZ, EntityPlayer entityPlayer, int sideHit, float hitX, float hitY, float hitZ) - { - if (alchemyArray != null) - { - alchemyArray.onArrayActivated(world, eventX, eventY, eventZ, arrayX, arrayY, arrayZ, entityPlayer, sideHit, hitX, hitY, hitZ); + public void onBlockActivated( + World world, + int eventX, + int eventY, + int eventZ, + int arrayX, + int arrayY, + int arrayZ, + EntityPlayer entityPlayer, + int sideHit, + float hitX, + float hitY, + float hitZ + ) { + if (alchemyArray != null) { + alchemyArray.onArrayActivated( + world, + eventX, + eventY, + eventZ, + arrayX, + arrayY, + arrayZ, + entityPlayer, + sideHit, + hitX, + hitY, + hitZ + ); } } - public void onBlockClicked(World world, int x, int y, int z, EntityPlayer entityPlayer) - { - onBlockClicked(world, x, y, z, this.xCoord, this.yCoord, this.zCoord, entityPlayer); + public void + onBlockClicked(World world, int x, int y, int z, EntityPlayer entityPlayer) { + onBlockClicked( + world, x, y, z, this.xCoord, this.yCoord, this.zCoord, entityPlayer + ); } - public void onBlockClicked(World world, int eventX, int eventY, int eventZ, int arrayX, int arrayY, int arrayZ, EntityPlayer entityPlayer) - { - if (alchemyArray != null) - { - alchemyArray.onArrayClicked(world, eventX, eventY, eventZ, arrayX, arrayY, arrayZ, entityPlayer); + public void onBlockClicked( + World world, + int eventX, + int eventY, + int eventZ, + int arrayX, + int arrayY, + int arrayZ, + EntityPlayer entityPlayer + ) { + if (alchemyArray != null) { + alchemyArray.onArrayClicked( + world, eventX, eventY, eventZ, arrayX, arrayY, arrayZ, entityPlayer + ); } } - public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) - { - onBlockDestroyedByExplosion(world, x, y, z, this.xCoord, this.yCoord, this.zCoord, explosion); + public void + onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) { + onBlockDestroyedByExplosion( + world, x, y, z, this.xCoord, this.yCoord, this.zCoord, explosion + ); } - public void onBlockDestroyedByExplosion(World world, int eventX, int eventY, int eventZ, int arrayX, int arrayY, int arrayZ, Explosion explosion) - { - if (alchemyArray != null) - { - alchemyArray.onArrayDestroyedByExplosion(world, eventX, eventY, eventZ, arrayX, arrayY, arrayZ, explosion); + public void onBlockDestroyedByExplosion( + World world, + int eventX, + int eventY, + int eventZ, + int arrayX, + int arrayY, + int arrayZ, + Explosion explosion + ) { + if (alchemyArray != null) { + alchemyArray.onArrayDestroyedByExplosion( + world, eventX, eventY, eventZ, arrayX, arrayY, arrayZ, explosion + ); } } - public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int metaData) - { - onBlockDestroyedByPlayer(world, x, y, z, this.xCoord, this.yCoord, this.zCoord, metaData); + public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int metaData) { + onBlockDestroyedByPlayer( + world, x, y, z, this.xCoord, this.yCoord, this.zCoord, metaData + ); } - public void onBlockDestroyedByPlayer(World world, int eventX, int eventY, int eventZ, int arrayX, int arrayY, int arrayZ, int metaData) - { - if (alchemyArray != null) - { - alchemyArray.onArrayDestroyedByPlayer(world, eventX, eventY, eventZ, arrayX, arrayY, arrayZ, metaData); + public void onBlockDestroyedByPlayer( + World world, + int eventX, + int eventY, + int eventZ, + int arrayX, + int arrayY, + int arrayZ, + int metaData + ) { + if (alchemyArray != null) { + alchemyArray.onArrayDestroyedByPlayer( + world, eventX, eventY, eventZ, arrayX, arrayY, arrayZ, metaData + ); } } - public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) - { - onEntityCollidedWithBlock(world, x, y, z, this.xCoord, this.yCoord, this.zCoord, entity); + public void + onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { + onEntityCollidedWithBlock( + world, x, y, z, this.xCoord, this.yCoord, this.zCoord, entity + ); } - public void onEntityCollidedWithBlock(World world, int eventX, int eventY, int eventZ, int arrayX, int arrayY, int arrayZ, Entity entity) - { - if (alchemyArray != null) - { - alchemyArray.onEntityCollidedWithArray(world, eventX, eventY, eventZ, arrayX, arrayY, arrayZ, entity); + public void onEntityCollidedWithBlock( + World world, + int eventX, + int eventY, + int eventZ, + int arrayX, + int arrayY, + int arrayZ, + Entity entity + ) { + if (alchemyArray != null) { + alchemyArray.onEntityCollidedWithArray( + world, eventX, eventY, eventZ, arrayX, arrayY, arrayZ, entity + ); } } - public void onFallenUpon(World world, int x, int y, int z, Entity entity, float fallDistance) - { - onFallenUpon(world, x, y, z, this.xCoord, this.yCoord, this.zCoord, entity, fallDistance); + public void + onFallenUpon(World world, int x, int y, int z, Entity entity, float fallDistance) { + onFallenUpon( + world, x, y, z, this.xCoord, this.yCoord, this.zCoord, entity, fallDistance + ); } - public void onFallenUpon(World world, int eventX, int eventY, int eventZ, int arrayX, int arrayY, int arrayZ, Entity entity, float fallDistance) - { - if (alchemyArray != null) - { - alchemyArray.onArrayFallenUpon(world, eventX, eventY, eventZ, arrayX, arrayY, arrayZ, entity, fallDistance); + public void onFallenUpon( + World world, + int eventX, + int eventY, + int eventZ, + int arrayX, + int arrayY, + int arrayZ, + Entity entity, + float fallDistance + ) { + if (alchemyArray != null) { + alchemyArray.onArrayFallenUpon( + world, + eventX, + eventY, + eventZ, + arrayX, + arrayY, + arrayZ, + entity, + fallDistance + ); } } - public void onUpdate(World world, int x, int y, int z, int tickCount) - { - if (alchemyArray != null) - { + public void onUpdate(World world, int x, int y, int z, int tickCount) { + if (alchemyArray != null) { alchemyArray.onUpdate(world, x, y, z, tickCount); } } @Override - public Packet getDescriptionPacket() - { - return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityAlchemyArray(this)); + public Packet getDescriptionPacket() { + return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityAlchemyArray(this + )); } @Override - public void readFromNBT(NBTTagCompound nbtTagCompound) - { + public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); rotation = ForgeDirection.getOrientation(nbtTagCompound.getInteger("rotation")); size = nbtTagCompound.getInteger("size"); - NBTTagCompound alchemyArrayTagCompound = nbtTagCompound.getCompoundTag("alchemyArray"); + NBTTagCompound alchemyArrayTagCompound + = nbtTagCompound.getCompoundTag("alchemyArray"); - if (!alchemyArrayTagCompound.hasNoTags()) - { + if (!alchemyArrayTagCompound.hasNoTags()) { alchemyArray = AlchemyArray.readArrayFromNBT(alchemyArrayTagCompound); - try - { - Class clazz = Class.forName(alchemyArray.getClassName(), true, Loader.instance().getModClassLoader()); + try { + Class clazz = Class.forName( + alchemyArray.getClassName(), + true, + Loader.instance().getModClassLoader() + ); alchemyArray = (AlchemyArray) clazz.getConstructor().newInstance(); alchemyArray.readFromNBT(alchemyArrayTagCompound); - } - catch (Exception e) - { + } catch (Exception e) { this.invalidate(); - if (worldObj != null) - { + if (worldObj != null) { worldObj.setBlockToAir(xCoord, yCoord, zCoord); } } - } - else - { + } else { this.invalidate(); } } @Override - public void writeToNBT(NBTTagCompound nbtTagCompound) - { + public void writeToNBT(NBTTagCompound nbtTagCompound) { super.writeToNBT(nbtTagCompound); nbtTagCompound.setInteger("rotation", rotation.ordinal()); nbtTagCompound.setInteger("size", size); NBTTagCompound alchemyArrayTagCompound = new NBTTagCompound(); - if (alchemyArray != null) - { + if (alchemyArray != null) { alchemyArray.writeToNBT(alchemyArrayTagCompound); } nbtTagCompound.setTag("alchemyArray", alchemyArrayTagCompound); } - private boolean areDummyBlocksValid() - { + private boolean areDummyBlocksValid() { boolean validDummyBlocks = true; int coordOffset = this.size / 2; - if (this.orientation == ForgeDirection.UP || this.orientation == ForgeDirection.DOWN) - { - for (int i = this.xCoord - coordOffset; i <= this.xCoord + coordOffset; i++) - { - for (int j = this.zCoord - coordOffset; j <= this.zCoord + coordOffset; j++) - { - if ((i != this.xCoord || j != this.zCoord) && !isValidDummyBlock(i, this.yCoord, j)) - { + if (this.orientation == ForgeDirection.UP + || this.orientation == ForgeDirection.DOWN) { + for (int i = this.xCoord - coordOffset; i <= this.xCoord + coordOffset; i++) { + for (int j = this.zCoord - coordOffset; j <= this.zCoord + coordOffset; + j++) { + if ((i != this.xCoord || j != this.zCoord) + && !isValidDummyBlock(i, this.yCoord, j)) { validDummyBlocks = false; } } @@ -411,12 +488,11 @@ public class TileEntityAlchemyArray extends TileEntityEE implements ISidedInvent } else if (this.orientation == ForgeDirection.NORTH || this.orientation == ForgeDirection.SOUTH) { - for (int i = this.xCoord - coordOffset; i <= this.xCoord + coordOffset; i++) - { - for (int j = this.yCoord - coordOffset; j <= this.yCoord + coordOffset; j++) - { - if ((i != this.xCoord || j != this.yCoord) && !isValidDummyBlock(i, j, this.zCoord)) - { + for (int i = this.xCoord - coordOffset; i <= this.xCoord + coordOffset; i++) { + for (int j = this.yCoord - coordOffset; j <= this.yCoord + coordOffset; + j++) { + if ((i != this.xCoord || j != this.yCoord) + && !isValidDummyBlock(i, j, this.zCoord)) { validDummyBlocks = false; } } @@ -424,12 +500,11 @@ public class TileEntityAlchemyArray extends TileEntityEE implements ISidedInvent } else if (this.orientation == ForgeDirection.EAST || this.orientation == ForgeDirection.WEST) { - for (int i = this.yCoord - coordOffset; i <= this.yCoord + coordOffset; i++) - { - for (int j = this.zCoord - coordOffset; j <= this.zCoord + coordOffset; j++) - { - if ((i != this.yCoord || j != this.zCoord) && !isValidDummyBlock(this.xCoord, i, j)) - { + for (int i = this.yCoord - coordOffset; i <= this.yCoord + coordOffset; i++) { + for (int j = this.zCoord - coordOffset; j <= this.zCoord + coordOffset; + j++) { + if ((i != this.yCoord || j != this.zCoord) + && !isValidDummyBlock(this.xCoord, i, j)) { validDummyBlocks = false; } } @@ -439,18 +514,16 @@ public class TileEntityAlchemyArray extends TileEntityEE implements ISidedInvent return validDummyBlocks; } - private boolean isValidDummyBlock(int x, int y, int z) - { - if (!this.worldObj.isRemote) - { - if (this.worldObj.getTileEntity(x, y, z) instanceof TileEntityDummyArray) - { - TileEntityDummyArray tileEntityDummyArray = (TileEntityDummyArray) this.worldObj.getTileEntity(x, y, z); + private boolean isValidDummyBlock(int x, int y, int z) { + if (!this.worldObj.isRemote) { + if (this.worldObj.getTileEntity(x, y, z) instanceof TileEntityDummyArray) { + TileEntityDummyArray tileEntityDummyArray + = (TileEntityDummyArray) this.worldObj.getTileEntity(x, y, z); - return tileEntityDummyArray.getOrientation() == this.orientation && - tileEntityDummyArray.getTrueXCoord() == this.xCoord && - tileEntityDummyArray.getTrueYCoord() == this.yCoord && - tileEntityDummyArray.getTrueZCoord() == this.zCoord; + return tileEntityDummyArray.getOrientation() == this.orientation + && tileEntityDummyArray.getTrueXCoord() == this.xCoord + && tileEntityDummyArray.getTrueYCoord() == this.yCoord + && tileEntityDummyArray.getTrueZCoord() == this.zCoord; } } @@ -458,10 +531,8 @@ public class TileEntityAlchemyArray extends TileEntityEE implements ISidedInvent } @Override - public int getSizeInventory() - { - if (alchemyArray instanceof IInventory) - { + public int getSizeInventory() { + if (alchemyArray instanceof IInventory) { return ((IInventory) alchemyArray).getSizeInventory(); } @@ -469,10 +540,8 @@ public class TileEntityAlchemyArray extends TileEntityEE implements ISidedInvent } @Override - public ItemStack getStackInSlot(int slotIndex) - { - if (alchemyArray instanceof IInventory) - { + public ItemStack getStackInSlot(int slotIndex) { + if (alchemyArray instanceof IInventory) { return ((IInventory) alchemyArray).getStackInSlot(slotIndex); } @@ -480,10 +549,8 @@ public class TileEntityAlchemyArray extends TileEntityEE implements ISidedInvent } @Override - public ItemStack decrStackSize(int slotIndex, int decrementAmount) - { - if (alchemyArray instanceof IInventory) - { + public ItemStack decrStackSize(int slotIndex, int decrementAmount) { + if (alchemyArray instanceof IInventory) { return ((IInventory) alchemyArray).decrStackSize(slotIndex, decrementAmount); } @@ -491,10 +558,8 @@ public class TileEntityAlchemyArray extends TileEntityEE implements ISidedInvent } @Override - public ItemStack getStackInSlotOnClosing(int slotIndex) - { - if (alchemyArray instanceof IInventory) - { + public ItemStack getStackInSlotOnClosing(int slotIndex) { + if (alchemyArray instanceof IInventory) { return ((IInventory) alchemyArray).getStackInSlotOnClosing(slotIndex); } @@ -502,19 +567,15 @@ public class TileEntityAlchemyArray extends TileEntityEE implements ISidedInvent } @Override - public void setInventorySlotContents(int slotIndex, ItemStack itemStack) - { - if (alchemyArray instanceof IInventory) - { + public void setInventorySlotContents(int slotIndex, ItemStack itemStack) { + if (alchemyArray instanceof IInventory) { ((IInventory) alchemyArray).setInventorySlotContents(slotIndex, itemStack); } } @Override - public String getInventoryName() - { - if (alchemyArray instanceof IInventory) - { + public String getInventoryName() { + if (alchemyArray instanceof IInventory) { return ((IInventory) alchemyArray).getInventoryName(); } @@ -522,10 +583,8 @@ public class TileEntityAlchemyArray extends TileEntityEE implements ISidedInvent } @Override - public boolean hasCustomInventoryName() - { - if (alchemyArray instanceof IInventory) - { + public boolean hasCustomInventoryName() { + if (alchemyArray instanceof IInventory) { return ((IInventory) alchemyArray).hasCustomInventoryName(); } @@ -533,10 +592,8 @@ public class TileEntityAlchemyArray extends TileEntityEE implements ISidedInvent } @Override - public int getInventoryStackLimit() - { - if (alchemyArray instanceof IInventory) - { + public int getInventoryStackLimit() { + if (alchemyArray instanceof IInventory) { return ((IInventory) alchemyArray).getInventoryStackLimit(); } @@ -544,10 +601,8 @@ public class TileEntityAlchemyArray extends TileEntityEE implements ISidedInvent } @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) - { - if (alchemyArray instanceof IInventory) - { + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + if (alchemyArray instanceof IInventory) { return ((IInventory) alchemyArray).isUseableByPlayer(entityplayer); } @@ -555,28 +610,22 @@ public class TileEntityAlchemyArray extends TileEntityEE implements ISidedInvent } @Override - public void openInventory() - { - if (alchemyArray instanceof IInventory) - { + public void openInventory() { + if (alchemyArray instanceof IInventory) { ((IInventory) alchemyArray).openInventory(); } } @Override - public void closeInventory() - { - if (alchemyArray instanceof IInventory) - { + public void closeInventory() { + if (alchemyArray instanceof IInventory) { ((IInventory) alchemyArray).closeInventory(); } } @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) - { - if (alchemyArray instanceof IInventory) - { + public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { + if (alchemyArray instanceof IInventory) { return ((IInventory) alchemyArray).isItemValidForSlot(slotIndex, itemStack); } @@ -584,20 +633,17 @@ public class TileEntityAlchemyArray extends TileEntityEE implements ISidedInvent } @Override - public int[] getAccessibleSlotsFromSide(int slotIndex) - { + public int[] getAccessibleSlotsFromSide(int slotIndex) { return new int[0]; } @Override - public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) - { + public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { return false; } @Override - public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) - { + public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) { return false; } } diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAludel.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAludel.java index 4c75bcd7..d531b2a7 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAludel.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAludel.java @@ -18,17 +18,16 @@ import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityAludel extends TileEntityEE implements ISidedInventory -{ +public class TileEntityAludel extends TileEntityEE implements ISidedInventory { public static final int INVENTORY_SIZE = 4; public static final int FUEL_INVENTORY_INDEX = 0; public static final int INPUT_INVENTORY_INDEX = 1; public static final int DUST_INVENTORY_INDEX = 2; public static final int OUTPUT_INVENTORY_INDEX = 3; - public int deviceCookTime; // How much longer the Aludel will cook - public int fuelBurnTime; // The fuel value for the currently burning fuel - public int itemCookTime; // How long the current item has been "cooking" + public int deviceCookTime; // How much longer the Aludel will cook + public int fuelBurnTime; // The fuel value for the currently burning fuel + public int itemCookTime; // How long the current item has been "cooking" public ItemStack outputItemStack; @@ -38,50 +37,45 @@ public class TileEntityAludel extends TileEntityEE implements ISidedInventory */ private ItemStack[] inventory; - public TileEntityAludel() - { + public TileEntityAludel() { inventory = new ItemStack[INVENTORY_SIZE]; } @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return side == ForgeDirection.DOWN.ordinal() ? new int[]{FUEL_INVENTORY_INDEX, OUTPUT_INVENTORY_INDEX} : new int[]{INPUT_INVENTORY_INDEX, DUST_INVENTORY_INDEX, OUTPUT_INVENTORY_INDEX}; + public int[] getAccessibleSlotsFromSide(int side) { + return side == ForgeDirection.DOWN.ordinal() + ? new int[] { FUEL_INVENTORY_INDEX, OUTPUT_INVENTORY_INDEX } + : new int[] { INPUT_INVENTORY_INDEX, + DUST_INVENTORY_INDEX, + OUTPUT_INVENTORY_INDEX }; } @Override - public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) - { - if (worldObj.getTileEntity(xCoord, yCoord + 1, zCoord) instanceof TileEntityGlassBell) - { + public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { + if (worldObj.getTileEntity(xCoord, yCoord + 1, zCoord) + instanceof TileEntityGlassBell) { return isItemValidForSlot(slotIndex, itemStack); - } - else - { + } else { return false; } } @Override - public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) - { + public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) { return slotIndex == OUTPUT_INVENTORY_INDEX; } @Override - public void readFromNBT(NBTTagCompound nbtTagCompound) - { + public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = nbtTagCompound.getTagList(Names.NBT.ITEMS, 10); inventory = new ItemStack[this.getSizeInventory()]; - for (int i = 0; i < tagList.tagCount(); ++i) - { + for (int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slotIndex = tagCompound.getByte("Slot"); - if (slotIndex >= 0 && slotIndex < inventory.length) - { + if (slotIndex >= 0 && slotIndex < inventory.length) { inventory[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); } } @@ -93,32 +87,24 @@ public class TileEntityAludel extends TileEntityEE implements ISidedInventory } @Override - public int getSizeInventory() - { + public int getSizeInventory() { return inventory.length; } @Override - public ItemStack getStackInSlot(int slotIndex) - { + public ItemStack getStackInSlot(int slotIndex) { return inventory[slotIndex]; } @Override - public ItemStack decrStackSize(int slotIndex, int decrementAmount) - { + public ItemStack decrStackSize(int slotIndex, int decrementAmount) { ItemStack itemStack = getStackInSlot(slotIndex); - if (itemStack != null) - { - if (itemStack.stackSize <= decrementAmount) - { + if (itemStack != null) { + if (itemStack.stackSize <= decrementAmount) { setInventorySlotContents(slotIndex, null); - } - else - { + } else { itemStack = itemStack.splitStack(decrementAmount); - if (itemStack.stackSize == 0) - { + if (itemStack.stackSize == 0) { setInventorySlotContents(slotIndex, null); } } @@ -128,97 +114,82 @@ public class TileEntityAludel extends TileEntityEE implements ISidedInventory } @Override - public ItemStack getStackInSlotOnClosing(int slotIndex) - { + public ItemStack getStackInSlotOnClosing(int slotIndex) { ItemStack itemStack = getStackInSlot(slotIndex); - if (itemStack != null) - { + if (itemStack != null) { setInventorySlotContents(slotIndex, null); } return itemStack; } @Override - public void setInventorySlotContents(int slotIndex, ItemStack itemStack) - { + public void setInventorySlotContents(int slotIndex, ItemStack itemStack) { inventory[slotIndex] = itemStack; - if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) - { + if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) { itemStack.stackSize = getInventoryStackLimit(); } } @Override - public String getInventoryName() - { + public String getInventoryName() { return this.hasCustomName() ? this.getCustomName() : Names.Containers.ALUDEL; } @Override - public boolean hasCustomInventoryName() - { + public boolean hasCustomInventoryName() { return this.hasCustomName(); } @Override - public int getInventoryStackLimit() - { + public int getInventoryStackLimit() { return 64; } @Override - public boolean isUseableByPlayer(EntityPlayer entityPlayer) - { - return this.worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && entityPlayer.getDistanceSq((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D; + public boolean isUseableByPlayer(EntityPlayer entityPlayer) { + return this.worldObj.getTileEntity(xCoord, yCoord, zCoord) == this + && entityPlayer.getDistanceSq( + (double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D + ) + <= 64D; } @Override - public void openInventory() - { + public void openInventory() { // NOOP } @Override - public void closeInventory() - { + public void closeInventory() { // NOOP } @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) - { - switch (slotIndex) - { - case FUEL_INVENTORY_INDEX: - { + public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { + switch (slotIndex) { + case FUEL_INVENTORY_INDEX: { return TileEntityFurnace.isItemFuel(itemStack); } - case INPUT_INVENTORY_INDEX: - { + case INPUT_INVENTORY_INDEX: { return true; } - case DUST_INVENTORY_INDEX: - { + case DUST_INVENTORY_INDEX: { return itemStack.getItem() instanceof ItemAlchemicalDust; } - default: - { + default: { return false; } } } @Override - public void writeToNBT(NBTTagCompound nbtTagCompound) - { + public void writeToNBT(NBTTagCompound nbtTagCompound) { super.writeToNBT(nbtTagCompound); // Write the ItemStacks in the inventory to NBT NBTTagList tagList = new NBTTagList(); - for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) - { - if (inventory[currentIndex] != null) - { + for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) { + if (inventory[currentIndex] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte) currentIndex); inventory[currentIndex].writeToNBT(tagCompound); @@ -233,120 +204,133 @@ public class TileEntityAludel extends TileEntityEE implements ISidedInventory } @Override - public Packet getDescriptionPacket() - { - return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityAludel(this, inventory[OUTPUT_INVENTORY_INDEX])); + public Packet getDescriptionPacket() { + return PacketHandler.INSTANCE.getPacketFrom( + new MessageTileEntityAludel(this, inventory[OUTPUT_INVENTORY_INDEX]) + ); } @Override - public void updateEntity() - { + public void updateEntity() { boolean isBurning = this.deviceCookTime > 0; boolean sendUpdate = false; // If the Aludel still has burn time, decrement it - if (this.deviceCookTime > 0) - { + if (this.deviceCookTime > 0) { this.deviceCookTime--; } - if (!this.worldObj.isRemote) - { + if (!this.worldObj.isRemote) { // Start "cooking" a new item, if we can - if (this.deviceCookTime == 0 && this.canInfuse()) - { - this.fuelBurnTime = this.deviceCookTime = TileEntityFurnace.getItemBurnTime(this.inventory[FUEL_INVENTORY_INDEX]); + if (this.deviceCookTime == 0 && this.canInfuse()) { + this.fuelBurnTime = this.deviceCookTime + = TileEntityFurnace.getItemBurnTime( + this.inventory[FUEL_INVENTORY_INDEX] + ); - if (this.deviceCookTime > 0) - { + if (this.deviceCookTime > 0) { sendUpdate = true; - if (this.inventory[FUEL_INVENTORY_INDEX] != null) - { + if (this.inventory[FUEL_INVENTORY_INDEX] != null) { --this.inventory[FUEL_INVENTORY_INDEX].stackSize; - if (this.inventory[FUEL_INVENTORY_INDEX].stackSize == 0) - { - this.inventory[FUEL_INVENTORY_INDEX] = this.inventory[FUEL_INVENTORY_INDEX].getItem().getContainerItem(inventory[FUEL_INVENTORY_INDEX]); + if (this.inventory[FUEL_INVENTORY_INDEX].stackSize == 0) { + this.inventory[FUEL_INVENTORY_INDEX] + = this.inventory[FUEL_INVENTORY_INDEX] + .getItem() + .getContainerItem(inventory[FUEL_INVENTORY_INDEX]); } } } } // Continue "cooking" the same item, if we can - if (this.deviceCookTime > 0 && this.canInfuse()) - { + if (this.deviceCookTime > 0 && this.canInfuse()) { this.itemCookTime++; - if (this.itemCookTime == 200) - { + if (this.itemCookTime == 200) { this.itemCookTime = 0; this.infuseItem(); sendUpdate = true; } - } - else - { + } else { this.itemCookTime = 0; } // If the state has changed, catch that something changed - if (isBurning != this.deviceCookTime > 0) - { + if (isBurning != this.deviceCookTime > 0) { sendUpdate = true; } } - if (sendUpdate) - { + if (sendUpdate) { this.markDirty(); this.state = this.deviceCookTime > 0 ? (byte) 1 : (byte) 0; - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.state); - PacketHandler.INSTANCE.sendToAllAround(new MessageTileEntityAludel(this, inventory[OUTPUT_INVENTORY_INDEX]), new NetworkRegistry.TargetPoint(this.worldObj.provider.dimensionId, (double) this.xCoord, (double) this.yCoord, (double) this.zCoord, 128d)); - this.worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.addBlockEvent( + this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.state + ); + PacketHandler.INSTANCE.sendToAllAround( + new MessageTileEntityAludel(this, inventory[OUTPUT_INVENTORY_INDEX]), + new NetworkRegistry.TargetPoint( + this.worldObj.provider.dimensionId, + (double) this.xCoord, + (double) this.yCoord, + (double) this.zCoord, + 128d + ) + ); + this.worldObj.notifyBlockChange( + this.xCoord, this.yCoord, this.zCoord, this.getBlockType() + ); } } @Override - public void markDirty() - { - PacketHandler.INSTANCE.sendToAllAround(new MessageTileEntityAludel(this, inventory[OUTPUT_INVENTORY_INDEX]), new NetworkRegistry.TargetPoint(this.worldObj.provider.dimensionId, (double) this.xCoord, (double) this.yCoord, (double) this.zCoord, 128d)); + public void markDirty() { + PacketHandler.INSTANCE.sendToAllAround( + new MessageTileEntityAludel(this, inventory[OUTPUT_INVENTORY_INDEX]), + new NetworkRegistry.TargetPoint( + this.worldObj.provider.dimensionId, + (double) this.xCoord, + (double) this.yCoord, + (double) this.zCoord, + 128d + ) + ); worldObj.func_147451_t(xCoord, yCoord, zCoord); - if (hasGlassBell) - { + if (hasGlassBell) { worldObj.func_147451_t(xCoord, yCoord + 1, zCoord); } } - private boolean canInfuse() - { - if (!hasGlassBell || inventory[INPUT_INVENTORY_INDEX] == null || inventory[DUST_INVENTORY_INDEX] == null) - { + private boolean canInfuse() { + if (!hasGlassBell || inventory[INPUT_INVENTORY_INDEX] == null + || inventory[DUST_INVENTORY_INDEX] == null) { return false; - } - else - { - ItemStack infusedItemStack = AludelRecipeManager.getInstance().getResult(inventory[INPUT_INVENTORY_INDEX], inventory[DUST_INVENTORY_INDEX]); + } else { + ItemStack infusedItemStack = AludelRecipeManager.getInstance().getResult( + inventory[INPUT_INVENTORY_INDEX], inventory[DUST_INVENTORY_INDEX] + ); - if (infusedItemStack == null) - { + if (infusedItemStack == null) { return false; } - if (inventory[OUTPUT_INVENTORY_INDEX] == null) - { + if (inventory[OUTPUT_INVENTORY_INDEX] == null) { return true; - } - else - { - boolean outputEquals = this.inventory[OUTPUT_INVENTORY_INDEX].isItemEqual(infusedItemStack); - int mergedOutputStackSize = this.inventory[OUTPUT_INVENTORY_INDEX].stackSize + infusedItemStack.stackSize; + } else { + boolean outputEquals + = this.inventory[OUTPUT_INVENTORY_INDEX].isItemEqual(infusedItemStack + ); + int mergedOutputStackSize + = this.inventory[OUTPUT_INVENTORY_INDEX].stackSize + + infusedItemStack.stackSize; - if (outputEquals) - { - return mergedOutputStackSize <= getInventoryStackLimit() && mergedOutputStackSize <= infusedItemStack.getMaxStackSize(); + if (outputEquals) { + return mergedOutputStackSize <= getInventoryStackLimit() + && mergedOutputStackSize <= infusedItemStack.getMaxStackSize(); } } } @@ -354,37 +338,38 @@ public class TileEntityAludel extends TileEntityEE implements ISidedInventory return false; } - public void infuseItem() - { - if (this.canInfuse()) - { - RecipeAludel recipe = AludelRecipeManager.getInstance().getRecipe(inventory[INPUT_INVENTORY_INDEX], inventory[DUST_INVENTORY_INDEX]); + public void infuseItem() { + if (this.canInfuse()) { + RecipeAludel recipe = AludelRecipeManager.getInstance().getRecipe( + inventory[INPUT_INVENTORY_INDEX], inventory[DUST_INVENTORY_INDEX] + ); - if (this.inventory[OUTPUT_INVENTORY_INDEX] == null) - { + if (this.inventory[OUTPUT_INVENTORY_INDEX] == null) { this.inventory[OUTPUT_INVENTORY_INDEX] = recipe.getRecipeOutput().copy(); - } - else if (this.inventory[OUTPUT_INVENTORY_INDEX].isItemEqual(recipe.getRecipeOutput())) - { - inventory[OUTPUT_INVENTORY_INDEX].stackSize += recipe.getRecipeOutput().stackSize; + } else if (this.inventory[OUTPUT_INVENTORY_INDEX].isItemEqual( + recipe.getRecipeOutput() + )) { + inventory[OUTPUT_INVENTORY_INDEX].stackSize + += recipe.getRecipeOutput().stackSize; } - decrStackSize(INPUT_INVENTORY_INDEX, recipe.getRecipeInputs()[0].getStackSize()); - decrStackSize(DUST_INVENTORY_INDEX, recipe.getRecipeInputs()[1].getStackSize()); + decrStackSize( + INPUT_INVENTORY_INDEX, recipe.getRecipeInputs()[0].getStackSize() + ); + decrStackSize( + DUST_INVENTORY_INDEX, recipe.getRecipeInputs()[1].getStackSize() + ); } } @SideOnly(Side.CLIENT) - public int getCookProgressScaled(int scale) - { + public int getCookProgressScaled(int scale) { return this.itemCookTime * scale / 200; } @SideOnly(Side.CLIENT) - public int getBurnTimeRemainingScaled(int scale) - { - if (this.fuelBurnTime > 0) - { + public int getBurnTimeRemainingScaled(int scale) { + if (this.fuelBurnTime > 0) { return this.deviceCookTime * scale / this.fuelBurnTime; } return 0; diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityCalcinator.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityCalcinator.java index f72d3337..8583d869 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityCalcinator.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityCalcinator.java @@ -17,17 +17,16 @@ import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.tileentity.TileEntityHopper; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityCalcinator extends TileEntityEE implements ISidedInventory -{ +public class TileEntityCalcinator extends TileEntityEE implements ISidedInventory { public static final int INVENTORY_SIZE = 4; public static final int FUEL_INVENTORY_INDEX = 0; public static final int INPUT_INVENTORY_INDEX = 1; public static final int OUTPUT_LEFT_INVENTORY_INDEX = 2; public static final int OUTPUT_RIGHT_INVENTORY_INDEX = 3; private static final int DEFAULT_ITEM_SUCK_COOL_DOWN = 20; - public int deviceCookTime; // How much longer the Calcinator will cook - public int fuelBurnTime; // The fuel value for the currently burning fuel - public int itemCookTime; // How long the current item has been "cooking" + public int deviceCookTime; // How much longer the Calcinator will cook + public int fuelBurnTime; // The fuel value for the currently burning fuel + public int itemCookTime; // How long the current item has been "cooking" public byte leftStackSize, leftStackMeta, rightStackSize, rightStackMeta; @@ -37,50 +36,56 @@ public class TileEntityCalcinator extends TileEntityEE implements ISidedInventor */ private ItemStack[] inventory; - public TileEntityCalcinator() - { + public TileEntityCalcinator() { inventory = new ItemStack[INVENTORY_SIZE]; } - public static boolean suckInItems(TileEntityCalcinator tileEntityCalcinator) - { - EntityItem entityitem = TileEntityHopper.func_145897_a(tileEntityCalcinator.getWorldObj(), tileEntityCalcinator.xCoord, tileEntityCalcinator.yCoord + 1.0D, tileEntityCalcinator.zCoord); + public static boolean suckInItems(TileEntityCalcinator tileEntityCalcinator) { + EntityItem entityitem = TileEntityHopper.func_145897_a( + tileEntityCalcinator.getWorldObj(), + tileEntityCalcinator.xCoord, + tileEntityCalcinator.yCoord + 1.0D, + tileEntityCalcinator.zCoord + ); - return entityitem != null && TileEntityHopper.func_145898_a(tileEntityCalcinator, entityitem); + return entityitem != null + && TileEntityHopper.func_145898_a(tileEntityCalcinator, entityitem); } @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return side == ForgeDirection.DOWN.ordinal() ? new int[]{FUEL_INVENTORY_INDEX, OUTPUT_LEFT_INVENTORY_INDEX, OUTPUT_RIGHT_INVENTORY_INDEX} : new int[]{FUEL_INVENTORY_INDEX, INPUT_INVENTORY_INDEX, OUTPUT_LEFT_INVENTORY_INDEX, OUTPUT_RIGHT_INVENTORY_INDEX}; + public int[] getAccessibleSlotsFromSide(int side) { + return side == ForgeDirection.DOWN.ordinal() + ? new int[] { FUEL_INVENTORY_INDEX, + OUTPUT_LEFT_INVENTORY_INDEX, + OUTPUT_RIGHT_INVENTORY_INDEX } + : new int[] { FUEL_INVENTORY_INDEX, + INPUT_INVENTORY_INDEX, + OUTPUT_LEFT_INVENTORY_INDEX, + OUTPUT_RIGHT_INVENTORY_INDEX }; } @Override public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { - return isItemValidForSlot(slotIndex, itemStack); } @Override - public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) - { - return slotIndex == OUTPUT_LEFT_INVENTORY_INDEX || slotIndex == OUTPUT_RIGHT_INVENTORY_INDEX; + public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) { + return slotIndex == OUTPUT_LEFT_INVENTORY_INDEX + || slotIndex == OUTPUT_RIGHT_INVENTORY_INDEX; } @Override - public void readFromNBT(NBTTagCompound nbtTagCompound) - { + public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = nbtTagCompound.getTagList(Names.NBT.ITEMS, 10); inventory = new ItemStack[this.getSizeInventory()]; - for (int i = 0; i < tagList.tagCount(); ++i) - { + for (int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slotIndex = tagCompound.getByte("Slot"); - if (slotIndex >= 0 && slotIndex < inventory.length) - { + if (slotIndex >= 0 && slotIndex < inventory.length) { inventory[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); } } @@ -92,33 +97,25 @@ public class TileEntityCalcinator extends TileEntityEE implements ISidedInventor } @Override - public int getSizeInventory() - { + public int getSizeInventory() { return inventory.length; } @Override - public ItemStack getStackInSlot(int slotIndex) - { + public ItemStack getStackInSlot(int slotIndex) { sendDustPileData(); return inventory[slotIndex]; } @Override - public ItemStack decrStackSize(int slotIndex, int decrementAmount) - { + public ItemStack decrStackSize(int slotIndex, int decrementAmount) { ItemStack itemStack = getStackInSlot(slotIndex); - if (itemStack != null) - { - if (itemStack.stackSize <= decrementAmount) - { + if (itemStack != null) { + if (itemStack.stackSize <= decrementAmount) { setInventorySlotContents(slotIndex, null); - } - else - { + } else { itemStack = itemStack.splitStack(decrementAmount); - if (itemStack.stackSize == 0) - { + if (itemStack.stackSize == 0) { setInventorySlotContents(slotIndex, null); } } @@ -128,70 +125,62 @@ public class TileEntityCalcinator extends TileEntityEE implements ISidedInventor } @Override - public ItemStack getStackInSlotOnClosing(int slotIndex) - { + public ItemStack getStackInSlotOnClosing(int slotIndex) { ItemStack itemStack = getStackInSlot(slotIndex); - if (itemStack != null) - { + if (itemStack != null) { setInventorySlotContents(slotIndex, null); } return itemStack; } @Override - public void setInventorySlotContents(int slotIndex, ItemStack itemStack) - { + public void setInventorySlotContents(int slotIndex, ItemStack itemStack) { inventory[slotIndex] = itemStack; - if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) - { + if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) { itemStack.stackSize = getInventoryStackLimit(); } } @Override - public String getInventoryName() - { + public String getInventoryName() { return this.hasCustomName() ? this.getCustomName() : Names.Containers.CALCINATOR; } @Override - public boolean hasCustomInventoryName() - { + public boolean hasCustomInventoryName() { return this.hasCustomName(); } @Override - public int getInventoryStackLimit() - { + public int getInventoryStackLimit() { return 64; } @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) - { - return this.worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && entityplayer.getDistanceSq((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D; + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return this.worldObj.getTileEntity(xCoord, yCoord, zCoord) == this + && entityplayer.getDistanceSq( + (double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D + ) + <= 64D; } @Override - public void openInventory() - { + public void openInventory() { // NOOP } @Override - public void closeInventory() - { + public void closeInventory() { // NOOP } @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { - if (itemStack != null) { if (slotIndex == FUEL_INVENTORY_INDEX) { return TileEntityFurnace.isItemFuel(itemStack); - } - else if (slotIndex == INPUT_INVENTORY_INDEX) { + } else if (slotIndex == INPUT_INVENTORY_INDEX) { return true; } } @@ -199,51 +188,69 @@ public class TileEntityCalcinator extends TileEntityEE implements ISidedInventor return false; } - private void sendDustPileData() - { - if (this.getBlockType() != null) - { - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 2, getLeftStackSize()); - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 3, getLeftStackMeta()); - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 4, getRightStackSize()); - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 5, getRightStackMeta()); + private void sendDustPileData() { + if (this.getBlockType() != null) { + this.worldObj.addBlockEvent( + this.xCoord, + this.yCoord, + this.zCoord, + this.getBlockType(), + 2, + getLeftStackSize() + ); + this.worldObj.addBlockEvent( + this.xCoord, + this.yCoord, + this.zCoord, + this.getBlockType(), + 3, + getLeftStackMeta() + ); + this.worldObj.addBlockEvent( + this.xCoord, + this.yCoord, + this.zCoord, + this.getBlockType(), + 4, + getRightStackSize() + ); + this.worldObj.addBlockEvent( + this.xCoord, + this.yCoord, + this.zCoord, + this.getBlockType(), + 5, + getRightStackMeta() + ); } } - private int getLeftStackSize() - { - if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] != null) - { + private int getLeftStackSize() { + if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] != null) { return this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize; } return 0; } - private int getLeftStackMeta() - { - if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] != null) - { + private int getLeftStackMeta() { + if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] != null) { return this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].getItemDamage(); } return 0; } - private int getRightStackSize() - { - if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] != null) - { + private int getRightStackSize() { + if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] != null) { return this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize; } return 0; } - private int getRightStackMeta() - { - if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] != null) - { + private int getRightStackMeta() { + if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] != null) { return this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].getItemDamage(); } @@ -251,16 +258,13 @@ public class TileEntityCalcinator extends TileEntityEE implements ISidedInventor } @Override - public void writeToNBT(NBTTagCompound nbtTagCompound) - { + public void writeToNBT(NBTTagCompound nbtTagCompound) { super.writeToNBT(nbtTagCompound); // Write the ItemStacks in the inventory to NBT NBTTagList tagList = new NBTTagList(); - for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) - { - if (inventory[currentIndex] != null) - { + for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) { + if (inventory[currentIndex] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte) currentIndex); inventory[currentIndex].writeToNBT(tagCompound); @@ -275,23 +279,19 @@ public class TileEntityCalcinator extends TileEntityEE implements ISidedInventor } @Override - public Packet getDescriptionPacket() - { + public Packet getDescriptionPacket() { sendDustPileData(); return PacketHandler.INSTANCE.getPacketFrom(new MessageTileCalcinator(this)); } @SideOnly(Side.CLIENT) - public int getCookProgressScaled(int scale) - { + public int getCookProgressScaled(int scale) { return this.itemCookTime * scale / 200; } @SideOnly(Side.CLIENT) - public int getBurnTimeRemainingScaled(int scale) - { - if (this.fuelBurnTime > 0) - { + public int getBurnTimeRemainingScaled(int scale) { + if (this.fuelBurnTime > 0) { return this.deviceCookTime * scale / this.fuelBurnTime; } @@ -299,218 +299,204 @@ public class TileEntityCalcinator extends TileEntityEE implements ISidedInventor } @Override - public void updateEntity() - { + public void updateEntity() { boolean isBurning = this.deviceCookTime > 0; boolean sendUpdate = false; // If the Calcinator still has burn time, decrement it - if (this.deviceCookTime > 0) - { + if (this.deviceCookTime > 0) { this.deviceCookTime--; } - if (!this.worldObj.isRemote) - { + if (!this.worldObj.isRemote) { // Start "cooking" a new item, if we can - if (this.deviceCookTime == 0 && this.canCalcinate()) - { - this.fuelBurnTime = this.deviceCookTime = TileEntityFurnace.getItemBurnTime(this.inventory[FUEL_INVENTORY_INDEX]); + if (this.deviceCookTime == 0 && this.canCalcinate()) { + this.fuelBurnTime = this.deviceCookTime + = TileEntityFurnace.getItemBurnTime( + this.inventory[FUEL_INVENTORY_INDEX] + ); - if (this.deviceCookTime > 0) - { + if (this.deviceCookTime > 0) { sendUpdate = true; - if (this.inventory[FUEL_INVENTORY_INDEX] != null) - { + if (this.inventory[FUEL_INVENTORY_INDEX] != null) { --this.inventory[FUEL_INVENTORY_INDEX].stackSize; - if (this.inventory[FUEL_INVENTORY_INDEX].stackSize == 0) - { - this.inventory[FUEL_INVENTORY_INDEX] = this.inventory[FUEL_INVENTORY_INDEX].getItem().getContainerItem(inventory[FUEL_INVENTORY_INDEX]); + if (this.inventory[FUEL_INVENTORY_INDEX].stackSize == 0) { + this.inventory[FUEL_INVENTORY_INDEX] + = this.inventory[FUEL_INVENTORY_INDEX] + .getItem() + .getContainerItem(inventory[FUEL_INVENTORY_INDEX]); } } } } // Continue "cooking" the same item, if we can - if (this.deviceCookTime > 0 && this.canCalcinate()) - { + if (this.deviceCookTime > 0 && this.canCalcinate()) { this.itemCookTime++; - if (this.itemCookTime == 200) - { + if (this.itemCookTime == 200) { this.itemCookTime = 0; this.calcinateItem(); sendUpdate = true; } - } - else - { + } else { this.itemCookTime = 0; } // If the state has changed, catch that something changed - if (isBurning != this.deviceCookTime > 0) - { + if (isBurning != this.deviceCookTime > 0) { sendUpdate = true; } //Item sucking - if (this.itemSuckCoolDown > 0) - { + if (this.itemSuckCoolDown > 0) { itemSuckCoolDown--; - } - else - { - if (suckInItems(this)) - { + } else { + if (suckInItems(this)) { markDirty(); } itemSuckCoolDown = DEFAULT_ITEM_SUCK_COOL_DOWN; } } - if (sendUpdate) - { + if (sendUpdate) { this.markDirty(); this.state = this.deviceCookTime > 0 ? (byte) 1 : (byte) 0; - this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.state); + this.worldObj.addBlockEvent( + this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.state + ); sendDustPileData(); - this.worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlockChange( + this.xCoord, this.yCoord, this.zCoord, this.getBlockType() + ); } } @Override - public boolean receiveClientEvent(int eventId, int eventData) - { - if (eventId == 1) - { + public boolean receiveClientEvent(int eventId, int eventData) { + if (eventId == 1) { this.state = (byte) eventData; - // NAME UPDATE - this.worldObj.updateAllLightTypes(this.xCoord, this.yCoord, this.zCoord); + // NAME UPDATE - this.worldObj.updateAllLightTypes(this.xCoord, this.yCoord, + // this.zCoord); this.worldObj.func_147451_t(this.xCoord, this.yCoord, this.zCoord); return true; - } - else if (eventId == 2) - { + } else if (eventId == 2) { this.leftStackSize = (byte) eventData; return true; - } - else if (eventId == 3) - { + } else if (eventId == 3) { this.leftStackMeta = (byte) eventData; return true; - } - else if (eventId == 4) - { + } else if (eventId == 4) { this.rightStackSize = (byte) eventData; return true; - } - else if (eventId == 5) - { + } else if (eventId == 5) { this.rightStackMeta = (byte) eventData; return true; - } - else - { + } else { return super.receiveClientEvent(eventId, eventData); } } - private boolean canCalcinate() - { - if (inventory[INPUT_INVENTORY_INDEX] == null) - { + private boolean canCalcinate() { + if (inventory[INPUT_INVENTORY_INDEX] == null) { return false; - } - else - { - ItemStack alchemicalDustStack = CalcinationHelper.getCalcinationResult(this.inventory[INPUT_INVENTORY_INDEX]); + } else { + ItemStack alchemicalDustStack = CalcinationHelper.getCalcinationResult( + this.inventory[INPUT_INVENTORY_INDEX] + ); /** * If we don't get a calcination result, then return false */ - if (alchemicalDustStack == null) - { + if (alchemicalDustStack == null) { return false; } /** * If either slot is empty, return true (we have a valid calcination result */ - if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] == null || this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] == null) - { + if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] == null + || this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] == null) { return true; } - boolean leftEquals = this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].isItemEqual(alchemicalDustStack); - int leftResult = this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize + alchemicalDustStack.stackSize; + boolean leftEquals = this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].isItemEqual( + alchemicalDustStack + ); + int leftResult = this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize + + alchemicalDustStack.stackSize; - boolean rightEquals = this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].isItemEqual(alchemicalDustStack); - int rightResult = this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize + alchemicalDustStack.stackSize; + boolean rightEquals + = this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].isItemEqual( + alchemicalDustStack + ); + int rightResult = this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize + + alchemicalDustStack.stackSize; - if (!leftEquals && !rightEquals) - { + if (!leftEquals && !rightEquals) { return false; - } - else if (leftEquals && !rightEquals) - { - return leftResult <= getInventoryStackLimit() && leftResult <= alchemicalDustStack.getMaxStackSize(); - } - else if (!leftEquals) - { - return rightResult <= getInventoryStackLimit() && rightResult <= alchemicalDustStack.getMaxStackSize(); - } - else - { - return leftResult <= getInventoryStackLimit() && leftResult <= alchemicalDustStack.getMaxStackSize() || rightResult <= getInventoryStackLimit() && rightResult <= alchemicalDustStack.getMaxStackSize(); + } else if (leftEquals && !rightEquals) { + return leftResult <= getInventoryStackLimit() + && leftResult <= alchemicalDustStack.getMaxStackSize(); + } else if (!leftEquals) { + return rightResult <= getInventoryStackLimit() + && rightResult <= alchemicalDustStack.getMaxStackSize(); + } else { + return leftResult <= getInventoryStackLimit() + && leftResult <= alchemicalDustStack.getMaxStackSize() + || rightResult <= getInventoryStackLimit() + && rightResult <= alchemicalDustStack.getMaxStackSize(); } } } - public void calcinateItem() - { - if (this.canCalcinate()) - { - ItemStack alchemicalDustStack = CalcinationHelper.getCalcinationResult(this.inventory[INPUT_INVENTORY_INDEX]); + public void calcinateItem() { + if (this.canCalcinate()) { + ItemStack alchemicalDustStack = CalcinationHelper.getCalcinationResult( + this.inventory[INPUT_INVENTORY_INDEX] + ); addItemStackToOutput(alchemicalDustStack.copy()); this.inventory[INPUT_INVENTORY_INDEX].stackSize--; - if (this.inventory[INPUT_INVENTORY_INDEX].stackSize <= 0) - { + if (this.inventory[INPUT_INVENTORY_INDEX].stackSize <= 0) { this.inventory[INPUT_INVENTORY_INDEX] = null; } } } - private void addItemStackToOutput(ItemStack alchemicalDustStack) - { - int maxStackSize = Math.min(getInventoryStackLimit(), alchemicalDustStack.getMaxStackSize()); + private void addItemStackToOutput(ItemStack alchemicalDustStack) { + int maxStackSize + = Math.min(getInventoryStackLimit(), alchemicalDustStack.getMaxStackSize()); - if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] == null) - { + if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] == null) { this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] = alchemicalDustStack; return; } - if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].isItemEqual(alchemicalDustStack) && this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize < maxStackSize) - { - int addedSize = Math.min(alchemicalDustStack.stackSize, maxStackSize - this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize); + if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].isItemEqual(alchemicalDustStack) + && this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize < maxStackSize) { + int addedSize = Math.min( + alchemicalDustStack.stackSize, + maxStackSize - this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize + ); alchemicalDustStack.stackSize -= addedSize; this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].stackSize += addedSize; - if (alchemicalDustStack.stackSize == 0) - { + if (alchemicalDustStack.stackSize == 0) { return; } } - if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] == null) - { + if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] == null) { this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] = alchemicalDustStack; return; } - if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].isItemEqual(alchemicalDustStack) && this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize < maxStackSize) - { - int addedSize = Math.min(alchemicalDustStack.stackSize, maxStackSize - this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize); + if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].isItemEqual(alchemicalDustStack) + && this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize < maxStackSize) { + int addedSize = Math.min( + alchemicalDustStack.stackSize, + maxStackSize - this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize + ); alchemicalDustStack.stackSize -= addedSize; this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].stackSize += addedSize; } diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityDummyArray.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityDummyArray.java index 41f31379..60aacc00 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityDummyArray.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityDummyArray.java @@ -5,54 +5,46 @@ import com.pahimar.ee3.network.message.MessageTileEntityDummy; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.Packet; -public class TileEntityDummyArray extends TileEntityEE -{ +public class TileEntityDummyArray extends TileEntityEE { private int trueXCoord, trueYCoord, trueZCoord; private int ticksSinceSync; - public TileEntityDummyArray() - { + public TileEntityDummyArray() { super(); } - public int getTrueXCoord() - { + public int getTrueXCoord() { return trueXCoord; } - public int getTrueYCoord() - { + public int getTrueYCoord() { return trueYCoord; } - public int getTrueZCoord() - { + public int getTrueZCoord() { return trueZCoord; } - public void setTrueCoords(int trueXCoord, int trueYCoord, int trueZCoord) - { + public void setTrueCoords(int trueXCoord, int trueYCoord, int trueZCoord) { this.trueXCoord = trueXCoord; this.trueYCoord = trueYCoord; this.trueZCoord = trueZCoord; } - public TileEntityAlchemyArray getAssociatedTileEntity() - { - if (this.worldObj.getTileEntity(trueXCoord, trueYCoord, trueZCoord) instanceof TileEntityAlchemyArray) - { - return (TileEntityAlchemyArray) this.worldObj.getTileEntity(trueXCoord, trueYCoord, trueZCoord); + public TileEntityAlchemyArray getAssociatedTileEntity() { + if (this.worldObj.getTileEntity(trueXCoord, trueYCoord, trueZCoord) + instanceof TileEntityAlchemyArray) { + return (TileEntityAlchemyArray + ) this.worldObj.getTileEntity(trueXCoord, trueYCoord, trueZCoord); } return null; } - public int getLightLevel() - { + public int getLightLevel() { TileEntityAlchemyArray tileEntityAlchemyArray = getAssociatedTileEntity(); - if (tileEntityAlchemyArray != null) - { + if (tileEntityAlchemyArray != null) { return tileEntityAlchemyArray.getLightLevel(); } @@ -60,14 +52,15 @@ public class TileEntityDummyArray extends TileEntityEE } @Override - public void updateEntity() - { + public void updateEntity() { super.updateEntity(); - if (++ticksSinceSync % 10 == 0) - { - if (!worldObj.isRemote && !(worldObj.getTileEntity(trueXCoord, trueYCoord, trueZCoord) instanceof TileEntityAlchemyArray)) - { + if (++ticksSinceSync % 10 == 0) { + if (!worldObj.isRemote + && !( + worldObj.getTileEntity(trueXCoord, trueYCoord, trueZCoord) + instanceof TileEntityAlchemyArray + )) { this.invalidate(); worldObj.setBlockToAir(xCoord, yCoord, zCoord); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); @@ -76,14 +69,12 @@ public class TileEntityDummyArray extends TileEntityEE } @Override - public Packet getDescriptionPacket() - { + public Packet getDescriptionPacket() { return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityDummy(this)); } @Override - public void readFromNBT(NBTTagCompound nbtTagCompound) - { + public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); this.trueXCoord = nbtTagCompound.getInteger("trueXCoord"); @@ -92,8 +83,7 @@ public class TileEntityDummyArray extends TileEntityEE } @Override - public void writeToNBT(NBTTagCompound nbtTagCompound) - { + public void writeToNBT(NBTTagCompound nbtTagCompound) { super.writeToNBT(nbtTagCompound); nbtTagCompound.setInteger("trueXCoord", trueXCoord); diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityEE.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityEE.java index 9d77e41a..ab386a99 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityEE.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityEE.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.tileentity; +import java.util.UUID; + import com.pahimar.ee3.network.PacketHandler; import com.pahimar.ee3.network.message.MessageTileEntityEE; import com.pahimar.ee3.reference.Names; @@ -10,142 +12,125 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.UsernameCache; import net.minecraftforge.common.util.ForgeDirection; -import java.util.UUID; - -public class TileEntityEE extends TileEntity -{ +public class TileEntityEE extends TileEntity { protected ForgeDirection orientation; protected byte state; protected String customName; protected UUID ownerUUID; - public TileEntityEE() - { + public TileEntityEE() { orientation = ForgeDirection.SOUTH; state = 0; customName = ""; ownerUUID = null; } - public ForgeDirection getOrientation() - { + public ForgeDirection getOrientation() { return orientation; } - public void setOrientation(ForgeDirection orientation) - { + public void setOrientation(ForgeDirection orientation) { this.orientation = orientation; } - public void setOrientation(int orientation) - { + public void setOrientation(int orientation) { this.orientation = ForgeDirection.getOrientation(orientation); } - public short getState() - { + public short getState() { return state; } - public void setState(byte state) - { + public void setState(byte state) { this.state = state; } - public String getCustomName() - { + public String getCustomName() { return customName; } - public void setCustomName(String customName) - { + public void setCustomName(String customName) { this.customName = customName; } - public UUID getOwnerUUID() - { + public UUID getOwnerUUID() { return ownerUUID; } - public String getOwnerName() - { - if (ownerUUID != null) - { + public String getOwnerName() { + if (ownerUUID != null) { return UsernameCache.getLastKnownUsername(ownerUUID); } return "Unknown"; } - public void setOwner(EntityPlayer entityPlayer) - { + public void setOwner(EntityPlayer entityPlayer) { this.ownerUUID = entityPlayer.getPersistentID(); } - public void setOwnerUUID(UUID ownerUUID) - { + public void setOwnerUUID(UUID ownerUUID) { this.ownerUUID = ownerUUID; } @Override - public void readFromNBT(NBTTagCompound nbtTagCompound) - { + public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); - if (nbtTagCompound.hasKey(Names.NBT.DIRECTION)) - { - this.orientation = ForgeDirection.getOrientation(nbtTagCompound.getByte(Names.NBT.DIRECTION)); + if (nbtTagCompound.hasKey(Names.NBT.DIRECTION)) { + this.orientation + = ForgeDirection.getOrientation(nbtTagCompound.getByte(Names.NBT.DIRECTION + )); } - if (nbtTagCompound.hasKey(Names.NBT.STATE)) - { + if (nbtTagCompound.hasKey(Names.NBT.STATE)) { this.state = nbtTagCompound.getByte(Names.NBT.STATE); } - if (nbtTagCompound.hasKey(Names.NBT.CUSTOM_NAME)) - { + if (nbtTagCompound.hasKey(Names.NBT.CUSTOM_NAME)) { this.customName = nbtTagCompound.getString(Names.NBT.CUSTOM_NAME); } - if (nbtTagCompound.hasKey(Names.NBT.OWNER_UUID_MOST_SIG) && nbtTagCompound.hasKey(Names.NBT.OWNER_UUID_LEAST_SIG)) - { - this.ownerUUID = new UUID(nbtTagCompound.getLong(Names.NBT.OWNER_UUID_MOST_SIG), nbtTagCompound.getLong(Names.NBT.OWNER_UUID_LEAST_SIG)); + if (nbtTagCompound.hasKey(Names.NBT.OWNER_UUID_MOST_SIG) + && nbtTagCompound.hasKey(Names.NBT.OWNER_UUID_LEAST_SIG)) { + this.ownerUUID = new UUID( + nbtTagCompound.getLong(Names.NBT.OWNER_UUID_MOST_SIG), + nbtTagCompound.getLong(Names.NBT.OWNER_UUID_LEAST_SIG) + ); } } @Override - public void writeToNBT(NBTTagCompound nbtTagCompound) - { + public void writeToNBT(NBTTagCompound nbtTagCompound) { super.writeToNBT(nbtTagCompound); nbtTagCompound.setByte(Names.NBT.DIRECTION, (byte) orientation.ordinal()); nbtTagCompound.setByte(Names.NBT.STATE, state); - if (this.hasCustomName()) - { + if (this.hasCustomName()) { nbtTagCompound.setString(Names.NBT.CUSTOM_NAME, customName); } - if (this.hasOwner()) - { - nbtTagCompound.setLong(Names.NBT.OWNER_UUID_MOST_SIG, ownerUUID.getMostSignificantBits()); - nbtTagCompound.setLong(Names.NBT.OWNER_UUID_LEAST_SIG, ownerUUID.getLeastSignificantBits()); + if (this.hasOwner()) { + nbtTagCompound.setLong( + Names.NBT.OWNER_UUID_MOST_SIG, ownerUUID.getMostSignificantBits() + ); + nbtTagCompound.setLong( + Names.NBT.OWNER_UUID_LEAST_SIG, ownerUUID.getLeastSignificantBits() + ); } } - public boolean hasCustomName() - { + public boolean hasCustomName() { return customName != null && customName.length() > 0; } - public boolean hasOwner() - { + public boolean hasOwner() { return ownerUUID != null; } @Override - public Packet getDescriptionPacket() - { + public Packet getDescriptionPacket() { return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityEE(this)); } } diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityGlassBell.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityGlassBell.java index f3cc43b4..a4549a50 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityGlassBell.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityGlassBell.java @@ -12,8 +12,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.Packet; -public class TileEntityGlassBell extends TileEntityEE implements IInventory -{ +public class TileEntityGlassBell extends TileEntityEE implements IInventory { public static final int INVENTORY_SIZE = 1; public static final int DISPLAY_SLOT_INVENTORY_INDEX = 0; public ItemStack outputItemStack; @@ -23,57 +22,45 @@ public class TileEntityGlassBell extends TileEntityEE implements IInventory */ private ItemStack[] inventory; - public TileEntityGlassBell() - { + public TileEntityGlassBell() { inventory = new ItemStack[INVENTORY_SIZE]; } @Override - public void readFromNBT(NBTTagCompound nbtTagCompound) - { + public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = nbtTagCompound.getTagList(Names.NBT.ITEMS, 10); inventory = new ItemStack[this.getSizeInventory()]; - for (int i = 0; i < tagList.tagCount(); ++i) - { + for (int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slotIndex = tagCompound.getByte("Slot"); - if (slotIndex >= 0 && slotIndex < inventory.length) - { + if (slotIndex >= 0 && slotIndex < inventory.length) { inventory[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); } } } @Override - public int getSizeInventory() - { + public int getSizeInventory() { return inventory.length; } @Override - public ItemStack getStackInSlot(int slotIndex) - { + public ItemStack getStackInSlot(int slotIndex) { return inventory[slotIndex]; } @Override - public ItemStack decrStackSize(int slotIndex, int decrementAmount) - { + public ItemStack decrStackSize(int slotIndex, int decrementAmount) { ItemStack itemStack = getStackInSlot(slotIndex); - if (itemStack != null) - { - if (itemStack.stackSize <= decrementAmount) - { + if (itemStack != null) { + if (itemStack.stackSize <= decrementAmount) { setInventorySlotContents(slotIndex, null); - } - else - { + } else { itemStack = itemStack.splitStack(decrementAmount); - if (itemStack.stackSize == 0) - { + if (itemStack.stackSize == 0) { setInventorySlotContents(slotIndex, null); } } @@ -83,96 +70,90 @@ public class TileEntityGlassBell extends TileEntityEE implements IInventory } @Override - public ItemStack getStackInSlotOnClosing(int slotIndex) - { + public ItemStack getStackInSlotOnClosing(int slotIndex) { ItemStack itemStack = getStackInSlot(slotIndex); - if (itemStack != null) - { + if (itemStack != null) { setInventorySlotContents(slotIndex, null); } return itemStack; } @Override - public void setInventorySlotContents(int slotIndex, ItemStack itemStack) - { + public void setInventorySlotContents(int slotIndex, ItemStack itemStack) { inventory[slotIndex] = itemStack; - if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) - { + if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) { itemStack.stackSize = getInventoryStackLimit(); } - if (!this.worldObj.isRemote) - { + if (!this.worldObj.isRemote) { ItemStack displayStack = this.inventory[DISPLAY_SLOT_INVENTORY_INDEX]; - if (displayStack != null) - { - this.state = (byte) Block.getBlockFromItem(displayStack.getItem()).getLightValue(); - } - else - { + if (displayStack != null) { + this.state = (byte) Block.getBlockFromItem(displayStack.getItem()) + .getLightValue(); + } else { this.state = 0; } - PacketHandler.INSTANCE.sendToAllAround(new MessageTileEntityGlassBell(this, displayStack), new NetworkRegistry.TargetPoint(this.worldObj.provider.dimensionId, this.xCoord, this.yCoord, this.zCoord, 128d)); + PacketHandler.INSTANCE.sendToAllAround( + new MessageTileEntityGlassBell(this, displayStack), + new NetworkRegistry.TargetPoint( + this.worldObj.provider.dimensionId, + this.xCoord, + this.yCoord, + this.zCoord, + 128d + ) + ); } this.markDirty(); } @Override - public String getInventoryName() - { + public String getInventoryName() { return this.hasCustomName() ? this.getCustomName() : Names.Containers.GLASS_BELL; } @Override - public boolean hasCustomInventoryName() - { + public boolean hasCustomInventoryName() { return this.hasCustomName(); } @Override - public int getInventoryStackLimit() - { + public int getInventoryStackLimit() { return 64; } @Override - public boolean isUseableByPlayer(EntityPlayer entityPlayer) - { - return this.worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && entityPlayer.getDistanceSq((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D; + public boolean isUseableByPlayer(EntityPlayer entityPlayer) { + return this.worldObj.getTileEntity(xCoord, yCoord, zCoord) == this + && entityPlayer.getDistanceSq( + (double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D + ) + <= 64D; } @Override - public void openInventory() - { - } + public void openInventory() {} @Override - public void closeInventory() - { - } + public void closeInventory() {} @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) - { + public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { return true; } @Override - public void writeToNBT(NBTTagCompound nbtTagCompound) - { + public void writeToNBT(NBTTagCompound nbtTagCompound) { super.writeToNBT(nbtTagCompound); // Write the ItemStacks in the inventory to NBT NBTTagList tagList = new NBTTagList(); - for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) - { - if (inventory[currentIndex] != null) - { + for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) { + if (inventory[currentIndex] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte) currentIndex); inventory[currentIndex].writeToNBT(tagCompound); @@ -183,8 +164,9 @@ public class TileEntityGlassBell extends TileEntityEE implements IInventory } @Override - public Packet getDescriptionPacket() - { - return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityGlassBell(this, getStackInSlot(DISPLAY_SLOT_INVENTORY_INDEX))); + public Packet getDescriptionPacket() { + return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityGlassBell( + this, getStackInSlot(DISPLAY_SLOT_INVENTORY_INDEX) + )); } } diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityResearchStation.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityResearchStation.java index fa8a1f9e..46bb83a7 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityResearchStation.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityResearchStation.java @@ -15,8 +15,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.Packet; -public class TileEntityResearchStation extends TileEntityEE implements IInventory -{ +public class TileEntityResearchStation extends TileEntityEE implements IInventory { public static final int INVENTORY_SIZE = 2; public static final int ITEM_SLOT_INVENTORY_INDEX = 0; public static final int ALCHENOMICON_SLOT_INVENTORY_INDEX = 1; @@ -25,38 +24,29 @@ public class TileEntityResearchStation extends TileEntityEE implements IInventor public boolean isItemKnown; private ItemStack[] inventory; - public TileEntityResearchStation() - { + public TileEntityResearchStation() { inventory = new ItemStack[INVENTORY_SIZE]; } @Override - public int getSizeInventory() - { + public int getSizeInventory() { return inventory.length; } @Override - public ItemStack getStackInSlot(int slotIndex) - { + public ItemStack getStackInSlot(int slotIndex) { return inventory[slotIndex]; } @Override - public ItemStack decrStackSize(int slotIndex, int decrementAmount) - { + public ItemStack decrStackSize(int slotIndex, int decrementAmount) { ItemStack itemStack = getStackInSlot(slotIndex); - if (itemStack != null) - { - if (itemStack.stackSize <= decrementAmount) - { + if (itemStack != null) { + if (itemStack.stackSize <= decrementAmount) { setInventorySlotContents(slotIndex, null); - } - else - { + } else { itemStack = itemStack.splitStack(decrementAmount); - if (itemStack.stackSize == 0) - { + if (itemStack.stackSize == 0) { setInventorySlotContents(slotIndex, null); } } @@ -66,79 +56,71 @@ public class TileEntityResearchStation extends TileEntityEE implements IInventor } @Override - public ItemStack getStackInSlotOnClosing(int slotIndex) - { + public ItemStack getStackInSlotOnClosing(int slotIndex) { ItemStack itemStack = getStackInSlot(slotIndex); - if (itemStack != null) - { + if (itemStack != null) { setInventorySlotContents(slotIndex, null); } return itemStack; } @Override - public void setInventorySlotContents(int slotIndex, ItemStack itemStack) - { + public void setInventorySlotContents(int slotIndex, ItemStack itemStack) { inventory[slotIndex] = itemStack; - if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) - { + if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) { itemStack.stackSize = getInventoryStackLimit(); } } @Override - public String getInventoryName() - { - return this.hasCustomName() ? this.getCustomName() : Names.Containers.RESEARCH_STATION; + public String getInventoryName() { + return this.hasCustomName() ? this.getCustomName() + : Names.Containers.RESEARCH_STATION; } @Override - public boolean hasCustomInventoryName() - { + public boolean hasCustomInventoryName() { return this.hasCustomName(); } @Override - public int getInventoryStackLimit() - { + public int getInventoryStackLimit() { return 1; } @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) - { - return this.worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && entityplayer.getDistanceSq((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D; + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return this.worldObj.getTileEntity(xCoord, yCoord, zCoord) == this + && entityplayer.getDistanceSq( + (double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D + ) + <= 64D; } @Override - public void openInventory() - { + public void openInventory() { // NOOP } @Override - public void closeInventory() - { + public void closeInventory() { // NOOP } @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) - { - return slotIndex == ITEM_SLOT_INVENTORY_INDEX && BlacklistRegistryProxy.isLearnable(itemStack); + public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { + return slotIndex == ITEM_SLOT_INVENTORY_INDEX + && BlacklistRegistryProxy.isLearnable(itemStack); } @Override - public void writeToNBT(NBTTagCompound nbtTagCompound) - { + public void writeToNBT(NBTTagCompound nbtTagCompound) { super.writeToNBT(nbtTagCompound); // Write the ItemStacks in the inventory to NBT NBTTagList tagList = new NBTTagList(); - for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) - { - if (inventory[currentIndex] != null) - { + for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) { + if (inventory[currentIndex] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte) currentIndex); inventory[currentIndex].writeToNBT(tagCompound); @@ -150,55 +132,48 @@ public class TileEntityResearchStation extends TileEntityEE implements IInventor } @Override - public void readFromNBT(NBTTagCompound nbtTagCompound) - { + public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = nbtTagCompound.getTagList(Names.NBT.ITEMS, 10); inventory = new ItemStack[this.getSizeInventory()]; - for (int i = 0; i < tagList.tagCount(); ++i) - { + for (int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slotIndex = tagCompound.getByte("Slot"); - if (slotIndex >= 0 && slotIndex < inventory.length) - { + if (slotIndex >= 0 && slotIndex < inventory.length) { inventory[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); } } itemLearnTime = nbtTagCompound.getInteger("itemLearnTime"); } - + @Override - public Packet getDescriptionPacket() - { - return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityResearchStation(this)); + public Packet getDescriptionPacket() { + return PacketHandler.INSTANCE.getPacketFrom( + new MessageTileEntityResearchStation(this) + ); } @SideOnly(Side.CLIENT) - public int getLearnProgressScaled(int scale) - { + public int getLearnProgressScaled(int scale) { return this.itemLearnTime * scale / 200; } @Override - public void updateEntity() - { - if (!this.worldObj.isRemote && inventory[ALCHENOMICON_SLOT_INVENTORY_INDEX] != null && inventory[ITEM_SLOT_INVENTORY_INDEX] != null) - { + public void updateEntity() { + if (!this.worldObj.isRemote + && inventory[ALCHENOMICON_SLOT_INVENTORY_INDEX] != null + && inventory[ITEM_SLOT_INVENTORY_INDEX] != null) { // Continue "cooking" the same item, if we can - if (this.canLearnItemStack()) - { + if (this.canLearnItemStack()) { this.itemLearnTime++; - if (this.itemLearnTime == 200) - { + if (this.itemLearnTime == 200) { this.itemLearnTime = 0; this.learnItemStack(); } - } - else - { + } else { this.itemLearnTime = 0; } @@ -206,42 +181,42 @@ public class TileEntityResearchStation extends TileEntityEE implements IInventor } } - private boolean canLearnItemStack() - { + private boolean canLearnItemStack() { ItemStack alchenomicon = inventory[ALCHENOMICON_SLOT_INVENTORY_INDEX]; String playerName = ItemStackUtils.getOwnerName(alchenomicon); - if (alchenomicon != null && playerName != null) - { - return PlayerKnowledgeRegistryProxy.canPlayerLearn(playerName, inventory[ITEM_SLOT_INVENTORY_INDEX]); + if (alchenomicon != null && playerName != null) { + return PlayerKnowledgeRegistryProxy.canPlayerLearn( + playerName, inventory[ITEM_SLOT_INVENTORY_INDEX] + ); } return false; } - private boolean isItemStackKnown() - { + private boolean isItemStackKnown() { ItemStack alchenomicon = inventory[ALCHENOMICON_SLOT_INVENTORY_INDEX]; String playerName = ItemStackUtils.getOwnerName(alchenomicon); - if (alchenomicon != null && playerName != null) - { - return PlayerKnowledgeRegistryProxy.doesPlayerKnow(playerName, inventory[ITEM_SLOT_INVENTORY_INDEX]); + if (alchenomicon != null && playerName != null) { + return PlayerKnowledgeRegistryProxy.doesPlayerKnow( + playerName, inventory[ITEM_SLOT_INVENTORY_INDEX] + ); } return false; } - private void learnItemStack() - { - if (this.canLearnItemStack()) - { - PlayerKnowledgeRegistryProxy.teachPlayer(ItemStackUtils.getOwnerName(inventory[ALCHENOMICON_SLOT_INVENTORY_INDEX]), inventory[ITEM_SLOT_INVENTORY_INDEX]); + private void learnItemStack() { + if (this.canLearnItemStack()) { + PlayerKnowledgeRegistryProxy.teachPlayer( + ItemStackUtils.getOwnerName(inventory[ALCHENOMICON_SLOT_INVENTORY_INDEX]), + inventory[ITEM_SLOT_INVENTORY_INDEX] + ); this.inventory[ITEM_SLOT_INVENTORY_INDEX].stackSize--; - if (this.inventory[ITEM_SLOT_INVENTORY_INDEX].stackSize <= 0) - { + if (this.inventory[ITEM_SLOT_INVENTORY_INDEX].stackSize <= 0) { this.inventory[ITEM_SLOT_INVENTORY_INDEX] = null; } } diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityTransmutationTablet.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityTransmutationTablet.java index de920cdb..51c3fc60 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityTransmutationTablet.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityTransmutationTablet.java @@ -1,5 +1,8 @@ package com.pahimar.ee3.tileentity; +import java.util.Collections; +import java.util.Set; + import com.pahimar.ee3.api.blacklist.BlacklistRegistryProxy; import com.pahimar.ee3.api.exchange.EnergyValue; import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; @@ -22,11 +25,8 @@ import net.minecraft.network.Packet; import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Collections; -import java.util.Set; - -public class TileEntityTransmutationTablet extends TileEntityEE implements ISidedInventory, ITransmutationContainer { - +public class TileEntityTransmutationTablet + extends TileEntityEE implements ISidedInventory, ITransmutationContainer { public static final int INVENTORY_SIZE = 10; public static final int ITEM_INPUT_1 = 0; public static final int ITEM_INPUT_2 = 1; @@ -45,7 +45,6 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide public PlayerKnowledge playerKnowledge; public TileEntityTransmutationTablet() { - super(); rotation = ForgeDirection.UNKNOWN; availableEnergy = new EnergyValue(0); @@ -54,17 +53,16 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide } @Override - public EnergyValue getAvailableEnergy() - { - if (inventory[STONE_INDEX] != null && inventory[STONE_INDEX].getItem() instanceof ITransmutationStone) { + public EnergyValue getAvailableEnergy() { + if (inventory[STONE_INDEX] != null + && inventory[STONE_INDEX].getItem() instanceof ITransmutationStone) { return availableEnergy; } else { return new EnergyValue(0); } } - public EnergyValue getStoredEnergy() - { + public EnergyValue getStoredEnergy() { return storedEnergy; } @@ -78,11 +76,9 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide @Override public Set getPlayerKnowledge() { - if (playerKnowledge != null) { return playerKnowledge.getKnownItemStacks(); - } - else { + } else { return Collections.emptySet(); } } @@ -97,37 +93,43 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide */ @Override public void consumeInventoryForEnergyValue(ItemStack outputItemStack) { - - EnergyValue outputEnergyValue = EnergyValueRegistryProxy.getEnergyValueForStack(outputItemStack); + EnergyValue outputEnergyValue + = EnergyValueRegistryProxy.getEnergyValueForStack(outputItemStack); /** * Algorithm: * - * 1) Check the Stone slot, and attempt to take EMC out of the stone there (til 0) - * 2) Search the inventory for items that will most make up the difference, decrement them and consume their EMC - * 3) Repeat 2 until Stored EMC > outputItemStack EMC - * 4) Profit + * 1) Check the Stone slot, and attempt to take EMC out of the stone there (til + * 0) 2) Search the inventory for items that will most make up the difference, + * decrement them and consume their EMC 3) Repeat 2 until Stored EMC > + * outputItemStack EMC 4) Profit */ if (this.storedEnergy.compareTo(outputEnergyValue) >= 0) { - this.storedEnergy = new EnergyValue(this.storedEnergy.getValue() - outputEnergyValue.getValue()); - } - else { - - while (this.storedEnergy.compareTo(outputEnergyValue) < 0 && this.availableEnergy.compareTo(outputEnergyValue) >= 0) { - + this.storedEnergy = new EnergyValue( + this.storedEnergy.getValue() - outputEnergyValue.getValue() + ); + } else { + while (this.storedEnergy.compareTo(outputEnergyValue) < 0 + && this.availableEnergy.compareTo(outputEnergyValue) >= 0) { for (int i = 0; i < STONE_INDEX; i++) { - ItemStack stackInSlot = getStackInSlot(i); - if (stackInSlot != null && EnergyValueRegistryProxy.hasEnergyValue(stackInSlot)) { - this.storedEnergy = new EnergyValue(this.storedEnergy.getValue() + EnergyValueRegistryProxy.getEnergyValue(stackInSlot).getValue()); + if (stackInSlot != null + && EnergyValueRegistryProxy.hasEnergyValue(stackInSlot)) { + this.storedEnergy = new EnergyValue( + this.storedEnergy.getValue() + + EnergyValueRegistryProxy.getEnergyValue(stackInSlot) + .getValue() + ); decrStackSize(i, 1); } } } if (this.storedEnergy.getValue() >= outputEnergyValue.getValue()) { - this.storedEnergy = new EnergyValue(this.storedEnergy.getValue() - outputEnergyValue.getValue()); + this.storedEnergy = new EnergyValue( + this.storedEnergy.getValue() - outputEnergyValue.getValue() + ); } } @@ -157,11 +159,13 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide @Override public void updateEnergyValueFromInventory() { - float newEnergyValue = storedEnergy.getValue(); for (int i = 0; i < STONE_INDEX; i++) { - if (inventory[i] != null && EnergyValueRegistryProxy.hasEnergyValue(inventory[i])) { - newEnergyValue += EnergyValueRegistryProxy.getEnergyValueForStack(inventory[i]).getValue(); + if (inventory[i] != null + && EnergyValueRegistryProxy.hasEnergyValue(inventory[i])) { + newEnergyValue + += EnergyValueRegistryProxy.getEnergyValueForStack(inventory[i]) + .getValue(); } } this.availableEnergy = new EnergyValue(newEnergyValue); @@ -170,36 +174,60 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getRenderBoundingBox() { - return AxisAlignedBB.getBoundingBox(xCoord - 1.5d, yCoord - 1, zCoord - 1.5d, xCoord + 1.5d, yCoord + 1, zCoord + 1.5d); + return AxisAlignedBB.getBoundingBox( + xCoord - 1.5d, + yCoord - 1, + zCoord - 1.5d, + xCoord + 1.5d, + yCoord + 1, + zCoord + 1.5d + ); } public boolean isStructureValid() { - - return ((worldObj.getBlock(xCoord - 1, yCoord, zCoord - 1) instanceof BlockAshInfusedStoneSlab && worldObj.getBlockMetadata(xCoord - 1, yCoord, zCoord - 1) == 1) && - (worldObj.getBlock(xCoord, yCoord, zCoord - 1) instanceof BlockAshInfusedStoneSlab && worldObj.getBlockMetadata(xCoord, yCoord, zCoord - 1) == 2) && - (worldObj.getBlock(xCoord + 1, yCoord, zCoord - 1) instanceof BlockAshInfusedStoneSlab && worldObj.getBlockMetadata(xCoord + 1, yCoord, zCoord - 1) == 3) && - (worldObj.getBlock(xCoord - 1, yCoord, zCoord) instanceof BlockAshInfusedStoneSlab && worldObj.getBlockMetadata(xCoord - 1, yCoord, zCoord) == 4) && - (worldObj.getBlock(xCoord + 1, yCoord, zCoord) instanceof BlockAshInfusedStoneSlab && worldObj.getBlockMetadata(xCoord + 1, yCoord, zCoord) == 5) && - (worldObj.getBlock(xCoord - 1, yCoord, zCoord + 1) instanceof BlockAshInfusedStoneSlab && worldObj.getBlockMetadata(xCoord - 1, yCoord, zCoord + 1) == 6) && - (worldObj.getBlock(xCoord, yCoord, zCoord + 1) instanceof BlockAshInfusedStoneSlab && worldObj.getBlockMetadata(xCoord, yCoord, zCoord + 1) == 7) && - (worldObj.getBlock(xCoord + 1, yCoord, zCoord + 1) instanceof BlockAshInfusedStoneSlab && worldObj.getBlockMetadata(xCoord + 1, yCoord, zCoord + 1) == 8)); + return ( + (worldObj.getBlock(xCoord - 1, yCoord, zCoord - 1) + instanceof BlockAshInfusedStoneSlab + && worldObj.getBlockMetadata(xCoord - 1, yCoord, zCoord - 1) == 1) + && (worldObj.getBlock(xCoord, yCoord, zCoord - 1) + instanceof BlockAshInfusedStoneSlab + && worldObj.getBlockMetadata(xCoord, yCoord, zCoord - 1) == 2) + && (worldObj.getBlock(xCoord + 1, yCoord, zCoord - 1) + instanceof BlockAshInfusedStoneSlab + && worldObj.getBlockMetadata(xCoord + 1, yCoord, zCoord - 1) == 3) + && (worldObj.getBlock(xCoord - 1, yCoord, zCoord) + instanceof BlockAshInfusedStoneSlab + && worldObj.getBlockMetadata(xCoord - 1, yCoord, zCoord) == 4) + && (worldObj.getBlock(xCoord + 1, yCoord, zCoord) + instanceof BlockAshInfusedStoneSlab + && worldObj.getBlockMetadata(xCoord + 1, yCoord, zCoord) == 5) + && (worldObj.getBlock(xCoord - 1, yCoord, zCoord + 1) + instanceof BlockAshInfusedStoneSlab + && worldObj.getBlockMetadata(xCoord - 1, yCoord, zCoord + 1) == 6) + && (worldObj.getBlock(xCoord, yCoord, zCoord + 1) + instanceof BlockAshInfusedStoneSlab + && worldObj.getBlockMetadata(xCoord, yCoord, zCoord + 1) == 7) + && (worldObj.getBlock(xCoord + 1, yCoord, zCoord + 1) + instanceof BlockAshInfusedStoneSlab + && worldObj.getBlockMetadata(xCoord + 1, yCoord, zCoord + 1) == 8) + ); } @Override public void updateEntity() { - super.updateEntity(); updateEnergyValueFromInventory(); } @Override public Packet getDescriptionPacket() { - return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityTransmutationTablet(this)); + return PacketHandler.INSTANCE.getPacketFrom( + new MessageTileEntityTransmutationTablet(this) + ); } @Override public void readFromNBT(NBTTagCompound nbtTagCompound) { - super.readFromNBT(nbtTagCompound); rotation = ForgeDirection.getOrientation(nbtTagCompound.getInteger("rotation")); @@ -214,18 +242,17 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide } } - NBTTagCompound energyValueTagCompound = nbtTagCompound.getCompoundTag("storedEnergy"); + NBTTagCompound energyValueTagCompound + = nbtTagCompound.getCompoundTag("storedEnergy"); if (!energyValueTagCompound.hasNoTags()) { storedEnergy = EnergyValue.loadEnergyValueFromNBT(energyValueTagCompound); - } - else { + } else { storedEnergy = new EnergyValue(0); } } @Override public void writeToNBT(NBTTagCompound nbtTagCompound) { - super.writeToNBT(nbtTagCompound); nbtTagCompound.setInteger("rotation", rotation.ordinal()); @@ -249,32 +276,24 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide } @Override - public int getSizeInventory() - { + public int getSizeInventory() { return inventory.length; } @Override - public ItemStack getStackInSlot(int slotIndex) - { + public ItemStack getStackInSlot(int slotIndex) { return inventory[slotIndex]; } @Override - public ItemStack decrStackSize(int slotIndex, int decrementAmount) - { + public ItemStack decrStackSize(int slotIndex, int decrementAmount) { ItemStack itemStack = getStackInSlot(slotIndex); - if (itemStack != null) - { - if (itemStack.stackSize <= decrementAmount) - { + if (itemStack != null) { + if (itemStack.stackSize <= decrementAmount) { setInventorySlotContents(slotIndex, null); - } - else - { + } else { itemStack = itemStack.splitStack(decrementAmount); - if (itemStack.stackSize == 0) - { + if (itemStack.stackSize == 0) { setInventorySlotContents(slotIndex, null); } } @@ -284,24 +303,19 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide } @Override - public ItemStack getStackInSlotOnClosing(int slotIndex) - { + public ItemStack getStackInSlotOnClosing(int slotIndex) { ItemStack itemStack = getStackInSlot(slotIndex); - if (itemStack != null) - { + if (itemStack != null) { setInventorySlotContents(slotIndex, null); } return itemStack; } @Override - public void setInventorySlotContents(int slotIndex, ItemStack itemStack) - { - if (slotIndex < getSizeInventory()) - { + public void setInventorySlotContents(int slotIndex, ItemStack itemStack) { + if (slotIndex < getSizeInventory()) { inventory[slotIndex] = itemStack; - if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) - { + if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) { itemStack.stackSize = getInventoryStackLimit(); } @@ -310,54 +324,49 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide } @Override - public String getInventoryName() - { - return this.hasCustomName() ? this.getCustomName() : Names.Containers.TRANSMUTATION_TABLET; + public String getInventoryName() { + return this.hasCustomName() ? this.getCustomName() + : Names.Containers.TRANSMUTATION_TABLET; } @Override - public boolean hasCustomInventoryName() - { + public boolean hasCustomInventoryName() { return this.hasCustomName(); } @Override - public int getInventoryStackLimit() - { + public int getInventoryStackLimit() { return 64; } @Override - public boolean isUseableByPlayer(EntityPlayer entityPlayer) - { - return this.worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && isStructureValid() && entityPlayer.getDistanceSq((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D; + public boolean isUseableByPlayer(EntityPlayer entityPlayer) { + return this.worldObj.getTileEntity(xCoord, yCoord, zCoord) == this + && isStructureValid() + && entityPlayer.getDistanceSq( + (double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D + ) + <= 64D; } @Override - public void openInventory() - { + public void openInventory() { // NOOP } @Override - public void closeInventory() - { + public void closeInventory() { // NOOP } @Override - public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) - { - if (slotIndex < STONE_INDEX && EnergyValueRegistryProxy.hasEnergyValue(itemStack) && BlacklistRegistryProxy.isExchangeable(itemStack)) - { + public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) { + if (slotIndex < STONE_INDEX && EnergyValueRegistryProxy.hasEnergyValue(itemStack) + && BlacklistRegistryProxy.isExchangeable(itemStack)) { return true; - } - else if (slotIndex == STONE_INDEX && itemStack.getItem() instanceof ITransmutationStone) - { + } else if (slotIndex == STONE_INDEX && itemStack.getItem() instanceof ITransmutationStone) { return true; - } - else if (slotIndex == ALCHENOMICON_INDEX && itemStack.getItem() instanceof ItemAlchenomicon) - { + } else if (slotIndex == ALCHENOMICON_INDEX && itemStack.getItem() instanceof ItemAlchenomicon) { return true; } @@ -365,20 +374,17 @@ public class TileEntityTransmutationTablet extends TileEntityEE implements ISide } @Override - public int[] getAccessibleSlotsFromSide(int slotIndex) - { + public int[] getAccessibleSlotsFromSide(int slotIndex) { return new int[0]; } @Override - public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) - { + public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) { return false; } @Override - public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) - { + public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) { return false; } diff --git a/src/main/java/com/pahimar/ee3/util/CalcinationHelper.java b/src/main/java/com/pahimar/ee3/util/CalcinationHelper.java index a6db81cd..cab09678 100644 --- a/src/main/java/com/pahimar/ee3/util/CalcinationHelper.java +++ b/src/main/java/com/pahimar/ee3/util/CalcinationHelper.java @@ -1,28 +1,34 @@ package com.pahimar.ee3.util; +import java.util.Random; + import com.pahimar.ee3.api.exchange.EnergyValue; import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; import com.pahimar.ee3.init.ModItems; import net.minecraft.item.ItemStack; -import java.util.Random; - -public class CalcinationHelper -{ +public class CalcinationHelper { private static Random random = new Random(); public static ItemStack getCalcinationResult(ItemStack itemStack) { - EnergyValue dustEnergyValue = EnergyValueRegistryProxy.getEnergyValue(new ItemStack(ModItems.alchemicalDust, 1, 3)); - EnergyValue itemStackEnergyValue = EnergyValueRegistryProxy.getEnergyValue(itemStack); + EnergyValue dustEnergyValue = EnergyValueRegistryProxy.getEnergyValue( + new ItemStack(ModItems.alchemicalDust, 1, 3) + ); + EnergyValue itemStackEnergyValue + = EnergyValueRegistryProxy.getEnergyValue(itemStack); if (dustEnergyValue != null && itemStackEnergyValue != null) { - int dustAmount = (int) Math.floor(itemStackEnergyValue.getValue() / dustEnergyValue.getValue()); - float residualEMC = itemStackEnergyValue.getValue() - (dustAmount * dustEnergyValue.getValue()); + int dustAmount = (int + ) Math.floor(itemStackEnergyValue.getValue() / dustEnergyValue.getValue()); + float residualEMC = itemStackEnergyValue.getValue() + - (dustAmount * dustEnergyValue.getValue()); - double u = (double) residualEMC / dustEnergyValue.getValue(); // expected value (µ) + double u + = (double) residualEMC / dustEnergyValue.getValue(); // expected value (µ) double s = u / 2; // deviation (σ) u *= 1 - 0.0043451773677092; // negative cut-off correction factor - dustAmount += (int) (Math.max(0, random.nextGaussian() * s + u) + random.nextDouble()); + dustAmount += (int + ) (Math.max(0, random.nextGaussian() * s + u) + random.nextDouble()); if (dustAmount > 0) { return new ItemStack(ModItems.alchemicalDust, dustAmount, 3); diff --git a/src/main/java/com/pahimar/ee3/util/ColorHelper.java b/src/main/java/com/pahimar/ee3/util/ColorHelper.java index d8ab0e76..f63abe36 100644 --- a/src/main/java/com/pahimar/ee3/util/ColorHelper.java +++ b/src/main/java/com/pahimar/ee3/util/ColorHelper.java @@ -5,44 +5,43 @@ import com.pahimar.ee3.reference.Names; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class ColorHelper -{ - public static boolean hasColor(ItemStack itemStack) - { - return itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey(Names.NBT.DISPLAY) && itemStack.getTagCompound().getCompoundTag(Names.NBT.DISPLAY).hasKey(Names.NBT.COLOR); +public class ColorHelper { + public static boolean hasColor(ItemStack itemStack) { + return itemStack.hasTagCompound() + && itemStack.getTagCompound().hasKey(Names.NBT.DISPLAY) + && itemStack.getTagCompound() + .getCompoundTag(Names.NBT.DISPLAY) + .hasKey(Names.NBT.COLOR); } - public static int getColor(ItemStack itemStack) - { + public static int getColor(ItemStack itemStack) { NBTTagCompound nbtTagCompound = itemStack.getTagCompound(); - if (nbtTagCompound == null) - { + if (nbtTagCompound == null) { return Integer.parseInt(Colors.PURE_WHITE, 16); - } - else - { - NBTTagCompound displayTagCompound = nbtTagCompound.getCompoundTag(Names.NBT.DISPLAY); - return displayTagCompound == null ? Integer.parseInt(Colors.PURE_WHITE, 16) : displayTagCompound.hasKey(Names.NBT.COLOR) ? displayTagCompound.getInteger(Names.NBT.COLOR) : Integer.parseInt(Colors.PURE_WHITE, 16); + } else { + NBTTagCompound displayTagCompound + = nbtTagCompound.getCompoundTag(Names.NBT.DISPLAY); + return displayTagCompound == null ? Integer.parseInt(Colors.PURE_WHITE, 16) + : displayTagCompound.hasKey(Names.NBT.COLOR) + ? displayTagCompound.getInteger(Names.NBT.COLOR) + : Integer.parseInt(Colors.PURE_WHITE, 16); } } - public static void setColor(ItemStack itemStack, int color) - { - if (itemStack != null) - { + public static void setColor(ItemStack itemStack, int color) { + if (itemStack != null) { NBTTagCompound nbtTagCompound = itemStack.getTagCompound(); - if (nbtTagCompound == null) - { + if (nbtTagCompound == null) { nbtTagCompound = new NBTTagCompound(); itemStack.setTagCompound(nbtTagCompound); } - NBTTagCompound colourTagCompound = nbtTagCompound.getCompoundTag(Names.NBT.DISPLAY); + NBTTagCompound colourTagCompound + = nbtTagCompound.getCompoundTag(Names.NBT.DISPLAY); - if (!nbtTagCompound.hasKey(Names.NBT.DISPLAY)) - { + if (!nbtTagCompound.hasKey(Names.NBT.DISPLAY)) { nbtTagCompound.setTag(Names.NBT.DISPLAY, colourTagCompound); } diff --git a/src/main/java/com/pahimar/ee3/util/CommonParticleHelper.java b/src/main/java/com/pahimar/ee3/util/CommonParticleHelper.java index eef11e97..1942d5ab 100644 --- a/src/main/java/com/pahimar/ee3/util/CommonParticleHelper.java +++ b/src/main/java/com/pahimar/ee3/util/CommonParticleHelper.java @@ -4,15 +4,46 @@ import com.pahimar.ee3.network.PacketHandler; import com.pahimar.ee3.network.message.MessageSingleParticleEvent; import cpw.mods.fml.common.network.NetworkRegistry; -public class CommonParticleHelper -{ - public static void spawnParticleAtLocation(String particleName, int dimensionId, double xCoord, double yCoord, double zCoord, double xVelocity, double yVelocity, double zVelocity) - { - spawnParticleAtLocation(particleName, dimensionId, xCoord, yCoord, zCoord, xVelocity, yVelocity, zVelocity, 64d); +public class CommonParticleHelper { + public static void spawnParticleAtLocation( + String particleName, + int dimensionId, + double xCoord, + double yCoord, + double zCoord, + double xVelocity, + double yVelocity, + double zVelocity + ) { + spawnParticleAtLocation( + particleName, + dimensionId, + xCoord, + yCoord, + zCoord, + xVelocity, + yVelocity, + zVelocity, + 64d + ); } - public static void spawnParticleAtLocation(String particleName, int dimensionId, double xCoord, double yCoord, double zCoord, double xVelocity, double yVelocity, double zVelocity, double range) - { - PacketHandler.INSTANCE.sendToAllAround(new MessageSingleParticleEvent(particleName, xCoord, yCoord, zCoord, xVelocity, yVelocity, zVelocity), new NetworkRegistry.TargetPoint(dimensionId, xCoord, yCoord, zCoord, range)); + public static void spawnParticleAtLocation( + String particleName, + int dimensionId, + double xCoord, + double yCoord, + double zCoord, + double xVelocity, + double yVelocity, + double zVelocity, + double range + ) { + PacketHandler.INSTANCE.sendToAllAround( + new MessageSingleParticleEvent( + particleName, xCoord, yCoord, zCoord, xVelocity, yVelocity, zVelocity + ), + new NetworkRegistry.TargetPoint(dimensionId, xCoord, yCoord, zCoord, range) + ); } } diff --git a/src/main/java/com/pahimar/ee3/util/CommonSoundHelper.java b/src/main/java/com/pahimar/ee3/util/CommonSoundHelper.java index dae95af0..3baf103a 100644 --- a/src/main/java/com/pahimar/ee3/util/CommonSoundHelper.java +++ b/src/main/java/com/pahimar/ee3/util/CommonSoundHelper.java @@ -5,25 +5,59 @@ import com.pahimar.ee3.network.message.MessageSoundEvent; import cpw.mods.fml.common.network.NetworkRegistry; import net.minecraft.entity.player.EntityPlayer; -public class CommonSoundHelper -{ - public static void playSoundAtLocation(int dimensionId, float xCoord, float yCoord, float zCoord, String soundName, float volume, float pitch) - { - playSoundAtLocation(dimensionId, xCoord, yCoord, zCoord, soundName, volume, pitch, 32d); +public class CommonSoundHelper { + public static void playSoundAtLocation( + int dimensionId, + float xCoord, + float yCoord, + float zCoord, + String soundName, + float volume, + float pitch + ) { + playSoundAtLocation( + dimensionId, xCoord, yCoord, zCoord, soundName, volume, pitch, 32d + ); } - public static void playSoundAtLocation(int dimensionId, float xCoord, float yCoord, float zCoord, String soundName, float volume, float pitch, double range) - { - PacketHandler.INSTANCE.sendToAllAround(new MessageSoundEvent(soundName, xCoord, yCoord, zCoord, volume, pitch), new NetworkRegistry.TargetPoint(dimensionId, xCoord, yCoord, zCoord, range)); + public static void playSoundAtLocation( + int dimensionId, + float xCoord, + float yCoord, + float zCoord, + String soundName, + float volume, + float pitch, + double range + ) { + PacketHandler.INSTANCE.sendToAllAround( + new MessageSoundEvent(soundName, xCoord, yCoord, zCoord, volume, pitch), + new NetworkRegistry.TargetPoint(dimensionId, xCoord, yCoord, zCoord, range) + ); } - public static void playSoundAtPlayer(EntityPlayer entityPlayer, String soundName, float volume, float pitch) - { + public static void playSoundAtPlayer( + EntityPlayer entityPlayer, String soundName, float volume, float pitch + ) { playSoundAtPlayer(entityPlayer, soundName, volume, pitch, 32d); } - public static void playSoundAtPlayer(EntityPlayer entityPlayer, String soundName, float volume, float pitch, double range) - { - PacketHandler.INSTANCE.sendToAllAround(new MessageSoundEvent(entityPlayer, soundName, volume, pitch), new NetworkRegistry.TargetPoint(entityPlayer.worldObj.provider.dimensionId, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, range)); + public static void playSoundAtPlayer( + EntityPlayer entityPlayer, + String soundName, + float volume, + float pitch, + double range + ) { + PacketHandler.INSTANCE.sendToAllAround( + new MessageSoundEvent(entityPlayer, soundName, volume, pitch), + new NetworkRegistry.TargetPoint( + entityPlayer.worldObj.provider.dimensionId, + entityPlayer.posX, + entityPlayer.posY, + entityPlayer.posZ, + range + ) + ); } } diff --git a/src/main/java/com/pahimar/ee3/util/CompressionHelper.java b/src/main/java/com/pahimar/ee3/util/CompressionHelper.java index 8ef5e9e8..31f64ec7 100644 --- a/src/main/java/com/pahimar/ee3/util/CompressionHelper.java +++ b/src/main/java/com/pahimar/ee3/util/CompressionHelper.java @@ -6,21 +6,21 @@ import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; public class CompressionHelper { - /** * * @param uncompressedString * @return */ public static byte[] compress(String uncompressedString) { - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - try (GZIPOutputStream gzipOutputStream = new GZIPOutputStream(byteArrayOutputStream)) { + try ( + GZIPOutputStream gzipOutputStream + = new GZIPOutputStream(byteArrayOutputStream) + ) { gzipOutputStream.write(uncompressedString.getBytes(StandardCharsets.UTF_8)); gzipOutputStream.close(); - } - catch (IOException e) { + } catch (IOException e) { e.printStackTrace(); } @@ -33,15 +33,18 @@ public class CompressionHelper { * @return */ public static String decompress(byte[] compressedString) { - StringBuilder stringBuilder = new StringBuilder(); String line; - try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new GZIPInputStream(new ByteArrayInputStream(compressedString)), StandardCharsets.UTF_8))) { + try ( + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader( + new GZIPInputStream(new ByteArrayInputStream(compressedString)), + StandardCharsets.UTF_8 + )) + ) { while ((line = bufferedReader.readLine()) != null) { stringBuilder.append(line); } - } - catch (IOException e) { + } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/com/pahimar/ee3/util/ConfigurationHelper.java b/src/main/java/com/pahimar/ee3/util/ConfigurationHelper.java index d3914c59..e2e6b024 100644 --- a/src/main/java/com/pahimar/ee3/util/ConfigurationHelper.java +++ b/src/main/java/com/pahimar/ee3/util/ConfigurationHelper.java @@ -3,20 +3,24 @@ package com.pahimar.ee3.util; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; -public class ConfigurationHelper -{ - public static String getString(Configuration configuration, String name, String category, String defaultValue, String comment, String[] validValues, String langKey) - { +public class ConfigurationHelper { + public static String getString( + Configuration configuration, + String name, + String category, + String defaultValue, + String comment, + String[] validValues, + String langKey + ) { Property property = configuration.get(category, name, defaultValue); property.setValidValues(validValues); property.setLanguageKey(langKey); property.comment = comment + " [default: " + defaultValue + "]"; String value = property.getString(); - for (int i = 0; i < validValues.length; i++) - { - if (value.equalsIgnoreCase(validValues[i])) - { + for (int i = 0; i < validValues.length; i++) { + if (value.equalsIgnoreCase(validValues[i])) { return validValues[i]; } } diff --git a/src/main/java/com/pahimar/ee3/util/DebugUtils.java b/src/main/java/com/pahimar/ee3/util/DebugUtils.java index 6bf5e226..ada32608 100644 --- a/src/main/java/com/pahimar/ee3/util/DebugUtils.java +++ b/src/main/java/com/pahimar/ee3/util/DebugUtils.java @@ -1,27 +1,26 @@ package com.pahimar.ee3.util; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -public class DebugUtils -{ - public static void dumpSortedOreDictionaryNames() - { - List oreNames = new ArrayList(Arrays.asList(OreDictionary.getOreNames())); +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public class DebugUtils { + public static void dumpSortedOreDictionaryNames() { + List oreNames + = new ArrayList(Arrays.asList(OreDictionary.getOreNames())); Collections.sort(oreNames); - for (String oreName : oreNames) - { + for (String oreName : oreNames) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(String.format("Ore: %s, ItemStacks: ", oreName)); - for (ItemStack itemStack : OreDictionary.getOres(oreName)) - { - stringBuilder.append(String.format("%s ", ItemStackUtils.toString(itemStack))); + for (ItemStack itemStack : OreDictionary.getOres(oreName)) { + stringBuilder.append( + String.format("%s ", ItemStackUtils.toString(itemStack)) + ); } LogHelper.info(stringBuilder.toString()); } diff --git a/src/main/java/com/pahimar/ee3/util/EntityHelper.java b/src/main/java/com/pahimar/ee3/util/EntityHelper.java index 88af3ab3..ecb06113 100644 --- a/src/main/java/com/pahimar/ee3/util/EntityHelper.java +++ b/src/main/java/com/pahimar/ee3/util/EntityHelper.java @@ -6,22 +6,20 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.IMob; import net.minecraft.nbt.NBTTagCompound; -public class EntityHelper -{ - public static NBTTagCompound getCustomEntityData(Entity entity) - { - if (entity != null && entity.getEntityData().hasKey(Reference.LOWERCASE_MOD_ID) && entity.getEntityData().getTag(Reference.LOWERCASE_MOD_ID) instanceof NBTTagCompound) - { +public class EntityHelper { + public static NBTTagCompound getCustomEntityData(Entity entity) { + if (entity != null && entity.getEntityData().hasKey(Reference.LOWERCASE_MOD_ID) + && entity.getEntityData().getTag(Reference.LOWERCASE_MOD_ID) + instanceof NBTTagCompound) { return entity.getEntityData().getCompoundTag(Reference.LOWERCASE_MOD_ID); } return new NBTTagCompound(); } - public static void saveCustomEntityData(Entity entity, NBTTagCompound nbtTagCompound) - { - if (entity != null) - { + public static void + saveCustomEntityData(Entity entity, NBTTagCompound nbtTagCompound) { + if (entity != null) { entity.getEntityData().setTag(Reference.LOWERCASE_MOD_ID, nbtTagCompound); } } diff --git a/src/main/java/com/pahimar/ee3/util/FilterUtils.java b/src/main/java/com/pahimar/ee3/util/FilterUtils.java index 4f89c65e..d9e4cf1d 100644 --- a/src/main/java/com/pahimar/ee3/util/FilterUtils.java +++ b/src/main/java/com/pahimar/ee3/util/FilterUtils.java @@ -1,38 +1,45 @@ package com.pahimar.ee3.util; +import java.util.*; + import com.pahimar.ee3.api.exchange.EnergyValue; import com.pahimar.ee3.api.exchange.EnergyValueRegistryProxy; import com.pahimar.ee3.reference.Comparators; import net.minecraft.item.ItemStack; -import java.util.*; - public class FilterUtils { - - - - public static Set filterByDisplayName(Set itemStacks, String filterString) { - return filterByDisplayName(itemStacks, filterString, NameFilterType.STARTS_WITH, null); + public static Set + filterByDisplayName(Set itemStacks, String filterString) { + return filterByDisplayName( + itemStacks, filterString, NameFilterType.STARTS_WITH, null + ); } - public static Set filterByDisplayName(Set itemStacks, String filterString, NameFilterType filterType) { + public static Set filterByDisplayName( + Set itemStacks, String filterString, NameFilterType filterType + ) { return filterByDisplayName(itemStacks, filterString, filterType, null); } - public static Set filterByDisplayName(Collection itemStacks, String filterString, NameFilterType filterType, Comparator comparator) { - - Set filteredSet = (comparator != null ? new TreeSet<>(comparator) : new TreeSet<>(Comparators.DISPLAY_NAME_COMPARATOR)); + public static Set filterByDisplayName( + Collection itemStacks, + String filterString, + NameFilterType filterType, + Comparator comparator + ) { + Set filteredSet + = (comparator != null ? new TreeSet<>(comparator) + : new TreeSet<>(Comparators.DISPLAY_NAME_COMPARATOR)); if (itemStacks != null) { if (filterString == null || filterString.isEmpty()) { filteredSet.addAll(itemStacks); - } - else { + } else { for (ItemStack itemStack : itemStacks) { - String itemDisplayName = itemStack.getDisplayName().toLowerCase(); - if (filterType == NameFilterType.STARTS_WITH && itemDisplayName.startsWith(filterString.toLowerCase())) { + if (filterType == NameFilterType.STARTS_WITH + && itemDisplayName.startsWith(filterString.toLowerCase())) { filteredSet.add(itemStack); } else if (filterType == NameFilterType.CONTAINS && itemDisplayName.contains(filterString.toLowerCase())) { filteredSet.add(itemStack); @@ -44,42 +51,72 @@ public class FilterUtils { return filteredSet; } - public static Set filterByEnergyValue(Collection itemStacks, Number valueBound) { - return filterByEnergyValue(itemStacks, new EnergyValue(valueBound.floatValue()), ValueFilterType.VALUE_LOWER_THAN_BOUND, null); + public static Set + filterByEnergyValue(Collection itemStacks, Number valueBound) { + return filterByEnergyValue( + itemStacks, + new EnergyValue(valueBound.floatValue()), + ValueFilterType.VALUE_LOWER_THAN_BOUND, + null + ); } - public static Set filterByEnergyValue(Collection itemStacks, EnergyValue valueBound) { - return filterByEnergyValue(itemStacks, valueBound, ValueFilterType.VALUE_LOWER_THAN_BOUND, null); + public static Set + filterByEnergyValue(Collection itemStacks, EnergyValue valueBound) { + return filterByEnergyValue( + itemStacks, valueBound, ValueFilterType.VALUE_LOWER_THAN_BOUND, null + ); } - public static Set filterByEnergyValue(Collection itemStacks, Number valueBound, ValueFilterType filterType) { - return filterByEnergyValue(itemStacks, new EnergyValue(valueBound.floatValue()), filterType, null); + public static Set filterByEnergyValue( + Collection itemStacks, Number valueBound, ValueFilterType filterType + ) { + return filterByEnergyValue( + itemStacks, new EnergyValue(valueBound.floatValue()), filterType, null + ); } - public static Set filterByEnergyValue(Collection itemStacks, EnergyValue valueBound, ValueFilterType filterType) { + public static Set filterByEnergyValue( + Collection itemStacks, + EnergyValue valueBound, + ValueFilterType filterType + ) { return filterByEnergyValue(itemStacks, valueBound, filterType, null); } - public static Set filterByEnergyValue(Collection itemStacks, Number valueBound, ValueFilterType filterType, Comparator comparator) { - return filterByEnergyValue(itemStacks, new EnergyValue(valueBound.floatValue()), filterType, comparator); + public static Set filterByEnergyValue( + Collection itemStacks, + Number valueBound, + ValueFilterType filterType, + Comparator comparator + ) { + return filterByEnergyValue( + itemStacks, new EnergyValue(valueBound.floatValue()), filterType, comparator + ); } - public static Set filterByEnergyValue(Collection itemStacks, EnergyValue valueBound, ValueFilterType filterType, Comparator comparator) { - - Set filteredSet = (comparator != null ? new TreeSet<>(comparator) : new TreeSet<>(Comparators.DISPLAY_NAME_COMPARATOR)); + public static Set filterByEnergyValue( + Collection itemStacks, + EnergyValue valueBound, + ValueFilterType filterType, + Comparator comparator + ) { + Set filteredSet + = (comparator != null ? new TreeSet<>(comparator) + : new TreeSet<>(Comparators.DISPLAY_NAME_COMPARATOR)); if (itemStacks != null) { - if (valueBound == null) { filteredSet.addAll(itemStacks); - } - else { + } else { for (ItemStack itemStack : itemStacks) { + EnergyValue energyValue + = EnergyValueRegistryProxy.getEnergyValue(itemStack, false); - EnergyValue energyValue = EnergyValueRegistryProxy.getEnergyValue(itemStack, false); - - if (energyValue != null && Float.compare(energyValue.getValue(), 0) > 0) { - if (filterType == ValueFilterType.VALUE_LOWER_THAN_BOUND && energyValue.compareTo(valueBound) <= 0) { + if (energyValue != null + && Float.compare(energyValue.getValue(), 0) > 0) { + if (filterType == ValueFilterType.VALUE_LOWER_THAN_BOUND + && energyValue.compareTo(valueBound) <= 0) { filteredSet.add(itemStack); } else if (filterType == ValueFilterType.VALUE_GREATER_THAN_BOUND && energyValue.compareTo(valueBound) >= 0) { @@ -94,7 +131,6 @@ public class FilterUtils { } public static Collection filterForItemStacks(Collection objects) { - Set itemStacks = new TreeSet<>(Comparators.ID_COMPARATOR); for (Object object : objects) { @@ -106,13 +142,7 @@ public class FilterUtils { return itemStacks; } - public enum NameFilterType { - STARTS_WITH, - CONTAINS - } + public enum NameFilterType { STARTS_WITH, CONTAINS } - public enum ValueFilterType { - VALUE_GREATER_THAN_BOUND, - VALUE_LOWER_THAN_BOUND - } + public enum ValueFilterType { VALUE_GREATER_THAN_BOUND, VALUE_LOWER_THAN_BOUND } } diff --git a/src/main/java/com/pahimar/ee3/util/FluidHelper.java b/src/main/java/com/pahimar/ee3/util/FluidHelper.java index f2101517..c5ab002e 100644 --- a/src/main/java/com/pahimar/ee3/util/FluidHelper.java +++ b/src/main/java/com/pahimar/ee3/util/FluidHelper.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.util; +import java.util.Comparator; + import com.pahimar.ee3.reference.Names; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -8,81 +10,72 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import java.util.Comparator; - public class FluidHelper { - public static final Comparator COMPARATOR = new Comparator() { - @Override public int compare(FluidStack fluidStack1, FluidStack fluidStack2) { - if (fluidStack1 != null && fluidStack2 != null) { - if (fluidStack1.getFluid() != null && fluidStack2.getFluid() != null) { - if (FluidRegistry.getFluidName(fluidStack1) != null && FluidRegistry.getFluidName(fluidStack2) != null) { - if (FluidRegistry.getFluidName(fluidStack1).equalsIgnoreCase(FluidRegistry.getFluidName(fluidStack2))) { + if (fluidStack1.getFluid() != null && fluidStack2.getFluid() != null) { + if (FluidRegistry.getFluidName(fluidStack1) != null + && FluidRegistry.getFluidName(fluidStack2) != null) { + if (FluidRegistry.getFluidName(fluidStack1) + .equalsIgnoreCase(FluidRegistry.getFluidName(fluidStack2) + )) { if (fluidStack1.amount == fluidStack2.amount) { if (fluidStack1.tag != null && fluidStack2.tag != null) { - return fluidStack1.tag.hashCode() - fluidStack2.tag.hashCode(); - } - else if (fluidStack1.tag != null) { + return fluidStack1.tag.hashCode() + - fluidStack2.tag.hashCode(); + } else if (fluidStack1.tag != null) { return -1; - } - else if (fluidStack2.tag != null) { + } else if (fluidStack2.tag != null) { return 1; - } - else { + } else { return 0; } - } - else { + } else { return fluidStack1.amount - fluidStack2.amount; } + } else { + return FluidRegistry.getFluidName(fluidStack1) + .compareToIgnoreCase( + FluidRegistry.getFluidName(fluidStack2) + ); } - else { - return FluidRegistry.getFluidName(fluidStack1).compareToIgnoreCase(FluidRegistry.getFluidName(fluidStack2)); - } - } - else if (FluidRegistry.getFluidName(fluidStack1) != null) { + } else if (FluidRegistry.getFluidName(fluidStack1) != null) { return -1; - } - else if (FluidRegistry.getFluidName(fluidStack2) != null) { + } else if (FluidRegistry.getFluidName(fluidStack2) != null) { return 1; - } - else { + } else { return 0; } - } - else if (fluidStack1.getFluid() != null) { + } else if (fluidStack1.getFluid() != null) { return -1; - } - else if (fluidStack2.getFluid() != null) { + } else if (fluidStack2.getFluid() != null) { return 1; - } - else { + } else { return 0; } - } - else if (fluidStack1 != null) { + } else if (fluidStack1 != null) { return -1; - } - else if (fluidStack2 != null) { + } else if (fluidStack2 != null) { return 1; - } - else { + } else { return 0; } } }; public static void registerFluids() { - // Register Milk in the FluidRegistry if it hasn't already been done if (!FluidRegistry.isFluidRegistered("milk")) { Fluid milk = new Fluid("milk").setUnlocalizedName(Names.Fluids.MILK); if (FluidRegistry.registerFluid(milk)) { - FluidContainerRegistry.registerFluidContainer(new FluidStack(milk, 1000), new ItemStack(Items.milk_bucket), new ItemStack(Items.bucket)); + FluidContainerRegistry.registerFluidContainer( + new FluidStack(milk, 1000), + new ItemStack(Items.milk_bucket), + new ItemStack(Items.bucket) + ); } } } @@ -92,9 +85,10 @@ public class FluidHelper { } public static String toString(FluidStack fluidStack) { - if (fluidStack != null) { - return String.format("%sxfluidStack.%s", fluidStack.amount, fluidStack.getFluid().getName()); + return String.format( + "%sxfluidStack.%s", fluidStack.amount, fluidStack.getFluid().getName() + ); } return "fluidStack[null]"; diff --git a/src/main/java/com/pahimar/ee3/util/IChargeable.java b/src/main/java/com/pahimar/ee3/util/IChargeable.java index 7caa352b..dbf4c07e 100644 --- a/src/main/java/com/pahimar/ee3/util/IChargeable.java +++ b/src/main/java/com/pahimar/ee3/util/IChargeable.java @@ -2,8 +2,7 @@ package com.pahimar.ee3.util; import net.minecraft.item.ItemStack; -public interface IChargeable -{ +public interface IChargeable { public abstract short getMaxChargeLevel(); public abstract short getChargeLevel(ItemStack itemStack); diff --git a/src/main/java/com/pahimar/ee3/util/IKeyBound.java b/src/main/java/com/pahimar/ee3/util/IKeyBound.java index 3d870918..2971fb68 100644 --- a/src/main/java/com/pahimar/ee3/util/IKeyBound.java +++ b/src/main/java/com/pahimar/ee3/util/IKeyBound.java @@ -4,7 +4,7 @@ import com.pahimar.ee3.reference.Key; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -public interface IKeyBound -{ - public abstract void doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key); +public interface IKeyBound { + public abstract void + doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key); } diff --git a/src/main/java/com/pahimar/ee3/util/IModalTool.java b/src/main/java/com/pahimar/ee3/util/IModalTool.java index f422ab77..833537e0 100644 --- a/src/main/java/com/pahimar/ee3/util/IModalTool.java +++ b/src/main/java/com/pahimar/ee3/util/IModalTool.java @@ -1,12 +1,11 @@ package com.pahimar.ee3.util; +import java.util.List; + import com.pahimar.ee3.reference.ToolMode; import net.minecraft.item.ItemStack; -import java.util.List; - -public interface IModalTool -{ +public interface IModalTool { public abstract List getAvailableToolModes(); public abstract ToolMode getCurrentToolMode(ItemStack itemStack); diff --git a/src/main/java/com/pahimar/ee3/util/INBTTaggable.java b/src/main/java/com/pahimar/ee3/util/INBTTaggable.java index 93c5fe22..1e966e5c 100644 --- a/src/main/java/com/pahimar/ee3/util/INBTTaggable.java +++ b/src/main/java/com/pahimar/ee3/util/INBTTaggable.java @@ -2,8 +2,7 @@ package com.pahimar.ee3.util; import net.minecraft.nbt.NBTTagCompound; -public interface INBTTaggable -{ +public interface INBTTaggable { void readFromNBT(NBTTagCompound nbtTagCompound); void writeToNBT(NBTTagCompound nbtTagCompound); diff --git a/src/main/java/com/pahimar/ee3/util/IOverlayItem.java b/src/main/java/com/pahimar/ee3/util/IOverlayItem.java index 0175f96e..ace9409a 100644 --- a/src/main/java/com/pahimar/ee3/util/IOverlayItem.java +++ b/src/main/java/com/pahimar/ee3/util/IOverlayItem.java @@ -1,5 +1,3 @@ package com.pahimar.ee3.util; -public interface IOverlayItem -{ -} +public interface IOverlayItem {} diff --git a/src/main/java/com/pahimar/ee3/util/IOwnable.java b/src/main/java/com/pahimar/ee3/util/IOwnable.java index e88f597e..82346f87 100644 --- a/src/main/java/com/pahimar/ee3/util/IOwnable.java +++ b/src/main/java/com/pahimar/ee3/util/IOwnable.java @@ -1,6 +1,3 @@ package com.pahimar.ee3.util; -public interface IOwnable -{ - -} +public interface IOwnable {} diff --git a/src/main/java/com/pahimar/ee3/util/ItemStackUtils.java b/src/main/java/com/pahimar/ee3/util/ItemStackUtils.java index b12baae3..c9daa325 100644 --- a/src/main/java/com/pahimar/ee3/util/ItemStackUtils.java +++ b/src/main/java/com/pahimar/ee3/util/ItemStackUtils.java @@ -1,33 +1,29 @@ package com.pahimar.ee3.util; +import java.util.ArrayList; +import java.util.UUID; + import com.pahimar.ee3.reference.Comparators; import com.pahimar.ee3.reference.Names; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import java.util.ArrayList; -import java.util.UUID; - public class ItemStackUtils { - public static ItemStack clone(ItemStack itemStack, int stackSize) { - if (itemStack != null) { ItemStack clonedItemStack = itemStack.copy(); clonedItemStack.stackSize = stackSize; return clonedItemStack; - } - else { + } else { return null; } } /** - * Compares two ItemStacks for equality, testing itemID, metaData, stackSize, and their NBTTagCompounds (if they are - * present) + * Compares two ItemStacks for equality, testing itemID, metaData, stackSize, and + * their NBTTagCompounds (if they are present) * * @param first The first ItemStack being tested for equality * @param second The second ItemStack being tested for equality @@ -37,7 +33,8 @@ public class ItemStackUtils { return (Comparators.ID_COMPARATOR.compare(first, second) == 0); } - public static boolean equalsIgnoreStackSize(ItemStack itemStack1, ItemStack itemStack2) { + public static boolean + equalsIgnoreStackSize(ItemStack itemStack1, ItemStack itemStack2) { return equals(clone(itemStack1, 1), clone(itemStack2, 1)); } @@ -46,13 +43,22 @@ public class ItemStackUtils { } public static String toString(ItemStack itemStack) { - if (itemStack != null) { if (itemStack.hasTagCompound()) { - return String.format("%sxitemStack[%s@%s:%s]", itemStack.stackSize, itemStack.getUnlocalizedName(), itemStack.getItemDamage(), itemStack.getTagCompound()); - } - else { - return String.format("%sxitemStack[%s@%s]", itemStack.stackSize, itemStack.getUnlocalizedName(), itemStack.getItemDamage()); + return String.format( + "%sxitemStack[%s@%s:%s]", + itemStack.stackSize, + itemStack.getUnlocalizedName(), + itemStack.getItemDamage(), + itemStack.getTagCompound() + ); + } else { + return String.format( + "%sxitemStack[%s@%s]", + itemStack.stackSize, + itemStack.getUnlocalizedName(), + itemStack.getItemDamage() + ); } } @@ -60,7 +66,6 @@ public class ItemStackUtils { } public static void setOwner(ItemStack itemStack, EntityPlayer entityPlayer) { - setOwnerName(itemStack, entityPlayer); setOwnerUUID(itemStack, entityPlayer); } @@ -70,18 +75,28 @@ public class ItemStackUtils { } public static UUID getOwnerUUID(ItemStack itemStack) { - - if (NBTHelper.getLong(itemStack, Names.NBT.OWNER_UUID_MOST_SIG) != null && NBTHelper.getLong(itemStack, Names.NBT.OWNER_UUID_LEAST_SIG) != null) { - return new UUID(NBTHelper.getLong(itemStack, Names.NBT.OWNER_UUID_MOST_SIG), NBTHelper.getLong(itemStack, Names.NBT.OWNER_UUID_LEAST_SIG)); + if (NBTHelper.getLong(itemStack, Names.NBT.OWNER_UUID_MOST_SIG) != null + && NBTHelper.getLong(itemStack, Names.NBT.OWNER_UUID_LEAST_SIG) != null) { + return new UUID( + NBTHelper.getLong(itemStack, Names.NBT.OWNER_UUID_MOST_SIG), + NBTHelper.getLong(itemStack, Names.NBT.OWNER_UUID_LEAST_SIG) + ); } return null; } public static void setOwnerUUID(ItemStack itemStack, EntityPlayer entityPlayer) { - - NBTHelper.setLong(itemStack, Names.NBT.OWNER_UUID_MOST_SIG, entityPlayer.getUniqueID().getMostSignificantBits()); - NBTHelper.setLong(itemStack, Names.NBT.OWNER_UUID_LEAST_SIG, entityPlayer.getUniqueID().getLeastSignificantBits()); + NBTHelper.setLong( + itemStack, + Names.NBT.OWNER_UUID_MOST_SIG, + entityPlayer.getUniqueID().getMostSignificantBits() + ); + NBTHelper.setLong( + itemStack, + Names.NBT.OWNER_UUID_LEAST_SIG, + entityPlayer.getUniqueID().getLeastSignificantBits() + ); } public static void setOwnerName(ItemStack itemStack, EntityPlayer entityPlayer) { @@ -90,13 +105,13 @@ public class ItemStackUtils { public static ItemStack convertObjectToItemStack(final Object obj) { if (obj instanceof Item) { - return new ItemStack((Item)obj); + return new ItemStack((Item) obj); } if (obj instanceof Block) { - return new ItemStack((Block)obj); + return new ItemStack((Block) obj); } if (obj instanceof ItemStack) { - return (ItemStack)obj; + return (ItemStack) obj; } return null; } @@ -104,7 +119,8 @@ public class ItemStackUtils { public static Object[] convertSingleStackToPluralStacks(final ItemStack stack) { final ArrayList list = new ArrayList<>(); for (int i = 0; i < stack.stackSize; ++i) { - final ItemStack currentStack = new ItemStack(stack.getItem(), 1, stack.getItemDamage()); + final ItemStack currentStack + = new ItemStack(stack.getItem(), 1, stack.getItemDamage()); list.add(currentStack); } return list.toArray(); diff --git a/src/main/java/com/pahimar/ee3/util/ItemUtil.java b/src/main/java/com/pahimar/ee3/util/ItemUtil.java index 173f7574..a99afc84 100644 --- a/src/main/java/com/pahimar/ee3/util/ItemUtil.java +++ b/src/main/java/com/pahimar/ee3/util/ItemUtil.java @@ -1,22 +1,19 @@ package com.pahimar.ee3.util; import com.pahimar.ee3.init.ModItems; - import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; public class ItemUtil { - private static double rand; - public static void dropMiniumShard(final EntityPlayer player, final EntityLivingBase entity) { + public static void + dropMiniumShard(final EntityPlayer player, final EntityLivingBase entity) { if (EntityHelper.isHostileEntity(entity)) { ItemUtil.rand = Math.random(); if (ItemUtil.rand < 0.15) { entity.dropItem(ModItems.shardMinium, 1); - } } } - } diff --git a/src/main/java/com/pahimar/ee3/util/LoaderHelper.java b/src/main/java/com/pahimar/ee3/util/LoaderHelper.java index 5a3b3754..8cece1f7 100644 --- a/src/main/java/com/pahimar/ee3/util/LoaderHelper.java +++ b/src/main/java/com/pahimar/ee3/util/LoaderHelper.java @@ -3,40 +3,23 @@ package com.pahimar.ee3.util; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.LoaderState; -public class LoaderHelper -{ - public static LoaderState getLoaderState() - { - if (Loader.instance().isInState(LoaderState.SERVER_STARTED)) - { +public class LoaderHelper { + public static LoaderState getLoaderState() { + if (Loader.instance().isInState(LoaderState.SERVER_STARTED)) { return LoaderState.SERVER_STARTED; - } - else if (Loader.instance().isInState(LoaderState.SERVER_STARTING)) - { + } else if (Loader.instance().isInState(LoaderState.SERVER_STARTING)) { return LoaderState.SERVER_STARTING; - } - else if (Loader.instance().isInState(LoaderState.SERVER_ABOUT_TO_START)) - { + } else if (Loader.instance().isInState(LoaderState.SERVER_ABOUT_TO_START)) { return LoaderState.SERVER_ABOUT_TO_START; - } - else if (Loader.instance().isInState(LoaderState.AVAILABLE)) - { + } else if (Loader.instance().isInState(LoaderState.AVAILABLE)) { return LoaderState.AVAILABLE; - } - else if (Loader.instance().isInState(LoaderState.POSTINITIALIZATION)) - { + } else if (Loader.instance().isInState(LoaderState.POSTINITIALIZATION)) { return LoaderState.POSTINITIALIZATION; - } - else if (Loader.instance().isInState(LoaderState.INITIALIZATION)) - { + } else if (Loader.instance().isInState(LoaderState.INITIALIZATION)) { return LoaderState.INITIALIZATION; - } - else if (Loader.instance().isInState(LoaderState.PREINITIALIZATION)) - { + } else if (Loader.instance().isInState(LoaderState.PREINITIALIZATION)) { return LoaderState.PREINITIALIZATION; - } - else - { + } else { return null; } } diff --git a/src/main/java/com/pahimar/ee3/util/LogHelper.java b/src/main/java/com/pahimar/ee3/util/LogHelper.java index 5a81e393..98c8efc0 100644 --- a/src/main/java/com/pahimar/ee3/util/LogHelper.java +++ b/src/main/java/com/pahimar/ee3/util/LogHelper.java @@ -4,8 +4,7 @@ import com.pahimar.ee3.reference.Reference; import org.apache.logging.log4j.*; import org.apache.logging.log4j.message.Message; -public class LogHelper -{ +public class LogHelper { public static final Marker MOD_MARKER = MarkerManager.getMarker(Reference.MOD_ID); private static Logger logger = LogManager.getLogger(Reference.MOD_ID); diff --git a/src/main/java/com/pahimar/ee3/util/NBTHelper.java b/src/main/java/com/pahimar/ee3/util/NBTHelper.java index 393f43d0..b5a72bb0 100644 --- a/src/main/java/com/pahimar/ee3/util/NBTHelper.java +++ b/src/main/java/com/pahimar/ee3/util/NBTHelper.java @@ -1,54 +1,52 @@ package com.pahimar.ee3.util; +import java.util.UUID; + import com.pahimar.ee3.reference.Names; import net.minecraft.item.ItemStack; import net.minecraft.nbt.*; -import java.util.UUID; - public class NBTHelper { - public static void clearStatefulNBTTags(ItemStack itemStack) { - if (NBTHelper.hasKey(itemStack, Names.NBT.CRAFTING_GUI_OPEN)) { NBTHelper.removeTag(itemStack, Names.NBT.CRAFTING_GUI_OPEN); - } - else if (NBTHelper.hasKey(itemStack, Names.NBT.TRANSMUTATION_GUI_OPEN)) { + } else if (NBTHelper.hasKey(itemStack, Names.NBT.TRANSMUTATION_GUI_OPEN)) { NBTHelper.removeTag(itemStack, Names.NBT.TRANSMUTATION_GUI_OPEN); - } - else if (NBTHelper.hasKey(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN)) { + } else if (NBTHelper.hasKey(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN)) { NBTHelper.removeTag(itemStack, Names.NBT.ALCHEMICAL_BAG_GUI_OPEN); } } public static boolean hasKey(ItemStack itemStack, String keyName) { - return itemStack != null && itemStack.stackTagCompound != null && itemStack.stackTagCompound.hasKey(keyName); + return itemStack != null && itemStack.stackTagCompound != null + && itemStack.stackTagCompound.hasKey(keyName); } public static void removeTag(ItemStack itemStack, String keyName) { - - if (itemStack != null && itemStack.stackTagCompound != null && keyName != null && !keyName.isEmpty()) { + if (itemStack != null && itemStack.stackTagCompound != null && keyName != null + && !keyName.isEmpty()) { itemStack.stackTagCompound.removeTag(keyName); } } public static boolean hasUUID(ItemStack itemStack) { - return getLong(itemStack, Names.NBT.UUID_MOST_SIG) != null && getLong(itemStack, Names.NBT.UUID_LEAST_SIG) != null; + return getLong(itemStack, Names.NBT.UUID_MOST_SIG) != null + && getLong(itemStack, Names.NBT.UUID_LEAST_SIG) != null; } public static UUID getUUID(ItemStack itemStack) { - if (hasUUID(itemStack)) { - return new UUID(getLong(itemStack, Names.NBT.UUID_MOST_SIG), getLong(itemStack, Names.NBT.UUID_LEAST_SIG)); + return new UUID( + getLong(itemStack, Names.NBT.UUID_MOST_SIG), + getLong(itemStack, Names.NBT.UUID_LEAST_SIG) + ); } return null; } public static void setUUID(ItemStack itemStack, UUID uuid) { - if (itemStack != null) { - initNBTTagCompound(itemStack); if (uuid == null) { @@ -63,10 +61,10 @@ public class NBTHelper { /** * Initializes the NBT Tag Compound for the given ItemStack * - * @param itemStack The ItemStack for which its NBT Tag Compound is being checked for initialization + * @param itemStack The ItemStack for which its NBT Tag Compound is being checked for + * initialization */ private static void initNBTTagCompound(ItemStack itemStack) { - if (itemStack != null && itemStack.stackTagCompound == null) { itemStack.setTagCompound(new NBTTagCompound()); } @@ -74,7 +72,6 @@ public class NBTHelper { // String public static String getString(ItemStack itemStack, String keyName) { - if (hasKey(itemStack, keyName)) { if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagString) { return itemStack.stackTagCompound.getString(keyName); @@ -85,7 +82,6 @@ public class NBTHelper { } public static void setString(ItemStack itemStack, String keyName, String keyValue) { - if (itemStack != null && keyName != null && !keyName.isEmpty()) { initNBTTagCompound(itemStack); itemStack.stackTagCompound.setString(keyName, keyValue); @@ -94,7 +90,6 @@ public class NBTHelper { // boolean public static Boolean getBoolean(ItemStack itemStack, String keyName) { - if (hasKey(itemStack, keyName)) { if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagByte) { itemStack.stackTagCompound.getBoolean(keyName); @@ -105,7 +100,6 @@ public class NBTHelper { } public static void setBoolean(ItemStack itemStack, String keyName, boolean keyValue) { - if (itemStack != null && keyName != null && !keyName.isEmpty()) { initNBTTagCompound(itemStack); itemStack.stackTagCompound.setBoolean(keyName, keyValue); @@ -114,7 +108,6 @@ public class NBTHelper { // byte public static Byte getByte(ItemStack itemStack, String keyName) { - if (hasKey(itemStack, keyName)) { if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagByte) { return itemStack.stackTagCompound.getByte(keyName); @@ -125,7 +118,6 @@ public class NBTHelper { } public static void setByte(ItemStack itemStack, String keyName, byte keyValue) { - if (itemStack != null && keyName != null && !keyName.isEmpty()) { initNBTTagCompound(itemStack); itemStack.stackTagCompound.setByte(keyName, keyValue); @@ -134,7 +126,6 @@ public class NBTHelper { // short public static Short getShort(ItemStack itemStack, String keyName) { - if (hasKey(itemStack, keyName)) { if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagShort) { return itemStack.stackTagCompound.getShort(keyName); @@ -145,7 +136,6 @@ public class NBTHelper { } public static void setShort(ItemStack itemStack, String keyName, short keyValue) { - if (itemStack != null && keyName != null && !keyName.isEmpty()) { initNBTTagCompound(itemStack); itemStack.stackTagCompound.setShort(keyName, keyValue); @@ -154,7 +144,6 @@ public class NBTHelper { // int public static Integer getInteger(ItemStack itemStack, String keyName) { - if (hasKey(itemStack, keyName)) { if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagInt) { return itemStack.stackTagCompound.getInteger(keyName); @@ -165,7 +154,6 @@ public class NBTHelper { } public static void setInteger(ItemStack itemStack, String keyName, int keyValue) { - if (itemStack != null && keyName != null && !keyName.isEmpty()) { initNBTTagCompound(itemStack); itemStack.stackTagCompound.setInteger(keyName, keyValue); @@ -174,7 +162,6 @@ public class NBTHelper { // long public static Long getLong(ItemStack itemStack, String keyName) { - if (hasKey(itemStack, keyName)) { if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagLong) { return itemStack.stackTagCompound.getLong(keyName); @@ -185,9 +172,7 @@ public class NBTHelper { } public static void setLong(ItemStack itemStack, String keyName, long keyValue) { - if (itemStack != null && keyName != null && !keyName.isEmpty()) { - initNBTTagCompound(itemStack); itemStack.stackTagCompound.setLong(keyName, keyValue); } @@ -195,7 +180,6 @@ public class NBTHelper { // float public static Float getFloat(ItemStack itemStack, String keyName) { - if (hasKey(itemStack, keyName)) { if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagFloat) { return itemStack.stackTagCompound.getFloat(keyName); @@ -206,7 +190,6 @@ public class NBTHelper { } public static void setFloat(ItemStack itemStack, String keyName, float keyValue) { - if (itemStack != null && keyName != null && !keyName.isEmpty()) { initNBTTagCompound(itemStack); itemStack.stackTagCompound.setFloat(keyName, keyValue); @@ -215,7 +198,6 @@ public class NBTHelper { // double public static Double getDouble(ItemStack itemStack, String keyName) { - if (hasKey(itemStack, keyName)) { if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagDouble) { return itemStack.stackTagCompound.getDouble(keyName); @@ -226,7 +208,6 @@ public class NBTHelper { } public static void setDouble(ItemStack itemStack, String keyName, double keyValue) { - if (itemStack != null && keyName != null && !keyName.isEmpty()) { initNBTTagCompound(itemStack); itemStack.stackTagCompound.setDouble(keyName, keyValue); @@ -234,8 +215,8 @@ public class NBTHelper { } // tag list - public static NBTTagList getTagList(ItemStack itemStack, String keyName, int nbtBaseType) { - + public static NBTTagList + getTagList(ItemStack itemStack, String keyName, int nbtBaseType) { if (hasKey(itemStack, keyName)) { if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagList) { return itemStack.stackTagCompound.getTagList(keyName, nbtBaseType); @@ -245,8 +226,8 @@ public class NBTHelper { return null; } - public static void setTagList(ItemStack itemStack, String keyName, NBTTagList nbtTagList) { - + public static void + setTagList(ItemStack itemStack, String keyName, NBTTagList nbtTagList) { if (itemStack != null && keyName != null && !keyName.isEmpty()) { initNBTTagCompound(itemStack); itemStack.stackTagCompound.setTag(keyName, nbtTagList); @@ -255,7 +236,6 @@ public class NBTHelper { // tag compound public static NBTTagCompound getTagCompound(ItemStack itemStack, String keyName) { - if (hasKey(itemStack, keyName)) { if (itemStack.getTagCompound().getTag(keyName) instanceof NBTTagCompound) { return itemStack.stackTagCompound.getCompoundTag(keyName); @@ -265,8 +245,8 @@ public class NBTHelper { return null; } - public static void setTagCompound(ItemStack itemStack, String keyName, NBTTagCompound nbtTagCompound) { - + public static void + setTagCompound(ItemStack itemStack, String keyName, NBTTagCompound nbtTagCompound) { if (itemStack != null && keyName != null && !keyName.isEmpty()) { initNBTTagCompound(itemStack); itemStack.stackTagCompound.setTag(keyName, nbtTagCompound); diff --git a/src/main/java/com/pahimar/ee3/util/OreDictionaryHelper.java b/src/main/java/com/pahimar/ee3/util/OreDictionaryHelper.java index 2c17e579..f11b48b3 100644 --- a/src/main/java/com/pahimar/ee3/util/OreDictionaryHelper.java +++ b/src/main/java/com/pahimar/ee3/util/OreDictionaryHelper.java @@ -1,16 +1,14 @@ package com.pahimar.ee3.util; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; - import java.util.Collection; import java.util.Set; import java.util.TreeSet; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + public class OreDictionaryHelper { - public static Collection getOreNames(ItemStack itemStack) { - Set oreNames = new TreeSet<>(); for (int oreId : OreDictionary.getOreIDs(itemStack)) { diff --git a/src/main/java/com/pahimar/ee3/util/PlayerHelper.java b/src/main/java/com/pahimar/ee3/util/PlayerHelper.java index 74eea50f..c11e4070 100644 --- a/src/main/java/com/pahimar/ee3/util/PlayerHelper.java +++ b/src/main/java/com/pahimar/ee3/util/PlayerHelper.java @@ -5,46 +5,39 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraftforge.common.util.FakePlayer; -public class PlayerHelper -{ - public static boolean isPlayerOp(EntityPlayer entityPlayer) - { - if (FMLCommonHandler.instance().getMinecraftServerInstance() != null) - { - return FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().func_152596_g((entityPlayer).getGameProfile()); +public class PlayerHelper { + public static boolean isPlayerOp(EntityPlayer entityPlayer) { + if (FMLCommonHandler.instance().getMinecraftServerInstance() != null) { + return FMLCommonHandler.instance() + .getMinecraftServerInstance() + .getConfigurationManager() + .func_152596_g((entityPlayer).getGameProfile()); } return false; } - public static boolean isFakePlayer(EntityPlayer entityPlayer) - { - if (entityPlayer instanceof FakePlayer) - { + public static boolean isFakePlayer(EntityPlayer entityPlayer) { + if (entityPlayer instanceof FakePlayer) { return true; - } - else if (entityPlayer.getGameProfile() == null || entityPlayer.getGameProfile().getId() == null) - { + } else if (entityPlayer.getGameProfile() == null || entityPlayer.getGameProfile().getId() == null) { return true; - } - else if (entityPlayer instanceof EntityPlayerMP) - { + } else if (entityPlayer instanceof EntityPlayerMP) { EntityPlayerMP entityPlayerMP = (EntityPlayerMP) entityPlayer; - if (entityPlayerMP.playerNetServerHandler == null) - { + if (entityPlayerMP.playerNetServerHandler == null) { return true; } - try - { + try { entityPlayerMP.getPlayerIP(); - } - catch (Exception e) - { + } catch (Exception e) { return true; } - return !FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList.contains(entityPlayer); + return !FMLCommonHandler.instance() + .getMinecraftServerInstance() + .getConfigurationManager() + .playerEntityList.contains(entityPlayer); } return false; diff --git a/src/main/java/com/pahimar/ee3/util/RecipeHelper.java b/src/main/java/com/pahimar/ee3/util/RecipeHelper.java index bfe5edbc..db8c6d59 100644 --- a/src/main/java/com/pahimar/ee3/util/RecipeHelper.java +++ b/src/main/java/com/pahimar/ee3/util/RecipeHelper.java @@ -1,8 +1,12 @@ package com.pahimar.ee3.util; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + import com.pahimar.ee3.exchange.OreStack; import com.pahimar.ee3.exchange.WrappedStack; - import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -14,11 +18,6 @@ import net.minecraft.item.crafting.ShapelessRecipes; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - /** * Equivalent-Exchange-3 *

    @@ -26,83 +25,66 @@ import java.util.List; * * @author pahimar */ -public class RecipeHelper -{ - +public class RecipeHelper { /** * Returns a list of elements that constitute the input in a crafting recipe * * @param recipe The IRecipe being examined - * @return List of elements that constitute the input of the given IRecipe. Could be an ItemStack or an Arraylist + * @return List of elements that constitute the input of the given IRecipe. Could be + * an ItemStack or an Arraylist */ - public static List getRecipeInputs(IRecipe recipe) - { + public static List getRecipeInputs(IRecipe recipe) { ArrayList recipeInputs = new ArrayList(); - if (recipe instanceof ShapedRecipes) - { + if (recipe instanceof ShapedRecipes) { ShapedRecipes shapedRecipe = (ShapedRecipes) recipe; - for (int i = 0; i < shapedRecipe.recipeItems.length; i++) - { - if (shapedRecipe.recipeItems[i] instanceof ItemStack) - { + for (int i = 0; i < shapedRecipe.recipeItems.length; i++) { + if (shapedRecipe.recipeItems[i] instanceof ItemStack) { ItemStack itemStack = shapedRecipe.recipeItems[i].copy(); - if (itemStack.stackSize > 1) - { + if (itemStack.stackSize > 1) { itemStack.stackSize = 1; } recipeInputs.add(WrappedStack.wrap(itemStack)); } } - } - else if (recipe instanceof ShapelessRecipes) - { + } else if (recipe instanceof ShapelessRecipes) { ShapelessRecipes shapelessRecipe = (ShapelessRecipes) recipe; - for (Object object : shapelessRecipe.recipeItems) - { - if (object instanceof ItemStack) - { + for (Object object : shapelessRecipe.recipeItems) { + if (object instanceof ItemStack) { ItemStack itemStack = ((ItemStack) object).copy(); - if (itemStack.stackSize > 1) - { + if (itemStack.stackSize > 1) { itemStack.stackSize = 1; } recipeInputs.add(WrappedStack.wrap(itemStack)); } } - } - else if (recipe instanceof ShapedOreRecipe) - { + } else if (recipe instanceof ShapedOreRecipe) { ShapedOreRecipe shapedOreRecipe = (ShapedOreRecipe) recipe; - if (validateOreDictionaryRecipe(Arrays.asList(shapedOreRecipe.getInput()))) - { - for (int i = 0; i < shapedOreRecipe.getInput().length; i++) - { - /* - * If the element is a list, then it is an OreStack - */ - if (shapedOreRecipe.getInput()[i] instanceof ArrayList) - { - WrappedStack oreStack = WrappedStack.wrap(shapedOreRecipe.getInput()[i]); + if (validateOreDictionaryRecipe(Arrays.asList(shapedOreRecipe.getInput()))) { + for (int i = 0; i < shapedOreRecipe.getInput().length; i++) { + /* + * If the element is a list, then it is an OreStack + */ + if (shapedOreRecipe.getInput()[i] instanceof ArrayList) { + WrappedStack oreStack + = WrappedStack.wrap(shapedOreRecipe.getInput()[i]); - if (oreStack != null && oreStack.getWrappedObject() instanceof OreStack) - { + if (oreStack != null + && oreStack.getWrappedObject() instanceof OreStack) { recipeInputs.add(oreStack); } - } - else if (shapedOreRecipe.getInput()[i] instanceof ItemStack) - { - ItemStack itemStack = ((ItemStack) shapedOreRecipe.getInput()[i]).copy(); + } else if (shapedOreRecipe.getInput()[i] instanceof ItemStack) { + ItemStack itemStack + = ((ItemStack) shapedOreRecipe.getInput()[i]).copy(); - if (itemStack.stackSize > 1) - { + if (itemStack.stackSize > 1) { itemStack.stackSize = 1; } @@ -110,27 +92,17 @@ public class RecipeHelper } } } - } - else if (recipe instanceof ShapelessOreRecipe) - { + } else if (recipe instanceof ShapelessOreRecipe) { ShapelessOreRecipe shapelessOreRecipe = (ShapelessOreRecipe) recipe; - if (validateOreDictionaryRecipe(shapelessOreRecipe.getInput())) - { - for (Object object : shapelessOreRecipe.getInput()) - { - - if (object instanceof ArrayList) - { + if (validateOreDictionaryRecipe(shapelessOreRecipe.getInput())) { + for (Object object : shapelessOreRecipe.getInput()) { + if (object instanceof ArrayList) { recipeInputs.add(WrappedStack.wrap(object)); - } - else if (object instanceof ItemStack) - { - + } else if (object instanceof ItemStack) { ItemStack itemStack = ((ItemStack) object).copy(); - if (itemStack.stackSize > 1) - { + if (itemStack.stackSize > 1) { itemStack.stackSize = 1; } @@ -144,58 +116,60 @@ public class RecipeHelper } /** - * Collates an uncollated, unsorted List of Objects into a sorted, collated List of WrappedStacks + * Collates an uncollated, unsorted List of Objects into a sorted, collated List of + * WrappedStacks * * @param uncollatedStacks List of objects for collating * @return A sorted, collated List of WrappedStacks */ - public static List collateInputStacks(List uncollatedStacks) - { + public static List collateInputStacks(List uncollatedStacks) { List collatedStacks = new ArrayList(); WrappedStack stack; boolean found; - for (Object object : uncollatedStacks) - { + for (Object object : uncollatedStacks) { found = false; - if (WrappedStack.canBeWrapped(object)) - { + if (WrappedStack.canBeWrapped(object)) { stack = WrappedStack.wrap(object); - if (collatedStacks.isEmpty()) - { + if (collatedStacks.isEmpty()) { collatedStacks.add(stack); - } - else - { - - for (WrappedStack collatedStack : collatedStacks) - { - if (collatedStack.getWrappedObject() != null) - { - if (stack.getWrappedObject() instanceof ItemStack && collatedStack.getWrappedObject() instanceof ItemStack) - { - if (ItemStackUtils.equals((ItemStack) stack.getWrappedObject(), (ItemStack) collatedStack.getWrappedObject())) - { - collatedStack.setStackSize(collatedStack.getStackSize() + stack.getStackSize()); + } else { + for (WrappedStack collatedStack : collatedStacks) { + if (collatedStack.getWrappedObject() != null) { + if (stack.getWrappedObject() instanceof ItemStack + && collatedStack.getWrappedObject() + instanceof ItemStack) { + if (ItemStackUtils.equals( + (ItemStack) stack.getWrappedObject(), + (ItemStack) collatedStack.getWrappedObject() + )) { + collatedStack.setStackSize( + collatedStack.getStackSize() + + stack.getStackSize() + ); found = true; } } else if (stack.getWrappedObject() instanceof OreStack && collatedStack.getWrappedObject() instanceof OreStack) { - if (OreStack.compareOreNames((OreStack) stack.getWrappedObject(), (OreStack) collatedStack.getWrappedObject())) - { - collatedStack.setStackSize(collatedStack.getStackSize() + stack.getStackSize()); + if (OreStack.compareOreNames( + (OreStack) stack.getWrappedObject(), + (OreStack) collatedStack.getWrappedObject() + )) { + collatedStack.setStackSize( + collatedStack.getStackSize() + + stack.getStackSize() + ); found = true; } } } } - if (!found) - { + if (!found) { collatedStacks.add(stack); } } @@ -206,22 +180,19 @@ public class RecipeHelper } /** - * Validates the list of recipe inputs for an OreDictionary recipe to ensure that if there is an - * OreDictionary entry found in the recipe (a list) that it is not empty (that there are ItemStacks - * associated with that particular OreDictionary entry) + * Validates the list of recipe inputs for an OreDictionary recipe to ensure that if + * there is an OreDictionary entry found in the recipe (a list) that it is not empty + * (that there are ItemStacks associated with that particular OreDictionary entry) * * @param objects a list of recipe inputs for an OreDictionary recipe - * @return true if there exists no "invalid" (empty) OreDictionary entries in the provided list of recipe inputs + * @return true if there exists no "invalid" (empty) OreDictionary entries in the + * provided list of recipe inputs */ // FIXME This is not working as intended - private static boolean validateOreDictionaryRecipe(List objects) - { - for (Object object : objects) - { - if (object != null) - { - if (!WrappedStack.canBeWrapped(object)) - { + private static boolean validateOreDictionaryRecipe(List objects) { + for (Object object : objects) { + if (object != null) { + if (!WrappedStack.canBeWrapped(object)) { return false; } } @@ -233,30 +204,34 @@ public class RecipeHelper public static void addRecipe(final ItemStack output, final Object... input) { GameRegistry.addShapelessRecipe(output, input); } - - public static void addRecipe(final ItemStack output, final ItemStack transmutationStone, final Object... input) { + + public static void addRecipe( + final ItemStack output, final ItemStack transmutationStone, final Object... input + ) { final Object[] inputs = new Object[input.length + 1]; System.arraycopy(input, 0, inputs, 0, input.length); inputs[input.length] = transmutationStone; addRecipe(output, inputs); } - + public static void addRecipe(final Block output, final Object... input) { addRecipe(new ItemStack(output), input); } - - public static void addRecipe(final Block output, final int count, final Object... input) { + + public static void + addRecipe(final Block output, final int count, final Object... input) { addRecipe(new ItemStack(output, count), input); } - + public static void addRecipe(final Item output, final Object... input) { addRecipe(new ItemStack(output), input); } - - public static void addRecipe(final Item output, final int count, final Object... input) { + + public static void + addRecipe(final Item output, final int count, final Object... input) { addRecipe(new ItemStack(output, count), input); } - + public static Object[] getMetaCycle(final Object input, final int n) { final ArrayList list = new ArrayList<>(); for (int i = 0; i < n; ++i) { @@ -266,8 +241,10 @@ public class RecipeHelper } return list.toArray(); } - - public static Object[] getMetaCycle(final Object input, final int n, final int... excludedMeta) { + + public static Object[] getMetaCycle( + final Object input, final int n, final int... excludedMeta + ) { final ArrayList list = new ArrayList<>(); for (int i = 0; i < n; ++i) { for (final int j : excludedMeta) { @@ -285,7 +262,9 @@ public class RecipeHelper return list.toArray(); } - public static void addSmeltingRecipe(final ItemStack input, final ItemStack stone, final ItemStack fuel) { + public static void addSmeltingRecipe( + final ItemStack input, final ItemStack stone, final ItemStack fuel + ) { final ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(input); if (input == null || input.getItem() == null || result == null) { return; @@ -297,10 +276,21 @@ public class RecipeHelper list[i] = new ItemStack(input.getItem(), 1, input.getItemDamage()); } if (result.stackSize * 7 <= result.getItem().getItemStackLimit()) { - GameRegistry.addShapelessRecipe(new ItemStack(result.getItem(), result.stackSize * 7, result.getItemDamage()), list); - } - else { - GameRegistry.addShapelessRecipe(new ItemStack(result.getItem(), result.getItem().getItemStackLimit(), result.getItemDamage()), list); + GameRegistry.addShapelessRecipe( + new ItemStack( + result.getItem(), result.stackSize * 7, result.getItemDamage() + ), + list + ); + } else { + GameRegistry.addShapelessRecipe( + new ItemStack( + result.getItem(), + result.getItem().getItemStackLimit(), + result.getItemDamage() + ), + list + ); } } } diff --git a/src/main/java/com/pahimar/ee3/util/ResourceLocationHelper.java b/src/main/java/com/pahimar/ee3/util/ResourceLocationHelper.java index d3d9c368..7ef8765c 100644 --- a/src/main/java/com/pahimar/ee3/util/ResourceLocationHelper.java +++ b/src/main/java/com/pahimar/ee3/util/ResourceLocationHelper.java @@ -3,15 +3,12 @@ package com.pahimar.ee3.util; import com.pahimar.ee3.reference.Reference; import net.minecraft.util.ResourceLocation; -public class ResourceLocationHelper -{ - public static ResourceLocation getResourceLocation(String modId, String path) - { +public class ResourceLocationHelper { + public static ResourceLocation getResourceLocation(String modId, String path) { return new ResourceLocation(modId, path); } - public static ResourceLocation getResourceLocation(String path) - { + public static ResourceLocation getResourceLocation(String path) { return getResourceLocation(Reference.LOWERCASE_MOD_ID, path); } } diff --git a/src/main/java/com/pahimar/ee3/util/SerializationHelper.java b/src/main/java/com/pahimar/ee3/util/SerializationHelper.java index 7d4a0a17..77894b9c 100644 --- a/src/main/java/com/pahimar/ee3/util/SerializationHelper.java +++ b/src/main/java/com/pahimar/ee3/util/SerializationHelper.java @@ -1,5 +1,12 @@ package com.pahimar.ee3.util; +import java.io.*; +import java.lang.reflect.Type; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; + import com.google.common.reflect.TypeToken; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -14,27 +21,22 @@ import cpw.mods.fml.common.FMLCommonHandler; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import java.io.*; -import java.lang.reflect.Type; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; -import java.util.TreeSet; - public class SerializationHelper { - - public static final Type ENERGY_VALUE_MAP_TYPE = new TypeToken>(){}.getType(); - public static final Type WRAPPED_STACK_SET_TYPE = new TypeToken>(){}.getType(); - public static final Gson GSON = new GsonBuilder() - .setPrettyPrinting() - .enableComplexMapKeySerialization() - .registerTypeAdapter(ItemStack.class, new ItemStackSerializer()) - .registerTypeAdapter(OreStack.class, new OreStackSerializer()) - .registerTypeAdapter(FluidStack.class, new FluidStackSerializer()) - .registerTypeAdapter(WrappedStack.class, new WrappedStackSerializer()) - .registerTypeAdapter(PlayerKnowledge.class, new PlayerKnowledgeSerializer()) - .registerTypeAdapter(ENERGY_VALUE_MAP_TYPE, new EnergyValueMapSerializer()) - .create(); + public static final Type ENERGY_VALUE_MAP_TYPE + = new TypeToken>() {}.getType(); + public static final Type WRAPPED_STACK_SET_TYPE + = new TypeToken>() {}.getType(); + public static final Gson GSON + = new GsonBuilder() + .setPrettyPrinting() + .enableComplexMapKeySerialization() + .registerTypeAdapter(ItemStack.class, new ItemStackSerializer()) + .registerTypeAdapter(OreStack.class, new OreStackSerializer()) + .registerTypeAdapter(FluidStack.class, new FluidStackSerializer()) + .registerTypeAdapter(WrappedStack.class, new WrappedStackSerializer()) + .registerTypeAdapter(PlayerKnowledge.class, new PlayerKnowledgeSerializer()) + .registerTypeAdapter(ENERGY_VALUE_MAP_TYPE, new EnergyValueMapSerializer()) + .create(); private static File instanceDataDirectory; private static File instancePlayerDataDirectory; @@ -45,36 +47,48 @@ public class SerializationHelper { * @return */ @Deprecated - public static File getInstanceDataDirectory() - { + public static File getInstanceDataDirectory() { return instanceDataDirectory; } /** * TODO Move this to {@link com.pahimar.ee3.reference.Files} * - * Creates (if one does not exist already) and initializes a mod specific File reference inside of the current world's playerdata directory + * Creates (if one does not exist already) and initializes a mod specific File + * reference inside of the current world's playerdata directory */ public static void initModDataDirectories() { - - instanceDataDirectory = new File(FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler().getWorldDirectory(), "data" + File.separator + Reference.LOWERCASE_MOD_ID); + instanceDataDirectory = new File( + FMLCommonHandler.instance() + .getMinecraftServerInstance() + .getEntityWorld() + .getSaveHandler() + .getWorldDirectory(), + "data" + File.separator + Reference.LOWERCASE_MOD_ID + ); instanceDataDirectory.mkdirs(); - instancePlayerDataDirectory = new File(FMLCommonHandler.instance().getMinecraftServerInstance().getEntityWorld().getSaveHandler().getWorldDirectory(), "playerdata" + File.separator + Reference.LOWERCASE_MOD_ID); + instancePlayerDataDirectory = new File( + FMLCommonHandler.instance() + .getMinecraftServerInstance() + .getEntityWorld() + .getSaveHandler() + .getWorldDirectory(), + "playerdata" + File.separator + Reference.LOWERCASE_MOD_ID + ); instancePlayerDataDirectory.mkdirs(); } public static Set readSetFromFile(File file) { - Set wrappedStackSet = new TreeSet<>(); try { wrappedStackSet = GSON.fromJson(readJsonFile(file), WRAPPED_STACK_SET_TYPE); - } - catch (JsonParseException exception) { - LogHelper.error("Unable to parse contents from file '{}'", file.getAbsoluteFile()); - } - catch (FileNotFoundException e) { + } catch (JsonParseException exception) { + LogHelper.error( + "Unable to parse contents from file '{}'", file.getAbsoluteFile() + ); + } catch (FileNotFoundException e) { LogHelper.warn("Unable to find file '{}'", file.getAbsoluteFile()); } @@ -85,41 +99,39 @@ public class SerializationHelper { writeJsonFile(file, GSON.toJson(wrappedStackSet)); } - public static Map readMapFromFile(File file) throws FileNotFoundException { - + public static Map readMapFromFile(File file) + throws FileNotFoundException { Map valueMap = new TreeMap<>(); try { valueMap = GSON.fromJson(readJsonFile(file), ENERGY_VALUE_MAP_TYPE); - } - catch (JsonParseException exception) { + } catch (JsonParseException exception) { // TODO Better logging of the exception (failed parsing so no values loaded) } return valueMap; } - public static void writeMapToFile(Map valueMap, File file) { + public static void + writeMapToFile(Map valueMap, File file) { writeJsonFile(file, GSON.toJson(valueMap, ENERGY_VALUE_MAP_TYPE)); } public static String readJsonFile(File file) throws FileNotFoundException { - StringBuilder jsonStringBuilder = new StringBuilder(); if (file != null) { - try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) { - + try ( + BufferedReader bufferedReader = new BufferedReader(new FileReader(file)) + ) { jsonStringBuilder = new StringBuilder(); String line; while ((line = bufferedReader.readLine()) != null) { jsonStringBuilder.append(line); } - } - catch (IOException exception) { + } catch (IOException exception) { if (exception instanceof FileNotFoundException) { - throw (FileNotFoundException) exception; - } - else { + throw(FileNotFoundException) exception; + } else { exception.printStackTrace(); // TODO Better logging of the exception } } @@ -128,9 +140,7 @@ public class SerializationHelper { } public static void writeJsonFile(File file, String fileContents) { - if (file != null) { - file.getParentFile().mkdirs(); File tempFile = new File(file.getAbsolutePath() + "_tmp"); @@ -138,8 +148,10 @@ public class SerializationHelper { tempFile.delete(); } - try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(tempFile))) { - + try ( + BufferedWriter bufferedWriter + = new BufferedWriter(new FileWriter(tempFile)) + ) { bufferedWriter.write(fileContents); bufferedWriter.close(); } catch (IOException exception) { diff --git a/src/main/java/com/pahimar/ee3/util/TileEntityDataHelper.java b/src/main/java/com/pahimar/ee3/util/TileEntityDataHelper.java index 1e4d74b8..ae1fc82f 100644 --- a/src/main/java/com/pahimar/ee3/util/TileEntityDataHelper.java +++ b/src/main/java/com/pahimar/ee3/util/TileEntityDataHelper.java @@ -1,85 +1,78 @@ package com.pahimar.ee3.util; +import java.util.UUID; + import com.pahimar.ee3.tileentity.TileEntityEE; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.UUID; - -public class TileEntityDataHelper -{ +public class TileEntityDataHelper { private static TileEntityDataHelper tileEntityDataHelper = null; - private TileEntityDataHelper() - { + private TileEntityDataHelper() {} - } - - public static TileEntityDataHelper getInstance() - { - if (tileEntityDataHelper == null) - { + public static TileEntityDataHelper getInstance() { + if (tileEntityDataHelper == null) { tileEntityDataHelper = new TileEntityDataHelper(); } return tileEntityDataHelper; } - public Class getTileEntityClass(World world, int xCoord, int yCoord, int zCoord) - { - if (!world.isRemote) - { + public Class getTileEntityClass(World world, int xCoord, int yCoord, int zCoord) { + if (!world.isRemote) { return world.getTileEntity(xCoord, yCoord, zCoord).getClass(); } return null; } - public ForgeDirection getOrientation(World world, int xCoord, int yCoord, int zCoord) - { - if (!world.isRemote && world.getTileEntity(xCoord, yCoord, zCoord) instanceof TileEntityEE) - { - return ((TileEntityEE) world.getTileEntity(xCoord, yCoord, zCoord)).getOrientation(); + public ForgeDirection + getOrientation(World world, int xCoord, int yCoord, int zCoord) { + if (!world.isRemote + && world.getTileEntity(xCoord, yCoord, zCoord) instanceof TileEntityEE) { + return ((TileEntityEE) world.getTileEntity(xCoord, yCoord, zCoord)) + .getOrientation(); } return null; } - public short getState(World world, int xCoord, int yCoord, int zCoord) - { - if (!world.isRemote && world.getTileEntity(xCoord, yCoord, zCoord) instanceof TileEntityEE) - { - return ((TileEntityEE) world.getTileEntity(xCoord, yCoord, zCoord)).getState(); + public short getState(World world, int xCoord, int yCoord, int zCoord) { + if (!world.isRemote + && world.getTileEntity(xCoord, yCoord, zCoord) instanceof TileEntityEE) { + return ((TileEntityEE) world.getTileEntity(xCoord, yCoord, zCoord)) + .getState(); } return Short.MIN_VALUE; } - public String getCustomName(World world, int xCoord, int yCoord, int zCoord) - { - if (!world.isRemote && world.getTileEntity(xCoord, yCoord, zCoord) instanceof TileEntityEE) - { - return ((TileEntityEE) world.getTileEntity(xCoord, yCoord, zCoord)).getCustomName(); + public String getCustomName(World world, int xCoord, int yCoord, int zCoord) { + if (!world.isRemote + && world.getTileEntity(xCoord, yCoord, zCoord) instanceof TileEntityEE) { + return ((TileEntityEE) world.getTileEntity(xCoord, yCoord, zCoord)) + .getCustomName(); } return null; } - public UUID getOwnerUUID(World world, int xCoord, int yCoord, int zCoord) - { - if (!world.isRemote && world.getTileEntity(xCoord, yCoord, zCoord) instanceof TileEntityEE) - { - return ((TileEntityEE) world.getTileEntity(xCoord, yCoord, zCoord)).getOwnerUUID(); + public UUID getOwnerUUID(World world, int xCoord, int yCoord, int zCoord) { + if (!world.isRemote + && world.getTileEntity(xCoord, yCoord, zCoord) instanceof TileEntityEE) { + return ((TileEntityEE) world.getTileEntity(xCoord, yCoord, zCoord)) + .getOwnerUUID(); } return null; } - public String getOwnerName(World world, int xCoord, int yCoord, int zCoord) - { - if (!world.isRemote && world.getTileEntity(xCoord, yCoord, zCoord) instanceof TileEntityEE) - { - return ((TileEntityEE) world.getTileEntity(xCoord, yCoord, zCoord)).getOwnerName(); + public String getOwnerName(World world, int xCoord, int yCoord, int zCoord) { + if (!world.isRemote + && world.getTileEntity(xCoord, yCoord, zCoord) instanceof TileEntityEE) { + return ((TileEntityEE) world.getTileEntity(xCoord, yCoord, zCoord)) + .getOwnerName(); } return null; diff --git a/src/main/java/com/pahimar/ee3/util/TransmutationHelper.java b/src/main/java/com/pahimar/ee3/util/TransmutationHelper.java index a4fe07c4..3e3ce7df 100644 --- a/src/main/java/com/pahimar/ee3/util/TransmutationHelper.java +++ b/src/main/java/com/pahimar/ee3/util/TransmutationHelper.java @@ -3,7 +3,6 @@ package com.pahimar.ee3.util; import java.util.ArrayList; import com.pahimar.ee3.handler.EquivalencyHandler; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -12,42 +11,63 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class TransmutationHelper { - public static ItemStack previousBlockStack; public static ItemStack currentBlockStack; public static ItemStack targetBlockStack; - public static boolean transmuteInWorld(final World world, final EntityPlayer player, final ItemStack stack, final int x, final int y, final int z, final Block target, final int targetMeta) { + public static boolean transmuteInWorld( + final World world, + final EntityPlayer player, + final ItemStack stack, + final int x, + final int y, + final int z, + final Block target, + final int targetMeta + ) { world.setBlock(x, y, z, target, targetMeta, 2); return true; } public static String formatTargetBlockInfo(final ItemStack targetBlock) { if (targetBlock != null) { - return TransmutationHelper.targetBlockStack.getUnlocalizedName() + ":" + TransmutationHelper.targetBlockStack.getItemDamage(); + return TransmutationHelper.targetBlockStack.getUnlocalizedName() + ":" + + TransmutationHelper.targetBlockStack.getItemDamage(); } return ""; } - public static void updateTargetBlock(final World world, final int x, final int y, final int z) { + public static void + updateTargetBlock(final World world, final int x, final int y, final int z) { final Block currentBlock = world.getBlock(x, y, z); int meta = world.getBlockMetadata(x, y, z); if (currentBlock != null) { meta = currentBlock.damageDropped(meta); TransmutationHelper.currentBlockStack = new ItemStack(currentBlock, 1, meta); if (TransmutationHelper.previousBlockStack == null) { - TransmutationHelper.previousBlockStack = TransmutationHelper.currentBlockStack; - TransmutationHelper.targetBlockStack = getNextBlock(TransmutationHelper.currentBlockStack.getItem(), TransmutationHelper.currentBlockStack.getItemDamage()); - } - else if (!EquivalencyHandler.instance().areEquivalent(TransmutationHelper.previousBlockStack, TransmutationHelper.currentBlockStack)) { - TransmutationHelper.previousBlockStack = TransmutationHelper.currentBlockStack; - TransmutationHelper.targetBlockStack = getNextBlock(TransmutationHelper.currentBlockStack.getItem(), TransmutationHelper.currentBlockStack.getItemDamage()); + TransmutationHelper.previousBlockStack + = TransmutationHelper.currentBlockStack; + TransmutationHelper.targetBlockStack = getNextBlock( + TransmutationHelper.currentBlockStack.getItem(), + TransmutationHelper.currentBlockStack.getItemDamage() + ); + } else if (!EquivalencyHandler.instance().areEquivalent( + TransmutationHelper.previousBlockStack, + TransmutationHelper.currentBlockStack + )) { + TransmutationHelper.previousBlockStack + = TransmutationHelper.currentBlockStack; + TransmutationHelper.targetBlockStack = getNextBlock( + TransmutationHelper.currentBlockStack.getItem(), + TransmutationHelper.currentBlockStack.getItemDamage() + ); } } } public static ItemStack getNextBlock(final Item id, final int meta) { - final ArrayList list = EquivalencyHandler.instance().getEquivalencyList(id, meta); + final ArrayList list + = EquivalencyHandler.instance().getEquivalencyList(id, meta); final ItemStack nextStack = null; if (list != null) { return getNextBlock(id, meta, id, meta); @@ -55,8 +75,10 @@ public class TransmutationHelper { return nextStack; } - private static ItemStack getNextBlock(final Item id, final int meta, final Item origId, final int origMeta) { - final ArrayList list = EquivalencyHandler.instance().getEquivalencyList(id, meta); + private static ItemStack + getNextBlock(final Item id, final int meta, final Item origId, final int origMeta) { + final ArrayList list + = EquivalencyHandler.instance().getEquivalencyList(id, meta); ItemStack nextStack = null; if (list == null) { return nextStack; @@ -69,20 +91,26 @@ public class TransmutationHelper { if (nextStack.getItem() instanceof ItemBlock) { return nextStack; } - return getNextBlock(nextStack.getItem(), nextStack.getItemDamage(), origId, origMeta); + return getNextBlock( + nextStack.getItem(), nextStack.getItemDamage(), origId, origMeta + ); } public static ItemStack getPreviousBlock(final Item itemID, final int meta) { - final ArrayList list = EquivalencyHandler.instance().getEquivalencyList(itemID, meta); + final ArrayList list + = EquivalencyHandler.instance().getEquivalencyList(itemID, meta); final ItemStack prevStack = null; if (list != null) { return getPreviousBlock(itemID, meta, itemID, meta); } return prevStack; } - - private static ItemStack getPreviousBlock(final Item id, final int meta, final Item origId, final int origMeta) { - final ArrayList list = EquivalencyHandler.instance().getEquivalencyList(id, meta); + + private static ItemStack getPreviousBlock( + final Item id, final int meta, final Item origId, final int origMeta + ) { + final ArrayList list + = EquivalencyHandler.instance().getEquivalencyList(id, meta); ItemStack prevStack = null; if (list == null) { return prevStack; @@ -95,7 +123,8 @@ public class TransmutationHelper { if (prevStack.getItem() instanceof ItemBlock) { return prevStack; } - return getPreviousBlock(prevStack.getItem(), prevStack.getItemDamage(), origId, origMeta); + return getPreviousBlock( + prevStack.getItem(), prevStack.getItemDamage(), origId, origMeta + ); } - } diff --git a/src/main/java/com/pahimar/ee3/util/serialize/EnergyValueMapSerializer.java b/src/main/java/com/pahimar/ee3/util/serialize/EnergyValueMapSerializer.java index 02150931..04ca8057 100644 --- a/src/main/java/com/pahimar/ee3/util/serialize/EnergyValueMapSerializer.java +++ b/src/main/java/com/pahimar/ee3/util/serialize/EnergyValueMapSerializer.java @@ -1,5 +1,10 @@ package com.pahimar.ee3.util.serialize; +import java.lang.reflect.Type; +import java.util.Iterator; +import java.util.Map; +import java.util.TreeMap; + import com.google.gson.*; import com.pahimar.ee3.api.exchange.EnergyValue; import com.pahimar.ee3.exchange.OreStack; @@ -7,77 +12,71 @@ import com.pahimar.ee3.exchange.WrappedStack; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import java.lang.reflect.Type; -import java.util.Iterator; -import java.util.Map; -import java.util.TreeMap; - -public class EnergyValueMapSerializer implements JsonSerializer>, JsonDeserializer> { - +public class EnergyValueMapSerializer + implements JsonSerializer>, + JsonDeserializer> { private static final String ENERGY_VALUE = "energyValue"; private static final String TYPE_ITEM_STACK = "itemstack"; private static final String TYPE_ORE_STACK = "orestack"; private static final String TYPE_FLUID_STACK = "fluidstack"; @Override - public Map deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - + public Map + deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { Map valueMap = new TreeMap<>(); if (json.isJsonArray()) { - JsonArray jsonArray = json.getAsJsonArray(); Iterator jsonArrayIterator = jsonArray.iterator(); while (jsonArrayIterator.hasNext()) { - JsonElement jsonElement = jsonArrayIterator.next(); if (validateValueMapping(jsonElement)) { - JsonObject jsonValueMapping = jsonElement.getAsJsonObject(); WrappedStack wrappedStack = null; EnergyValue energyValue = null; if (jsonValueMapping.get(ENERGY_VALUE).isJsonPrimitive()) { - - if (jsonValueMapping.getAsJsonPrimitive(ENERGY_VALUE).isNumber()) { + if (jsonValueMapping.getAsJsonPrimitive(ENERGY_VALUE) + .isNumber()) { try { - energyValue = new EnergyValue(jsonValueMapping.getAsJsonPrimitive(ENERGY_VALUE).getAsNumber()); - } - catch (NumberFormatException e) { + energyValue = new EnergyValue( + jsonValueMapping.getAsJsonPrimitive(ENERGY_VALUE) + .getAsNumber() + ); + } catch (NumberFormatException e) { // TODO Logging } } } if (jsonValueMapping.has(TYPE_ITEM_STACK)) { - try { - ItemStack itemStack = context.deserialize(jsonValueMapping.get(TYPE_ITEM_STACK), ItemStack.class); + ItemStack itemStack = context.deserialize( + jsonValueMapping.get(TYPE_ITEM_STACK), ItemStack.class + ); wrappedStack = WrappedStack.wrap(itemStack); - } - catch (JsonParseException e) { + } catch (JsonParseException e) { // TODO Logging } - } - else if (jsonValueMapping.has(TYPE_ORE_STACK)) { - + } else if (jsonValueMapping.has(TYPE_ORE_STACK)) { try { - OreStack oreStack = context.deserialize(jsonValueMapping.get(TYPE_ORE_STACK), OreStack.class); + OreStack oreStack = context.deserialize( + jsonValueMapping.get(TYPE_ORE_STACK), OreStack.class + ); wrappedStack = WrappedStack.wrap(oreStack); - } - catch (JsonParseException e) { + } catch (JsonParseException e) { // TODO Logging } - } - else if (jsonValueMapping.has(TYPE_FLUID_STACK)) { - + } else if (jsonValueMapping.has(TYPE_FLUID_STACK)) { try { - FluidStack fluidStack = context.deserialize(jsonValueMapping.get(TYPE_FLUID_STACK), FluidStack.class); + FluidStack fluidStack = context.deserialize( + jsonValueMapping.get(TYPE_FLUID_STACK), FluidStack.class + ); wrappedStack = WrappedStack.wrap(fluidStack); - } - catch (JsonParseException e) { + } catch (JsonParseException e) { // TODO Logging } } @@ -93,49 +92,69 @@ public class EnergyValueMapSerializer implements JsonSerializer src, Type typeOfSrc, JsonSerializationContext context) { - + public JsonElement serialize( + Map src, + Type typeOfSrc, + JsonSerializationContext context + ) { JsonArray jsonArray = new JsonArray(); if (src != null) { - src.keySet().stream() - .filter(wrappedStack -> wrappedStack != null && wrappedStack.getWrappedObject() != null) - .forEach(wrappedStack -> { - JsonObject jsonMapping = new JsonObject(); - JsonElement jsonElement = context.serialize(wrappedStack.getWrappedObject()); + src.keySet() + .stream() + .filter( + wrappedStack + -> wrappedStack != null && wrappedStack.getWrappedObject() != null + ) + .forEach(wrappedStack -> { + JsonObject jsonMapping = new JsonObject(); + JsonElement jsonElement + = context.serialize(wrappedStack.getWrappedObject()); - if (jsonElement.isJsonObject()) { - jsonMapping.add(wrappedStack.getWrappedObject().getClass().getSimpleName().toLowerCase(), context.serialize(wrappedStack.getWrappedObject())); + if (jsonElement.isJsonObject()) { + jsonMapping.add( + wrappedStack.getWrappedObject() + .getClass() + .getSimpleName() + .toLowerCase(), + context.serialize(wrappedStack.getWrappedObject()) + ); - if (src.get(wrappedStack) != null) { - jsonMapping.addProperty(ENERGY_VALUE, src.get(wrappedStack).getValue()); - } - else { - jsonMapping.add(ENERGY_VALUE, JsonNull.INSTANCE); - } - - jsonArray.add(jsonMapping); + if (src.get(wrappedStack) != null) { + jsonMapping.addProperty( + ENERGY_VALUE, src.get(wrappedStack).getValue() + ); + } else { + jsonMapping.add(ENERGY_VALUE, JsonNull.INSTANCE); } - }); + + jsonArray.add(jsonMapping); + } + }); } return jsonArray; } /*** - * Validates whether or not the provided {@link JsonElement} is a valid json encoded {@link WrappedStack}:{@link EnergyValue} mapping + * Validates whether or not the provided {@link JsonElement} is a valid json encoded + * {@link WrappedStack}:{@link EnergyValue} mapping * * @param jsonElement the {@link JsonElement} being validated - * @return true if jsonElement is a valid json encoded {@link WrappedStack}:{@link EnergyValue} mapping, false otherwise + * @return true if jsonElement is a valid json encoded {@link WrappedStack}:{@link + * EnergyValue} mapping, false otherwise */ private static boolean validateValueMapping(JsonElement jsonElement) { - if (jsonElement.isJsonObject()) { JsonObject jsonObject = jsonElement.getAsJsonObject(); - if (jsonObject.entrySet().size() == 2 && jsonObject.has(ENERGY_VALUE) && jsonObject.get(ENERGY_VALUE).isJsonPrimitive()) { - return (jsonObject.has(TYPE_ITEM_STACK) && jsonObject.get(TYPE_ITEM_STACK).isJsonObject()) || - (jsonObject.has(TYPE_ORE_STACK) && jsonObject.get(TYPE_ORE_STACK).isJsonObject()) || - (jsonObject.has(TYPE_FLUID_STACK) && jsonObject.get(TYPE_FLUID_STACK).isJsonObject()); + if (jsonObject.entrySet().size() == 2 && jsonObject.has(ENERGY_VALUE) + && jsonObject.get(ENERGY_VALUE).isJsonPrimitive()) { + return (jsonObject.has(TYPE_ITEM_STACK) + && jsonObject.get(TYPE_ITEM_STACK).isJsonObject()) + || (jsonObject.has(TYPE_ORE_STACK) + && jsonObject.get(TYPE_ORE_STACK).isJsonObject()) + || (jsonObject.has(TYPE_FLUID_STACK) + && jsonObject.get(TYPE_FLUID_STACK).isJsonObject()); } } diff --git a/src/main/java/com/pahimar/ee3/util/serialize/FluidStackSerializer.java b/src/main/java/com/pahimar/ee3/util/serialize/FluidStackSerializer.java index 1702d983..79c22aee 100644 --- a/src/main/java/com/pahimar/ee3/util/serialize/FluidStackSerializer.java +++ b/src/main/java/com/pahimar/ee3/util/serialize/FluidStackSerializer.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.util.serialize; +import java.lang.reflect.Type; + import com.google.gson.*; import net.minecraft.nbt.JsonToNBT; import net.minecraft.nbt.NBTBase; @@ -9,16 +11,15 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import java.lang.reflect.Type; - -public class FluidStackSerializer implements JsonSerializer, JsonDeserializer { - +public class FluidStackSerializer + implements JsonSerializer, JsonDeserializer { private static final String NAME = "name"; private static final String TAG_COMPOUND = "tagCompound"; @Override - public FluidStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - + public FluidStack + deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { if (json.isJsonObject()) { JsonObject jsonObject = json.getAsJsonObject(); @@ -29,19 +30,18 @@ public class FluidStackSerializer implements JsonSerializer, JsonDes name = jsonObject.getAsJsonPrimitive(NAME).getAsString(); } - if (jsonObject.has(TAG_COMPOUND) && jsonObject.get(TAG_COMPOUND).isJsonPrimitive()) { - + if (jsonObject.has(TAG_COMPOUND) + && jsonObject.get(TAG_COMPOUND).isJsonPrimitive()) { try { - NBTBase nbtBase = JsonToNBT.func_150315_a(jsonObject.get(TAG_COMPOUND).getAsString()); + NBTBase nbtBase = JsonToNBT.func_150315_a( + jsonObject.get(TAG_COMPOUND).getAsString() + ); if (nbtBase instanceof NBTTagCompound) { tagCompound = (NBTTagCompound) nbtBase; } - } - catch (NBTException e) { - } + } catch (NBTException e) {} } - if (name != null) { Fluid fluid = FluidRegistry.getFluid(name); @@ -61,8 +61,8 @@ public class FluidStackSerializer implements JsonSerializer, JsonDes } @Override - public JsonElement serialize(FluidStack src, Type typeOfSrc, JsonSerializationContext context) { - + public JsonElement + serialize(FluidStack src, Type typeOfSrc, JsonSerializationContext context) { if (src != null) { JsonObject jsonObject = new JsonObject(); diff --git a/src/main/java/com/pahimar/ee3/util/serialize/ItemStackSerializer.java b/src/main/java/com/pahimar/ee3/util/serialize/ItemStackSerializer.java index 3c71c0d7..98106ec7 100644 --- a/src/main/java/com/pahimar/ee3/util/serialize/ItemStackSerializer.java +++ b/src/main/java/com/pahimar/ee3/util/serialize/ItemStackSerializer.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.util.serialize; +import java.lang.reflect.Type; + import com.google.gson.*; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -8,17 +10,16 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTException; import net.minecraft.nbt.NBTTagCompound; -import java.lang.reflect.Type; - -public class ItemStackSerializer implements JsonSerializer, JsonDeserializer { - +public class ItemStackSerializer + implements JsonSerializer, JsonDeserializer { private static final String NAME = "name"; private static final String META_VALUE = "metaValue"; private static final String TAG_COMPOUND = "tagCompound"; @Override - public ItemStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - + public ItemStack + deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { if (json.isJsonObject()) { JsonObject jsonObject = json.getAsJsonObject(); @@ -30,24 +31,25 @@ public class ItemStackSerializer implements JsonSerializer, JsonDeser name = jsonObject.getAsJsonPrimitive(NAME).getAsString(); } - if (jsonObject.has(META_VALUE) && jsonObject.get(META_VALUE).isJsonPrimitive()) { + if (jsonObject.has(META_VALUE) + && jsonObject.get(META_VALUE).isJsonPrimitive()) { try { metaValue = jsonObject.getAsJsonPrimitive(META_VALUE).getAsInt(); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { // TODO Logging } } - if (jsonObject.has(TAG_COMPOUND) && jsonObject.get(TAG_COMPOUND).isJsonPrimitive()) { - + if (jsonObject.has(TAG_COMPOUND) + && jsonObject.get(TAG_COMPOUND).isJsonPrimitive()) { try { - NBTBase nbtBase = JsonToNBT.func_150315_a(jsonObject.getAsJsonPrimitive(TAG_COMPOUND).getAsString()); + NBTBase nbtBase = JsonToNBT.func_150315_a( + jsonObject.getAsJsonPrimitive(TAG_COMPOUND).getAsString() + ); if (nbtBase instanceof NBTTagCompound) { tagCompound = (NBTTagCompound) nbtBase; } - } - catch (NBTException e) { + } catch (NBTException e) { // TODO Logging } } @@ -56,7 +58,9 @@ public class ItemStackSerializer implements JsonSerializer, JsonDeser Item item = (Item) Item.itemRegistry.getObject(name); if (item != null) { - ItemStack itemStack = new ItemStack((Item) Item.itemRegistry.getObject(name), 1, metaValue); + ItemStack itemStack = new ItemStack( + (Item) Item.itemRegistry.getObject(name), 1, metaValue + ); if (tagCompound != null) { itemStack.setTagCompound(tagCompound); @@ -71,15 +75,16 @@ public class ItemStackSerializer implements JsonSerializer, JsonDeser } @Override - public JsonElement serialize(ItemStack src, Type typeOfSrc, JsonSerializationContext context) { - + public JsonElement + serialize(ItemStack src, Type typeOfSrc, JsonSerializationContext context) { if (src != null && src.getItem() != null) { JsonObject jsonObject = new JsonObject(); if (Item.itemRegistry.getNameForObject(src.getItem()) != null) { - jsonObject.addProperty(NAME, Item.itemRegistry.getNameForObject(src.getItem())); - } - else { + jsonObject.addProperty( + NAME, Item.itemRegistry.getNameForObject(src.getItem()) + ); + } else { return JsonNull.INSTANCE; } diff --git a/src/main/java/com/pahimar/ee3/util/serialize/OreStackSerializer.java b/src/main/java/com/pahimar/ee3/util/serialize/OreStackSerializer.java index f4731255..8f918c61 100644 --- a/src/main/java/com/pahimar/ee3/util/serialize/OreStackSerializer.java +++ b/src/main/java/com/pahimar/ee3/util/serialize/OreStackSerializer.java @@ -1,19 +1,19 @@ package com.pahimar.ee3.util.serialize; +import java.lang.reflect.Type; + import com.google.gson.*; import com.pahimar.ee3.exchange.OreStack; -import java.lang.reflect.Type; - -public class OreStackSerializer implements JsonSerializer, JsonDeserializer { - +public class OreStackSerializer + implements JsonSerializer, JsonDeserializer { private static final String NAME = "name"; @Override - public OreStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - + public OreStack + deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { if (json.isJsonObject()) { - JsonObject jsonObject = (JsonObject) json; if (jsonObject.has(NAME) && jsonObject.get(NAME).isJsonPrimitive()) { @@ -26,8 +26,8 @@ public class OreStackSerializer implements JsonSerializer, JsonDeseria } @Override - public JsonElement serialize(OreStack src, Type typeOfSrc, JsonSerializationContext context) { - + public JsonElement + serialize(OreStack src, Type typeOfSrc, JsonSerializationContext context) { if (src != null) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty(NAME, src.oreName); diff --git a/src/main/java/com/pahimar/ee3/util/serialize/PlayerKnowledgeSerializer.java b/src/main/java/com/pahimar/ee3/util/serialize/PlayerKnowledgeSerializer.java index d82834a7..457c8931 100644 --- a/src/main/java/com/pahimar/ee3/util/serialize/PlayerKnowledgeSerializer.java +++ b/src/main/java/com/pahimar/ee3/util/serialize/PlayerKnowledgeSerializer.java @@ -1,43 +1,41 @@ package com.pahimar.ee3.util.serialize; +import java.lang.reflect.Type; +import java.util.Iterator; +import java.util.Set; +import java.util.TreeSet; + import com.google.gson.*; import com.pahimar.ee3.exchange.WrappedStack; import com.pahimar.ee3.knowledge.PlayerKnowledge; import com.pahimar.ee3.reference.Comparators; import net.minecraft.item.ItemStack; -import java.lang.reflect.Type; -import java.util.Iterator; -import java.util.Set; -import java.util.TreeSet; - -public class PlayerKnowledgeSerializer implements JsonSerializer, JsonDeserializer { - +public class PlayerKnowledgeSerializer + implements JsonSerializer, JsonDeserializer { @Override - public PlayerKnowledge deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - + public PlayerKnowledge + deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { Set knownItemStacks = new TreeSet<>(Comparators.ID_COMPARATOR); if (json.isJsonArray()) { - JsonArray jsonArray = json.getAsJsonArray(); Iterator jsonArrayIterator = jsonArray.iterator(); while (jsonArrayIterator.hasNext()) { - JsonElement jsonElement = jsonArrayIterator.next(); if (jsonElement.isJsonObject()) { - WrappedStack wrappedStack = null; try { - wrappedStack = context.deserialize(jsonElement, WrappedStack.class); - } - catch (JsonParseException e){ - } + wrappedStack + = context.deserialize(jsonElement, WrappedStack.class); + } catch (JsonParseException e) {} - if (wrappedStack != null && wrappedStack.getWrappedObject() instanceof ItemStack) { + if (wrappedStack != null + && wrappedStack.getWrappedObject() instanceof ItemStack) { knownItemStacks.add((ItemStack) wrappedStack.getWrappedObject()); } } @@ -48,8 +46,8 @@ public class PlayerKnowledgeSerializer implements JsonSerializer, JsonDeserializer { - +public class WrappedStackSerializer + implements JsonSerializer, JsonDeserializer { private static final String TYPE_ITEM_STACK = "itemstack"; private static final String TYPE_ORE_STACK = "orestack"; private static final String TYPE_FLUID_STACK = "fluidstack"; @Override - public WrappedStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - + public WrappedStack + deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { if (json.isJsonObject()) { - JsonObject jsonObject = json.getAsJsonObject(); WrappedStack wrappedStack = null; if (jsonObject.has(TYPE_ITEM_STACK)) { - try { - ItemStack itemStack = context.deserialize(jsonObject.get(TYPE_ITEM_STACK), ItemStack.class); + ItemStack itemStack = context.deserialize( + jsonObject.get(TYPE_ITEM_STACK), ItemStack.class + ); wrappedStack = WrappedStack.wrap(itemStack); - } - catch (JsonParseException e) { + } catch (JsonParseException e) { // TODO Logging } - } - else if (jsonObject.has(TYPE_ORE_STACK)) { - + } else if (jsonObject.has(TYPE_ORE_STACK)) { try { - OreStack oreStack = context.deserialize(jsonObject.get(TYPE_ORE_STACK), OreStack.class); + OreStack oreStack = context.deserialize( + jsonObject.get(TYPE_ORE_STACK), OreStack.class + ); wrappedStack = WrappedStack.wrap(oreStack); - } - catch (JsonParseException e) { + } catch (JsonParseException e) { // TODO Logging } - } - else if (jsonObject.has(TYPE_FLUID_STACK)) { - + } else if (jsonObject.has(TYPE_FLUID_STACK)) { try { - FluidStack fluidStack = context.deserialize(jsonObject.get(TYPE_FLUID_STACK), FluidStack.class); + FluidStack fluidStack = context.deserialize( + jsonObject.get(TYPE_FLUID_STACK), FluidStack.class + ); wrappedStack = WrappedStack.wrap(fluidStack); - } - catch (JsonParseException e) { + } catch (JsonParseException e) { // TODO Logging } } @@ -63,12 +61,15 @@ public class WrappedStackSerializer implements JsonSerializer, Jso } @Override - public JsonElement serialize(WrappedStack src, Type typeOfSrc, JsonSerializationContext context) { - + public JsonElement + serialize(WrappedStack src, Type typeOfSrc, JsonSerializationContext context) { final JsonObject jsonObject = new JsonObject(); if (src != null && src.getWrappedObject() != null) { - jsonObject.add(src.getWrappedObject().getClass().getSimpleName().toLowerCase(), context.serialize(src.getWrappedObject())); + jsonObject.add( + src.getWrappedObject().getClass().getSimpleName().toLowerCase(), + context.serialize(src.getWrappedObject()) + ); return jsonObject; } diff --git a/src/main/java/com/pahimar/ee3/waila/WailaDataProvider.java b/src/main/java/com/pahimar/ee3/waila/WailaDataProvider.java index 5fe44c01..a4a2d913 100644 --- a/src/main/java/com/pahimar/ee3/waila/WailaDataProvider.java +++ b/src/main/java/com/pahimar/ee3/waila/WailaDataProvider.java @@ -1,5 +1,7 @@ package com.pahimar.ee3.waila; +import java.util.List; + import com.pahimar.ee3.block.BlockAshInfusedStoneSlab; import com.pahimar.ee3.reference.Messages; import com.pahimar.ee3.reference.Names; @@ -12,124 +14,160 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -import java.util.List; - -public class WailaDataProvider implements IWailaDataProvider -{ +public class WailaDataProvider implements IWailaDataProvider { @Override - public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) - { + public ItemStack + getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { return null; } @Override - public List getWailaHead(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { - if (accessor.getTileEntity() instanceof TileEntityAludel) - { - if (accessor.getWorld().getTileEntity(accessor.getPosition().blockX, accessor.getPosition().blockY + 1, accessor.getPosition().blockZ) instanceof TileEntityGlassBell) - { - currentTip.set(0, String.format("%s%s", SpecialChars.WHITE, StatCollector.translateToLocal(Names.Containers.ALUDEL))); + public List getWailaHead( + ItemStack itemStack, + List currentTip, + IWailaDataAccessor accessor, + IWailaConfigHandler config + ) { + if (accessor.getTileEntity() instanceof TileEntityAludel) { + if (accessor.getWorld().getTileEntity( + accessor.getPosition().blockX, + accessor.getPosition().blockY + 1, + accessor.getPosition().blockZ + ) instanceof TileEntityGlassBell) { + currentTip.set( + 0, + String.format( + "%s%s", + SpecialChars.WHITE, + StatCollector.translateToLocal(Names.Containers.ALUDEL) + ) + ); } - } - else if (accessor.getTileEntity() instanceof TileEntityGlassBell) - { - if (accessor.getWorld().getTileEntity(accessor.getPosition().blockX, accessor.getPosition().blockY - 1, accessor.getPosition().blockZ) instanceof TileEntityAludel) - { - currentTip.set(0, String.format("%s%s", SpecialChars.WHITE, StatCollector.translateToLocal(Names.Containers.ALUDEL))); + } else if (accessor.getTileEntity() instanceof TileEntityGlassBell) { + if (accessor.getWorld().getTileEntity( + accessor.getPosition().blockX, + accessor.getPosition().blockY - 1, + accessor.getPosition().blockZ + ) instanceof TileEntityAludel) { + currentTip.set( + 0, + String.format( + "%s%s", + SpecialChars.WHITE, + StatCollector.translateToLocal(Names.Containers.ALUDEL) + ) + ); } - } - else if (accessor.getTileEntity() instanceof TileEntityAlchemicalChestSmall) - { - currentTip.set(0, SpecialChars.WHITE + StatCollector.translateToLocal(Messages.Tooltips.SMALL) + " " + StatCollector.translateToLocal(Names.Blocks.ALCHEMICAL_CHEST)); - } - else if (accessor.getTileEntity() instanceof TileEntityAlchemicalChestMedium) - { - currentTip.set(0, SpecialChars.WHITE + StatCollector.translateToLocal(Messages.Tooltips.MEDIUM) + " " + StatCollector.translateToLocal(Names.Blocks.ALCHEMICAL_CHEST)); - } - else if (accessor.getTileEntity() instanceof TileEntityAlchemicalChestLarge) - { - currentTip.set(0, SpecialChars.WHITE + StatCollector.translateToLocal(Messages.Tooltips.LARGE) + " " + StatCollector.translateToLocal(Names.Blocks.ALCHEMICAL_CHEST)); - } - else if (accessor.getTileEntity() instanceof TileEntityAlchemyArray) - { - TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) accessor.getTileEntity(); + } else if (accessor.getTileEntity() instanceof TileEntityAlchemicalChestSmall) { + currentTip.set( + 0, + SpecialChars.WHITE + + StatCollector.translateToLocal(Messages.Tooltips.SMALL) + " " + + StatCollector.translateToLocal(Names.Blocks.ALCHEMICAL_CHEST) + ); + } else if (accessor.getTileEntity() instanceof TileEntityAlchemicalChestMedium) { + currentTip.set( + 0, + SpecialChars.WHITE + + StatCollector.translateToLocal(Messages.Tooltips.MEDIUM) + " " + + StatCollector.translateToLocal(Names.Blocks.ALCHEMICAL_CHEST) + ); + } else if (accessor.getTileEntity() instanceof TileEntityAlchemicalChestLarge) { + currentTip.set( + 0, + SpecialChars.WHITE + + StatCollector.translateToLocal(Messages.Tooltips.LARGE) + " " + + StatCollector.translateToLocal(Names.Blocks.ALCHEMICAL_CHEST) + ); + } else if (accessor.getTileEntity() instanceof TileEntityAlchemyArray) { + TileEntityAlchemyArray tileEntityAlchemyArray + = (TileEntityAlchemyArray) accessor.getTileEntity(); - if (tileEntityAlchemyArray.getAlchemyArray() != null) - { - currentTip.set(0, SpecialChars.WHITE + tileEntityAlchemyArray.getAlchemyArray().getDisplayName()); + if (tileEntityAlchemyArray.getAlchemyArray() != null) { + currentTip.set( + 0, + SpecialChars.WHITE + + tileEntityAlchemyArray.getAlchemyArray().getDisplayName() + ); + } else { + currentTip.set( + 0, + SpecialChars.WHITE + + StatCollector.translateToLocal(Names.Blocks.ALCHEMY_ARRAY) + ); } - else - { - currentTip.set(0, SpecialChars.WHITE + StatCollector.translateToLocal(Names.Blocks.ALCHEMY_ARRAY)); - } - } - else if (accessor.getTileEntity() instanceof TileEntityDummyArray) - { - TileEntityDummyArray tileEntityDummyArray = (TileEntityDummyArray) accessor.getTileEntity(); - TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) accessor.getWorld().getTileEntity(tileEntityDummyArray.getTrueXCoord(), tileEntityDummyArray.getTrueYCoord(), tileEntityDummyArray.getTrueZCoord()); + } else if (accessor.getTileEntity() instanceof TileEntityDummyArray) { + TileEntityDummyArray tileEntityDummyArray + = (TileEntityDummyArray) accessor.getTileEntity(); + TileEntityAlchemyArray tileEntityAlchemyArray + = (TileEntityAlchemyArray) accessor.getWorld().getTileEntity( + tileEntityDummyArray.getTrueXCoord(), + tileEntityDummyArray.getTrueYCoord(), + tileEntityDummyArray.getTrueZCoord() + ); - if (tileEntityAlchemyArray != null && tileEntityAlchemyArray.getAlchemyArray() != null && tileEntityAlchemyArray.getAlchemyArray().getDisplayName() != null) - { - currentTip.set(0, SpecialChars.WHITE + tileEntityAlchemyArray.getAlchemyArray().getDisplayName()); + if (tileEntityAlchemyArray != null + && tileEntityAlchemyArray.getAlchemyArray() != null + && tileEntityAlchemyArray.getAlchemyArray().getDisplayName() != null) { + currentTip.set( + 0, + SpecialChars.WHITE + + tileEntityAlchemyArray.getAlchemyArray().getDisplayName() + ); + } else { + currentTip.set( + 0, + SpecialChars.WHITE + + StatCollector.translateToLocal(Names.Blocks.DUMMY_ARRAY) + ); } - else - { - currentTip.set(0, SpecialChars.WHITE + StatCollector.translateToLocal(Names.Blocks.DUMMY_ARRAY)); - } - } - else if (accessor.getBlock() instanceof BlockAshInfusedStoneSlab) - { + } else if (accessor.getBlock() instanceof BlockAshInfusedStoneSlab) { int metaData = accessor.getMetadata(); int x = accessor.getPosition().blockX; int y = accessor.getPosition().blockY; int z = accessor.getPosition().blockZ; - String unLocalizedBlockName = accessor.getWorld().getBlock(x, y, z).getUnlocalizedName() + ".name"; + String unLocalizedBlockName + = accessor.getWorld().getBlock(x, y, z).getUnlocalizedName() + ".name"; - if (metaData == 1) - { + if (metaData == 1) { x++; z++; - } - else if (metaData == 2) - { + } else if (metaData == 2) { z++; - } - else if (metaData == 3) - { + } else if (metaData == 3) { x--; z++; - } - else if (metaData == 4) - { + } else if (metaData == 4) { x++; - } - else if (metaData == 5) - { + } else if (metaData == 5) { x--; - } - else if (metaData == 6) - { + } else if (metaData == 6) { x++; z--; - } - else if (metaData == 7) - { + } else if (metaData == 7) { z--; - } - else if (metaData == 8) - { + } else if (metaData == 8) { x--; z--; } - if (metaData != 0 && accessor.getWorld().getTileEntity(x, y, z) instanceof TileEntityTransmutationTablet) - { - currentTip.set(0, SpecialChars.WHITE + StatCollector.translateToLocal(accessor.getWorld().getBlock(x, y, z).getUnlocalizedName() + ".name")); - } - else - { - currentTip.set(0, SpecialChars.WHITE + StatCollector.translateToLocal(unLocalizedBlockName)); + if (metaData != 0 + && accessor.getWorld().getTileEntity(x, y, z) + instanceof TileEntityTransmutationTablet) { + currentTip.set( + 0, + SpecialChars.WHITE + + StatCollector.translateToLocal( + accessor.getWorld().getBlock(x, y, z).getUnlocalizedName() + + ".name" + ) + ); + } else { + currentTip.set( + 0, + SpecialChars.WHITE + + StatCollector.translateToLocal(unLocalizedBlockName) + ); } } @@ -137,32 +175,57 @@ public class WailaDataProvider implements IWailaDataProvider } @Override - public List getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { + public List getWailaBody( + ItemStack itemStack, + List currentTip, + IWailaDataAccessor accessor, + IWailaConfigHandler config + ) { return currentTip; } @Override - public List getWailaTail(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { + public List getWailaTail( + ItemStack itemStack, + List currentTip, + IWailaDataAccessor accessor, + IWailaConfigHandler config + ) { return currentTip; } @Override - public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) - { + public NBTTagCompound getNBTData( + EntityPlayerMP player, + TileEntity te, + NBTTagCompound tag, + World world, + int x, + int y, + int z + ) { return null; } - public static void callbackRegister(IWailaRegistrar registrar) - { + public static void callbackRegister(IWailaRegistrar registrar) { registrar.registerHeadProvider(new WailaDataProvider(), TileEntityAludel.class); - registrar.registerHeadProvider(new WailaDataProvider(), TileEntityGlassBell.class); - registrar.registerHeadProvider(new WailaDataProvider(), TileEntityAlchemicalChestSmall.class); - registrar.registerHeadProvider(new WailaDataProvider(), TileEntityAlchemicalChestMedium.class); - registrar.registerHeadProvider(new WailaDataProvider(), TileEntityAlchemicalChestLarge.class); - registrar.registerHeadProvider(new WailaDataProvider(), TileEntityAlchemyArray.class); - registrar.registerHeadProvider(new WailaDataProvider(), TileEntityDummyArray.class); - registrar.registerHeadProvider(new WailaDataProvider(), BlockAshInfusedStoneSlab.class); + registrar + .registerHeadProvider(new WailaDataProvider(), TileEntityGlassBell.class); + registrar.registerHeadProvider( + new WailaDataProvider(), TileEntityAlchemicalChestSmall.class + ); + registrar.registerHeadProvider( + new WailaDataProvider(), TileEntityAlchemicalChestMedium.class + ); + registrar.registerHeadProvider( + new WailaDataProvider(), TileEntityAlchemicalChestLarge.class + ); + registrar + .registerHeadProvider(new WailaDataProvider(), TileEntityAlchemyArray.class); + registrar + .registerHeadProvider(new WailaDataProvider(), TileEntityDummyArray.class); + registrar.registerHeadProvider( + new WailaDataProvider(), BlockAshInfusedStoneSlab.class + ); } } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/audio/SoundBase.java b/src/main/java/com/pahimar/repackage/cofh/lib/audio/SoundBase.java index bc2f3ca5..50d9ac38 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/audio/SoundBase.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/audio/SoundBase.java @@ -6,15 +6,13 @@ import net.minecraft.client.audio.ISound; import net.minecraft.util.ResourceLocation; /** - * Generic ISound class with lots of constructor functionality. Required because - of course - Mojang has no generic that lets you specify *any* arguments for - * this. + * Generic ISound class with lots of constructor functionality. Required because - of + * course - Mojang has no generic that lets you specify *any* arguments for this. * * @author skyboy */ @SideOnly(Side.CLIENT) -public class SoundBase implements ISound -{ - +public class SoundBase implements ISound { protected AttenuationType attenuation; protected final ResourceLocation sound; protected float volume; @@ -25,87 +23,115 @@ public class SoundBase implements ISound protected boolean repeat; protected int repeatDelay; - public SoundBase(String sound) - { - + public SoundBase(String sound) { this(sound, 0); } - public SoundBase(String sound, float volume) - { - + public SoundBase(String sound, float volume) { this(sound, volume, 0); } - public SoundBase(String sound, float volume, float pitch) - { - + public SoundBase(String sound, float volume, float pitch) { this(sound, volume, pitch, false, 0); } - public SoundBase(String sound, float volume, float pitch, boolean repeat, int repeatDelay) - { - + public SoundBase( + String sound, float volume, float pitch, boolean repeat, int repeatDelay + ) { this(sound, volume, pitch, repeat, repeatDelay, 0, 0, 0, AttenuationType.NONE); } - public SoundBase(String sound, float volume, float pitch, double x, double y, double z) - { - + public SoundBase( + String sound, float volume, float pitch, double x, double y, double z + ) { this(sound, volume, pitch, false, 0, x, y, z); } - public SoundBase(String sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z) - { - + public SoundBase( + 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 SoundBase(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); + public SoundBase( + 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 + ); } - public SoundBase(ResourceLocation sound) - { - + public SoundBase(ResourceLocation sound) { this(sound, 0); } - public SoundBase(ResourceLocation sound, float volume) - { - + public SoundBase(ResourceLocation sound, float volume) { this(sound, volume, 0); } - public SoundBase(ResourceLocation sound, float volume, float pitch) - { - + public SoundBase(ResourceLocation sound, float volume, float pitch) { this(sound, volume, pitch, false, 0); } - public SoundBase(ResourceLocation sound, float volume, float pitch, boolean repeat, int repeatDelay) - { - + public SoundBase( + ResourceLocation sound, float volume, float pitch, boolean repeat, int repeatDelay + ) { this(sound, volume, pitch, repeat, repeatDelay, 0, 0, 0, AttenuationType.NONE); } - public SoundBase(ResourceLocation sound, float volume, float pitch, double x, double y, double z) - { - + public SoundBase( + ResourceLocation sound, float volume, float pitch, double x, double y, double z + ) { this(sound, volume, pitch, false, 0, x, y, z); } - public SoundBase(ResourceLocation sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z) - { - + public SoundBase( + 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 SoundBase(ResourceLocation sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z, AttenuationType attenuation) - { - + public SoundBase( + ResourceLocation sound, + float volume, + float pitch, + boolean repeat, + int repeatDelay, + double x, + double y, + double z, + AttenuationType attenuation + ) { this.attenuation = attenuation; this.sound = sound; this.volume = volume; @@ -117,9 +143,7 @@ public class SoundBase implements ISound this.repeatDelay = repeatDelay; } - public SoundBase(SoundBase other) - { - + public SoundBase(SoundBase other) { this.attenuation = other.attenuation; this.sound = other.sound; this.volume = other.volume; @@ -132,66 +156,47 @@ public class SoundBase implements ISound } @Override - public AttenuationType getAttenuationType() - { - + public AttenuationType getAttenuationType() { return attenuation; } @Override - public ResourceLocation getPositionedSoundLocation() - { - + public ResourceLocation getPositionedSoundLocation() { return sound; } @Override - public float getVolume() - { - + public float getVolume() { return volume; } @Override - public float getPitch() - { - + public float getPitch() { return pitch; } @Override - public float getXPosF() - { - + public float getXPosF() { return x; } @Override - public float getYPosF() - { - + public float getYPosF() { return y; } @Override - public float getZPosF() - { - + public float getZPosF() { return z; } @Override - public boolean canRepeat() - { - + public boolean canRepeat() { return repeat; } @Override - public int getRepeatDelay() - { - + public int getRepeatDelay() { return repeatDelay; } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/GuiBase.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/GuiBase.java index 0cfe2cfc..9c709be0 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/GuiBase.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/GuiBase.java @@ -1,5 +1,10 @@ package com.pahimar.repackage.cofh.lib.gui; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + import com.pahimar.repackage.cofh.lib.audio.SoundBase; import com.pahimar.repackage.cofh.lib.gui.element.ElementBase; import com.pahimar.repackage.cofh.lib.gui.element.TabBase; @@ -22,20 +27,15 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - /** - * Base class for a modular GUIs. Works with Elements {@link ElementBase} and Tabs {@link TabBase} which are both modular elements. + * Base class for a modular GUIs. Works with Elements {@link ElementBase} and Tabs {@link + * TabBase} which are both modular elements. * * @author King Lemming */ -public abstract class GuiBase extends GuiContainer -{ - - public static final SoundHandler guiSoundManager = FMLClientHandler.instance().getClient().getSoundHandler(); +public abstract class GuiBase extends GuiContainer { + public static final SoundHandler guiSoundManager + = FMLClientHandler.instance().getClient().getSoundHandler(); protected boolean drawTitle = true; protected boolean drawInventory = true; @@ -53,44 +53,33 @@ public abstract class GuiBase extends GuiContainer protected List tooltip = new LinkedList(); protected boolean tooltips = true; - public static void playSound(String name, float volume, float pitch) - { - + public static void playSound(String name, float volume, float pitch) { guiSoundManager.playSound(new SoundBase(name, volume, pitch)); } - public GuiBase(Container container) - { - + public GuiBase(Container container) { super(container); } - public GuiBase(Container container, ResourceLocation texture) - { - + public GuiBase(Container container, ResourceLocation texture) { super(container); this.texture = texture; } @Override - public void initGui() - { - + public void initGui() { super.initGui(); tabs.clear(); elements.clear(); } @Override - public void drawScreen(int x, int y, float partialTick) - { - + public void drawScreen(int x, int y, float partialTick) { updateElementInformation(); super.drawScreen(x, y, partialTick); - if (tooltips && mc.thePlayer.inventory.getItemStack() == null) - { + if (tooltips && mc.thePlayer.inventory.getItemStack() == null) { addTooltips(tooltip); drawTooltip(tooltip); } @@ -101,25 +90,29 @@ public abstract class GuiBase extends GuiContainer } @Override - protected void drawGuiContainerForegroundLayer(int x, int y) - { - - if (drawTitle) - { - fontRendererObj.drawString(StringHelper.localize(name), getCenteredOffset(StringHelper.localize(name)), 6, 0x404040); + protected void drawGuiContainerForegroundLayer(int x, int y) { + if (drawTitle) { + fontRendererObj.drawString( + StringHelper.localize(name), + getCenteredOffset(StringHelper.localize(name)), + 6, + 0x404040 + ); } - if (drawInventory) - { - fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 3, 0x404040); + if (drawInventory) { + fontRendererObj.drawString( + StatCollector.translateToLocal("container.inventory"), + 8, + ySize - 96 + 3, + 0x404040 + ); } drawElements(0, true); drawTabs(0, true); } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int x, int y) - { - + protected void drawGuiContainerBackgroundLayer(float partialTick, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); bindTexture(texture); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); @@ -135,18 +128,13 @@ public abstract class GuiBase extends GuiContainer } @Override - protected void keyTyped(char characterTyped, int keyPressed) - { - - for (int i = elements.size(); i-- > 0; ) - { + protected void keyTyped(char characterTyped, int keyPressed) { + for (int i = elements.size(); i-- > 0;) { ElementBase c = elements.get(i); - if (!c.isVisible() || !c.isEnabled()) - { + if (!c.isVisible() || !c.isEnabled()) { continue; } - if (c.onKeyTyped(characterTyped, keyPressed)) - { + if (c.onKeyTyped(characterTyped, keyPressed)) { return; } } @@ -154,9 +142,7 @@ public abstract class GuiBase extends GuiContainer } @Override - public void handleMouseInput() - { - + public void handleMouseInput() { int x = Mouse.getEventX() * width / mc.displayWidth; int y = height - Mouse.getEventY() * height / mc.displayHeight - 1; @@ -165,24 +151,20 @@ public abstract class GuiBase extends GuiContainer int wheelMovement = Mouse.getEventDWheel(); - if (wheelMovement != 0) - { - for (int i = elements.size(); i-- > 0; ) - { + if (wheelMovement != 0) { + for (int i = elements.size(); i-- > 0;) { ElementBase c = elements.get(i); - if (!c.isVisible() || !c.isEnabled() || !c.intersectsWith(mouseX, mouseY)) - { + if (!c.isVisible() || !c.isEnabled() + || !c.intersectsWith(mouseX, mouseY)) { continue; } - if (c.onMouseWheel(mouseX, mouseY, wheelMovement)) - { + if (c.onMouseWheel(mouseX, mouseY, wheelMovement)) { return; } } TabBase tab = getTabAtPosition(mouseX, mouseY); - if (tab != null && tab.onMouseWheel(mouseX, mouseY, wheelMovement)) - { + if (tab != null && tab.onMouseWheel(mouseX, mouseY, wheelMovement)) { return; } } @@ -190,37 +172,28 @@ public abstract class GuiBase extends GuiContainer } @Override - protected void mouseClicked(int mX, int mY, int mouseButton) - { - + protected void mouseClicked(int mX, int mY, int mouseButton) { mX -= guiLeft; mY -= guiTop; - for (int i = elements.size(); i-- > 0; ) - { + for (int i = elements.size(); i-- > 0;) { ElementBase c = elements.get(i); - if (!c.isVisible() || !c.isEnabled() || !c.intersectsWith(mX, mY)) - { + if (!c.isVisible() || !c.isEnabled() || !c.intersectsWith(mX, mY)) { continue; } - if (c.onMousePressed(mX, mY, mouseButton)) - { + if (c.onMousePressed(mX, mY, mouseButton)) { return; } } TabBase tab = getTabAtPosition(mX, mY); - if (tab != null) - { + if (tab != null) { int tMx = mX; - if (!tab.onMousePressed(tMx, mY, mouseButton)) - { - for (int i = tabs.size(); i-- > 0; ) - { + if (!tab.onMousePressed(tMx, mY, mouseButton)) { + for (int i = tabs.size(); i-- > 0;) { TabBase other = tabs.get(i); - if (other != tab && other.open && other.side == tab.side) - { + if (other != tab && other.open && other.side == tab.side) { other.toggleOpen(); } } @@ -232,10 +205,8 @@ public abstract class GuiBase extends GuiContainer mX += guiLeft; mY += guiTop; - if (tab != null) - { - switch (tab.side) - { + if (tab != null) { + switch (tab.side) { case TabBase.LEFT: guiLeft -= tab.currentWidth; break; @@ -245,10 +216,8 @@ public abstract class GuiBase extends GuiContainer } } super.mouseClicked(mX, mY, mouseButton); - if (tab != null) - { - switch (tab.side) - { + if (tab != null) { + switch (tab.side) { case TabBase.LEFT: guiLeft += tab.currentWidth; break; @@ -260,19 +229,15 @@ public abstract class GuiBase extends GuiContainer } @Override - protected void mouseMovedOrUp(int mX, int mY, int mouseButton) - { - + protected void mouseMovedOrUp(int mX, int mY, int mouseButton) { mX -= guiLeft; mY -= guiTop; - if (mouseButton >= 0 && mouseButton <= 2) - { // 0:left, 1:right, 2: middle - for (int i = elements.size(); i-- > 0; ) - { + if (mouseButton >= 0 && mouseButton <= 2) { // 0:left, 1:right, 2: middle + for (int i = elements.size(); i-- > 0;) { ElementBase c = elements.get(i); - if (!c.isVisible() || !c.isEnabled()) - { // no bounds checking on mouseUp events + if (!c.isVisible() + || !c.isEnabled()) { // no bounds checking on mouseUp events continue; } c.onMouseReleased(mX, mY); @@ -285,72 +250,54 @@ public abstract class GuiBase extends GuiContainer } @Override - protected void mouseClickMove(int mX, int mY, int lastClick, long timeSinceClick) - { - + protected void mouseClickMove(int mX, int mY, int lastClick, long timeSinceClick) { Slot slot = getSlotAtPosition(mX, mY); ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack(); - if (this.field_147007_t && slot != null && itemstack != null && slot instanceof SlotFalseCopy) - { - if (lastIndex != slot.slotNumber) - { + if (this.field_147007_t && slot != null && itemstack != null + && slot instanceof SlotFalseCopy) { + if (lastIndex != slot.slotNumber) { lastIndex = slot.slotNumber; this.handleMouseClick(slot, slot.slotNumber, 0, 0); } - } - else - { + } else { lastIndex = -1; super.mouseClickMove(mX, mY, lastClick, timeSinceClick); } } - public Slot getSlotAtPosition(int xCoord, int yCoord) - { - - for (int k = 0; k < this.inventorySlots.inventorySlots.size(); ++k) - { + public Slot getSlotAtPosition(int xCoord, int yCoord) { + for (int k = 0; k < this.inventorySlots.inventorySlots.size(); ++k) { Slot slot = (Slot) this.inventorySlots.inventorySlots.get(k); - if (this.isMouseOverSlot(slot, xCoord, yCoord)) - { + if (this.isMouseOverSlot(slot, xCoord, yCoord)) { return slot; } } return null; } - public boolean isMouseOverSlot(Slot theSlot, int xCoord, int yCoord) - { - - return this.func_146978_c(theSlot.xDisplayPosition, theSlot.yDisplayPosition, 16, 16, xCoord, yCoord); + public boolean isMouseOverSlot(Slot theSlot, int xCoord, int yCoord) { + return this.func_146978_c( + theSlot.xDisplayPosition, theSlot.yDisplayPosition, 16, 16, xCoord, yCoord + ); } /** * Draws the elements for this GUI. */ - protected void drawElements(float partialTick, boolean foreground) - { - - if (foreground) - { - for (int i = 0; i < elements.size(); i++) - { + protected void drawElements(float partialTick, boolean foreground) { + if (foreground) { + for (int i = 0; i < elements.size(); i++) { ElementBase element = elements.get(i); - if (element.isVisible()) - { + if (element.isVisible()) { element.drawForeground(mouseX, mouseY); } } - } - else - { - for (int i = 0; i < elements.size(); i++) - { + } else { + for (int i = 0; i < elements.size(); i++) { ElementBase element = elements.get(i); - if (element.isVisible()) - { + if (element.isVisible()) { element.drawBackground(mouseX, mouseY, partialTick); } } @@ -360,31 +307,23 @@ public abstract class GuiBase extends GuiContainer /** * Draws the tabs for this GUI. Handles Tab open/close animation. */ - protected void drawTabs(float partialTick, boolean foreground) - { - - if (foreground) - { + protected void drawTabs(float partialTick, boolean foreground) { + if (foreground) { return; } int yPosRight = 4; int yPosLeft = 4; - for (int i = 0; i < tabs.size(); i++) - { + for (int i = 0; i < tabs.size(); i++) { TabBase tab = tabs.get(i); tab.update(); - if (!tab.isVisible()) - { + if (!tab.isVisible()) { continue; } - if (tab.side == TabBase.LEFT) - { + if (tab.side == TabBase.LEFT) { tab.draw(0, yPosLeft); yPosLeft += tab.currentHeight; - } - else - { + } else { tab.draw(xSize, yPosRight); yPosRight += tab.currentHeight; } @@ -395,57 +334,44 @@ public abstract class GuiBase extends GuiContainer * Called by NEI if installed */ // @Override - public List handleTooltip(int mousex, int mousey, List tooltip) - { - - if (mc.thePlayer.inventory.getItemStack() == null) - { + public List handleTooltip(int mousex, int mousey, List tooltip) { + if (mc.thePlayer.inventory.getItemStack() == null) { addTooltips(tooltip); } return tooltip; } - public void addTooltips(List tooltip) - { - + public void addTooltips(List tooltip) { TabBase tab = getTabAtPosition(mouseX, mouseY); - if (tab != null) - { + if (tab != null) { tab.addTooltip(tooltip); } ElementBase element = getElementAtPosition(mouseX, mouseY); - if (element != null) - { + if (element != null) { element.addTooltip(tooltip); } } /* ELEMENTS */ - public ElementBase addElement(ElementBase element) - { - + public ElementBase addElement(ElementBase element) { elements.add(element); return element; } - public TabBase addTab(TabBase tab) - { - + public TabBase addTab(TabBase tab) { int yOffset = 4; - for (int i = 0; i < tabs.size(); i++) - { - if (tabs.get(i).side == tab.side && tabs.get(i).isVisible()) - { + for (int i = 0; i < tabs.size(); i++) { + if (tabs.get(i).side == tab.side && tabs.get(i).isVisible()) { yOffset += tabs.get(i).currentHeight; } } tab.setPosition(tab.side == TabBase.LEFT ? 0 : xSize, yOffset); tabs.add(tab); - if (TabTracker.getOpenedLeftTab() != null && tab.getClass().equals(TabTracker.getOpenedLeftTab())) - { + if (TabTracker.getOpenedLeftTab() != null + && tab.getClass().equals(TabTracker.getOpenedLeftTab())) { tab.setFullyOpen(); } else if (TabTracker.getOpenedRightTab() != null && tab.getClass().equals(TabTracker.getOpenedRightTab())) @@ -455,36 +381,27 @@ public abstract class GuiBase extends GuiContainer return tab; } - protected ElementBase getElementAtPosition(int mX, int mY) - { - - for (int i = elements.size(); i-- > 0; ) - { + protected ElementBase getElementAtPosition(int mX, int mY) { + for (int i = elements.size(); i-- > 0;) { ElementBase element = elements.get(i); - if (element.intersectsWith(mX, mY)) - { + if (element.intersectsWith(mX, mY)) { return element; } } return null; } - protected TabBase getTabAtPosition(int mX, int mY) - { - + protected TabBase getTabAtPosition(int mX, int mY) { int xShift = 0; int yShift = 4; - for (int i = 0; i < tabs.size(); i++) - { + for (int i = 0; i < tabs.size(); i++) { TabBase tab = tabs.get(i); - if (!tab.isVisible() || tab.side == TabBase.RIGHT) - { + if (!tab.isVisible() || tab.side == TabBase.RIGHT) { continue; } tab.setCurrentShift(xShift, yShift); - if (tab.intersectsWith(mX, mY, xShift, yShift)) - { + if (tab.intersectsWith(mX, mY, xShift, yShift)) { return tab; } yShift += tab.currentHeight; @@ -493,16 +410,13 @@ public abstract class GuiBase extends GuiContainer xShift = xSize; yShift = 4; - for (int i = 0; i < tabs.size(); i++) - { + for (int i = 0; i < tabs.size(); i++) { TabBase tab = tabs.get(i); - if (!tab.isVisible() || tab.side == TabBase.LEFT) - { + if (!tab.isVisible() || tab.side == TabBase.LEFT) { continue; } tab.setCurrentShift(xShift, yShift); - if (tab.intersectsWith(mX, mY, xShift, yShift)) - { + if (tab.intersectsWith(mX, mY, xShift, yShift)) { return tab; } yShift += tab.currentHeight; @@ -510,68 +424,48 @@ public abstract class GuiBase extends GuiContainer return null; } - protected final void updateElements() - { - - for (int i = elements.size(); i-- > 0; ) - { + protected final void updateElements() { + for (int i = elements.size(); i-- > 0;) { ElementBase c = elements.get(i); - if (c.isVisible() && c.isEnabled()) - { + if (c.isVisible() && c.isEnabled()) { c.update(mouseX, mouseY); } } } - protected void updateElementInformation() - { + protected void updateElementInformation() {} - } - - public void handleElementButtonClick(String buttonName, int mouseButton) - { - - } + public void handleElementButtonClick(String buttonName, int mouseButton) {} /* HELPERS */ - public void bindTexture(ResourceLocation texture) - { - + public void bindTexture(ResourceLocation texture) { mc.renderEngine.bindTexture(texture); } /** - * Abstract method to retrieve icons by name from a registry. You must override this if you use any of the String methods below. + * Abstract method to retrieve icons by name from a registry. You must override this + * if you use any of the String methods below. */ - public IIcon getIcon(String name) - { - + public IIcon getIcon(String name) { return null; } /** * Essentially a placeholder method for tabs to use should they need to draw a button. */ - public void drawButton(IIcon icon, int x, int y, int spriteSheet, int mode) - { - + public void drawButton(IIcon icon, int x, int y, int spriteSheet, int mode) { drawIcon(icon, x, y, spriteSheet); } - public void drawButton(String iconName, int x, int y, int spriteSheet, int mode) - { - + public void drawButton(String iconName, int x, int y, int spriteSheet, int mode) { drawButton(getIcon(iconName), x, y, spriteSheet, mode); } /** * Simple method used to draw a fluid of arbitrary size. */ - public void drawFluid(int x, int y, FluidStack fluid, int width, int height) - { - - if (fluid == null || fluid.getFluid() == null) - { + public void drawFluid(int x, int y, FluidStack fluid, int width, int height) { + if (fluid == null || fluid.getFluid() == null) { return; } RenderHelper.setBlockTextureSheet(); @@ -580,75 +474,57 @@ public abstract class GuiBase extends GuiContainer drawTiledTexture(x, y, fluid.getFluid().getIcon(fluid), width, height); } - public void drawTiledTexture(int x, int y, IIcon icon, int width, int height) - { - + public void drawTiledTexture(int x, int y, IIcon icon, int width, int height) { int i = 0; int j = 0; int drawHeight = 0; int drawWidth = 0; - for (i = 0; i < width; i += 16) - { - for (j = 0; j < height; j += 16) - { + for (i = 0; i < width; i += 16) { + for (j = 0; j < height; j += 16) { drawWidth = Math.min(width - i, 16); drawHeight = Math.min(height - j, 16); - drawScaledTexturedModelRectFromIcon(x + i, y + j, icon, drawWidth, drawHeight); + drawScaledTexturedModelRectFromIcon( + x + i, y + j, icon, drawWidth, drawHeight + ); } } GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); } - public void drawIcon(IIcon icon, int x, int y, int spriteSheet) - { - - if (spriteSheet == 0) - { + public void drawIcon(IIcon icon, int x, int y, int spriteSheet) { + if (spriteSheet == 0) { RenderHelper.setBlockTextureSheet(); - } - else - { + } else { RenderHelper.setItemTextureSheet(); } GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); drawTexturedModelRectFromIcon(x, y, icon, 16, 16); } - public void drawColorIcon(IIcon icon, int x, int y, int spriteSheet) - { - - if (spriteSheet == 0) - { + public void drawColorIcon(IIcon icon, int x, int y, int spriteSheet) { + if (spriteSheet == 0) { RenderHelper.setBlockTextureSheet(); - } - else - { + } else { RenderHelper.setItemTextureSheet(); } drawTexturedModelRectFromIcon(x, y, icon, 16, 16); } - public void drawIcon(String iconName, int x, int y, int spriteSheet) - { - + public void drawIcon(String iconName, int x, int y, int spriteSheet) { drawIcon(getIcon(iconName), x, y, spriteSheet); } - public void drawSizedModalRect(int x1, int y1, int x2, int y2, int color) - { - + public void drawSizedModalRect(int x1, int y1, int x2, int y2, int color) { int temp; - if (x1 < x2) - { + if (x1 < x2) { temp = x1; x1 = x2; x2 = temp; } - if (y1 < y2) - { + if (y1 < y2) { temp = y1; y1 = y2; y2 = temp; @@ -673,19 +549,15 @@ public abstract class GuiBase extends GuiContainer GL11.glDisable(GL11.GL_BLEND); } - public void drawSizedRect(int x1, int y1, int x2, int y2, int color) - { - + public void drawSizedRect(int x1, int y1, int x2, int y2, int color) { int temp; - if (x1 < x2) - { + if (x1 < x2) { temp = x1; x1 = x2; x2 = temp; } - if (y1 < y2) - { + if (y1 < y2) { temp = y1; y1 = y2; y2 = temp; @@ -707,25 +579,31 @@ public abstract class GuiBase extends GuiContainer GL11.glEnable(GL11.GL_TEXTURE_2D); } - public void drawSizedTexturedModalRect(int x, int y, int u, int v, int width, int height, float texW, float texH) - { - + public void drawSizedTexturedModalRect( + int x, int y, int u, int v, int width, int height, float texW, float texH + ) { float texU = 1 / texW; float texV = 1 / texH; Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(x + 0, y + height, this.zLevel, (u + 0) * texU, (v + height) * texV); - tessellator.addVertexWithUV(x + width, y + height, this.zLevel, (u + width) * texU, (v + height) * texV); - tessellator.addVertexWithUV(x + width, y + 0, this.zLevel, (u + width) * texU, (v + 0) * texV); - tessellator.addVertexWithUV(x + 0, y + 0, this.zLevel, (u + 0) * texU, (v + 0) * texV); + tessellator.addVertexWithUV( + x + 0, y + height, this.zLevel, (u + 0) * texU, (v + height) * texV + ); + tessellator.addVertexWithUV( + x + width, y + height, this.zLevel, (u + width) * texU, (v + height) * texV + ); + tessellator.addVertexWithUV( + x + width, y + 0, this.zLevel, (u + width) * texU, (v + 0) * texV + ); + tessellator.addVertexWithUV( + x + 0, y + 0, this.zLevel, (u + 0) * texU, (v + 0) * texV + ); tessellator.draw(); } - public void drawScaledTexturedModelRectFromIcon(int x, int y, IIcon icon, int width, int height) - { - - if (icon == null) - { + public void + drawScaledTexturedModelRectFromIcon(int x, int y, IIcon icon, int width, int height) { + if (icon == null) { return; } double minU = icon.getMinU(); @@ -735,26 +613,31 @@ public abstract class GuiBase extends GuiContainer Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(x + 0, y + height, this.zLevel, minU, minV + (maxV - minV) * height / 16F); - tessellator.addVertexWithUV(x + width, y + height, this.zLevel, minU + (maxU - minU) * width / 16F, minV + (maxV - minV) * height / 16F); - tessellator.addVertexWithUV(x + width, y + 0, this.zLevel, minU + (maxU - minU) * width / 16F, minV); + tessellator.addVertexWithUV( + x + 0, y + height, this.zLevel, minU, minV + (maxV - minV) * height / 16F + ); + tessellator.addVertexWithUV( + x + width, + y + height, + this.zLevel, + minU + (maxU - minU) * width / 16F, + minV + (maxV - minV) * height / 16F + ); + tessellator.addVertexWithUV( + x + width, y + 0, this.zLevel, minU + (maxU - minU) * width / 16F, minV + ); tessellator.addVertexWithUV(x + 0, y + 0, this.zLevel, minU, minV); tessellator.draw(); } - public void drawTooltip(List list) - { - + public void drawTooltip(List list) { drawTooltipHoveringText(list, mouseX + guiLeft, mouseY + guiTop, fontRendererObj); tooltip.clear(); } @SuppressWarnings("rawtypes") - protected void drawTooltipHoveringText(List list, int x, int y, FontRenderer font) - { - - if (list == null || list.isEmpty()) - { + protected void drawTooltipHoveringText(List list, int x, int y, FontRenderer font) { + if (list == null || list.isEmpty()) { return; } GL11.glDisable(GL12.GL_RESCALE_NORMAL); @@ -763,13 +646,11 @@ public abstract class GuiBase extends GuiContainer int k = 0; Iterator iterator = list.iterator(); - while (iterator.hasNext()) - { + while (iterator.hasNext()) { String s = (String) iterator.next(); int l = font.getStringWidth(s); - if (l > k) - { + if (l > k) { k = l; } } @@ -777,16 +658,13 @@ public abstract class GuiBase extends GuiContainer int j1 = y - 12; int k1 = 8; - if (list.size() > 1) - { + if (list.size() > 1) { k1 += 2 + (list.size() - 1) * 10; } - if (i1 + k > this.width) - { + if (i1 + k > this.width) { i1 -= 28 + k; } - if (j1 + k1 + 6 > this.height) - { + if (j1 + k1 + 6 > this.height) { j1 = this.height - k1 - 6; } this.zLevel = 300.0F; @@ -800,17 +678,17 @@ public abstract class GuiBase extends GuiContainer int i2 = 1347420415; int j2 = (i2 & 16711422) >> 1 | i2 & -16777216; this.drawGradientRect(i1 - 3, j1 - 3 + 1, i1 - 3 + 1, j1 + k1 + 3 - 1, i2, j2); - this.drawGradientRect(i1 + k + 2, j1 - 3 + 1, i1 + k + 3, j1 + k1 + 3 - 1, i2, j2); + this.drawGradientRect( + i1 + k + 2, j1 - 3 + 1, i1 + k + 3, j1 + k1 + 3 - 1, i2, j2 + ); this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 - 3 + 1, i2, i2); this.drawGradientRect(i1 - 3, j1 + k1 + 2, i1 + k + 3, j1 + k1 + 3, j2, j2); - for (int k2 = 0; k2 < list.size(); ++k2) - { + for (int k2 = 0; k2 < list.size(); ++k2) { String s1 = (String) list.get(k2); font.drawStringWithShadow(s1, i1, j1, -1); - if (k2 == 0) - { + if (k2 == 0) { j1 += 2; } j1 += 10; @@ -825,57 +703,37 @@ public abstract class GuiBase extends GuiContainer /** * Passthrough method for tab use. */ - public void mouseClicked(int mouseButton) - { - + public void mouseClicked(int mouseButton) { super.mouseClicked(guiLeft + mouseX, guiTop + mouseY, mouseButton); } - public FontRenderer getFontRenderer() - { - + public FontRenderer getFontRenderer() { return fontRendererObj; } - protected int getCenteredOffset(String string) - { - + protected int getCenteredOffset(String string) { return this.getCenteredOffset(string, xSize); } - protected int getCenteredOffset(String string, int xWidth) - { - + protected int getCenteredOffset(String string, int xWidth) { return (xWidth - fontRendererObj.getStringWidth(string)) / 2; } - public int getGuiLeft() - { - + public int getGuiLeft() { return guiLeft; } - public int getGuiTop() - { - + public int getGuiTop() { return guiTop; } - public int getMouseX() - { - + public int getMouseX() { return mouseX; } - public int getMouseY() - { - + public int getMouseY() { return mouseY; } - public void overlayRecipe() - { - - } - + public void overlayRecipe() {} } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/GuiBook.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/GuiBook.java index 4417d9b4..738d0430 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/GuiBook.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/GuiBook.java @@ -2,10 +2,7 @@ package com.pahimar.repackage.cofh.lib.gui; import net.minecraft.client.gui.GuiScreen; -public class GuiBook extends GuiScreen -{ - +public class GuiBook extends GuiScreen { protected int mouseX = 0; protected int mouseY = 0; - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/GuiColor.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/GuiColor.java index 9b4a92a8..7e502f1c 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/GuiColor.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/GuiColor.java @@ -1,127 +1,86 @@ package com.pahimar.repackage.cofh.lib.gui; -public class GuiColor extends Number -{ - +public class GuiColor extends Number { private static final long serialVersionUID = 7024827242888861187L; private final int _color; - public GuiColor(int argb) - { - + public GuiColor(int argb) { _color = argb; } - public GuiColor(int rgba, Void dummy) - { - + public GuiColor(int rgba, Void dummy) { this(rgba >>> 24, rgba >> 16, rgba >> 8, rgba); } - public GuiColor(byte alpha, int argb) - { - + public GuiColor(byte alpha, int argb) { this(argb >> 16, argb >> 8, argb, alpha); } - public GuiColor(int rgba, byte alpha) - { - + public GuiColor(int rgba, byte alpha) { this(rgba >>> 24, rgba >> 16, rgba >> 8, alpha); } - public GuiColor(int r, int g, int b) - { - + public GuiColor(int r, int g, int b) { this(r, g, b, 255); } - public GuiColor(int r, int g, int b, int a) - { - + public GuiColor(int r, int g, int b, int a) { _color = (b & 0xFF) | (g & 0xFF) << 8 | (r & 0xFF) << 16 | (a & 0xFF) << 24; } - public int getColor() - { - + public int getColor() { return _color; } - public int getIntR() - { - + public int getIntR() { return (_color >> 16) & 0xFF; } - public int getIntG() - { - + public int getIntG() { return (_color >> 8) & 0xFF; } - public int getIntB() - { - + public int getIntB() { return (_color >> 0) & 0xFF; } - public int getIntA() - { - + public int getIntA() { return (_color >> 24) & 0xFF; } - public float getFloatR() - { - + public float getFloatR() { return getIntR() / 255f; } - public float getFloatG() - { - + public float getFloatG() { return getIntG() / 255f; } - public float getFloatB() - { - + public float getFloatB() { return getIntB() / 255f; } - public float getFloatA() - { - + public float getFloatA() { return getIntA() / 255f; } @Override - public int intValue() - { - + public int intValue() { return getColor(); } @Override - public long longValue() - { - + public long longValue() { return getColor(); } @Override - public float floatValue() - { - + public float floatValue() { return getColor(); } @Override - public double doubleValue() - { - + public double doubleValue() { return getColor(); } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/GuiProps.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/GuiProps.java index d7e949a9..95cbcc71 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/GuiProps.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/GuiProps.java @@ -2,9 +2,7 @@ package com.pahimar.repackage.cofh.lib.gui; import com.pahimar.ee3.reference.Textures; -public class GuiProps -{ - +public class GuiProps { /* GUI */ public static final String PATH_GFX = Textures.RESOURCE_PREFIX + "textures/"; public static final String PATH_ARMOR = PATH_GFX + "armor/"; @@ -12,5 +10,4 @@ public class GuiProps public static final String PATH_RENDER = PATH_GFX + "blocks/"; public static final String PATH_ELEMENTS = PATH_GUI + "elements/"; public static final String PATH_ICON = PATH_GUI + "icons/"; - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/TabTracker.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/TabTracker.java index 3e9d09db..d9f90459 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/TabTracker.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/TabTracker.java @@ -7,34 +7,23 @@ import com.pahimar.repackage.cofh.lib.gui.element.TabBase; * * @author King Lemming */ -public class TabTracker -{ - +public class TabTracker { private static Class openedLeftTab; private static Class openedRightTab; - public static Class getOpenedLeftTab() - { - + public static Class getOpenedLeftTab() { return openedLeftTab; } - public static Class getOpenedRightTab() - { - + public static Class getOpenedRightTab() { return openedRightTab; } - public static void setOpenedLeftTab(Class tabClass) - { - + public static void setOpenedLeftTab(Class tabClass) { openedLeftTab = tabClass; } - public static void setOpenedRightTab(Class tabClass) - { - + public static void setOpenedRightTab(Class tabClass) { openedRightTab = tabClass; } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementBase.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementBase.java index 788408b9..991250d2 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementBase.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementBase.java @@ -1,21 +1,20 @@ package com.pahimar.repackage.cofh.lib.gui.element; +import java.util.List; + import com.pahimar.repackage.cofh.lib.gui.GuiBase; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -import java.util.List; - /** - * Base class for a modular GUI element. Has self-contained rendering methods and a link back to the {@link GuiBase} it is a part of. + * Base class for a modular GUI element. Has self-contained rendering methods and a link + * back to the {@link GuiBase} it is a part of. * * @author King Lemming */ -public abstract class ElementBase -{ - +public abstract class ElementBase { protected GuiBase gui; protected ResourceLocation texture; @@ -33,17 +32,13 @@ public abstract class ElementBase private boolean visible = true; private boolean enabled = true; - public ElementBase(GuiBase gui, int posX, int posY) - { - + public ElementBase(GuiBase gui, int posX, int posY) { this.gui = gui; this.posX = posX; this.posY = posY; } - public ElementBase(GuiBase gui, int posX, int posY, int width, int height) - { - + public ElementBase(GuiBase gui, int posX, int posY, int width, int height) { this.gui = gui; this.posX = posX; this.posY = posY; @@ -51,101 +46,72 @@ public abstract class ElementBase this.sizeY = height; } - public ElementBase setName(String name) - { - + public ElementBase setName(String name) { this.name = name; return this; } - public ElementBase setPosition(int posX, int posY) - { - + public ElementBase setPosition(int posX, int posY) { this.posX = posX; this.posY = posY; return this; } - public ElementBase setSize(int sizeX, int sizeY) - { - + public ElementBase setSize(int sizeX, int sizeY) { this.sizeX = sizeX; this.sizeY = sizeY; return this; } - public ElementBase setTexture(String texture, int texW, int texH) - { - + public ElementBase setTexture(String texture, int texW, int texH) { this.texture = new ResourceLocation(texture); this.texW = texW; this.texH = texH; return this; } - public ElementBase setTexture(ResourceLocation texture, int texW, int texH) - { - + public ElementBase setTexture(ResourceLocation texture, int texW, int texH) { this.texture = texture; this.texW = texW; this.texH = texH; return this; } - public final ElementBase setVisible(boolean visible) - { - + public final ElementBase setVisible(boolean visible) { this.visible = visible; return this; } - public boolean isVisible() - { - + public boolean isVisible() { return visible; } - public final ElementBase setEnabled(boolean enabled) - { - + public final ElementBase setEnabled(boolean enabled) { this.enabled = enabled; return this; } - public boolean isEnabled() - { - + public boolean isEnabled() { return enabled; } - public void update(int mouseX, int mouseY) - { - + public void update(int mouseX, int mouseY) { update(); } - public void update() - { - - } + public void update() {} public abstract void drawBackground(int mouseX, int mouseY, float gameTicks); public abstract void drawForeground(int mouseX, int mouseY); - public void addTooltip(List list) - { - - } - - public void drawModalRect(int x, int y, int width, int height, int color) - { + public void addTooltip(List list) {} + public void drawModalRect(int x, int y, int width, int height, int color) { gui.drawSizedModalRect(x, y, width, height, color); } - public void drawStencil(int xStart, int yStart, int xEnd, int yEnd, int flag) - { + public void drawStencil(int xStart, int yStart, int xEnd, int yEnd, int flag) { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glStencilFunc(GL11.GL_ALWAYS, flag, flag); GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_REPLACE); @@ -165,93 +131,67 @@ public abstract class ElementBase GL11.glDepthMask(true); } - public void drawTexturedModalRect(int x, int y, int u, int v, int width, int height) - { - + public void drawTexturedModalRect(int x, int y, int u, int v, int width, int height) { gui.drawSizedTexturedModalRect(x, y, u, v, width, height, texW, texH); } - public void drawCenteredString(FontRenderer fontRenderer, String text, int x, int y, int color) - { - - fontRenderer.drawStringWithShadow(text, x - fontRenderer.getStringWidth(text) / 2, y, color); + public void + drawCenteredString(FontRenderer fontRenderer, String text, int x, int y, int color) { + fontRenderer.drawStringWithShadow( + text, x - fontRenderer.getStringWidth(text) / 2, y, color + ); } - public boolean onMousePressed(int mouseX, int mouseY, int mouseButton) - { - + public boolean onMousePressed(int mouseX, int mouseY, int mouseButton) { return false; } - public void onMouseReleased(int mouseX, int mouseY) - { - - } - - public boolean onMouseWheel(int mouseX, int mouseY, int movement) - { + public void onMouseReleased(int mouseX, int mouseY) {} + public boolean onMouseWheel(int mouseX, int mouseY, int movement) { return false; } - public boolean onKeyTyped(char characterTyped, int keyPressed) - { - + public boolean onKeyTyped(char characterTyped, int keyPressed) { return false; } - public boolean intersectsWith(int mouseX, int mouseY) - { - - return mouseX >= this.posX && mouseX <= this.posX + this.sizeX && mouseY >= this.posY && mouseY <= this.posY + this.sizeY; + public boolean intersectsWith(int mouseX, int mouseY) { + return mouseX >= this.posX && mouseX <= this.posX + this.sizeX + && mouseY >= this.posY && mouseY <= this.posY + this.sizeY; } - public final String getName() - { - + public final String getName() { return name; } - public final GuiBase getContainerScreen() - { - + public final GuiBase getContainerScreen() { return gui; } - public final FontRenderer getFontRenderer() - { - + public final FontRenderer getFontRenderer() { return gui.getFontRenderer(); } /** * This method is relative to the GUI's y coordinate */ - public final int getPosY() - { - + public final int getPosY() { return posY; } /** * This method is relative to the GUI's x coordinate */ - public final int getPosX() - { - + public final int getPosX() { return posX; } - public final int getHeight() - { - + public final int getHeight() { return sizeY; } - public final int getWidth() - { - + public final int getWidth() { return sizeX; } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementButton.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementButton.java index 7f5e4ab8..20ed744a 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementButton.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementButton.java @@ -1,16 +1,14 @@ package com.pahimar.repackage.cofh.lib.gui.element; +import java.util.List; + import com.pahimar.ee3.util.ResourceLocationHelper; import com.pahimar.repackage.cofh.lib.gui.GuiBase; import com.pahimar.repackage.cofh.lib.render.RenderHelper; import com.pahimar.repackage.cofh.lib.util.helpers.StringHelper; import net.minecraft.util.ResourceLocation; -import java.util.List; - -public class ElementButton extends ElementBase -{ - +public class ElementButton extends ElementBase { int sheetX; int sheetY; int hoverX; @@ -20,19 +18,113 @@ public class ElementButton extends ElementBase boolean tooltipLocalized = false; String tooltip; - public ElementButton(GuiBase gui, int posX, int posY, String name, int sheetX, int sheetY, int hoverX, int hoverY, int sizeX, int sizeY, String texture) { - this(gui, posX, posY, name, sheetX, sheetY, hoverX, hoverY, sizeX, sizeY, 256, 256, texture); + public ElementButton( + GuiBase gui, + int posX, + int posY, + String name, + int sheetX, + int sheetY, + int hoverX, + int hoverY, + int sizeX, + int sizeY, + String texture + ) { + this( + gui, + posX, + posY, + name, + sheetX, + sheetY, + hoverX, + hoverY, + sizeX, + sizeY, + 256, + 256, + texture + ); } - public ElementButton(GuiBase gui, int posX, int posY, String name, int sheetX, int sheetY, int hoverX, int hoverY, int sizeX, int sizeY, ResourceLocation texture) { - this(gui, posX, posY, name, sheetX, sheetY, hoverX, hoverY, sizeX, sizeY, 256, 256, texture); + public ElementButton( + GuiBase gui, + int posX, + int posY, + String name, + int sheetX, + int sheetY, + int hoverX, + int hoverY, + int sizeX, + int sizeY, + ResourceLocation texture + ) { + this( + gui, + posX, + posY, + name, + sheetX, + sheetY, + hoverX, + hoverY, + sizeX, + sizeY, + 256, + 256, + texture + ); } - public ElementButton(GuiBase gui, int posX, int posY, String name, int sheetX, int sheetY, int hoverX, int hoverY, int sizeX, int sizeY, int texW, int texH, String texture) { - this(gui, posX, posY, name, sheetX, sheetY, hoverX, hoverY, sizeX, sizeY, texW, texH, ResourceLocationHelper.getResourceLocation(texture)); + public ElementButton( + GuiBase gui, + int posX, + int posY, + String name, + int sheetX, + int sheetY, + int hoverX, + int hoverY, + int sizeX, + int sizeY, + int texW, + int texH, + String texture + ) { + this( + gui, + posX, + posY, + name, + sheetX, + sheetY, + hoverX, + hoverY, + sizeX, + sizeY, + texW, + texH, + ResourceLocationHelper.getResourceLocation(texture) + ); } - public ElementButton(GuiBase gui, int posX, int posY, String name, int sheetX, int sheetY, int hoverX, int hoverY, int sizeX, int sizeY, int texW, int texH, ResourceLocation texture) { + public ElementButton( + GuiBase gui, + int posX, + int posY, + String name, + int sheetX, + int sheetY, + int hoverX, + int hoverY, + int sizeX, + int sizeY, + int texW, + int texH, + ResourceLocation texture + ) { super(gui, posX, posY); setName(name); setSize(sizeX, sizeY); @@ -43,11 +135,59 @@ public class ElementButton extends ElementBase this.hoverY = hoverY; } - public ElementButton(GuiBase gui, int posX, int posY, String name, int sheetX, int sheetY, int hoverX, int hoverY, int disabledX, int disabledY, int sizeX, int sizeY, int texW, int texH, String texture) { - this(gui, posX, posY, name, sheetX, sheetY, hoverX, hoverY, disabledX, disabledY, sizeX, sizeY, texW, texH, ResourceLocationHelper.getResourceLocation(texture)); + public ElementButton( + GuiBase gui, + int posX, + int posY, + String name, + int sheetX, + int sheetY, + int hoverX, + int hoverY, + int disabledX, + int disabledY, + int sizeX, + int sizeY, + int texW, + int texH, + String texture + ) { + this( + gui, + posX, + posY, + name, + sheetX, + sheetY, + hoverX, + hoverY, + disabledX, + disabledY, + sizeX, + sizeY, + texW, + texH, + ResourceLocationHelper.getResourceLocation(texture) + ); } - public ElementButton(GuiBase gui, int posX, int posY, String name, int sheetX, int sheetY, int hoverX, int hoverY, int disabledX, int disabledY, int sizeX, int sizeY, int texW, int texH, ResourceLocation texture) { + public ElementButton( + GuiBase gui, + int posX, + int posY, + String name, + int sheetX, + int sheetY, + int hoverX, + int hoverY, + int disabledX, + int disabledY, + int sizeX, + int sizeY, + int texW, + int texH, + ResourceLocation texture + ) { super(gui, posX, posY); setName(name); setSize(sizeX, sizeY); @@ -60,133 +200,89 @@ public class ElementButton extends ElementBase this.disabledY = disabledY; } - public ElementButton clearToolTip() - { - + public ElementButton clearToolTip() { this.tooltip = null; return this; } - public ElementButton setToolTip(String tooltip) - { - + public ElementButton setToolTip(String tooltip) { this.tooltip = tooltip; return this; } - public ElementButton setToolTipLocalized(boolean localized) - { - + public ElementButton setToolTipLocalized(boolean localized) { this.tooltipLocalized = localized; return this; } @Override - public void drawBackground(int mouseX, int mouseY, float gameTicks) - { - + public void drawBackground(int mouseX, int mouseY, float gameTicks) { RenderHelper.bindTexture(texture); - if (isEnabled()) - { - if (intersectsWith(mouseX, mouseY)) - { - + if (isEnabled()) { + if (intersectsWith(mouseX, mouseY)) { drawTexturedModalRect(posX, posY, hoverX, hoverY, sizeX, sizeY); - } - else - { + } else { drawTexturedModalRect(posX, posY, sheetX, sheetY, sizeX, sizeY); } - } - else - { + } else { drawTexturedModalRect(posX, posY, disabledX, disabledY, sizeX, sizeY); } } @Override - public void drawForeground(int mouseX, int mouseY) - { - - } + public void drawForeground(int mouseX, int mouseY) {} @Override - public void addTooltip(List list) - { - - if (tooltip != null) - { - if (tooltipLocalized) - { + public void addTooltip(List list) { + if (tooltip != null) { + if (tooltipLocalized) { list.add(tooltip); - } - else - { + } else { list.add(StringHelper.localize(tooltip)); } } } @Override - public boolean onMousePressed(int x, int y, int mouseButton) - { - - if (isEnabled()) - { + public boolean onMousePressed(int x, int y, int mouseButton) { + if (isEnabled()) { gui.handleElementButtonClick(getName(), mouseButton); return true; } return false; } - public void setSheetX(int pos) - { - + public void setSheetX(int pos) { sheetX = pos; } - public void setSheetY(int pos) - { - + public void setSheetY(int pos) { sheetY = pos; } - public void setHoverX(int pos) - { - + public void setHoverX(int pos) { hoverX = pos; } - public void setHoverY(int pos) - { - + public void setHoverY(int pos) { hoverY = pos; } - public ElementButton setDisabledX(int pos) - { - + public ElementButton setDisabledX(int pos) { disabledX = pos; return this; } - public ElementButton setDisabledY(int pos) - { - + public ElementButton setDisabledY(int pos) { disabledY = pos; return this; } - public void setActive() - { - + public void setActive() { setEnabled(true); } - public void setDisabled() - { - + public void setDisabled() { setEnabled(false); } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementButtonManaged.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementButtonManaged.java index b0e2af1a..98e64852 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementButtonManaged.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementButtonManaged.java @@ -5,84 +5,83 @@ import com.pahimar.repackage.cofh.lib.gui.GuiProps; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -public abstract class ElementButtonManaged extends ElementBase -{ - - public static final ResourceLocation HOVER = new ResourceLocation(GuiProps.PATH_ELEMENTS + "Button_Hover.png"); - public static final ResourceLocation ENABLED = new ResourceLocation(GuiProps.PATH_ELEMENTS + "Button_Enabled.png"); - public static final ResourceLocation DISABLED = new ResourceLocation(GuiProps.PATH_ELEMENTS + "Button_Disabled.png"); +public abstract class ElementButtonManaged extends ElementBase { + public static final ResourceLocation HOVER + = new ResourceLocation(GuiProps.PATH_ELEMENTS + "Button_Hover.png"); + public static final ResourceLocation ENABLED + = new ResourceLocation(GuiProps.PATH_ELEMENTS + "Button_Enabled.png"); + public static final ResourceLocation DISABLED + = new ResourceLocation(GuiProps.PATH_ELEMENTS + "Button_Disabled.png"); private String _text; - public ElementButtonManaged(GuiBase containerScreen, int posX, int posY, int sizeX, int sizeY, String text) - { + public ElementButtonManaged( + GuiBase containerScreen, int posX, int posY, int sizeX, int sizeY, String text + ) { super(containerScreen, posX, posY, sizeX, sizeY); _text = text; } - public void setText(String text) - { + public void setText(String text) { _text = text; } @Override - public void drawBackground(int mouseX, int mouseY, float gameTicks) - { - if (!isEnabled()) - { + public void drawBackground(int mouseX, int mouseY, float gameTicks) { + if (!isEnabled()) { gui.bindTexture(DISABLED); - } - else if (intersectsWith(mouseX, mouseY)) - { + } else if (intersectsWith(mouseX, mouseY)) { gui.bindTexture(HOVER); - } - else - { + } else { gui.bindTexture(ENABLED); } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); drawTexturedModalRect(posX, posY, 0, 0, sizeX / 2, sizeY / 2); - drawTexturedModalRect(posX, posY + sizeY / 2, 0, 256 - sizeY / 2, sizeX / 2, sizeY / 2); - drawTexturedModalRect(posX + sizeX / 2, posY, 256 - sizeX / 2, 0, sizeX / 2, sizeY / 2); - drawTexturedModalRect(posX + sizeX / 2, posY + sizeY / 2, 256 - sizeX / 2, 256 - sizeY / 2, sizeX / 2, sizeY / 2); + drawTexturedModalRect( + posX, posY + sizeY / 2, 0, 256 - sizeY / 2, sizeX / 2, sizeY / 2 + ); + drawTexturedModalRect( + posX + sizeX / 2, posY, 256 - sizeX / 2, 0, sizeX / 2, sizeY / 2 + ); + drawTexturedModalRect( + posX + sizeX / 2, + posY + sizeY / 2, + 256 - sizeX / 2, + 256 - sizeY / 2, + sizeX / 2, + sizeY / 2 + ); } @Override - public void drawForeground(int mouseX, int mouseY) - { + public void drawForeground(int mouseX, int mouseY) { String text = getFontRenderer().trimStringToWidth(_text, sizeX - 4); - drawCenteredString(getFontRenderer(), text, posX + sizeX / 2, posY + (sizeY - 8) / 2, getTextColor(mouseX, mouseY)); + drawCenteredString( + getFontRenderer(), + text, + posX + sizeX / 2, + posY + (sizeY - 8) / 2, + getTextColor(mouseX, mouseY) + ); } - protected int getTextColor(int mouseX, int mouseY) - { - if (!isEnabled()) - { + protected int getTextColor(int mouseX, int mouseY) { + if (!isEnabled()) { return -6250336; - } - else if (intersectsWith(mouseX, mouseY)) - { + } else if (intersectsWith(mouseX, mouseY)) { return 16777120; - } - else - { + } else { return 14737632; } } @Override - public boolean onMousePressed(int mouseX, int mouseY, int mouseButton) - { + public boolean onMousePressed(int mouseX, int mouseY, int mouseButton) { GuiBase.playSound("random.click", 1.0F, 1.0F); - if (mouseButton == 0) - { + if (mouseButton == 0) { onClick(); - } - else if (mouseButton == 1) - { + } else if (mouseButton == 1) { onRightClick(); - } - else if (mouseButton == 2) - { + } else if (mouseButton == 2) { onMiddleClick(); } return true; @@ -90,13 +89,7 @@ public abstract class ElementButtonManaged extends ElementBase public abstract void onClick(); - public void onRightClick() - { + public void onRightClick() {} - } - - public void onMiddleClick() - { - - } + public void onMiddleClick() {} } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementButtonOption.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementButtonOption.java index 4691c453..8213f695 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementButtonOption.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementButtonOption.java @@ -1,43 +1,34 @@ package com.pahimar.repackage.cofh.lib.gui.element; -import com.pahimar.repackage.cofh.lib.gui.GuiBase; - import java.util.HashMap; import java.util.Map; -public abstract class ElementButtonOption extends ElementButtonManaged -{ +import com.pahimar.repackage.cofh.lib.gui.GuiBase; +public abstract class ElementButtonOption extends ElementButtonManaged { private final Map _values = new HashMap(); private int _currentValue = 0; private int _maxValue; - public ElementButtonOption(GuiBase containerScreen, int x, int y, int width, int height) - { - + public ElementButtonOption( + GuiBase containerScreen, int x, int y, int width, int height + ) { super(containerScreen, x, y, width, height, ""); } - public void setValue(int value, String label) - { - + public void setValue(int value, String label) { _values.put(value, label); - if (value > _maxValue) - { + if (value > _maxValue) { _maxValue = value; } } @Override - public void onClick() - { - + public void onClick() { int nextValue = _currentValue; - do - { + do { nextValue++; - if (nextValue > _maxValue) - { + if (nextValue > _maxValue) { nextValue = 0; } } while (_values.get(nextValue) == null); @@ -45,42 +36,31 @@ public abstract class ElementButtonOption extends ElementButtonManaged } @Override - public void onRightClick() - { - + public void onRightClick() { int nextValue = _currentValue; - do - { + do { nextValue--; - if (nextValue < 0) - { + if (nextValue < 0) { nextValue = _maxValue; } } while (_values.get(nextValue) == null); setSelectedIndex(nextValue); } - public int getSelectedIndex() - { - + public int getSelectedIndex() { return _currentValue; } - public void setSelectedIndex(int index) - { - + public void setSelectedIndex(int index) { _currentValue = index; setText(_values.get(_currentValue)); onValueChanged(_currentValue, _values.get(_currentValue)); } - public String getValue() - { - + public String getValue() { return _values.get(_currentValue); } public abstract void onValueChanged(int value, String label); - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementDualScaled.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementDualScaled.java index 3bc10d2b..f7444e7b 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementDualScaled.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementDualScaled.java @@ -3,55 +3,48 @@ package com.pahimar.repackage.cofh.lib.gui.element; import com.pahimar.repackage.cofh.lib.gui.GuiBase; import com.pahimar.repackage.cofh.lib.render.RenderHelper; -public class ElementDualScaled extends ElementBase -{ - +public class ElementDualScaled extends ElementBase { public int quantity; public int mode; public boolean background = true; - public ElementDualScaled(GuiBase gui, int posX, int posY) - { - + public ElementDualScaled(GuiBase gui, int posX, int posY) { super(gui, posX, posY); } - public ElementDualScaled setBackground(boolean background) - { - + public ElementDualScaled setBackground(boolean background) { this.background = background; return this; } - public ElementDualScaled setMode(int mode) - { - + public ElementDualScaled setMode(int mode) { this.mode = mode; return this; } - public ElementDualScaled setQuantity(int quantity) - { - + public ElementDualScaled setQuantity(int quantity) { this.quantity = quantity; return this; } @Override - public void drawBackground(int mouseX, int mouseY, float gameTicks) - { - + public void drawBackground(int mouseX, int mouseY, float gameTicks) { RenderHelper.bindTexture(texture); - if (background) - { + if (background) { drawTexturedModalRect(posX, posY, 0, 0, sizeX, sizeY); } - switch (mode) - { + switch (mode) { case 0: // vertical bottom -> top - drawTexturedModalRect(posX, posY + sizeY - quantity, sizeX, sizeY - quantity, sizeX, quantity); + drawTexturedModalRect( + posX, + posY + sizeY - quantity, + sizeX, + sizeY - quantity, + sizeX, + quantity + ); return; case 1: // horizontal left -> right @@ -59,14 +52,17 @@ public class ElementDualScaled extends ElementBase return; case 2: // horizontal right -> left - drawTexturedModalRect(posX + sizeX - quantity, posY, sizeX + sizeX - quantity, 0, quantity, sizeY); + drawTexturedModalRect( + posX + sizeX - quantity, + posY, + sizeX + sizeX - quantity, + 0, + quantity, + sizeY + ); } } @Override - public void drawForeground(int mouseX, int mouseY) - { - - } - + public void drawForeground(int mouseX, int mouseY) {} } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementListBox.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementListBox.java index 2ac5c731..8acb4db2 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementListBox.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementListBox.java @@ -1,18 +1,16 @@ package com.pahimar.repackage.cofh.lib.gui.element; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + import com.pahimar.repackage.cofh.lib.gui.GuiBase; import com.pahimar.repackage.cofh.lib.gui.GuiColor; import com.pahimar.repackage.cofh.lib.gui.element.listbox.IListBoxElement; import com.pahimar.repackage.cofh.lib.util.helpers.StringHelper; import org.lwjgl.opengl.GL11; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; - -public class ElementListBox extends ElementBase -{ - +public class ElementListBox extends ElementBase { public int borderColor = new GuiColor(120, 120, 120, 255).getColor(); public int backgroundColor = new GuiColor(0, 0, 0, 255).getColor(); public int selectedLineColor = new GuiColor(0, 0, 0, 255).getColor(); @@ -30,106 +28,76 @@ public class ElementListBox extends ElementBase private int _selectedIndex; private int scrollHoriz; - public ElementListBox(GuiBase containerScreen, int x, int y, int width, int height) - { - + public ElementListBox(GuiBase containerScreen, int x, int y, int width, int height) { super(containerScreen, x, y, width, height); } - public void add(IListBoxElement element) - { - + public void add(IListBoxElement element) { _elements.add(element); } - public void add(Collection elements) - { - + public void add(Collection elements) { _elements.addAll(elements); } - public void remove(IListBoxElement element) - { - + public void remove(IListBoxElement element) { _elements.remove(element); } - public void removeAt(int index) - { - + public void removeAt(int index) { _elements.remove(index); } - public int getInternalWidth() - { - + public int getInternalWidth() { int width = 0; - for (int i = 0; i < _elements.size(); i++) - { + for (int i = 0; i < _elements.size(); i++) { width = Math.max(_elements.get(i).getWidth(), width); } return width; } - public int getInternalHeight() - { - + public int getInternalHeight() { int height = 0; - for (int i = 0; i < _elements.size(); i++) - { + for (int i = 0; i < _elements.size(); i++) { height += _elements.get(i).getHeight(); } return height; } - public int getContentWidth() - { - + public int getContentWidth() { return sizeX - _marginLeft - _marginRight; } - public int getContentHeight() - { - + public int getContentHeight() { return sizeY - _marginTop - _marginBottom; } - public int getContentTop() - { - + public int getContentTop() { return posY + _marginTop; } - public int getContentLeft() - { - + public int getContentLeft() { return posX + _marginLeft; } - public final int getContentBottom() - { - + public final int getContentBottom() { return getContentTop() + getContentHeight(); } - public final int getContentRight() - { - + public final int getContentRight() { return getContentLeft() + getContentWidth(); } @Override - public void drawBackground(int mouseX, int mouseY, float gameTicks) - { - - drawModalRect(posX - 1, posY - 1, posX + sizeX + 1, posY + sizeY + 1, borderColor); + public void drawBackground(int mouseX, int mouseY, float gameTicks) { + drawModalRect( + posX - 1, posY - 1, posX + sizeX + 1, posY + sizeY + 1, borderColor + ); drawModalRect(posX, posY, posX + sizeX, posY + sizeY, backgroundColor); } @Override - public void drawForeground(int mouseX, int mouseY) - { - + public void drawForeground(int mouseX, int mouseY) { int heightDrawn = 0; int nextElement = _firstIndexDisplayed; @@ -138,20 +106,32 @@ public class ElementListBox extends ElementBase GL11.glEnable(GL11.GL_STENCIL_TEST); GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT); - drawStencil(getContentLeft(), getContentTop(), getContentRight(), getContentBottom(), 1); + drawStencil( + getContentLeft(), getContentTop(), getContentRight(), getContentBottom(), 1 + ); GL11.glTranslated(-scrollHoriz, 0, 0); int e = _elements.size(); - while (nextElement < e && heightDrawn <= getContentHeight()) - { - if (nextElement == _selectedIndex) - { - _elements.get(nextElement).draw(this, getContentLeft(), getContentTop() + heightDrawn, selectedLineColor, selectedTextColor); - } - else - { - _elements.get(nextElement).draw(this, getContentLeft(), getContentTop() + heightDrawn, backgroundColor, textColor); + while (nextElement < e && heightDrawn <= getContentHeight()) { + if (nextElement == _selectedIndex) { + _elements.get(nextElement) + .draw( + this, + getContentLeft(), + getContentTop() + heightDrawn, + selectedLineColor, + selectedTextColor + ); + } else { + _elements.get(nextElement) + .draw( + this, + getContentLeft(), + getContentTop() + heightDrawn, + backgroundColor, + textColor + ); } heightDrawn += _elements.get(nextElement).getHeight(); nextElement++; @@ -163,19 +143,15 @@ public class ElementListBox extends ElementBase } @Override - public boolean onMousePressed(int mouseX, int mouseY, int mouseButton) - { - + public boolean onMousePressed(int mouseX, int mouseY, int mouseButton) { int heightChecked = 0; - for (int i = _firstIndexDisplayed; i < _elements.size(); i++) - { - if (heightChecked > getContentHeight()) - { + for (int i = _firstIndexDisplayed; i < _elements.size(); i++) { + if (heightChecked > getContentHeight()) { break; } int elementHeight = _elements.get(i).getHeight(); - if (getContentTop() + heightChecked <= mouseY && getContentTop() + heightChecked + elementHeight >= mouseY) - { + if (getContentTop() + heightChecked <= mouseY + && getContentTop() + heightChecked + elementHeight >= mouseY) { setSelectedIndex(i); onElementClicked(_elements.get(i)); break; @@ -186,89 +162,63 @@ public class ElementListBox extends ElementBase } @Override - public boolean onMouseWheel(int mouseX, int mouseY, int movement) - { - - if (StringHelper.isControlKeyDown()) - { - if (movement > 0) - { + public boolean onMouseWheel(int mouseX, int mouseY, int movement) { + if (StringHelper.isControlKeyDown()) { + if (movement > 0) { scrollLeft(); - } - else if (movement < 0) - { + } else if (movement < 0) { scrollRight(); } - } - else - { - if (movement > 0) - { + } else { + if (movement > 0) { scrollUp(); - } - else if (movement < 0) - { + } else if (movement < 0) { scrollDown(); } } return true; } - public void scrollDown() - { - + public void scrollDown() { int heightDisplayed = 0; int elementsDisplayed = 0; - for (int i = _firstIndexDisplayed; i < _elements.size(); i++) - { - if (heightDisplayed + _elements.get(i).getHeight() > sizeY) - { + for (int i = _firstIndexDisplayed; i < _elements.size(); i++) { + if (heightDisplayed + _elements.get(i).getHeight() > sizeY) { break; } heightDisplayed += _elements.get(i).getHeight(); elementsDisplayed++; } - if (_firstIndexDisplayed + elementsDisplayed < _elements.size()) - { + if (_firstIndexDisplayed + elementsDisplayed < _elements.size()) { _firstIndexDisplayed++; } onScrollV(_firstIndexDisplayed); } - public void scrollUp() - { - - if (_firstIndexDisplayed > 0) - { + public void scrollUp() { + if (_firstIndexDisplayed > 0) { _firstIndexDisplayed--; } onScrollV(_firstIndexDisplayed); } - public void scrollLeft() - { - + public void scrollLeft() { scrollHoriz = Math.max(scrollHoriz - 15, 0); onScrollH(scrollHoriz); } - public void scrollRight() - { - + public void scrollRight() { scrollHoriz = Math.min(scrollHoriz + 15, getLastScrollPositionH()); onScrollH(scrollHoriz); } - public int getLastScrollPosition() - { - + public int getLastScrollPosition() { int position = _elements.size() - 1; int heightUsed = _elements.get(position).getHeight(); - while (position > 0 && heightUsed < sizeY) - { + while (position > 0 && heightUsed < sizeY) { position--; heightUsed += _elements.get(position).getHeight(); } @@ -276,95 +226,59 @@ public class ElementListBox extends ElementBase return position + 1; } - public int getLastScrollPositionH() - { - + public int getLastScrollPositionH() { return Math.max(getInternalWidth() - getContentWidth(), 0); } - public int getSelectedIndex() - { - + public int getSelectedIndex() { return _selectedIndex; } - public int getIndexOf(Object value) - { - - for (int i = 0; i < _elements.size(); i++) - { - if (_elements.get(i).getValue().equals(value)) - { + public int getIndexOf(Object value) { + for (int i = 0; i < _elements.size(); i++) { + if (_elements.get(i).getValue().equals(value)) { return i; } } return -1; } - public IListBoxElement getSelectedElement() - { - + public IListBoxElement getSelectedElement() { return _elements.get(_selectedIndex); } - public void setSelectedIndex(int index) - { - - if (index >= 0 && index < _elements.size() && index != _selectedIndex) - { + public void setSelectedIndex(int index) { + if (index >= 0 && index < _elements.size() && index != _selectedIndex) { _selectedIndex = index; onSelectionChanged(_selectedIndex, getSelectedElement()); } } - public IListBoxElement getElement(int index) - { - + public IListBoxElement getElement(int index) { return _elements.get(index); } - public int getElementCount() - { - + public int getElementCount() { return _elements.size(); } - public void scrollToV(int index) - { - - if (index >= 0 && index < _elements.size()) - { + public void scrollToV(int index) { + if (index >= 0 && index < _elements.size()) { _firstIndexDisplayed = index; } } - public void scrollToH(int index) - { - - if (index >= 0 && index <= getLastScrollPositionH()) - { + public void scrollToH(int index) { + if (index >= 0 && index <= getLastScrollPositionH()) { scrollHoriz = index; } } - protected void onElementClicked(IListBoxElement element) - { + protected void onElementClicked(IListBoxElement element) {} - } + protected void onScrollV(int newStartIndex) {} - protected void onScrollV(int newStartIndex) - { - - } - - protected void onScrollH(int newStartIndex) - { - - } - - protected void onSelectionChanged(int newIndex, IListBoxElement newElement) - { - - } + protected void onScrollH(int newStartIndex) {} + protected void onSelectionChanged(int newIndex, IListBoxElement newElement) {} } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementSimple.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementSimple.java index 3112334a..b8c43cb6 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementSimple.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementSimple.java @@ -8,39 +8,28 @@ import com.pahimar.repackage.cofh.lib.render.RenderHelper; * * @author King Lemming */ -public class ElementSimple extends ElementBase -{ - +public class ElementSimple extends ElementBase { int texU = 0; int texV = 0; - public ElementSimple(GuiBase gui, int posX, int posY) - { - + public ElementSimple(GuiBase gui, int posX, int posY) { super(gui, posX, posY); } - public ElementSimple setTextureOffsets(int u, int v) - { - + public ElementSimple setTextureOffsets(int u, int v) { texU = u; texV = v; return this; } @Override - public void drawBackground(int mouseX, int mouseY, float gameTicks) - { - + public void drawBackground(int mouseX, int mouseY, float gameTicks) { RenderHelper.bindTexture(texture); drawTexturedModalRect(posX, posY, texU, texV, sizeX, sizeY); } @Override - public void drawForeground(int mouseX, int mouseY) - { - + public void drawForeground(int mouseX, int mouseY) { return; } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementSlider.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementSlider.java index e3c5c2c9..08b5e0db 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementSlider.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementSlider.java @@ -6,8 +6,7 @@ import com.pahimar.repackage.cofh.lib.gui.GuiColor; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -public abstract class ElementSlider extends ElementBase -{ +public abstract class ElementSlider extends ElementBase { protected int _value; protected int _valueMin; protected int _valueMax; @@ -23,115 +22,127 @@ public abstract class ElementSlider extends ElementBase protected ResourceLocation hoverTexture = Textures.Gui.Elements.BUTTON_HOVER; protected ResourceLocation disabledTexture = Textures.Gui.Elements.BUTTON_DISABLED; - protected ElementSlider(GuiBase containerScreen, int x, int y, int width, int height, int maxValue) - { + protected ElementSlider( + GuiBase containerScreen, int x, int y, int width, int height, int maxValue + ) { this(containerScreen, x, y, width, height, maxValue, 0); } - protected ElementSlider(GuiBase containerScreen, int x, int y, int width, int height, int maxValue, int minValue) - { + protected ElementSlider( + GuiBase containerScreen, + int x, + int y, + int width, + int height, + int maxValue, + int minValue + ) { super(containerScreen, x, y, width, height); _valueMax = maxValue; _valueMin = minValue; } - protected ElementSlider(GuiBase containerScreen, String elementName, int x, int y, int width, int height, int maxValue, int minValue) - { + protected ElementSlider( + GuiBase containerScreen, + String elementName, + int x, + int y, + int width, + int height, + int maxValue, + int minValue + ) { super(containerScreen, x, y, width, height); this.name = elementName; _valueMax = maxValue; _valueMin = minValue; } - public ElementSlider setColor(int backgroundColor, int borderColor) - { + public ElementSlider setColor(int backgroundColor, int borderColor) { this.borderColor = borderColor; this.backgroundColor = backgroundColor; return this; } - public ElementSlider setSliderSize(int width, int height) - { + public ElementSlider setSliderSize(int width, int height) { _sliderWidth = width; _sliderHeight = height; return this; } - public int getValue() - { + public int getValue() { return this._value; } - public int getValueMin() - { + public int getValueMin() { return this._valueMin; } - public int getValueMax() - { + public int getValueMax() { return this._valueMax; } - public ElementSlider setValue(int value) - { + public ElementSlider setValue(int value) { value = Math.max(_valueMin, Math.min(_valueMax, value)); - if (value != _value) - { + if (value != _value) { _value = value; onValueChanged(_value); } return this; } - public ElementSlider setMinValue(int minValue) - { + public ElementSlider setMinValue(int minValue) { _valueMin = minValue; return this; } - public ElementSlider setMaxValue(int maxValue) - { + public ElementSlider setMaxValue(int maxValue) { _valueMax = maxValue; return this; } @Override - public void drawBackground(int mouseX, int mouseY, float gameTicks) - { - drawModalRect(posX - 1, posY - 1, posX + sizeX + 1, posY + sizeY + 1, borderColor); + public void drawBackground(int mouseX, int mouseY, float gameTicks) { + drawModalRect( + posX - 1, posY - 1, posX + sizeX + 1, posY + sizeY + 1, borderColor + ); drawModalRect(posX, posY, posX + sizeX, posY + sizeY, backgroundColor); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } - protected void drawSlider(int mouseX, int mouseY, int sliderX, int sliderY) - { + protected void drawSlider(int mouseX, int mouseY, int sliderX, int sliderY) { int sliderMidX = _sliderWidth / 2; int sliderMidY = _sliderHeight / 2; int sliderEndX = _sliderWidth - sliderMidX; int sliderEndY = _sliderHeight - sliderMidY; - if (!isEnabled()) - { + if (!isEnabled()) { gui.bindTexture(disabledTexture); - } - else if (isHovering(mouseX, mouseY)) - { + } else if (isHovering(mouseX, mouseY)) { gui.bindTexture(hoverTexture); - } - else - { + } else { gui.bindTexture(enabledTexture); } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); drawTexturedModalRect(sliderX, sliderY, 0, 0, sliderMidX, sliderMidY); - drawTexturedModalRect(sliderX, sliderY + sliderMidY, 0, 256 - sliderEndY, sliderMidX, sliderEndY); - drawTexturedModalRect(sliderX + sliderMidX, sliderY, 256 - sliderEndX, 0, sliderEndX, sliderMidY); - drawTexturedModalRect(sliderX + sliderMidX, sliderY + sliderMidY, 256 - sliderEndX, 256 - sliderEndY, sliderEndX, sliderEndY); + drawTexturedModalRect( + sliderX, sliderY + sliderMidY, 0, 256 - sliderEndY, sliderMidX, sliderEndY + ); + drawTexturedModalRect( + sliderX + sliderMidX, sliderY, 256 - sliderEndX, 0, sliderEndX, sliderMidY + ); + drawTexturedModalRect( + sliderX + sliderMidX, + sliderY + sliderMidY, + 256 - sliderEndX, + 256 - sliderEndY, + sliderEndX, + sliderEndY + ); } @Override - public void drawForeground(int mouseX, int mouseY) - { + public void drawForeground(int mouseX, int mouseY) { int sliderX = posX + getSliderX(); int sliderY = posY + getSliderY(); @@ -139,44 +150,36 @@ public abstract class ElementSlider extends ElementBase GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } - protected boolean isHovering(int x, int y) - { + protected boolean isHovering(int x, int y) { return intersectsWith(x, y); } - public int getSliderX() - { + public int getSliderX() { return 0; } - public int getSliderY() - { + public int getSliderY() { return 0; } @Override - public boolean onMousePressed(int mouseX, int mouseY, int mouseButton) - { + public boolean onMousePressed(int mouseX, int mouseY, int mouseButton) { _isDragging = mouseButton == 0; update(mouseX, mouseY); return true; } @Override - public void onMouseReleased(int mouseX, int mouseY) - { - if (_isDragging) - { + public void onMouseReleased(int mouseX, int mouseY) { + if (_isDragging) { onStopDragging(); } _isDragging = false; } @Override - public void update(int mouseX, int mouseY) - { - if (_isDragging) - { + public void update(int mouseX, int mouseY) { + if (_isDragging) { dragSlider(mouseX - posX, mouseY - posY); } } @@ -184,41 +187,32 @@ public abstract class ElementSlider extends ElementBase protected abstract void dragSlider(int x, int y); @Override - public boolean onMouseWheel(int mouseX, int mouseY, int movement) - { - if (movement > 0) - { + public boolean onMouseWheel(int mouseX, int mouseY, int movement) { + if (movement > 0) { setValue(_value - 1); - } - else if (movement < 0) - { + } else if (movement < 0) { setValue(_value + 1); } return true; } - public void onValueChanged(int value) - { + public void onValueChanged(int value) { return; } - public void onStopDragging() - { + public void onStopDragging() { return; } - public void setEnabledTexture(ResourceLocation enabledTexture) - { + public void setEnabledTexture(ResourceLocation enabledTexture) { this.enabledTexture = enabledTexture; } - public void setDisabledTexture(ResourceLocation disabledTexture) - { + public void setDisabledTexture(ResourceLocation disabledTexture) { this.disabledTexture = disabledTexture; } - public void setHoverTexture(ResourceLocation hoverTexture) - { + public void setHoverTexture(ResourceLocation hoverTexture) { this.hoverTexture = hoverTexture; } } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementTextField.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementTextField.java index 3ec6589e..03e3a6d1 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementTextField.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementTextField.java @@ -1,5 +1,7 @@ package com.pahimar.repackage.cofh.lib.gui.element; +import static org.lwjgl.opengl.GL11.*; + import com.pahimar.repackage.cofh.lib.gui.GuiBase; import com.pahimar.repackage.cofh.lib.gui.GuiColor; import com.pahimar.repackage.cofh.lib.util.helpers.MathHelper; @@ -9,11 +11,7 @@ import net.minecraft.util.ChatAllowedCharacters; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import static org.lwjgl.opengl.GL11.*; - - -public class ElementTextField extends ElementBase -{ +public class ElementTextField extends ElementBase { public int borderColor = new GuiColor(55, 55, 55).getColor(); public int backgroundColor = new GuiColor(139, 139, 139).getColor(); public int disabledColor = new GuiColor(198, 198, 198).getColor(); @@ -41,70 +39,65 @@ public class ElementTextField extends ElementBase protected boolean enableStencil = true; - public ElementTextField(GuiBase gui, int posX, int posY, int width, int height) - { + public ElementTextField(GuiBase gui, int posX, int posY, int width, int height) { this(gui, posX, posY, width, height, (short) 32); } - public ElementTextField(GuiBase gui, int posX, int posY, int width, int height, short limit) - { + public ElementTextField( + GuiBase gui, int posX, int posY, int width, int height, short limit + ) { super(gui, posX, posY, width, height); setPadding(1, 1, 1, 1); setMaxLength(limit); } - public ElementTextField(GuiBase gui, int posX, int posY, String name, int width, int height) - { + public ElementTextField( + GuiBase gui, int posX, int posY, String name, int width, int height + ) { this(gui, posX, posY, name, width, height, (short) 32); } - public ElementTextField(GuiBase gui, int posX, int posY, String name, int width, int height, short limit) - { + public ElementTextField( + GuiBase gui, int posX, int posY, String name, int width, int height, short limit + ) { super(gui, posX, posY, width, height); setName(name); setPadding(1, 1, 1, 1); setMaxLength(limit); } - public ElementTextField setTextColor(Number textColor, Number selectedTextColor) - { - if (textColor != null) - { + public ElementTextField setTextColor(Number textColor, Number selectedTextColor) { + if (textColor != null) { this.textColor = textColor.intValue(); } - if (selectedTextColor != null) - { + if (selectedTextColor != null) { this.selectedTextColor = selectedTextColor.intValue(); } return this; } - public ElementTextField setPaddingLeft(int paddingLeft) - { + public ElementTextField setPaddingLeft(int paddingLeft) { this.paddingLeft = paddingLeft; return this; } - public ElementTextField setPaddingRight(int paddingRight) - { + public ElementTextField setPaddingRight(int paddingRight) { this.paddingRight = paddingRight; return this; } - public ElementTextField setPaddingTop(int paddingTop) - { + public ElementTextField setPaddingTop(int paddingTop) { this.paddingTop = paddingTop; return this; } - public ElementTextField setPaddingBottom(int paddingBottom) - { + public ElementTextField setPaddingBottom(int paddingBottom) { this.paddingBottom = paddingBottom; return this; } - public ElementTextField setPadding(int paddingTop, int paddingRight, int paddingBottom, int paddingLeft) - { + public ElementTextField + setPadding(int paddingTop, int paddingRight, int paddingBottom, int paddingLeft) { this.paddingTop = paddingTop; this.paddingRight = paddingRight; this.paddingBottom = paddingBottom; @@ -112,133 +105,109 @@ public class ElementTextField extends ElementBase return this; } - public ElementTextField setSelectionColor(Number selectedLineColor, Number defaultCaretColor) - { - if (selectedLineColor != null) - { + public ElementTextField + setSelectionColor(Number selectedLineColor, Number defaultCaretColor) { + if (selectedLineColor != null) { this.selectedLineColor = selectedLineColor.intValue(); } - if (defaultCaretColor != null) - { + if (defaultCaretColor != null) { this.defaultCaretColor = defaultCaretColor.intValue(); } return this; } - public ElementTextField setBackgroundColor(Number backgroundColor, Number disabledColor, Number borderColor) - { - if (backgroundColor != null) - { + public ElementTextField + setBackgroundColor(Number backgroundColor, Number disabledColor, Number borderColor) { + if (backgroundColor != null) { this.backgroundColor = backgroundColor.intValue(); } - if (disabledColor != null) - { + if (disabledColor != null) { this.disabledColor = disabledColor.intValue(); } - if (borderColor != null) - { + if (borderColor != null) { this.borderColor = borderColor.intValue(); } return this; } - public ElementTextField setFocusable(boolean focusable) - { + public ElementTextField setFocusable(boolean focusable) { canFocusChange = focusable; return this; } - public ElementTextField setFocused(boolean focused) - { - if (canFocusChange) - { + public ElementTextField setFocused(boolean focused) { + if (canFocusChange) { isFocused = focused; caretCounter = 0; } return this; } - public ElementTextField setText(String text) - { + public ElementTextField setText(String text) { selectionStart = 0; selectionEnd = textLength; writeText(text); return this; } - public ElementTextField setMaxLength(short limit) - { + public ElementTextField setMaxLength(short limit) { char[] oldText = text; text = new char[limit]; textLength = Math.min(limit, textLength); - if (oldText != null) - { + if (oldText != null) { System.arraycopy(oldText, 0, text, 0, textLength); } findRenderStart(); return this; } - public int getMaxStringLength() - { + public int getMaxStringLength() { return text.length; } - public boolean isFocused() - { + public boolean isFocused() { return isEnabled() && isFocused; } - public boolean isFocusable() - { + public boolean isFocusable() { return canFocusChange; } - public int getContentWidth() - { + public int getContentWidth() { FontRenderer font = getFontRenderer(); int width = 0; - for (int i = 0; i < textLength; ++i) - { + for (int i = 0; i < textLength; ++i) { width += font.getCharWidth(text[i]); } return width; } - public int getPaddingLeft() - { + public int getPaddingLeft() { return paddingLeft; } - public int getPaddingRight() - { + public int getPaddingRight() { return paddingRight; } - public int getPaddingTop() - { + public int getPaddingTop() { return paddingTop; } - public int getPaddingBottom() - { + public int getPaddingBottom() { return paddingBottom; } - public int getVisibleWidth() - { + public int getVisibleWidth() { FontRenderer font = getFontRenderer(); int width = 0, endX = sizeX - 1; - for (int i = renderStart; i < textLength; ++i) - { + for (int i = renderStart; i < textLength; ++i) { int charW = font.getCharWidth(text[i]); - if (!enableStencil && (width + charW) > endX) - { + if (!enableStencil && (width + charW) > endX) { break; } width += charW; - if (width >= endX) - { + if (width >= endX) { width = Math.min(width, endX); break; } @@ -246,28 +215,21 @@ public class ElementTextField extends ElementBase return width; } - public String getText() - { + public String getText() { return new String(text, 0, textLength); } - public String getSelectedText() - { - - if (selectionStart != selectionEnd) - { + public String getSelectedText() { + if (selectionStart != selectionEnd) { return new String(text, selectionStart, selectionEnd); } return getText(); } - public void writeText(String text) - { + public void writeText(String text) { int i = 0; - for (int e = text.length(); i < e; ++i) - { - if (!insertCharacter(text.charAt(i))) - { + for (int e = text.length(); i < e; ++i) { + if (!insertCharacter(text.charAt(i))) { break; } } @@ -276,70 +238,48 @@ public class ElementTextField extends ElementBase onCharacterEntered(i > 0); } - public boolean isAllowedCharacter(char charTyped) - { + public boolean isAllowedCharacter(char charTyped) { return ChatAllowedCharacters.isAllowedCharacter(charTyped); } - protected boolean onEnter() - { + protected boolean onEnter() { return false; } - protected void onFocusLost() - { + protected void onFocusLost() {} - } + protected void onCharacterEntered(boolean success) {} - protected void onCharacterEntered(boolean success) - { - - } - - protected boolean insertCharacter(char charTyped) - { - - if (isAllowedCharacter(charTyped)) - { - - if (selectionStart != selectionEnd) - { - if (caret == selectionStart) - { + protected boolean insertCharacter(char charTyped) { + if (isAllowedCharacter(charTyped)) { + if (selectionStart != selectionEnd) { + if (caret == selectionStart) { ++caret; } text[selectionStart++] = charTyped; return true; } - if ((caretInsert && caret == text.length) || textLength == text.length) - { + if ((caretInsert && caret == text.length) || textLength == text.length) { return false; } - if (!caretInsert) - { - if (caret < textLength) - { + if (!caretInsert) { + if (caret < textLength) { System.arraycopy(text, caret, text, caret + 1, textLength - caret); } ++textLength; } text[caret++] = charTyped; return true; - } - else - { + } else { return true; } } - protected void findRenderStart() - { - + protected void findRenderStart() { caret = MathHelper.clampI(caret, 0, textLength); - if (caret < renderStart) - { + if (caret < renderStart) { renderStart = caret; return; } @@ -347,28 +287,23 @@ public class ElementTextField extends ElementBase FontRenderer font = getFontRenderer(); int endX = sizeX - 2; - for (int i = renderStart, width = 0; i < caret; ++i) - { + for (int i = renderStart, width = 0; i < caret; ++i) { width += font.getCharWidth(text[i]); - while (width >= endX) - { + while (width >= endX) { width -= font.getCharWidth(text[renderStart++]); - if (renderStart >= textLength) - { + if (renderStart >= textLength) { return; } } } } - protected void clearSelection() - { - - if (selectionStart != selectionEnd) - { - if (selectionEnd < textLength) - { - System.arraycopy(text, selectionEnd, text, selectionStart, textLength - selectionEnd); + protected void clearSelection() { + if (selectionStart != selectionEnd) { + if (selectionEnd < textLength) { + System.arraycopy( + text, selectionEnd, text, selectionStart, textLength - selectionEnd + ); } textLength -= selectionEnd - selectionStart; @@ -377,49 +312,43 @@ public class ElementTextField extends ElementBase } } - protected final int seekNextCaretLocation(int pos) - { - + protected final int seekNextCaretLocation(int pos) { return seekNextCaretLocation(pos, true); } - protected int seekNextCaretLocation(int pos, boolean forward) - { - + protected int seekNextCaretLocation(int pos, boolean forward) { int dir = forward ? 1 : -1; int e = forward ? textLength : 0; - if (pos == textLength) - { + if (pos == textLength) { --pos; } char prevChar = text[pos]; - while (pos != e && Character.isSpaceChar(prevChar)) - { + while (pos != e && Character.isSpaceChar(prevChar)) { prevChar = text[pos += dir]; } - if (smartCaret) - { - for (int i = pos; i != e; i += dir) - { + if (smartCaret) { + for (int i = pos; i != e; i += dir) { char curChar = text[i]; - boolean caze = Character.isUpperCase(curChar) != Character.isUpperCase(prevChar); - if (caze || Character.isSpaceChar(curChar) != Character.isSpaceChar(prevChar) || - Character.isLetterOrDigit(curChar) != Character.isLetterOrDigit(prevChar)) - { - if ((pos + dir) != i || !Character.isLetterOrDigit(curChar)) - { - return i + (smartCaretCase && caze && Character.isUpperCase(prevChar) ? -dir : 0); + boolean caze + = Character.isUpperCase(curChar) != Character.isUpperCase(prevChar); + if (caze + || Character.isSpaceChar(curChar) != Character.isSpaceChar(prevChar) + || Character.isLetterOrDigit(curChar) + != Character.isLetterOrDigit(prevChar)) { + if ((pos + dir) != i || !Character.isLetterOrDigit(curChar)) { + return i + + (smartCaretCase && caze && Character.isUpperCase(prevChar) + ? -dir + : 0); } } prevChar = curChar; } } - for (int i = pos; i != e; i += dir) - { + for (int i = pos; i != e; i += dir) { char curChar = text[i]; - if (Character.isSpaceChar(curChar) != Character.isSpaceChar(prevChar)) - { + if (Character.isSpaceChar(curChar) != Character.isSpaceChar(prevChar)) { return i; } } @@ -427,29 +356,24 @@ public class ElementTextField extends ElementBase } @Override - public boolean onKeyTyped(char charTyped, int keyTyped) - { - if (!isFocused()) - { + public boolean onKeyTyped(char charTyped, int keyTyped) { + if (!isFocused()) { return false; } - switch (charTyped) - { + switch (charTyped) { case 1: // ^A selectionEnd = caret = textLength; selectionStart = 0; findRenderStart(); return true; case 3: // ^C - if (selectionStart != selectionEnd) - { + if (selectionStart != selectionEnd) { GuiScreen.setClipboardString(getSelectedText()); } return true; case 24: // ^X - if (selectionStart != selectionEnd) - { + if (selectionStart != selectionEnd) { GuiScreen.setClipboardString(getSelectedText()); clearSelection(); } @@ -460,8 +384,7 @@ public class ElementTextField extends ElementBase return true; default: - switch (keyTyped) - { + switch (keyTyped) { case Keyboard.KEY_ESCAPE: setFocused(false); return !isFocused(); @@ -469,12 +392,9 @@ public class ElementTextField extends ElementBase case Keyboard.KEY_NUMPADENTER: return onEnter(); case Keyboard.KEY_INSERT: - if (GuiScreen.isShiftKeyDown()) - { + if (GuiScreen.isShiftKeyDown()) { writeText(GuiScreen.getClipboardString()); - } - else - { + } else { caretInsert = !caretInsert; } @@ -484,29 +404,23 @@ public class ElementTextField extends ElementBase return true; case Keyboard.KEY_DELETE: // delete - if (!GuiScreen.isShiftKeyDown()) - { - if (selectionStart != selectionEnd) - { + if (!GuiScreen.isShiftKeyDown()) { + if (selectionStart != selectionEnd) { clearSelection(); - } - else if (GuiScreen.isCtrlKeyDown()) - { + } else if (GuiScreen.isCtrlKeyDown()) { int size = seekNextCaretLocation(caret, true) - caret; selectionStart = caret; selectionEnd = caret + size; clearSelection(); - } - else - { - if (caret < textLength && textLength > 0) - { + } else { + if (caret < textLength && textLength > 0) { --textLength; - System.arraycopy(text, caret + 1, text, caret, textLength - caret); + System.arraycopy( + text, caret + 1, text, caret, textLength - caret + ); } } - if (caret <= renderStart) - { + if (caret <= renderStart) { renderStart = MathHelper.clampI(caret - 3, 0, textLength); } findRenderStart(); @@ -515,60 +429,47 @@ public class ElementTextField extends ElementBase } // continue.. (shift+delete = backspace) case Keyboard.KEY_BACK: // backspace - if (selectionStart != selectionEnd) - { + if (selectionStart != selectionEnd) { clearSelection(); - } - else if (GuiScreen.isCtrlKeyDown()) - { + } else if (GuiScreen.isCtrlKeyDown()) { int size = seekNextCaretLocation(caret, false) - caret; selectionStart = caret + size; selectionEnd = caret; clearSelection(); - } - else - { - if (caret > 0 && textLength > 0) - { + } else { + if (caret > 0 && textLength > 0) { --caret; - System.arraycopy(text, caret + 1, text, caret, textLength - caret); + System.arraycopy( + text, caret + 1, text, caret, textLength - caret + ); --textLength; } } - if (caret <= renderStart) - { + if (caret <= renderStart) { renderStart = MathHelper.clampI(caret - 3, 0, textLength); } findRenderStart(); onCharacterEntered(true); return true; case Keyboard.KEY_HOME: // home - if (GuiScreen.isShiftKeyDown()) - { - if (caret > selectionEnd) - { + if (GuiScreen.isShiftKeyDown()) { + if (caret > selectionEnd) { selectionEnd = selectionStart; } selectionStart = 0; - } - else - { + } else { selectionStart = selectionEnd = 0; } renderStart = caret = 0; return true; case Keyboard.KEY_END: // end - if (GuiScreen.isShiftKeyDown()) - { - if (caret < selectionStart) - { + if (GuiScreen.isShiftKeyDown()) { + if (caret < selectionStart) { selectionStart = selectionEnd; } selectionEnd = textLength; - } - else - { + } else { selectionStart = selectionEnd = textLength; } caret = textLength; @@ -578,58 +479,50 @@ public class ElementTextField extends ElementBase case Keyboard.KEY_LEFT: // left arrow case Keyboard.KEY_RIGHT: // right arrow int size = keyTyped == 203 ? -1 : 1; - if (GuiScreen.isCtrlKeyDown()) - { + if (GuiScreen.isCtrlKeyDown()) { size = seekNextCaretLocation(caret, keyTyped == 205) - caret; } - if (selectionStart == selectionEnd || !GuiScreen.isShiftKeyDown()) - { + if (selectionStart == selectionEnd + || !GuiScreen.isShiftKeyDown()) { selectionStart = selectionEnd = caret; } - { - int t = caret; - caret = MathHelper.clampI(caret + size, 0, textLength); - size = caret - t; - } - findRenderStart(); - - if (GuiScreen.isShiftKeyDown()) - { - if (caret == selectionStart + size) { - selectionStart = caret; + int t = caret; + caret = MathHelper.clampI(caret + size, 0, textLength); + size = caret - t; } - else if (caret == selectionEnd + size) - { - selectionEnd = caret; - } - // this logic is 'broken' in that the selection doesn't wrap - // such that a|bc|def becomes abc|def| but it will highlight - // the rest of the word the caret is on i.e., a|bc|def -> a|bcdef| - // i don't know that it matters (home+end exhibit the former) + findRenderStart(); - if (selectionStart > selectionEnd) - { - int t = selectionStart; - selectionStart = selectionEnd; - selectionEnd = t; - } - } + if (GuiScreen.isShiftKeyDown()) { + if (caret == selectionStart + size) { + selectionStart = caret; + } else if (caret == selectionEnd + size) { + selectionEnd = caret; + } + // this logic is 'broken' in that the selection doesn't wrap + // such that a|bc|def becomes abc|def| but it will highlight + // the rest of the word the caret is on i.e., a|bc|def -> + // a|bcdef| i don't know that it matters (home+end exhibit the + // former) - return true; + if (selectionStart > selectionEnd) { + int t = selectionStart; + selectionStart = selectionEnd; + selectionEnd = t; + } + } + + return true; default: - if (isAllowedCharacter(charTyped)) - { + if (isAllowedCharacter(charTyped)) { boolean typed = insertCharacter(charTyped); clearSelection(); findRenderStart(); onCharacterEntered(typed); return true; - } - else - { + } else { return false; } } @@ -637,25 +530,19 @@ public class ElementTextField extends ElementBase } @Override - public boolean onMousePressed(int mouseX, int mouseY, int mouseButton) - { - + public boolean onMousePressed(int mouseX, int mouseY, int mouseButton) { selecting = mouseButton == 0; - l: - if (selecting) - { - if (textLength == 0) - { + l: + if (selecting) { + if (textLength == 0) { selectionStart = selectionEnd = caret = 0; break l; } FontRenderer font = getFontRenderer(); int pos = mouseX - posX - 1; - for (int i = renderStart, width = 0; ; ) - { + for (int i = renderStart, width = 0;;) { int charW = font.getCharWidth(text[i]); - if ((width += charW) > pos || ++i >= textLength) - { + if ((width += charW) > pos || ++i >= textLength) { selectionStart = selectionEnd = caret = i; break; } @@ -667,9 +554,7 @@ public class ElementTextField extends ElementBase } @Override - public void update(int mouseX, int mouseY) - { - + public void update(int mouseX, int mouseY) { ++caretCounter; //if (selecting) { // FontRenderer font = getFontRenderer(); @@ -680,15 +565,11 @@ public class ElementTextField extends ElementBase } @Override - public void onMouseReleased(int mouseX, int mouseY) - { - - if (!selecting) - { + public void onMouseReleased(int mouseX, int mouseY) { + if (!selecting) { boolean focus = isFocused(); setFocused(false); - if (focus && !isFocused()) - { + if (focus && !isFocused()) { onFocusLost(); } } @@ -696,19 +577,22 @@ public class ElementTextField extends ElementBase } @Override - public void drawBackground(int mouseX, int mouseY, float gameTicks) - { - - drawModalRect(posX - 1, posY - 1, posX + sizeX + 1, posY + sizeY + 1, borderColor); - drawModalRect(posX, posY, posX + sizeX, posY + sizeY, isEnabled() ? backgroundColor : disabledColor); + public void drawBackground(int mouseX, int mouseY, float gameTicks) { + drawModalRect( + posX - 1, posY - 1, posX + sizeX + 1, posY + sizeY + 1, borderColor + ); + drawModalRect( + posX, + posY, + posX + sizeX, + posY + sizeY, + isEnabled() ? backgroundColor : disabledColor + ); } @Override - public void drawForeground(int mouseX, int mouseY) - { - - if (enableStencil) - { + public void drawForeground(int mouseX, int mouseY) { + if (enableStencil) { glEnable(GL_STENCIL_TEST); glClear(GL_STENCIL_BUFFER_BIT); drawStencil(posX + 1, posY + 1, posX + sizeX - 1, posY + sizeY - 1, 1); @@ -716,66 +600,74 @@ public class ElementTextField extends ElementBase FontRenderer font = getFontRenderer(); char[] text = this.text; - int startX = posX + paddingLeft, endX = sizeX - paddingRight, startY = posY + paddingTop, endY = startY + font.FONT_HEIGHT + paddingBottom; - for (int i = renderStart, width = 0; i <= textLength; ++i) - { + int startX = posX + paddingLeft, endX = sizeX - paddingRight, + startY = posY + paddingTop, endY = startY + font.FONT_HEIGHT + paddingBottom; + for (int i = renderStart, width = 0; i <= textLength; ++i) { boolean end = i == textLength; int charW = 2; - if (!end) - { + if (!end) { charW = font.getCharWidth(text[i]); - if (!enableStencil && (width + charW) > endX) - { + if (!enableStencil && (width + charW) > endX) { break; } } boolean drawCaret = i == caret && (caretCounter &= 31) < 16 && isFocused(); - if (drawCaret) - { + if (drawCaret) { int caretEnd = width + 2; - if (caretInsert) - { + if (caretInsert) { caretEnd = width + charW; } - drawModalRect(startX + width, startY - 1, startX + caretEnd, endY, (0xFF000000 & defaultCaretColor) | (~defaultCaretColor & 0xFFFFFF)); + drawModalRect( + startX + width, + startY - 1, + startX + caretEnd, + endY, + (0xFF000000 & defaultCaretColor) | (~defaultCaretColor & 0xFFFFFF) + ); } - if (!end) - { + if (!end) { boolean selected = i >= selectionStart & i < selectionEnd; - if (selected) - { - drawModalRect(startX + width, startY, startX + width + charW, endY, selectedLineColor); + if (selected) { + drawModalRect( + startX + width, + startY, + startX + width + charW, + endY, + selectedLineColor + ); } - font.drawStringWithShadow(String.valueOf(text[i]), startX + width, startY, selected ? selectedTextColor : textColor); + font.drawStringWithShadow( + String.valueOf(text[i]), + startX + width, + startY, + selected ? selectedTextColor : textColor + ); } - if (drawCaret) - { + if (drawCaret) { int caretEnd = width + 2; - if (caretInsert) - { + if (caretInsert) { caretEnd = width + charW; } GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ZERO); - gui.drawSizedModalRect(startX + width, startY - 1, startX + caretEnd, endY, -1); + gui.drawSizedModalRect( + startX + width, startY - 1, startX + caretEnd, endY, -1 + ); GL11.glDisable(GL11.GL_BLEND); } width += charW; - if (width > endX) - { + if (width > endX) { break; } } - if (enableStencil) - { + if (enableStencil) { glDisable(GL_STENCIL_TEST); } } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementTextFieldFiltered.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementTextFieldFiltered.java index c1781432..aa7c7bff 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementTextFieldFiltered.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementTextFieldFiltered.java @@ -1,26 +1,25 @@ package com.pahimar.repackage.cofh.lib.gui.element; -import com.pahimar.repackage.cofh.lib.gui.GuiBase; -import com.pahimar.repackage.cofh.lib.util.CharacterSingleton; - import java.util.regex.Matcher; import java.util.regex.Pattern; -public class ElementTextFieldFiltered extends ElementTextField -{ +import com.pahimar.repackage.cofh.lib.gui.GuiBase; +import com.pahimar.repackage.cofh.lib.util.CharacterSingleton; + +public class ElementTextFieldFiltered extends ElementTextField { protected boolean includeVanilla = true; protected CharacterSingleton seq = new CharacterSingleton(); protected Matcher filter; - public ElementTextFieldFiltered(GuiBase gui, int posX, int posY, int width, int height) - { - + public ElementTextFieldFiltered( + GuiBase gui, int posX, int posY, int width, int height + ) { super(gui, posX, posY, width, height); } - public ElementTextFieldFiltered(GuiBase gui, int posX, int posY, int width, int height, short limit) - { - + public ElementTextFieldFiltered( + GuiBase gui, int posX, int posY, int width, int height, short limit + ) { super(gui, posX, posY, width, height, limit); } @@ -29,21 +28,16 @@ public class ElementTextFieldFiltered extends ElementTextField * @param includeVanilla Include vanilla disallowed characters * @return this */ - public ElementTextFieldFiltered setFilter(Pattern pattern, boolean includeVanilla) - { - + public ElementTextFieldFiltered setFilter(Pattern pattern, boolean includeVanilla) { filter = pattern.matcher(seq); this.includeVanilla = includeVanilla; return this; } @Override - public boolean isAllowedCharacter(char charTyped) - { - + public boolean isAllowedCharacter(char charTyped) { seq.character = charTyped; - return (!includeVanilla || super.isAllowedCharacter(charTyped)) && (filter == null || filter.reset().matches()); + return (!includeVanilla || super.isAllowedCharacter(charTyped)) + && (filter == null || filter.reset().matches()); } - } - diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementTextFieldLimited.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementTextFieldLimited.java index 50ee1921..e8740ec3 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementTextFieldLimited.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/ElementTextFieldLimited.java @@ -2,21 +2,19 @@ package com.pahimar.repackage.cofh.lib.gui.element; import com.pahimar.repackage.cofh.lib.gui.GuiBase; -public class ElementTextFieldLimited extends ElementTextField -{ - +public class ElementTextFieldLimited extends ElementTextField { protected boolean includeVanilla = true; protected String filter; - public ElementTextFieldLimited(GuiBase gui, int posX, int posY, int width, int height) - { - + public ElementTextFieldLimited( + GuiBase gui, int posX, int posY, int width, int height + ) { super(gui, posX, posY, width, height); } - public ElementTextFieldLimited(GuiBase gui, int posX, int posY, int width, int height, short limit) - { - + public ElementTextFieldLimited( + GuiBase gui, int posX, int posY, int width, int height, short limit + ) { super(gui, posX, posY, width, height, limit); } @@ -25,20 +23,15 @@ public class ElementTextFieldLimited extends ElementTextField * @param includeVanilla Include vanilla disallowed characters * @return this */ - public ElementTextFieldLimited setFilter(String pattern, boolean includeVanilla) - { - + public ElementTextFieldLimited setFilter(String pattern, boolean includeVanilla) { filter = pattern; this.includeVanilla = includeVanilla; return this; } @Override - public boolean isAllowedCharacter(char charTyped) - { - - return (!includeVanilla || super.isAllowedCharacter(charTyped)) && (filter == null || filter.indexOf(charTyped) >= 0); + public boolean isAllowedCharacter(char charTyped) { + return (!includeVanilla || super.isAllowedCharacter(charTyped)) + && (filter == null || filter.indexOf(charTyped) >= 0); } - } - diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/TabBase.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/TabBase.java index 8588e394..64d3c3d3 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/TabBase.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/TabBase.java @@ -9,13 +9,12 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; /** - * Base class for a tab element. Has self-contained rendering methods and a link back to the {@link GuiBase} it is a part of. + * Base class for a tab element. Has self-contained rendering methods and a link back to + * the {@link GuiBase} it is a part of. * * @author King Lemming */ -public abstract class TabBase extends ElementBase -{ - +public abstract class TabBase extends ElementBase { public static int tabExpandSpeed = 8; public static final int LEFT = 0; @@ -44,112 +43,79 @@ public abstract class TabBase extends ElementBase public int maxHeight = 22; public int currentHeight = minHeight; - public static final ResourceLocation DEFAULT_TEXTURE_LEFT = new ResourceLocation(GuiProps.PATH_ELEMENTS + "Tab_Left.png"); - public static final ResourceLocation DEFAULT_TEXTURE_RIGHT = new ResourceLocation(GuiProps.PATH_ELEMENTS + "Tab_Right.png"); - - public TabBase(GuiBase gui) - { + public static final ResourceLocation DEFAULT_TEXTURE_LEFT + = new ResourceLocation(GuiProps.PATH_ELEMENTS + "Tab_Left.png"); + public static final ResourceLocation DEFAULT_TEXTURE_RIGHT + = new ResourceLocation(GuiProps.PATH_ELEMENTS + "Tab_Right.png"); + public TabBase(GuiBase gui) { super(gui, 0, 0); texture = DEFAULT_TEXTURE_RIGHT; } - public TabBase(GuiBase gui, int side) - { - + public TabBase(GuiBase gui, int side) { super(gui, 0, 0); this.side = side; - if (side == LEFT) - { + if (side == LEFT) { texture = DEFAULT_TEXTURE_LEFT; - } - else - { + } else { texture = DEFAULT_TEXTURE_RIGHT; } } - public TabBase setOffsets(int x, int y) - { - + public TabBase setOffsets(int x, int y) { offsetX = x; offsetY = y; return this; } - public void draw(int x, int y) - { - + public void draw(int x, int y) { posX = x + offsetX; posY = y + offsetY; draw(); } - public void draw() - { - + public void draw() { return; } @Override - public void drawBackground(int mouseX, int mouseY, float gameTicks) - { - - } + public void drawBackground(int mouseX, int mouseY, float gameTicks) {} @Override - public void drawForeground(int mouseX, int mouseY) - { - - } + public void drawForeground(int mouseX, int mouseY) {} @Override - public void update() - { - - if (open && currentWidth < maxWidth) - { + public void update() { + if (open && currentWidth < maxWidth) { currentWidth += tabExpandSpeed; - } - else if (!open && currentWidth > minWidth) - { + } else if (!open && currentWidth > minWidth) { currentWidth -= tabExpandSpeed; } - if (currentWidth > maxWidth) - { + if (currentWidth > maxWidth) { currentWidth = maxWidth; - } - else if (currentWidth < minWidth) - { + } else if (currentWidth < minWidth) { currentWidth = minWidth; } - if (open && currentHeight < maxHeight) - { + if (open && currentHeight < maxHeight) { currentHeight += tabExpandSpeed; - } - else if (!open && currentHeight > minHeight) - { + } else if (!open && currentHeight > minHeight) { currentHeight -= tabExpandSpeed; } - if (currentHeight > maxHeight) - { + if (currentHeight > maxHeight) { currentHeight = maxHeight; - } - else if (currentHeight < minHeight) - { + } else if (currentHeight < minHeight) { currentHeight = minHeight; } - if (!fullyOpen && open && currentWidth == maxWidth && currentHeight == maxHeight) - { + if (!fullyOpen && open && currentWidth == maxWidth + && currentHeight == maxHeight) { setFullyOpen(); } } - protected void drawBackground() - { - + protected void drawBackground() { float colorR = (backgroundColor >> 16 & 255) / 255.0F; float colorG = (backgroundColor >> 8 & 255) / 255.0F; float colorB = (backgroundColor & 255) / 255.0F; @@ -160,132 +126,113 @@ public abstract class TabBase extends ElementBase int xPosition = posX(); - gui.drawTexturedModalRect(xPosition, posY + 4, 0, 256 - currentHeight + 4, 4, currentHeight - 4); - gui.drawTexturedModalRect(xPosition + 4, posY, 256 - currentWidth + 4, 0, currentWidth - 4, 4); + gui.drawTexturedModalRect( + xPosition, posY + 4, 0, 256 - currentHeight + 4, 4, currentHeight - 4 + ); + gui.drawTexturedModalRect( + xPosition + 4, posY, 256 - currentWidth + 4, 0, currentWidth - 4, 4 + ); gui.drawTexturedModalRect(xPosition, posY, 0, 0, 4, 4); - gui.drawTexturedModalRect(xPosition + 4, posY + 4, 256 - currentWidth + 4, 256 - currentHeight + 4, currentWidth - 4, currentHeight - 4); + gui.drawTexturedModalRect( + xPosition + 4, + posY + 4, + 256 - currentWidth + 4, + 256 - currentHeight + 4, + currentWidth - 4, + currentHeight - 4 + ); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); } - protected void drawTabIcon(String iconName) - { - + protected void drawTabIcon(String iconName) { gui.drawIcon(iconName, posXOffset(), posY + 3, 1); } /** * Shortcut to correct for the proper X position. */ - protected int posX() - { - - if (side == LEFT) - { + protected int posX() { + if (side == LEFT) { return posX - currentWidth; } return posX; } /** - * Corrects for shadowing differences in tabs to ensure that they always look nice - used in font rendering, typically. + * Corrects for shadowing differences in tabs to ensure that they always look nice - + * used in font rendering, typically. */ - protected int posXOffset() - { - + protected int posXOffset() { return posX() + sideOffset(); } - protected int sideOffset() - { - + protected int sideOffset() { return (side == LEFT ? 4 : 2); } - public boolean intersectsWith(int mouseX, int mouseY, int shiftX, int shiftY) - { - + public boolean intersectsWith(int mouseX, int mouseY, int shiftX, int shiftY) { shiftX += offsetX; shiftY += offsetY; - if (side == LEFT) - { - if (mouseX <= shiftX && mouseX >= shiftX - currentWidth && mouseY >= shiftY && mouseY <= shiftY + currentHeight) - { + if (side == LEFT) { + if (mouseX <= shiftX && mouseX >= shiftX - currentWidth && mouseY >= shiftY + && mouseY <= shiftY + currentHeight) { return true; } - } - else if (mouseX >= shiftX && mouseX <= shiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + currentHeight) - { + } else if (mouseX >= shiftX && mouseX <= shiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + currentHeight) { return true; } return false; } - public boolean isFullyOpened() - { - + public boolean isFullyOpened() { return fullyOpen; } - public void setCurrentShift(int x, int y) - { - + public void setCurrentShift(int x, int y) { currentShiftX = x + offsetX; currentShiftY = y + offsetY; } - public void setFullyOpen() - { - + public void setFullyOpen() { open = true; currentWidth = maxWidth; currentHeight = maxHeight; fullyOpen = true; } - public void toggleOpen() - { - - if (open) - { + public void toggleOpen() { + if (open) { open = false; - if (side == LEFT) - { + if (side == LEFT) { TabTracker.setOpenedLeftTab(null); - } - else - { + } else { TabTracker.setOpenedRightTab(null); } fullyOpen = false; - } - else - { + } else { open = true; - if (side == LEFT) - { + if (side == LEFT) { TabTracker.setOpenedLeftTab(this.getClass()); - } - else - { + } else { TabTracker.setOpenedRightTab(this.getClass()); } } } - public Rectangle4i getBounds() - { - - if (isVisible()) - { - return new Rectangle4i(posX() + gui.getGuiLeft(), posY + gui.getGuiTop(), currentWidth, currentHeight); + public Rectangle4i getBounds() { + if (isVisible()) { + return new Rectangle4i( + posX() + gui.getGuiLeft(), + posY + gui.getGuiTop(), + currentWidth, + currentHeight + ); + } else { + return new Rectangle4i( + posX() + gui.getGuiLeft(), posY + gui.getGuiTop(), 0, 0 + ); } - else - { - return new Rectangle4i(posX() + gui.getGuiLeft(), posY + gui.getGuiTop(), 0, 0); - } - } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/listbox/IListBoxElement.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/listbox/IListBoxElement.java index 6a355ba6..cec454cd 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/listbox/IListBoxElement.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/listbox/IListBoxElement.java @@ -2,9 +2,7 @@ package com.pahimar.repackage.cofh.lib.gui.element.listbox; import com.pahimar.repackage.cofh.lib.gui.element.ElementListBox; -public interface IListBoxElement -{ - +public interface IListBoxElement { public int getHeight(); public int getWidth(); diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/listbox/ListBoxElementText.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/listbox/ListBoxElementText.java index 6dd2cb9f..c754bd34 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/listbox/ListBoxElementText.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/listbox/ListBoxElementText.java @@ -3,43 +3,30 @@ package com.pahimar.repackage.cofh.lib.gui.element.listbox; import com.pahimar.repackage.cofh.lib.gui.element.ElementListBox; import net.minecraft.client.Minecraft; -public class ListBoxElementText implements IListBoxElement -{ - +public class ListBoxElementText implements IListBoxElement { private final String _text; - public ListBoxElementText(String text) - { - + public ListBoxElementText(String text) { _text = text; } @Override - public Object getValue() - { - + public Object getValue() { return _text; } @Override - public int getHeight() - { - + public int getHeight() { return 10; } @Override - public int getWidth() - { - + public int getWidth() { return Minecraft.getMinecraft().fontRenderer.getStringWidth(_text); } @Override - public void draw(ElementListBox listBox, int x, int y, int backColor, int textColor) - { - + public void draw(ElementListBox listBox, int x, int y, int backColor, int textColor) { listBox.getFontRenderer().drawStringWithShadow(_text, x, y, textColor); } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/listbox/SliderHorizontal.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/listbox/SliderHorizontal.java index f53b84da..abfa3064 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/listbox/SliderHorizontal.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/listbox/SliderHorizontal.java @@ -3,36 +3,36 @@ package com.pahimar.repackage.cofh.lib.gui.element.listbox; import com.pahimar.repackage.cofh.lib.gui.GuiBase; import com.pahimar.repackage.cofh.lib.gui.element.ElementSlider; -public class SliderHorizontal extends ElementSlider -{ - - public SliderHorizontal(GuiBase containerScreen, int x, int y, int width, int height, int maxValue) - { - +public class SliderHorizontal extends ElementSlider { + public SliderHorizontal( + GuiBase containerScreen, int x, int y, int width, int height, int maxValue + ) { this(containerScreen, x, y, width, height, maxValue, 0); } - public SliderHorizontal(GuiBase containerScreen, int x, int y, int width, int height, int maxValue, int minValue) - { - + public SliderHorizontal( + GuiBase containerScreen, + int x, + int y, + int width, + int height, + int maxValue, + int minValue + ) { super(containerScreen, x, y, width, height, maxValue, minValue); int dist = maxValue - minValue; setSliderSize(dist <= 0 ? width : Math.max(width / ++dist, 9), height); } @Override - public int getSliderX() - { - + public int getSliderX() { int dist = _valueMax - _valueMin; int maxPos = sizeX - _sliderWidth; return Math.min(dist == 0 ? 0 : maxPos * (_value - _valueMin) / dist, maxPos); } @Override - public void dragSlider(int v, int y) - { - + public void dragSlider(int v, int y) { v += Math.round(_sliderWidth * (v / (float) sizeX) + (_sliderWidth * 0.25f)); setValue(_valueMin + ((_valueMax - _valueMin) * v / sizeX)); } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/listbox/SliderVertical.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/listbox/SliderVertical.java index 6558d975..3ed481b7 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/listbox/SliderVertical.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/element/listbox/SliderVertical.java @@ -3,36 +3,36 @@ package com.pahimar.repackage.cofh.lib.gui.element.listbox; import com.pahimar.repackage.cofh.lib.gui.GuiBase; import com.pahimar.repackage.cofh.lib.gui.element.ElementSlider; -public class SliderVertical extends ElementSlider -{ - - public SliderVertical(GuiBase containerScreen, int x, int y, int width, int height, int maxValue) - { - +public class SliderVertical extends ElementSlider { + public SliderVertical( + GuiBase containerScreen, int x, int y, int width, int height, int maxValue + ) { this(containerScreen, x, y, width, height, maxValue, 0); } - public SliderVertical(GuiBase containerScreen, int x, int y, int width, int height, int maxValue, int minValue) - { - + public SliderVertical( + GuiBase containerScreen, + int x, + int y, + int width, + int height, + int maxValue, + int minValue + ) { super(containerScreen, x, y, width, height, maxValue, minValue); int dist = maxValue - minValue; setSliderSize(width, dist <= 0 ? height : Math.max(height / ++dist, 9)); } @Override - public int getSliderY() - { - + public int getSliderY() { int dist = _valueMax - _valueMin; int maxPos = sizeY - _sliderHeight; return Math.min(dist == 0 ? 0 : maxPos * (_value - _valueMin) / dist, maxPos); } @Override - public void dragSlider(int x, int v) - { - + public void dragSlider(int x, int v) { v += Math.round(_sliderHeight * (v / (float) sizeY) + (_sliderHeight * 0.25f)); setValue(_valueMin + ((_valueMax - _valueMin) * v / sizeY)); } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/ISlotValidator.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/ISlotValidator.java index f7af4478..02e64fc2 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/ISlotValidator.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/ISlotValidator.java @@ -7,12 +7,9 @@ import net.minecraft.item.ItemStack; * * @author King Lemming */ -public interface ISlotValidator -{ - +public interface ISlotValidator { /** * Essentially a passthrough so an arbitrary criterion can be checked against. */ boolean isItemValid(ItemStack stack); - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotAcceptAssignable.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotAcceptAssignable.java index d2638ace..39d24215 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotAcceptAssignable.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotAcceptAssignable.java @@ -8,23 +8,18 @@ import net.minecraft.item.ItemStack; /** * Slot that will only accept ItemStacks whose items are a subclass of the given class. */ -public class SlotAcceptAssignable extends Slot -{ - +public class SlotAcceptAssignable extends Slot { protected Class clazz; - public SlotAcceptAssignable(IInventory inventory, int index, int x, int y, Class c) - { - + public SlotAcceptAssignable( + IInventory inventory, int index, int x, int y, Class c + ) { super(inventory, index, x, y); clazz = c; } @Override - public boolean isItemValid(ItemStack stack) - { - + public boolean isItemValid(ItemStack stack) { return stack != null && clazz.isInstance(stack.getItem()); } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotAcceptInsertable.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotAcceptInsertable.java index b77dc48f..9767853e 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotAcceptInsertable.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotAcceptInsertable.java @@ -5,37 +5,28 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; /** - * Slot that will only accept ItemStacks when the IInventory returns true from isItemValidForSlot. - *

    - * If an ISidedInventory, canInsertItem (from side 6 (UNKNOWN)) must also return true. + * Slot that will only accept ItemStacks when the IInventory returns true from + * isItemValidForSlot.

    If an ISidedInventory, canInsertItem (from side 6 (UNKNOWN)) + * must also return true. */ -public class SlotAcceptInsertable extends SlotAcceptValid -{ - +public class SlotAcceptInsertable extends SlotAcceptValid { protected ISidedInventory sidedInv; - public SlotAcceptInsertable(IInventory inventory, int index, int x, int y) - { - + public SlotAcceptInsertable(IInventory inventory, int index, int x, int y) { super(inventory, index, x, y); - if (inventory instanceof ISidedInventory) - { + if (inventory instanceof ISidedInventory) { sidedInv = (ISidedInventory) inventory; - } - else - { + } else { sidedInv = null; } } @Override - public boolean isItemValid(ItemStack stack) - { - + public boolean isItemValid(ItemStack stack) { boolean valid = super.isItemValid(stack); - return valid && sidedInv != null ? sidedInv.canInsertItem(slotNumber, stack, 6) : valid; + return valid && sidedInv != null ? sidedInv.canInsertItem(slotNumber, stack, 6) + : valid; } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotAcceptValid.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotAcceptValid.java index 4b531a13..4910952d 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotAcceptValid.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotAcceptValid.java @@ -5,22 +5,16 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; /** - * Slot that will only accept ItemStacks when the IInventory returns true from isItemValidForSlot. + * Slot that will only accept ItemStacks when the IInventory returns true from + * isItemValidForSlot. */ -public class SlotAcceptValid extends Slot -{ - - public SlotAcceptValid(IInventory inventory, int index, int x, int y) - { - +public class SlotAcceptValid extends Slot { + public SlotAcceptValid(IInventory inventory, int index, int x, int y) { super(inventory, index, x, y); } @Override - public boolean isItemValid(ItemStack stack) - { - + public boolean isItemValid(ItemStack stack) { return stack != null && this.inventory.isItemValidForSlot(this.slotNumber, stack); } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotCraftingLocked.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotCraftingLocked.java index b6dee496..ed53f47e 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotCraftingLocked.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotCraftingLocked.java @@ -10,27 +10,25 @@ import net.minecraft.item.ItemStack; * * @author King Lemming */ -public class SlotCraftingLocked extends SlotCrafting -{ - - public SlotCraftingLocked(EntityPlayer player, IInventory craftMatrix, IInventory inventory, int index, int x, int y) - { - +public class SlotCraftingLocked extends SlotCrafting { + public SlotCraftingLocked( + EntityPlayer player, + IInventory craftMatrix, + IInventory inventory, + int index, + int x, + int y + ) { super(player, craftMatrix, inventory, index, x, y); } @Override - public boolean isItemValid(ItemStack stack) - { - + public boolean isItemValid(ItemStack stack) { return false; } @Override - public boolean canTakeStack(EntityPlayer player) - { - + public boolean canTakeStack(EntityPlayer player) { return false; } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotFalseCopy.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotFalseCopy.java index 02c570e3..cd4cd301 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotFalseCopy.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotFalseCopy.java @@ -6,46 +6,35 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; /** - * Slot which copies an ItemStack when clicked on, does not decrement the ItemStack on the cursor. + * Slot which copies an ItemStack when clicked on, does not decrement the ItemStack on the + * cursor. * * @author King Lemming */ -public class SlotFalseCopy extends Slot -{ - +public class SlotFalseCopy extends Slot { public int slotIndex = 0; - public SlotFalseCopy(IInventory inventory, int index, int x, int y) - { - + public SlotFalseCopy(IInventory inventory, int index, int x, int y) { super(inventory, index, x, y); slotIndex = index; } @Override - public boolean canTakeStack(EntityPlayer player) - { - + public boolean canTakeStack(EntityPlayer player) { return false; } @Override - public boolean isItemValid(ItemStack stack) - { - + public boolean isItemValid(ItemStack stack) { return true; } @Override - public void putStack(ItemStack stack) - { - - if (stack != null) - { + public void putStack(ItemStack stack) { + if (stack != null) { stack.stackSize = 1; } this.inventory.setInventorySlotContents(this.slotIndex, stack); this.onSlotChanged(); } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotInvisible.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotInvisible.java index 3c2e1d2a..958b4a78 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotInvisible.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotInvisible.java @@ -8,57 +8,42 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; /** - * Slot that will redirect inserts to another inventory slot (other than index), but not be visible. - *

    - * Used primarily for containers that have a larger internal inventory than external (e.g., DeepStorageUnit) + * Slot that will redirect inserts to another inventory slot (other than index), but not + * be visible.

    Used primarily for containers that have a larger internal inventory + * than external (e.g., DeepStorageUnit) */ -public class SlotInvisible extends Slot -{ - +public class SlotInvisible extends Slot { protected final int slotIndex; - public SlotInvisible(IInventory inventory, int index, int x, int y, int slot) - { - + public SlotInvisible(IInventory inventory, int index, int x, int y, int slot) { super(inventory, index, x, y); slotIndex = slot; } @Override - public void putStack(ItemStack stack) - { - + public void putStack(ItemStack stack) { this.inventory.setInventorySlotContents(slotIndex, stack); this.onSlotChanged(); } @Override - public ItemStack getStack() - { - + public ItemStack getStack() { return null; } @Override - public ItemStack decrStackSize(int par1) - { - + public ItemStack decrStackSize(int par1) { return null; } @Override - public boolean canTakeStack(EntityPlayer p) - { - + public boolean canTakeStack(EntityPlayer p) { return false; } @Override @SideOnly(Side.CLIENT) - public boolean func_111238_b() - { - + public boolean func_111238_b() { return false; } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotPotion.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotPotion.java index a6d07b96..50b4b2b6 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotPotion.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotPotion.java @@ -8,20 +8,13 @@ import net.minecraft.item.ItemStack; /** * Slot that will only accept Potions. */ -public class SlotPotion extends Slot -{ - - public SlotPotion(IInventory inventory, int index, int x, int y) - { - +public class SlotPotion extends Slot { + public SlotPotion(IInventory inventory, int index, int x, int y) { super(inventory, index, x, y); } @Override - public boolean isItemValid(ItemStack stack) - { - + public boolean isItemValid(ItemStack stack) { return stack != null && stack.getItem().equals(Items.potionitem); } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotPotionIngredient.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotPotionIngredient.java index 834df901..4a3998f5 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotPotionIngredient.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotPotionIngredient.java @@ -7,20 +7,13 @@ import net.minecraft.item.ItemStack; /** * Slot that will only accept Potion Ingredients. */ -public class SlotPotionIngredient extends Slot -{ - - public SlotPotionIngredient(IInventory inventory, int index, int x, int y) - { - +public class SlotPotionIngredient extends Slot { + public SlotPotionIngredient(IInventory inventory, int index, int x, int y) { super(inventory, index, x, y); } @Override - public boolean isItemValid(ItemStack stack) - { - + public boolean isItemValid(ItemStack stack) { return stack != null && stack.getItem().isPotionIngredient(stack); } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotRemoveOnly.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotRemoveOnly.java index fe8d273c..0e9ed651 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotRemoveOnly.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotRemoveOnly.java @@ -7,20 +7,13 @@ import net.minecraft.item.ItemStack; /** * Slot which players can only remove items from. */ -public class SlotRemoveOnly extends Slot -{ - - public SlotRemoveOnly(IInventory inventory, int index, int x, int y) - { - +public class SlotRemoveOnly extends Slot { + public SlotRemoveOnly(IInventory inventory, int index, int x, int y) { super(inventory, index, x, y); } @Override - public boolean isItemValid(ItemStack stack) - { - + public boolean isItemValid(ItemStack stack) { return false; } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotValidated.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotValidated.java index 8d1c98e8..e4327f36 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotValidated.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotValidated.java @@ -5,27 +5,23 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; /** - * A slot where the input can be validated based on any arbitrary criteria by using a passthrough method to an {@link ISlotValidator}. + * A slot where the input can be validated based on any arbitrary criteria by using a + * passthrough method to an {@link ISlotValidator}. * * @author King Lemming */ -public class SlotValidated extends Slot -{ - +public class SlotValidated extends Slot { ISlotValidator validator; - public SlotValidated(ISlotValidator validator, IInventory inventory, int index, int x, int y) - { - + public SlotValidated( + ISlotValidator validator, IInventory inventory, int index, int x, int y + ) { super(inventory, index, x, y); this.validator = validator; } @Override - public boolean isItemValid(ItemStack stack) - { - + public boolean isItemValid(ItemStack stack) { return validator.isItemValid(stack); } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotViewOnly.java b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotViewOnly.java index 9c6741a6..808e211a 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotViewOnly.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/gui/slot/SlotViewOnly.java @@ -8,59 +8,44 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; /** - * A slot that can only be used to display an item, not edited. Can optionally not highlight when moused over. + * A slot that can only be used to display an item, not edited. Can optionally not + * highlight when moused over. */ -public class SlotViewOnly extends Slot -{ - +public class SlotViewOnly extends Slot { protected boolean showHighlight; - public SlotViewOnly(IInventory inventory, int index, int x, int y) - { - + public SlotViewOnly(IInventory inventory, int index, int x, int y) { this(inventory, index, x, y, false); } - public SlotViewOnly(IInventory inventory, int index, int x, int y, boolean highlight) - { - + public SlotViewOnly( + IInventory inventory, int index, int x, int y, boolean highlight + ) { super(inventory, index, x, y); showHighlight = highlight; } @Override - public void putStack(ItemStack stack) - { - - } + public void putStack(ItemStack stack) {} @Override - public ItemStack decrStackSize(int i) - { - + public ItemStack decrStackSize(int i) { return null; } @Override - public boolean canTakeStack(EntityPlayer player) - { - + public boolean canTakeStack(EntityPlayer player) { return false; } @Override - public boolean isItemValid(ItemStack stack) - { - + public boolean isItemValid(ItemStack stack) { return false; } @Override @SideOnly(Side.CLIENT) - public boolean func_111238_b() - { - + public boolean func_111238_b() { return showHighlight; } - } \ No newline at end of file diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/render/RenderHelper.java b/src/main/java/com/pahimar/repackage/cofh/lib/render/RenderHelper.java index feebcb17..e4f464b3 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/render/RenderHelper.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/render/RenderHelper.java @@ -20,65 +20,71 @@ import org.lwjgl.opengl.GL11; * * @author King Lemming */ -public final class RenderHelper -{ - +public final class RenderHelper { public static final double RENDER_OFFSET = 1.0D / 1024.0D; - public static final ResourceLocation MC_BLOCK_SHEET = new ResourceLocation("textures/atlas/blocks.png"); - public static final ResourceLocation MC_ITEM_SHEET = new ResourceLocation("textures/atlas/items.png"); - public static final ResourceLocation MC_FONT_DEFAULT = new ResourceLocation("textures/font/ascii.png"); - public static final ResourceLocation MC_FONT_ALTERNATE = new ResourceLocation("textures/font/ascii_sga.png"); - public static final ResourceLocation MC_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + public static final ResourceLocation MC_BLOCK_SHEET + = new ResourceLocation("textures/atlas/blocks.png"); + public static final ResourceLocation MC_ITEM_SHEET + = new ResourceLocation("textures/atlas/items.png"); + public static final ResourceLocation MC_FONT_DEFAULT + = new ResourceLocation("textures/font/ascii.png"); + public static final ResourceLocation MC_FONT_ALTERNATE + = new ResourceLocation("textures/font/ascii_sga.png"); + public static final ResourceLocation MC_ITEM_GLINT + = new ResourceLocation("textures/misc/enchanted_item_glint.png"); - private RenderHelper() - { - - } - - public static final TextureManager engine() - { + private RenderHelper() {} + public static final TextureManager engine() { return Minecraft.getMinecraft().renderEngine; } - public static final Tessellator tessellator() - { - + public static final Tessellator tessellator() { return Tessellator.instance; } - public static void setColor3ub(int color) - { - - GL11.glColor3ub((byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF)); + public static void setColor3ub(int color) { + GL11.glColor3ub( + (byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF) + ); } - public static void setColor4ub(int color) - { - - GL11.glColor4ub((byte) (color >> 24 & 0xFF), (byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF)); + public static void setColor4ub(int color) { + GL11.glColor4ub( + (byte) (color >> 24 & 0xFF), + (byte) (color >> 16 & 0xFF), + (byte) (color >> 8 & 0xFF), + (byte) (color & 0xFF) + ); } - public static void resetColor() - { - + public static void resetColor() { GL11.glColor4f(1F, 1F, 1F, 1F); } - public static void renderItemAsBlock(RenderBlocks renderer, ItemStack item, double translateX, double translateY, double translateZ) - { - - renderTextureAsBlock(renderer, item.getIconIndex(), translateX, translateY, translateZ); + public static void renderItemAsBlock( + RenderBlocks renderer, + ItemStack item, + double translateX, + double translateY, + double translateZ + ) { + renderTextureAsBlock( + renderer, item.getIconIndex(), translateX, translateY, translateZ + ); } - public static void renderTextureAsBlock(RenderBlocks renderer, IIcon texture, double translateX, double translateY, double translateZ) - { - + public static void renderTextureAsBlock( + RenderBlocks renderer, + IIcon texture, + double translateX, + double translateY, + double translateZ + ) { Tessellator tessellator = Tessellator.instance; Block block = Blocks.stone; - if (texture == null) - { + if (texture == null) { return; } renderer.setRenderBoundsFromBlock(block); @@ -106,15 +112,20 @@ public final class RenderHelper tessellator.draw(); } - public static void renderItemIn2D(IIcon icon) - { - - ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F); + public static void renderItemIn2D(IIcon icon) { + ItemRenderer.renderItemIn2D( + Tessellator.instance, + icon.getMaxU(), + icon.getMinV(), + icon.getMinU(), + icon.getMaxV(), + icon.getIconWidth(), + icon.getIconHeight(), + 0.0625F + ); } - public static void renderIcon(IIcon icon, double z) - { - + public static void renderIcon(IIcon icon, double z) { Tessellator.instance.startDrawingQuads(); Tessellator.instance.addVertexWithUV(0, 16, z, icon.getMinU(), icon.getMaxV()); Tessellator.instance.addVertexWithUV(16, 16, z, icon.getMaxU(), icon.getMaxV()); @@ -123,78 +134,61 @@ public final class RenderHelper Tessellator.instance.draw(); } - public static void renderIcon(double x, double y, double z, IIcon icon, int width, int height) - { - + public static void + renderIcon(double x, double y, double z, IIcon icon, int width, int height) { Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.addVertexWithUV(x, y + height, z, icon.getMinU(), icon.getMaxV()); - tessellator.addVertexWithUV(x + width, y + height, z, icon.getMaxU(), icon.getMaxV()); + tessellator.addVertexWithUV( + x + width, y + height, z, icon.getMaxU(), icon.getMaxV() + ); tessellator.addVertexWithUV(x + width, y, z, icon.getMaxU(), icon.getMinV()); tessellator.addVertexWithUV(x, y, z, icon.getMinU(), icon.getMinV()); tessellator.draw(); } - public static final IIcon getFluidTexture(Fluid fluid) - { - - if (fluid == null) - { + public static final IIcon getFluidTexture(Fluid fluid) { + if (fluid == null) { return FluidRegistry.LAVA.getIcon(); } return fluid.getIcon(); } - public static final IIcon getFluidTexture(FluidStack fluid) - { - - if (fluid == null || fluid.getFluid() == null || fluid.getFluid().getIcon(fluid) == null) - { + public static final IIcon getFluidTexture(FluidStack fluid) { + if (fluid == null || fluid.getFluid() == null + || fluid.getFluid().getIcon(fluid) == null) { return FluidRegistry.LAVA.getIcon(); } return fluid.getFluid().getIcon(fluid); } - public static final void bindItemTexture(ItemStack stack) - { - - engine().bindTexture(stack.getItemSpriteNumber() == 0 ? MC_BLOCK_SHEET : MC_ITEM_SHEET); + public static final void bindItemTexture(ItemStack stack) { + engine().bindTexture( + stack.getItemSpriteNumber() == 0 ? MC_BLOCK_SHEET : MC_ITEM_SHEET + ); } - public static final void bindTexture(ResourceLocation texture) - { - + public static final void bindTexture(ResourceLocation texture) { engine().bindTexture(texture); } - public static final void setBlockTextureSheet() - { - + public static final void setBlockTextureSheet() { bindTexture(MC_BLOCK_SHEET); } - public static final void setItemTextureSheet() - { - + public static final void setItemTextureSheet() { bindTexture(MC_ITEM_SHEET); } - public static final void setDefaultFontTextureSheet() - { - + public static final void setDefaultFontTextureSheet() { bindTexture(MC_FONT_DEFAULT); } - public static final void setSGAFontTextureSheet() - { - + public static final void setSGAFontTextureSheet() { bindTexture(MC_FONT_ALTERNATE); } - public static final void enableGUIStandardItemLighting() - { - + public static final void enableGUIStandardItemLighting() { net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/util/CharacterSingleton.java b/src/main/java/com/pahimar/repackage/cofh/lib/util/CharacterSingleton.java index 2820d9f3..fe666ad9 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/util/CharacterSingleton.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/util/CharacterSingleton.java @@ -1,34 +1,23 @@ package com.pahimar.repackage.cofh.lib.util; -public class CharacterSingleton implements CharSequence -{ - +public class CharacterSingleton implements CharSequence { public char character; @Override - public int length() - { - + public int length() { return 1; } @Override - public char charAt(int index) - { - + public char charAt(int index) { return character; } @Override - public CharSequence subSequence(int start, int end) - { - - if (start == end) - { + public CharSequence subSequence(int start, int end) { + if (start == end) { return ""; } return this; } - } - diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/util/Rectangle4i.java b/src/main/java/com/pahimar/repackage/cofh/lib/util/Rectangle4i.java index 8ec756d0..de76713f 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/util/Rectangle4i.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/util/Rectangle4i.java @@ -5,138 +5,96 @@ package com.pahimar.repackage.cofh.lib.util; * * @author Chicken Bones */ -public class Rectangle4i -{ - +public class Rectangle4i { public int x; public int y; public int w; public int h; - public Rectangle4i() - { - - } - - public Rectangle4i(int x, int y, int w, int h) - { + public Rectangle4i() {} + public Rectangle4i(int x, int y, int w, int h) { this.x = x; this.y = y; this.w = w; this.h = h; } - public int x1() - { - + public int x1() { return x; } - public int y1() - { - + public int y1() { return y; } - public int x2() - { - + public int x2() { return x + w - 1; } - public int y2() - { - + public int y2() { return y + h - 1; } - public void set(int x, int y, int w, int h) - { - + public void set(int x, int y, int w, int h) { this.x = x; this.y = y; this.w = w; this.h = h; } - public Rectangle4i offset(int dx, int dy) - { - + public Rectangle4i offset(int dx, int dy) { x += dx; y += dy; return this; } - public Rectangle4i include(int px, int py) - { - - if (px < x) - { + public Rectangle4i include(int px, int py) { + if (px < x) { expand(px - x, 0); } - if (px >= x + w) - { + if (px >= x + w) { expand(px - x - w + 1, 0); } - if (py < y) - { + if (py < y) { expand(0, py - y); } - if (py >= y + h) - { + if (py >= y + h) { expand(0, py - y - h + 1); } return this; } - public Rectangle4i include(Rectangle4i r) - { - + public Rectangle4i include(Rectangle4i r) { include(r.x, r.y); return include(r.x2(), r.y2()); } - public Rectangle4i expand(int px, int py) - { - - if (px > 0) - { + public Rectangle4i expand(int px, int py) { + if (px > 0) { w += px; - } - else - { + } else { x += px; w -= px; } - if (py > 0) - { + if (py > 0) { h += py; - } - else - { + } else { y += py; h -= py; } return this; } - public boolean contains(int px, int py) - { - + public boolean contains(int px, int py) { return x <= px && px < x + w && y <= py && py < y + h; } - public boolean intersects(Rectangle4i r) - { - + public boolean intersects(Rectangle4i r) { return r.x + r.w > x && r.x < x + w && r.y + r.h > y && r.y < y + h; } - public int area() - { - + public int area() { return w * h; } - } diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/util/helpers/MathHelper.java b/src/main/java/com/pahimar/repackage/cofh/lib/util/helpers/MathHelper.java index 4f60df50..7875c871 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/util/helpers/MathHelper.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/util/helpers/MathHelper.java @@ -3,26 +3,20 @@ package com.pahimar.repackage.cofh.lib.util.helpers; import java.util.Random; /** - * Contains various math-related helper functions. Often faster than conventional implementations. + * Contains various math-related helper functions. Often faster than conventional + * implementations. * * @author King Lemming */ -public final class MathHelper -{ - - private MathHelper() - { - - } +public final class MathHelper { + private MathHelper() {} public static final Random RANDOM = new Random(); public static final double PHI = 1.618034; public static final double[] SIN_TABLE = new double[65536]; - static - { - for (int i = 0; i < 65536; i++) - { + static { + for (int i = 0; i < 65536; i++) { SIN_TABLE[i] = Math.sin(i / 65536D * 2 * Math.PI); } SIN_TABLE[0] = 0; @@ -31,214 +25,157 @@ public final class MathHelper SIN_TABLE[49152] = 1; } - public static double sin(double d) - { - + public static double sin(double d) { return SIN_TABLE[(int) ((float) d * 10430.378F) & 65535]; } - public static double cos(double d) - { - + public static double cos(double d) { return SIN_TABLE[(int) ((float) d * 10430.378F + 16384.0F) & 65535]; } - public static int clampI(int a, int min, int max) - { - + public static int clampI(int a, int min, int max) { return a < min ? min : (a > max ? max : a); } - public static float clampF(float a, float min, float max) - { - + public static float clampF(float a, float min, float max) { return a < min ? min : (a > max ? max : a); } - public static float approachLinear(float a, float b, float max) - { - + public static float approachLinear(float a, float b, float max) { return a > b ? a - b < max ? b : a - max : b - a < max ? b : a + max; } - public static double approachLinear(double a, double b, double max) - { - + public static double approachLinear(double a, double b, double max) { return a > b ? a - b < max ? b : a - max : b - a < max ? b : a + max; } - public static float interpolate(float a, float b, float d) - { - + public static float interpolate(float a, float b, float d) { return a + (b - a) * d; } - public static double interpolate(double a, double b, double d) - { - + public static double interpolate(double a, double b, double d) { return a + (b - a) * d; } - public static double approachExp(double a, double b, double ratio) - { - + public static double approachExp(double a, double b, double ratio) { return a + (b - a) * ratio; } - public static double approachExp(double a, double b, double ratio, double cap) - { - + public static double approachExp(double a, double b, double ratio, double cap) { double d = (b - a) * ratio; - if (Math.abs(d) > cap) - { + if (Math.abs(d) > cap) { d = Math.signum(d) * cap; } return a + d; } - public static double retreatExp(double a, double b, double c, double ratio, double kick) - { - + public static double + retreatExp(double a, double b, double c, double ratio, double kick) { double d = (Math.abs(c - a) + kick) * ratio; - if (d > Math.abs(b - a)) - { + if (d > Math.abs(b - a)) { return b; } return a + Math.signum(b - a) * d; } - public static double clip(double value, double min, double max) - { - - if (value > max) - { + public static double clip(double value, double min, double max) { + if (value > max) { value = max; - } - else if (value < min) - { + } else if (value < min) { value = min; } return value; } - public static boolean between(double a, double x, double b) - { - + public static boolean between(double a, double x, double b) { return a <= x && x <= b; } - public static int approachExpI(int a, int b, double ratio) - { - + public static int approachExpI(int a, int b, double ratio) { int r = (int) Math.round(approachExp(a, b, ratio)); return r == a ? b : r; } - public static int retreatExpI(int a, int b, int c, double ratio, int kick) - { - + public static int retreatExpI(int a, int b, int c, double ratio, int kick) { int r = (int) Math.round(retreatExp(a, b, c, ratio, kick)); return r == a ? b : r; } /** - * Unchecked implementation to round a number. Parameter should be known to be valid in advance. + * Unchecked implementation to round a number. Parameter should be known to be valid + * in advance. */ - public static int round(double d) - { - + public static int round(double d) { return (int) (d + 0.5D); } /** - * Unchecked implementation to round a number up. Parameter should be known to be valid in advance. + * Unchecked implementation to round a number up. Parameter should be known to be + * valid in advance. */ - public static int ceil(double d) - { - + public static int ceil(double d) { return (int) (d + 0.9999D); } /** - * Unchecked implementation to round a number down. Parameter should be known to be valid in advance. + * Unchecked implementation to round a number down. Parameter should be known to be + * valid in advance. */ - public static int floor(double d) - { - + public static int floor(double d) { int i = (int) d; return d < i ? i - 1 : i; } /** - * Unchecked implementation to determine the smaller of two Floats. Parameters should be known to be valid in advance. + * Unchecked implementation to determine the smaller of two Floats. Parameters should + * be known to be valid in advance. */ - public static float minF(float a, float b) - { - + public static float minF(float a, float b) { return a < b ? a : b; } - public static float minF(int a, float b) - { - + public static float minF(int a, float b) { return a < b ? a : b; } - public static float minF(float a, int b) - { - + public static float minF(float a, int b) { return a < b ? a : b; } /** - * Unchecked implementation to determine the larger of two Floats. Parameters should be known to be valid in advance. + * Unchecked implementation to determine the larger of two Floats. Parameters should + * be known to be valid in advance. */ - public static float maxF(float a, float b) - { - + public static float maxF(float a, float b) { return a > b ? a : b; } - public static float maxF(int a, float b) - { - + public static float maxF(int a, float b) { return a > b ? a : b; } - public static float maxF(float a, int b) - { - + public static float maxF(float a, int b) { return a > b ? a : b; } - public static double maxAbs(double a, double b) - { - - if (a < 0.0D) - { + public static double maxAbs(double a, double b) { + if (a < 0.0D) { a = -a; } - if (b < 0.0D) - { + if (b < 0.0D) { b = -b; } return a > b ? a : b; } - public static int setBit(int mask, int bit, boolean value) - { - + public static int setBit(int mask, int bit, boolean value) { mask |= (value ? 1 : 0) << bit; return mask; } - public static boolean isBitSet(int mask, int bit) - { - + public static boolean isBitSet(int mask, int bit) { return (mask & 1 << bit) != 0; } - } - diff --git a/src/main/java/com/pahimar/repackage/cofh/lib/util/helpers/StringHelper.java b/src/main/java/com/pahimar/repackage/cofh/lib/util/helpers/StringHelper.java index 42cc1269..ca691e70 100644 --- a/src/main/java/com/pahimar/repackage/cofh/lib/util/helpers/StringHelper.java +++ b/src/main/java/com/pahimar/repackage/cofh/lib/util/helpers/StringHelper.java @@ -1,5 +1,7 @@ package com.pahimar.repackage.cofh.lib.util.helpers; +import java.util.List; + import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; @@ -8,82 +10,59 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.input.Keyboard; -import java.util.List; - /** * Contains various helper functions to assist with String manipulation. * * @author King Lemming */ -public final class StringHelper -{ - - private StringHelper() - { - - } +public final class StringHelper { + private StringHelper() {} /* KEY HELPERS */ - public static boolean isAltKeyDown() - { - - return Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU); + public static boolean isAltKeyDown() { + return Keyboard.isKeyDown(Keyboard.KEY_LMENU) + || Keyboard.isKeyDown(Keyboard.KEY_RMENU); } - public static boolean isControlKeyDown() - { - - return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); + public static boolean isControlKeyDown() { + return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) + || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); } - public static boolean isShiftKeyDown() - { - - return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + public static boolean isShiftKeyDown() { + return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) + || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); } /* FORMAT HELPERS */ - public static int getSplitStringHeight(FontRenderer fontRenderer, String input, int width) - { - - @SuppressWarnings("rawtypes") List stringRows = fontRenderer.listFormattedStringToWidth(input, width); + public static int + getSplitStringHeight(FontRenderer fontRenderer, String input, int width) { + @SuppressWarnings("rawtypes") + List stringRows = fontRenderer.listFormattedStringToWidth(input, width); return stringRows.size() * fontRenderer.FONT_HEIGHT; } - public static String camelCase(String input) - { - + public static String camelCase(String input) { return input.substring(0, 1).toLowerCase() + input.substring(1); } - public static String titleCase(String input) - { - + public static String titleCase(String input) { return input.substring(0, 1).toUpperCase() + input.substring(1); } - public static String localize(String key) - { - + public static String localize(String key) { return StatCollector.translateToLocal(key); } - public static String getFluidName(FluidStack stack) - { - + public static String getFluidName(FluidStack stack) { Fluid fluid = stack.getFluid(); String name = "" + END; - if (fluid.getRarity() == EnumRarity.uncommon) - { + if (fluid.getRarity() == EnumRarity.uncommon) { name += YELLOW; - } - else if (fluid.getRarity() == EnumRarity.rare) - { + } else if (fluid.getRarity() == EnumRarity.rare) { name += BRIGHT_BLUE; - } - else if (fluid.getRarity() == EnumRarity.epic) - { + } else if (fluid.getRarity() == EnumRarity.epic) { name += PINK; } name += fluid.getLocalizedName(stack) + END; @@ -91,30 +70,20 @@ public final class StringHelper return name; } - public static String getFluidName(FluidStack stack, String defaultName) - { - - if (stack == null) - { + public static String getFluidName(FluidStack stack, String defaultName) { + if (stack == null) { return defaultName; } return getFluidName(stack); } - public static String getItemName(ItemStack stack) - { - + public static String getItemName(ItemStack stack) { String name = "" + END; - if (stack.getRarity() == EnumRarity.uncommon) - { + if (stack.getRarity() == EnumRarity.uncommon) { name += YELLOW; - } - else if (stack.getRarity() == EnumRarity.rare) - { + } else if (stack.getRarity() == EnumRarity.rare) { name += BRIGHT_BLUE; - } - else if (stack.getRarity() == EnumRarity.epic) - { + } else if (stack.getRarity() == EnumRarity.epic) { name += PINK; } name += stack.getDisplayName() + END; @@ -122,64 +91,42 @@ public final class StringHelper return name; } - public static String getScaledNumber(long number) - { - - if (number >= 1000000000) - { + public static String getScaledNumber(long number) { + if (number >= 1000000000) { return number / 1000000000 + "." + (number % 1000000000 / 10000000) + "G"; - } - else if (number >= 1000000) - { + } else if (number >= 1000000) { return number / 1000000 + "." + (number % 1000000 / 10000) + "M"; - } - else if (number >= 1000) - { + } else if (number >= 1000) { return number / 1000 + "." + (number % 1000 / 10) + "k"; - } - else - { + } else { return String.valueOf(number); } } @Deprecated - public static String getScaledNumber(long number, int minDigits) - { - + public static String getScaledNumber(long number, int minDigits) { return getScaledNumber(number); } /* ITEM TEXT HELPERS */ - public static String getActivationText(String key) - { - + public static String getActivationText(String key) { return BRIGHT_BLUE + localize(key) + END; } - public static String getDeactivationText(String key) - { - + public static String getDeactivationText(String key) { return YELLOW + localize(key) + END; } - public static String getInfoText(String key) - { - + public static String getInfoText(String key) { return BRIGHT_GREEN + localize(key) + END; } - public static String getFlavorText(String key) - { - + public static String getFlavorText(String key) { return LIGHT_GRAY + ITALIC + localize(key) + END; } - public static String getRarity(int level) - { - - switch (level) - { + public static String getRarity(int level) { + switch (level) { case 2: return StringHelper.YELLOW; case 3: @@ -189,46 +136,34 @@ public final class StringHelper } } - public static String shiftForDetails() - { - - return LIGHT_GRAY + localize("info.cofh.hold") + " " + YELLOW + ITALIC + localize("info.cofh.shift") + " " + END + LIGHT_GRAY + localize("info.cofh.forDetails") + END; + public static String shiftForDetails() { + return LIGHT_GRAY + localize("info.cofh.hold") + " " + YELLOW + ITALIC + + localize("info.cofh.shift") + " " + END + LIGHT_GRAY + + localize("info.cofh.forDetails") + END; } /* TUTORIAL TAB HELPERS */ - public static String tutorialTabAugment() - { - + public static String tutorialTabAugment() { return localize("info.cofh.tutorial.tabAugment"); } - public static String tutorialTabConfiguration() - { - + public static String tutorialTabConfiguration() { return localize("info.cofh.tutorial.tabConfiguration.0"); } - public static String tutorialTabOperation() - { - + public static String tutorialTabOperation() { return localize("info.cofh.tutorial.tabConfiguration.1"); } - public static String tutorialTabRedstone() - { - + public static String tutorialTabRedstone() { return localize("info.cofh.tutorial.tabRedstone"); } - public static String tutorialTabSecurity() - { - + public static String tutorialTabSecurity() { return localize("info.cofh.tutorial.tabSecurity"); } - public static String tutorialTabFluxRequired() - { - + public static String tutorialTabFluxRequired() { return localize("info.cofh.tutorial.fluxRequired"); } @@ -259,9 +194,9 @@ public final class StringHelper public static final String ITALIC = (char) 167 + "o"; public static final String END = (char) 167 + "r"; - public static final String[] ROMAN_NUMERAL = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"}; + public static final String[] ROMAN_NUMERAL + = { "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X" }; public static boolean displayShiftForDetail = true; public static boolean displayStackCount = false; - } diff --git a/src/main/java/moze_intel/projecte/api/ProjectEAPI.java b/src/main/java/moze_intel/projecte/api/ProjectEAPI.java index c97cb56d..4f69d7d1 100644 --- a/src/main/java/moze_intel/projecte/api/ProjectEAPI.java +++ b/src/main/java/moze_intel/projecte/api/ProjectEAPI.java @@ -1,97 +1,91 @@ package moze_intel.projecte.api; import cpw.mods.fml.common.FMLLog; -import moze_intel.projecte.api.proxy.IEMCProxy; import moze_intel.projecte.api.proxy.IBlacklistProxy; import moze_intel.projecte.api.proxy.IConversionProxy; +import moze_intel.projecte.api.proxy.IEMCProxy; import moze_intel.projecte.api.proxy.ITransmutationProxy; -public final class ProjectEAPI -{ - private static IEMCProxy emcProxy; - private static ITransmutationProxy transProxy; - private static IBlacklistProxy blacklistProxy; - private static IConversionProxy recipeProxy; +public final class ProjectEAPI { + private static IEMCProxy emcProxy; + private static ITransmutationProxy transProxy; + private static IBlacklistProxy blacklistProxy; + private static IConversionProxy recipeProxy; - private ProjectEAPI() {} + private ProjectEAPI() {} - /** - * Retrieves the proxy for EMC-based API queries. - * @return The proxy for EMC-based API queries - */ - public static IEMCProxy getEMCProxy() - { - if (emcProxy == null) - { - try - { - Class clazz = Class.forName("moze_intel.projecte.impl.EMCProxyImpl"); - emcProxy = (IEMCProxy) clazz.getField("instance").get(null); - } catch (ReflectiveOperationException ex) - { - FMLLog.warning("[ProjectEAPI] Error retrieving EMCProxyImpl, ProjectE may be absent, damaged, or outdated."); - } - } - return emcProxy; - } + /** + * Retrieves the proxy for EMC-based API queries. + * @return The proxy for EMC-based API queries + */ + public static IEMCProxy getEMCProxy() { + if (emcProxy == null) { + try { + Class clazz = Class.forName("moze_intel.projecte.impl.EMCProxyImpl"); + emcProxy = (IEMCProxy) clazz.getField("instance").get(null); + } catch (ReflectiveOperationException ex) { + FMLLog.warning( + "[ProjectEAPI] Error retrieving EMCProxyImpl, ProjectE may be absent, damaged, or outdated." + ); + } + } + return emcProxy; + } - /** - * Retrieves the proxy for EMC-Recipe-Calculation-based API queries. - * @return The proxy for EMC-Recipe-Calculation-based API queries - */ - public static IConversionProxy getConversionProxy() - { - if (recipeProxy == null) - { - try - { - Class clazz = Class.forName("moze_intel.projecte.impl.ConversionProxyImpl"); - recipeProxy = (IConversionProxy) clazz.getField("instance").get(null); - } catch (ReflectiveOperationException ex) - { - FMLLog.warning("[ProjectEAPI] Error retrieving ConversionProxyImpl, ProjectE may be absent, damaged, or outdated."); - } - } - return recipeProxy; - } + /** + * Retrieves the proxy for EMC-Recipe-Calculation-based API queries. + * @return The proxy for EMC-Recipe-Calculation-based API queries + */ + public static IConversionProxy getConversionProxy() { + if (recipeProxy == null) { + try { + Class clazz + = Class.forName("moze_intel.projecte.impl.ConversionProxyImpl"); + recipeProxy = (IConversionProxy) clazz.getField("instance").get(null); + } catch (ReflectiveOperationException ex) { + FMLLog.warning( + "[ProjectEAPI] Error retrieving ConversionProxyImpl, ProjectE may be absent, damaged, or outdated." + ); + } + } + return recipeProxy; + } - /** - * Retrieves the proxy for Transmutation-based API queries. - * @return The proxy for Transmutation-based API queries - */ - public static ITransmutationProxy getTransmutationProxy() - { - if (transProxy == null) - { - try - { - Class clazz = Class.forName("moze_intel.projecte.impl.TransmutationProxyImpl"); - transProxy = (ITransmutationProxy) clazz.getField("instance").get(null); - } catch (ReflectiveOperationException ex) - { - FMLLog.warning("[ProjectEAPI] Error retrieving TransmutationProxyImpl, ProjectE may be absent, damaged, or outdated."); - } - } - return transProxy; - } + /** + * Retrieves the proxy for Transmutation-based API queries. + * @return The proxy for Transmutation-based API queries + */ + public static ITransmutationProxy getTransmutationProxy() { + if (transProxy == null) { + try { + Class clazz + = Class.forName("moze_intel.projecte.impl.TransmutationProxyImpl"); + transProxy = (ITransmutationProxy) clazz.getField("instance").get(null); + } catch (ReflectiveOperationException ex) { + FMLLog.warning( + "[ProjectEAPI] Error retrieving TransmutationProxyImpl, ProjectE may be absent, damaged, or outdated." + ); + } + } + return transProxy; + } - /** - * Retrieves the proxy for black/whitelist-based API queries. - * @return The proxy for black/whitelist-based API queries - */ - public static IBlacklistProxy getBlacklistProxy() - { - if (blacklistProxy == null) - { - try - { - Class clazz = Class.forName("moze_intel.projecte.impl.BlacklistProxyImpl"); - blacklistProxy = (IBlacklistProxy) clazz.getField("instance").get(null); - } catch (ReflectiveOperationException ex) - { - FMLLog.warning("[ProjectEAPI] Error retrieving BlacklistProxyImpl, ProjectE may be absent, damaged, or outdated."); - } - } - return blacklistProxy; - } + /** + * Retrieves the proxy for black/whitelist-based API queries. + * @return The proxy for black/whitelist-based API queries + */ + public static IBlacklistProxy getBlacklistProxy() { + if (blacklistProxy == null) { + try { + Class clazz + = Class.forName("moze_intel.projecte.impl.BlacklistProxyImpl"); + blacklistProxy = (IBlacklistProxy) clazz.getField("instance").get(null); + } catch (ReflectiveOperationException ex) { + FMLLog.warning( + "[ProjectEAPI] Error retrieving BlacklistProxyImpl, ProjectE may be absent, damaged, or outdated." + ); + } + } + return blacklistProxy; + } } \ No newline at end of file diff --git a/src/main/java/moze_intel/projecte/api/event/PlayerKnowledgeChangeEvent.java b/src/main/java/moze_intel/projecte/api/event/PlayerKnowledgeChangeEvent.java index 17737b6b..4dcf6c32 100644 --- a/src/main/java/moze_intel/projecte/api/event/PlayerKnowledgeChangeEvent.java +++ b/src/main/java/moze_intel/projecte/api/event/PlayerKnowledgeChangeEvent.java @@ -2,20 +2,18 @@ package moze_intel.projecte.api.event; import java.util.UUID; -import net.minecraft.entity.player.EntityPlayer; import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.entity.player.EntityPlayer; /** * This event is fired after a players transmutation knowledge is changed * This event is not cancelable, and has no result * This event is fired on MinecraftForge#EVENT_BUS */ -public class PlayerKnowledgeChangeEvent extends Event -{ - public final UUID playerUUID; +public class PlayerKnowledgeChangeEvent extends Event { + public final UUID playerUUID; - public PlayerKnowledgeChangeEvent(EntityPlayer entityPlayer) - { - playerUUID = entityPlayer.getUniqueID(); + public PlayerKnowledgeChangeEvent(EntityPlayer entityPlayer) { + playerUUID = entityPlayer.getUniqueID(); } } diff --git a/src/main/java/moze_intel/projecte/api/item/IAlchBagItem.java b/src/main/java/moze_intel/projecte/api/item/IAlchBagItem.java index adf100ad..81dd9f58 100644 --- a/src/main/java/moze_intel/projecte/api/item/IAlchBagItem.java +++ b/src/main/java/moze_intel/projecte/api/item/IAlchBagItem.java @@ -4,19 +4,19 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; /** - * This interfaces specifies items that perform a specific function every tick when inside an Alchemical Bag, on a player + * This interfaces specifies items that perform a specific function every tick when inside + * an Alchemical Bag, on a player * * @author williewillus */ -public interface IAlchBagItem -{ - /** - * Called on both client and server every time the alchemical bag ticks this item - * - * @param inv The inventory of the bag - * @param player The player whose bag is being ticked - * @param stack The ItemStack being ticked - * @return Whether the inventory was changed by this item ticking - */ - boolean updateInAlchBag(ItemStack[] inv, EntityPlayer player, ItemStack stack); +public interface IAlchBagItem { + /** + * Called on both client and server every time the alchemical bag ticks this item + * + * @param inv The inventory of the bag + * @param player The player whose bag is being ticked + * @param stack The ItemStack being ticked + * @return Whether the inventory was changed by this item ticking + */ + boolean updateInAlchBag(ItemStack[] inv, EntityPlayer player, ItemStack stack); } diff --git a/src/main/java/moze_intel/projecte/api/item/IAlchChestItem.java b/src/main/java/moze_intel/projecte/api/item/IAlchChestItem.java index 32a462c1..4d37fc69 100644 --- a/src/main/java/moze_intel/projecte/api/item/IAlchChestItem.java +++ b/src/main/java/moze_intel/projecte/api/item/IAlchChestItem.java @@ -4,16 +4,17 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; /** - * This interface specifies items that perform a specific function every tick when inside an Alchemical Chest + * This interface specifies items that perform a specific function every tick when inside + * an Alchemical Chest * * @author williewillus */ -public interface IAlchChestItem -{ +public interface IAlchChestItem { /** * Called on both client and server every time the alchemical chest ticks this item - * Implementers that modify the chest inventory (serverside) MUST call markDirty() on the tile entity. - * If you do not, your changes may not be saved when the world/chunk unloads! + * Implementers that modify the chest inventory (serverside) MUST call markDirty() on + * the tile entity. If you do not, your changes may not be saved when the world/chunk + * unloads! * * @param world The World * @param stack The ItemStack being ticked diff --git a/src/main/java/moze_intel/projecte/api/item/IExtraFunction.java b/src/main/java/moze_intel/projecte/api/item/IExtraFunction.java index 1974459f..23944231 100644 --- a/src/main/java/moze_intel/projecte/api/item/IExtraFunction.java +++ b/src/main/java/moze_intel/projecte/api/item/IExtraFunction.java @@ -4,14 +4,14 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; /** - * This interface specifies items that perform a specific function when the Extra Function key is activated (default C) + * This interface specifies items that perform a specific function when the Extra Function + * key is activated (default C) */ -public interface IExtraFunction -{ - /** - * Called serverside when the server receives a Extra Function key packet - * @param stack The ItemStack performing this function - * @param player The player performing this function - */ - void doExtraFunction(ItemStack stack, EntityPlayer player); +public interface IExtraFunction { + /** + * Called serverside when the server receives a Extra Function key packet + * @param stack The ItemStack performing this function + * @param player The player performing this function + */ + void doExtraFunction(ItemStack stack, EntityPlayer player); } diff --git a/src/main/java/moze_intel/projecte/api/item/IItemCharge.java b/src/main/java/moze_intel/projecte/api/item/IItemCharge.java index 87027c04..2bc0780d 100644 --- a/src/main/java/moze_intel/projecte/api/item/IItemCharge.java +++ b/src/main/java/moze_intel/projecte/api/item/IItemCharge.java @@ -4,21 +4,22 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; /** - * This interface specifies items that have a charge that changes when the respective keybinding is activated (default V) + * This interface specifies items that have a charge that changes when the respective + * keybinding is activated (default V) */ -public interface IItemCharge -{ - /** - * Returns the current charge on the given ItemStack - * @param stack Stack whose charge we want - * @return The charge on the stack - */ - byte getCharge(ItemStack stack); +public interface IItemCharge { + /** + * Returns the current charge on the given ItemStack + * @param stack Stack whose charge we want + * @return The charge on the stack + */ + byte getCharge(ItemStack stack); - /** - * Called serverside when the player presses the charge keybinding; reading sneaking state is up to you - * @param player The player - * @param stack The item being charged - */ - void changeCharge(EntityPlayer player, ItemStack stack); + /** + * Called serverside when the player presses the charge keybinding; reading sneaking + * state is up to you + * @param player The player + * @param stack The item being charged + */ + void changeCharge(EntityPlayer player, ItemStack stack); } diff --git a/src/main/java/moze_intel/projecte/api/item/IItemEmc.java b/src/main/java/moze_intel/projecte/api/item/IItemEmc.java index d296f97c..3c5cdc22 100644 --- a/src/main/java/moze_intel/projecte/api/item/IItemEmc.java +++ b/src/main/java/moze_intel/projecte/api/item/IItemEmc.java @@ -3,39 +3,40 @@ package moze_intel.projecte.api.item; import net.minecraft.item.ItemStack; /** - * This interface defines the contract for items that wish to expose their internal EMC storage for external manipulation + * This interface defines the contract for items that wish to expose their internal EMC + * storage for external manipulation * * @author williewillus */ -public interface IItemEmc -{ - /** - * Adds EMC to the itemstack - * @param stack The itemstack to add to - * @param toAdd The maximum amount to add - * @return The amount that was actually added - */ - double addEmc(ItemStack stack, double toAdd); +public interface IItemEmc { + /** + * Adds EMC to the itemstack + * @param stack The itemstack to add to + * @param toAdd The maximum amount to add + * @return The amount that was actually added + */ + double addEmc(ItemStack stack, double toAdd); - /** - * Extracts EMC from the itemstack - * @param stack The itemstack to remove from - * @param toRemove The maximum amount to remove - * @return The amount that was actually extracted - */ - double extractEmc(ItemStack stack, double toRemove); + /** + * Extracts EMC from the itemstack + * @param stack The itemstack to remove from + * @param toRemove The maximum amount to remove + * @return The amount that was actually extracted + */ + double extractEmc(ItemStack stack, double toRemove); - /** - * Gets the current EMC this stack is showing to the public - * @param stack The stack to query - * @return The current publicly-accessible EMC stored in this stack - */ - double getStoredEmc(ItemStack stack); + /** + * Gets the current EMC this stack is showing to the public + * @param stack The stack to query + * @return The current publicly-accessible EMC stored in this stack + */ + double getStoredEmc(ItemStack stack); - /** - * Gets the maximum EMC that is allowed to be stored in this stack - * @param stack The stack to query - * @return The maximum amount of publicly-accessible EMC that can be stored in this stack - */ - double getMaximumEmc(ItemStack stack); + /** + * Gets the maximum EMC that is allowed to be stored in this stack + * @param stack The stack to query + * @return The maximum amount of publicly-accessible EMC that can be stored in this + * stack + */ + double getMaximumEmc(ItemStack stack); } diff --git a/src/main/java/moze_intel/projecte/api/item/IModeChanger.java b/src/main/java/moze_intel/projecte/api/item/IModeChanger.java index 711ed515..7a9bfce2 100644 --- a/src/main/java/moze_intel/projecte/api/item/IModeChanger.java +++ b/src/main/java/moze_intel/projecte/api/item/IModeChanger.java @@ -4,21 +4,21 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; /** - * This interface specifies items that switch between modes when the mode switch keybind is activated (default G) + * This interface specifies items that switch between modes when the mode switch keybind + * is activated (default G) */ -public interface IModeChanger -{ - /** - * Gets the mode from this ItemStack - * @param stack The stack we want the mode of - * @return The mode of this ItemStack - */ - byte getMode(ItemStack stack); +public interface IModeChanger { + /** + * Gets the mode from this ItemStack + * @param stack The stack we want the mode of + * @return The mode of this ItemStack + */ + byte getMode(ItemStack stack); - /** - * Called serverside when the player presses change mode - * @param player The player pressing the change mode key - * @param stack The stack whose mode we are changing - */ - void changeMode(EntityPlayer player, ItemStack stack); + /** + * Called serverside when the player presses change mode + * @param player The player pressing the change mode key + * @param stack The stack whose mode we are changing + */ + void changeMode(EntityPlayer player, ItemStack stack); } diff --git a/src/main/java/moze_intel/projecte/api/item/IPedestalItem.java b/src/main/java/moze_intel/projecte/api/item/IPedestalItem.java index 06246ce5..e0f3ca92 100644 --- a/src/main/java/moze_intel/projecte/api/item/IPedestalItem.java +++ b/src/main/java/moze_intel/projecte/api/item/IPedestalItem.java @@ -1,28 +1,30 @@ package moze_intel.projecte.api.item; +import java.util.List; + import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -import java.util.List; - /** - * This interface specifies items that perform a specific function every tick when inside an activated Dark Matter Pedestal + * This interface specifies items that perform a specific function every tick when inside + * an activated Dark Matter Pedestal * * @author williewillus */ public interface IPedestalItem { + String TOOLTIPDISABLED = EnumChatFormatting.RED + + StatCollector.translateToLocal("pe.pedestal.item_disabled"); - String TOOLTIPDISABLED = EnumChatFormatting.RED + StatCollector.translateToLocal("pe.pedestal.item_disabled"); - - /*** - * Called on both client and server each time an active DMPedestalTile ticks with this item inside - */ + /*** + * Called on both client and server each time an active DMPedestalTile ticks with this + * item inside + */ void updateInPedestal(World world, int x, int y, int z); - /*** - * Called clientside when inside the pedestal gui to add special function descriptions - * @return Brief strings describing the item's function in an activated pedestal - */ - List getPedestalDescription(); + /*** + * Called clientside when inside the pedestal gui to add special function descriptions + * @return Brief strings describing the item's function in an activated pedestal + */ + List getPedestalDescription(); } diff --git a/src/main/java/moze_intel/projecte/api/item/IProjectileShooter.java b/src/main/java/moze_intel/projecte/api/item/IProjectileShooter.java index 424be1ff..adbd37ea 100644 --- a/src/main/java/moze_intel/projecte/api/item/IProjectileShooter.java +++ b/src/main/java/moze_intel/projecte/api/item/IProjectileShooter.java @@ -4,15 +4,15 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; /** - * This interface specifies items that fire a projectile when the Shoot Projectile keybind is activated (default R) + * This interface specifies items that fire a projectile when the Shoot Projectile keybind + * is activated (default R) */ -public interface IProjectileShooter -{ - /** - * Called serverside when the player presses the Fire Projectile Button - * @param player The player pressing the key - * @param stack The stack we are using to shoot - * @return If the projectile was actually fired - */ - boolean shootProjectile(EntityPlayer player, ItemStack stack); +public interface IProjectileShooter { + /** + * Called serverside when the player presses the Fire Projectile Button + * @param player The player pressing the key + * @param stack The stack we are using to shoot + * @return If the projectile was actually fired + */ + boolean shootProjectile(EntityPlayer player, ItemStack stack); } diff --git a/src/main/java/moze_intel/projecte/api/proxy/IBlacklistProxy.java b/src/main/java/moze_intel/projecte/api/proxy/IBlacklistProxy.java index 59668025..652a0754 100644 --- a/src/main/java/moze_intel/projecte/api/proxy/IBlacklistProxy.java +++ b/src/main/java/moze_intel/projecte/api/proxy/IBlacklistProxy.java @@ -4,8 +4,7 @@ import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -public interface IBlacklistProxy -{ +public interface IBlacklistProxy { /** * Blacklist an Entity class from being repelled by the Interdiction Torch * Call this during the postinit phase @@ -22,15 +21,15 @@ public interface IBlacklistProxy /** * Prevent the Watch of Flowing Time from speeding up this TileEntity - * Modders: Use this only to prevent things from breaking badly - leave balance to the modpacker and player - * Call this during the postinit phase + * Modders: Use this only to prevent things from breaking badly - leave balance to the + * modpacker and player Call this during the postinit phase * @param clazz The TileEntity to blacklist */ void blacklistTimeWatch(Class clazz); /** - * Whitelist an ItemStack, allowing stacks of its kind to dupe NBT during Transmutation and Condensation - * Call this during the postinit phase + * Whitelist an ItemStack, allowing stacks of its kind to dupe NBT during + * Transmutation and Condensation Call this during the postinit phase * @param stack The stack to whitelist */ void whitelistNBT(ItemStack stack); diff --git a/src/main/java/moze_intel/projecte/api/proxy/IConversionProxy.java b/src/main/java/moze_intel/projecte/api/proxy/IConversionProxy.java index a028fc16..9f8e38f7 100644 --- a/src/main/java/moze_intel/projecte/api/proxy/IConversionProxy.java +++ b/src/main/java/moze_intel/projecte/api/proxy/IConversionProxy.java @@ -1,65 +1,75 @@ package moze_intel.projecte.api.proxy; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraft.block.Block; -import net.minecraft.item.Item; - import java.util.Map; -public interface IConversionProxy -{ - /** - * Add a Conversion to the EMC Calculation. - * - * Adding a Conversion allows ProjectE to calculate the EMC value for the output based on the specified ingredients. - * These do not need to be actually Conversions. You can use it to make the EMC value of an item relative to the EMC value of other items. - * ProjectE will automatically select the Conversion with the lowest EMC value. - * - * Has to be called after {@code FMLInitializationEvent} and before {@code FMLServerStartingEvent}. - * - * You can use the following things for the {@code output}-Parameter and the keys in the {@code ingredients} Map: - *

      - *
    • {@link ItemStack} - The ItemId and Metadata will be used to identify this ItemStack (May contain a {@code Block} or {@code Item}). You can use {@link net.minecraftforge.oredict.OreDictionary#WILDCARD_VALUE} as metadata.
    • - *
    • {@link Block} - Same as calling it with {@code new ItemStack(block)}. Uses the Id and metadata = 0
    • - *
    • {@link Item} - Same as calling it with {@code new ItemStack(item)}. Uses the Id and metadata = 0
    • - *
    • {@link FluidStack} - {@link FluidStack#getFluid()} and {@link Fluid#getName()} will be used to identify this Fluid.
    • - *
    • {@link String} - will be interpreted as an OreDictionary name.
    • - *
    • {@link Object} - (No subclasses of {@code Object} - only {@code Object}!) can be used as a intermediate fake object for complex conversion.
    • - *
    - * All {@code Object}s will be assumed to be a single instance. No stacksize will be used. - * - * Use the {@code amount} parameter to specify how many {@code output}s are created. - * Use the value in the {@code ingredients}-Map to specify how much of an ingredient is required. - * (Use Millibuckets for Fluids) - * - * Examples: - * - *
    {@code
    -	 * //Furnace Crafting Recipe:
    -	 * addConversion(1, Blocks.furnace, ImmutableMap.of((Object)Blocks.cobblestone, 8));
    -	 * //alternatively:
    -	 * addConversion(1, Blocks.furnace, ImmutableMap.of(Blocks.cobblestone, 8));
    -	 *
    -	 * //Bed Crafting Recipe with OreDictionary Names:
    -	 * //3 "plankWood" and 3 "blockWool" turn into 1 Blocks.bed
    -	 * addConversion(1, Blocks.bed, ImmutableMap.of("plankWood", 3, "blockWool", 3));
    -	 *
    -	 * //For Recipes that have multiple possible Ingredients, that don't belong to a known OreDict entry you can use a fake-item Object:
    -	 * Object blackOrWhite = new Object();
    -	 * //1 White Wool can be turned into 1 'blackOrWhite'
    -	 * addConversion(1, blackOrWhite, ImmutableMap.of((Object)new ItemStack(Blocks.wool, 1, 0), 1));
    -	 * //1 Black Wool can be turned into 1 'blackOrWhite'
    -	 * addConversion(1, blackOrWhite, ImmutableMap.of((Object)new ItemStack(Blocks.wool, 1, 15), 1));
    -	 * //Bed created with black or white wool only
    -	 * addConversion(1, Blocks.bed, ImmutableMap.of(blackOrWhite, 3, "plankWood", 3));
    -	 * }
    -	 * 
    - * - * @param amount - * @param output - * @param ingredients - */ - void addConversion(int amount, Object output, Map ingredients); +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +public interface IConversionProxy { + /** + * Add a Conversion to the EMC Calculation. + * + * Adding a Conversion allows ProjectE to calculate the EMC value for the output based + * on the specified ingredients. These do not need to be actually Conversions. You can + * use it to make the EMC value of an item relative to the EMC value of other items. + * ProjectE will automatically select the Conversion with the lowest EMC value. + * + * Has to be called after {@code FMLInitializationEvent} and before {@code + * FMLServerStartingEvent}. + * + * You can use the following things for the {@code output}-Parameter and the keys in + * the {@code ingredients} Map:
    • {@link ItemStack} - The ItemId and Metadata + * will be used to identify this ItemStack (May contain a {@code Block} or {@code + * Item}). You can use {@link net.minecraftforge.oredict.OreDictionary#WILDCARD_VALUE} + * as metadata.
    • {@link Block} - Same as calling it with {@code new + * ItemStack(block)}. Uses the Id and metadata = 0
    • {@link Item} - Same as + * calling it with {@code new ItemStack(item)}. Uses the Id and metadata = 0
    • + *
    • {@link FluidStack} - {@link FluidStack#getFluid()} and {@link + * Fluid#getName()} will be used to identify this Fluid.
    • {@link String} - + * will be interpreted as an OreDictionary name.
    • {@link Object} - (No + * subclasses of {@code Object} - only {@code Object}!) can be used as a intermediate + * fake object for complex conversion.
    • + *
    + * All {@code Object}s will be assumed to be a single instance. No stacksize will be + * used. + * + * Use the {@code amount} parameter to specify how many {@code output}s are created. + * Use the value in the {@code ingredients}-Map to specify how much of an ingredient + * is required. (Use Millibuckets for Fluids) + * + * Examples: + * + *
    {@code
    +     * //Furnace Crafting Recipe:
    +     * addConversion(1, Blocks.furnace, ImmutableMap.of((Object)Blocks.cobblestone, 8));
    +     * //alternatively:
    +     * addConversion(1, Blocks.furnace, ImmutableMap.of(Blocks.cobblestone, 8));
    +     *
    +     * //Bed Crafting Recipe with OreDictionary Names:
    +     * //3 "plankWood" and 3 "blockWool" turn into 1 Blocks.bed
    +     * addConversion(1, Blocks.bed, ImmutableMap.of("plankWood", 3,
    +     * "blockWool", 3));
    +     *
    +     * //For Recipes that have multiple possible Ingredients, that don't belong to a known
    +     * OreDict entry you can use a fake-item Object: Object blackOrWhite = new Object();
    +     * //1 White Wool can be turned into 1 'blackOrWhite'
    +     * addConversion(1, blackOrWhite, ImmutableMap.of((Object)new ItemStack(Blocks.wool,
    +     * 1, 0), 1));
    +     * //1 Black Wool can be turned into 1 'blackOrWhite'
    +     * addConversion(1, blackOrWhite, ImmutableMap.of((Object)new ItemStack(Blocks.wool,
    +     * 1, 15), 1));
    +     * //Bed created with black or white wool only
    +     * addConversion(1, Blocks.bed, ImmutableMap.of(blackOrWhite, 3, "plankWood", 3));
    +     * }
    +     * 
    + * + * @param amount + * @param output + * @param ingredients + */ + void addConversion(int amount, Object output, Map ingredients); } \ No newline at end of file diff --git a/src/main/java/moze_intel/projecte/api/proxy/IEMCProxy.java b/src/main/java/moze_intel/projecte/api/proxy/IEMCProxy.java index 07b3cdca..e1810fcf 100644 --- a/src/main/java/moze_intel/projecte/api/proxy/IEMCProxy.java +++ b/src/main/java/moze_intel/projecte/api/proxy/IEMCProxy.java @@ -1,13 +1,12 @@ package moze_intel.projecte.api.proxy; +import java.util.Map; + import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import java.util.Map; - -public interface IEMCProxy -{ +public interface IEMCProxy { /** * Registers a custom EMC value for this ItemStack * Call this during any of the main loading phases (Preinit, Init, Postinit) @@ -20,16 +19,18 @@ public interface IEMCProxy * Register a custom EMC value for emc calculation that is used in Recipes. * You can use the following things for the {@code o}-Parameter: *
      - *
    • {@link ItemStack} - The Modname:unlocalizedName and Metadata will be used to identify this ItemStack (May contain a {@code Block} or {@code Item})
    • + *
    • {@link ItemStack} - The Modname:unlocalizedName and Metadata will be used + * to identify this ItemStack (May contain a {@code Block} or {@code Item})
    • *
    • {@link String} - will be interpreted as an OreDictionary name.
    • - *
    • {@link Object} - (No subclasses of {@code Object} - only {@code Object}!) can be used as a intermediate fake object for complex recipes.
    • + *
    • {@link Object} - (No subclasses of {@code Object} - only {@code Object}!) + * can be used as a intermediate fake object for complex recipes.
    • *
    * @param o * @param value * @see IConversionProxy#addConversion(int, Object, Map) */ void registerCustomEMC(Object o, int value); - + /** * Queries the EMC value registry if the given block has an EMC value * Can be called at any time, but will only return valid results if a world is loaded @@ -40,9 +41,9 @@ public interface IEMCProxy boolean hasValue(Block block); /** - * Queries the EMC value registry if the given item with a damage value of 0 has an EMC value - * Can be called at any time, but will only return valid results if a world is loaded - * Can be called on both sides + * Queries the EMC value registry if the given item with a damage value of 0 has an + * EMC value Can be called at any time, but will only return valid results if a world + * is loaded Can be called on both sides * @param item The item we want to query * @return Whether the item has an emc value */ diff --git a/src/main/java/moze_intel/projecte/api/proxy/ITransmutationProxy.java b/src/main/java/moze_intel/projecte/api/proxy/ITransmutationProxy.java index cfc2aef9..9fea3fab 100644 --- a/src/main/java/moze_intel/projecte/api/proxy/ITransmutationProxy.java +++ b/src/main/java/moze_intel/projecte/api/proxy/ITransmutationProxy.java @@ -1,14 +1,13 @@ package moze_intel.projecte.api.proxy; +import java.util.List; +import java.util.UUID; +import javax.annotation.Nullable; + import net.minecraft.block.Block; import net.minecraft.item.ItemStack; -import javax.annotation.Nullable; -import java.util.List; -import java.util.UUID; - -public interface ITransmutationProxy -{ +public interface ITransmutationProxy { /** * Register a world transmutation with the Philosopher's Stone * Calls this during the postinit phase @@ -16,37 +15,53 @@ public interface ITransmutationProxy * @param originMeta Original metadata * @param result1 First result block * @param result1Meta First result metadata - * @param result2 Alternate result (when sneaking). You may pass null, in which there will be no alternate transmutation - * @param result2meta Alternate result metadata. If result2 is null, this value is ignored - * @return Whether the registration succeeded. It may fail if transmutations already exist for block origin + * @param result2 Alternate result (when sneaking). You may pass null, in which there + * will be no alternate transmutation + * @param result2meta Alternate result metadata. If result2 is null, this value is + * ignored + * @return Whether the registration succeeded. It may fail if transmutations already + * exist for block origin */ - boolean registerWorldTransmutation(Block origin, int originMeta, Block result1, int result1Meta, @Nullable Block result2, int result2meta); + boolean registerWorldTransmutation( + Block origin, + int originMeta, + Block result1, + int result1Meta, + @Nullable Block result2, + int result2meta + ); /** * Queries the knowledge of the provided player - * Can be called on both sides, only if the client player exists or the server is started - * If called on the client side, playerUUID is ignored and the client player is used instead + * Can be called on both sides, only if the client player exists or the server is + * started If called on the client side, playerUUID is ignored and the client player + * is used instead * @param playerUUID The Player to query * @param stack The ItemStack to query - * @return Whether the player has knowledge for this ItemStack, false if player is not found + * @return Whether the player has knowledge for this ItemStack, false if player is not + * found */ boolean hasKnowledgeFor(UUID playerUUID, ItemStack stack); /** * Queries all the knowledge of the provided player - * Can be called on both sides, only if the client player exists or the server is started - * If called on the client side, playerUUID is ignored and the client player is used instead + * Can be called on both sides, only if the client player exists or the server is + * started If called on the client side, playerUUID is ignored and the client player + * is used instead * @param playerUUID The Player to query - * @return List List of ItemStacks the player has transmutation knowledge of. + * @return List List of ItemStacks the player has transmutation knowledge + * of. */ List getKnowledge(UUID playerUUID); - + /** * Queries the knowledge of the provided player - * Can be called on both sides, only if the client player exists or the server is started - * If called on the client side, playerUUID is ignored and the client player is used instead + * Can be called on both sides, only if the client player exists or the server is + * started If called on the client side, playerUUID is ignored and the client player + * is used instead * @param playerUUID The Player to query - * @return Whether the player has full/override knowledge from the Tome, false if player is not found + * @return Whether the player has full/override knowledge from the Tome, false if + * player is not found * @deprecated as of API version 8, use {@link #hasKnowledgeFor(UUID, ItemStack)} */ @Deprecated @@ -69,8 +84,8 @@ public interface ITransmutationProxy void removeKnowledge(UUID playerUUID, ItemStack stack); /** - * Sets the player's personal transmutation emc to that provided. Only works if player is online - * Calls may only be issued on the server side, and if the server is running + * Sets the player's personal transmutation emc to that provided. Only works if player + * is online Calls may only be issued on the server side, and if the server is running * @param playerUUID The Player to modify * @param emc The value to set */ @@ -78,8 +93,9 @@ public interface ITransmutationProxy /** * Gets the player's personal transmutation emc - * Can be called on both sides, only if the client player exists or the server is started - * If called on the client side, playerUUID is ignored and the client player is used instead + * Can be called on both sides, only if the client player exists or the server is + * started If called on the client side, playerUUID is ignored and the client player + * is used instead * @param playerUUID The Player to modify * @return The emc, or NaN if player is not found */ diff --git a/src/main/java/moze_intel/projecte/api/tile/IEmcAcceptor.java b/src/main/java/moze_intel/projecte/api/tile/IEmcAcceptor.java index c5e33862..57662301 100644 --- a/src/main/java/moze_intel/projecte/api/tile/IEmcAcceptor.java +++ b/src/main/java/moze_intel/projecte/api/tile/IEmcAcceptor.java @@ -3,20 +3,20 @@ package moze_intel.projecte.api.tile; import net.minecraftforge.common.util.ForgeDirection; /** - * Implement this interface to specify that "EMC can be given to this Tile Entity from an external source" - * The contract of this interface is only the above statement - * However, ProjectE implements an "active-push" system, where providers automatically send EMC to acceptors. You are recommended to follow this convention - * Reference implementation provided in TileEmcHandler + * Implement this interface to specify that "EMC can be given to this Tile Entity from an + * external source" The contract of this interface is only the above statement However, + * ProjectE implements an "active-push" system, where providers automatically send EMC to + * acceptors. You are recommended to follow this convention Reference implementation + * provided in TileEmcHandler * * @author williewillus */ -public interface IEmcAcceptor extends IEmcStorage -{ - /** - * Accept, at most, the given amount of EMC from the given side - * @param side The side to accept EMC from - * @param toAccept The maximum amount to accept - * @return The amount actually accepted - */ - double acceptEMC(ForgeDirection side, double toAccept); +public interface IEmcAcceptor extends IEmcStorage { + /** + * Accept, at most, the given amount of EMC from the given side + * @param side The side to accept EMC from + * @param toAccept The maximum amount to accept + * @return The amount actually accepted + */ + double acceptEMC(ForgeDirection side, double toAccept); } diff --git a/src/main/java/moze_intel/projecte/api/tile/IEmcProvider.java b/src/main/java/moze_intel/projecte/api/tile/IEmcProvider.java index f39b5635..ccb503a3 100644 --- a/src/main/java/moze_intel/projecte/api/tile/IEmcProvider.java +++ b/src/main/java/moze_intel/projecte/api/tile/IEmcProvider.java @@ -3,20 +3,20 @@ package moze_intel.projecte.api.tile; import net.minecraftforge.common.util.ForgeDirection; /** - * Implement this interface to specify that "EMC can be taken from this Tile Entity from an external source" - * The contract of this interface is limited to only the above statement - * However, ProjectE implements an "active-push" system, where providers automatically send EMC to acceptors. You are recommended to follow this convention + * Implement this interface to specify that "EMC can be taken from this Tile Entity from + * an external source" The contract of this interface is limited to only the above + * statement However, ProjectE implements an "active-push" system, where providers + * automatically send EMC to acceptors. You are recommended to follow this convention * Reference implementation provided in TileEmcHandler * * @author williewillus */ -public interface IEmcProvider extends IEmcStorage -{ - /** - * Extract, at most, the given amount of EMC from the given side - * @param side The side to extract EMC from - * @param toExtract The maximum amount to extract - * @return The amount actually extracted - */ - double provideEMC(ForgeDirection side, double toExtract); +public interface IEmcProvider extends IEmcStorage { + /** + * Extract, at most, the given amount of EMC from the given side + * @param side The side to extract EMC from + * @param toExtract The maximum amount to extract + * @return The amount actually extracted + */ + double provideEMC(ForgeDirection side, double toExtract); } diff --git a/src/main/java/moze_intel/projecte/api/tile/IEmcStorage.java b/src/main/java/moze_intel/projecte/api/tile/IEmcStorage.java index 023e038e..0be6632d 100644 --- a/src/main/java/moze_intel/projecte/api/tile/IEmcStorage.java +++ b/src/main/java/moze_intel/projecte/api/tile/IEmcStorage.java @@ -3,21 +3,21 @@ package moze_intel.projecte.api.tile; /** * Defines the contract for arbitrary objects that can store EMC * You usually do not want to use this directly - * Use extensions IEMCAcceptor and IEMCProvider, or the provided reference implementations instead + * Use extensions IEMCAcceptor and IEMCProvider, or the provided reference implementations + * instead * * @author williewillus */ -public interface IEmcStorage -{ - /** - * Gets the current amount of EMC in this IEMCStorage - * @return The current EMC stored - */ - double getStoredEmc(); +public interface IEmcStorage { + /** + * Gets the current amount of EMC in this IEMCStorage + * @return The current EMC stored + */ + double getStoredEmc(); - /** - * Gets the maximum amount of EMC this IEMCStorage is allowed to contain - * @return The maximum EMC allowed - */ - double getMaximumEmc(); + /** + * Gets the maximum amount of EMC this IEMCStorage is allowed to contain + * @return The maximum EMC allowed + */ + double getMaximumEmc(); } diff --git a/src/main/java/moze_intel/projecte/api/tile/ITileEmc.java b/src/main/java/moze_intel/projecte/api/tile/ITileEmc.java index 13048e59..1b8b7741 100644 --- a/src/main/java/moze_intel/projecte/api/tile/ITileEmc.java +++ b/src/main/java/moze_intel/projecte/api/tile/ITileEmc.java @@ -1,50 +1,50 @@ package moze_intel.projecte.api.tile; /** - * This interface is now DEPRECATED. Do not use! Update to IEMCAcceptor, IEMCProvider, or TileEmcHandler ASAP!! - * You will not crash, but using this will have no effect as the ProjectE machines no longer recognize nor implement this interface + * This interface is now DEPRECATED. Do not use! Update to IEMCAcceptor, IEMCProvider, or + * TileEmcHandler ASAP!! You will not crash, but using this will have no effect as the + * ProjectE machines no longer recognize nor implement this interface */ @Deprecated -public interface ITileEmc -{ - /** - * Set the EMC value of this Tile Entity - * @param value The EMC amount to set - */ - @Deprecated - void setEmc(double value); +public interface ITileEmc { + /** + * Set the EMC value of this Tile Entity + * @param value The EMC amount to set + */ + @Deprecated + void setEmc(double value); - /** - * Add EMC to this Tile Entity - * @param value The EMC amount to add - */ - @Deprecated - void addEmc(double value); - - /** - * Remove EMC from the tile entity - * @param value The EMC amount to remove - */ - @Deprecated - void removeEmc(double value); - - /** - * @return The stored EMC in this TileEntity - */ - @Deprecated - double getStoredEmc(); - - /** - * @return Whether or not the EMC buffer is full - */ - @Deprecated - boolean hasMaxedEmc(); - - /** - * If this returns true, the Tile Entity will accept EMC from any valid provider - * EMC will be received only on the server side - * @return If this Tile Entity can accept EMC from adjacent providers - */ - @Deprecated - boolean isRequestingEmc(); + /** + * Add EMC to this Tile Entity + * @param value The EMC amount to add + */ + @Deprecated + void addEmc(double value); + + /** + * Remove EMC from the tile entity + * @param value The EMC amount to remove + */ + @Deprecated + void removeEmc(double value); + + /** + * @return The stored EMC in this TileEntity + */ + @Deprecated + double getStoredEmc(); + + /** + * @return Whether or not the EMC buffer is full + */ + @Deprecated + boolean hasMaxedEmc(); + + /** + * If this returns true, the Tile Entity will accept EMC from any valid provider + * EMC will be received only on the server side + * @return If this Tile Entity can accept EMC from adjacent providers + */ + @Deprecated + boolean isRequestingEmc(); } diff --git a/src/main/java/moze_intel/projecte/api/tile/TileEmcAcceptor.java b/src/main/java/moze_intel/projecte/api/tile/TileEmcAcceptor.java index 9ed9e318..c387dde3 100644 --- a/src/main/java/moze_intel/projecte/api/tile/TileEmcAcceptor.java +++ b/src/main/java/moze_intel/projecte/api/tile/TileEmcAcceptor.java @@ -7,13 +7,11 @@ import net.minecraftforge.common.util.ForgeDirection; * * @author williewillus */ -public class TileEmcAcceptor extends TileEmcBase implements IEmcAcceptor -{ - @Override - public double acceptEMC(ForgeDirection side, double toAccept) - { - double toAdd = Math.min(maximumEMC - currentEMC, toAccept); - addEMC(toAdd); - return toAdd; - } +public class TileEmcAcceptor extends TileEmcBase implements IEmcAcceptor { + @Override + public double acceptEMC(ForgeDirection side, double toAccept) { + double toAdd = Math.min(maximumEMC - currentEMC, toAccept); + addEMC(toAdd); + return toAdd; + } } diff --git a/src/main/java/moze_intel/projecte/api/tile/TileEmcBase.java b/src/main/java/moze_intel/projecte/api/tile/TileEmcBase.java index e1c425d9..f73274a3 100644 --- a/src/main/java/moze_intel/projecte/api/tile/TileEmcBase.java +++ b/src/main/java/moze_intel/projecte/api/tile/TileEmcBase.java @@ -4,87 +4,76 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; /** - * Base class for the reference implementations TileEmcProvider, TileEmcAcceptor, and TileEmcHandler - * Usually you want to use one of three derived reference implementations - * Extend this if you want fine-grained control over all aspects of how your tile provides or accepts EMC + * Base class for the reference implementations TileEmcProvider, TileEmcAcceptor, and + * TileEmcHandler Usually you want to use one of three derived reference implementations + * Extend this if you want fine-grained control over all aspects of how your tile provides + * or accepts EMC * * @author williewillus */ -public class TileEmcBase extends TileEntity implements IEmcStorage -{ - protected double maximumEMC; - protected double currentEMC = 0; +public class TileEmcBase extends TileEntity implements IEmcStorage { + protected double maximumEMC; + protected double currentEMC = 0; - protected TileEmcBase() - { - setMaximumEMC(Double.MAX_VALUE); - } + protected TileEmcBase() { + setMaximumEMC(Double.MAX_VALUE); + } - public final void setMaximumEMC(double max) - { - maximumEMC = max; - if (currentEMC > maximumEMC) - { - currentEMC = maximumEMC; - } - } + public final void setMaximumEMC(double max) { + maximumEMC = max; + if (currentEMC > maximumEMC) { + currentEMC = maximumEMC; + } + } - @Override - public double getStoredEmc() - { - return currentEMC; - } + @Override + public double getStoredEmc() { + return currentEMC; + } - @Override - public double getMaximumEmc() - { - return maximumEMC; - } + @Override + public double getMaximumEmc() { + return maximumEMC; + } - /** - * Add EMC directly into the internal buffer. Use for internal implementation of your tile - */ - protected void addEMC(double toAdd) - { - currentEMC += toAdd; - if (currentEMC > maximumEMC) - { - currentEMC = maximumEMC; - } - } + /** + * Add EMC directly into the internal buffer. Use for internal implementation of your + * tile + */ + protected void addEMC(double toAdd) { + currentEMC += toAdd; + if (currentEMC > maximumEMC) { + currentEMC = maximumEMC; + } + } - /** - * Removes EMC directly into the internal buffer. Use for internal implementation of your tile - */ - protected void removeEMC(double toRemove) - { - currentEMC -= toRemove; - if (currentEMC < 0) - { - currentEMC = 0; - } - } + /** + * Removes EMC directly into the internal buffer. Use for internal implementation of + * your tile + */ + protected void removeEMC(double toRemove) { + currentEMC -= toRemove; + if (currentEMC < 0) { + currentEMC = 0; + } + } - @Override - public void writeToNBT(NBTTagCompound tag) - { - super.writeToNBT(tag); - if (currentEMC > maximumEMC) - { - currentEMC = maximumEMC; - } - tag.setDouble("EMC", currentEMC); - } + @Override + public void writeToNBT(NBTTagCompound tag) { + super.writeToNBT(tag); + if (currentEMC > maximumEMC) { + currentEMC = maximumEMC; + } + tag.setDouble("EMC", currentEMC); + } - @Override - public void readFromNBT(NBTTagCompound tag) - { - super.readFromNBT(tag); - double set = tag.getDouble("EMC"); - if (set > maximumEMC) - { - set = maximumEMC; - } - currentEMC = set; - } + @Override + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); + double set = tag.getDouble("EMC"); + if (set > maximumEMC) { + set = maximumEMC; + } + currentEMC = set; + } } diff --git a/src/main/java/moze_intel/projecte/api/tile/TileEmcHandler.java b/src/main/java/moze_intel/projecte/api/tile/TileEmcHandler.java index efe843d2..d9388844 100644 --- a/src/main/java/moze_intel/projecte/api/tile/TileEmcHandler.java +++ b/src/main/java/moze_intel/projecte/api/tile/TileEmcHandler.java @@ -7,46 +7,39 @@ import net.minecraftforge.common.util.ForgeDirection; * * @author williewillus */ -public class TileEmcHandler extends TileEmcBase implements IEmcAcceptor, IEmcProvider -{ - public TileEmcHandler() - { - this.maximumEMC = Double.MAX_VALUE; - } +public class TileEmcHandler extends TileEmcBase implements IEmcAcceptor, IEmcProvider { + public TileEmcHandler() { + this.maximumEMC = Double.MAX_VALUE; + } - public TileEmcHandler(double max) - { - this.maximumEMC = max; - } + public TileEmcHandler(double max) { + this.maximumEMC = max; + } - // -- IEMCAcceptor -- // - @Override - public double acceptEMC(ForgeDirection side, double toAccept) - { - double toAdd = Math.min(maximumEMC - currentEMC, toAccept); - currentEMC += toAdd; - return toAdd; - } + // -- IEMCAcceptor -- // + @Override + public double acceptEMC(ForgeDirection side, double toAccept) { + double toAdd = Math.min(maximumEMC - currentEMC, toAccept); + currentEMC += toAdd; + return toAdd; + } - // -- IEMCProvider -- // - @Override - public double provideEMC(ForgeDirection side, double toExtract) - { - double toRemove = Math.min(currentEMC, toExtract); - currentEMC -= toRemove; - return toRemove; - } + // -- IEMCProvider -- // + @Override + public double provideEMC(ForgeDirection side, double toExtract) { + double toRemove = Math.min(currentEMC, toExtract); + currentEMC -= toRemove; + return toRemove; + } - // -- IEMCStorage --// - @Override - public double getStoredEmc() - { - return currentEMC; - } + // -- IEMCStorage --// + @Override + public double getStoredEmc() { + return currentEMC; + } - @Override - public double getMaximumEmc() - { - return maximumEMC; - } + @Override + public double getMaximumEmc() { + return maximumEMC; + } } diff --git a/src/main/java/moze_intel/projecte/api/tile/TileEmcProvider.java b/src/main/java/moze_intel/projecte/api/tile/TileEmcProvider.java index 15b3da99..ce693477 100644 --- a/src/main/java/moze_intel/projecte/api/tile/TileEmcProvider.java +++ b/src/main/java/moze_intel/projecte/api/tile/TileEmcProvider.java @@ -7,13 +7,11 @@ import net.minecraftforge.common.util.ForgeDirection; * * @author williewillus */ -public class TileEmcProvider extends TileEmcBase implements IEmcProvider -{ - @Override - public double provideEMC(ForgeDirection side, double toExtract) - { - double toRemove = Math.min(currentEMC, toExtract); - removeEMC(toRemove); - return toRemove; - } +public class TileEmcProvider extends TileEmcBase implements IEmcProvider { + @Override + public double provideEMC(ForgeDirection side, double toExtract) { + double toRemove = Math.min(currentEMC, toExtract); + removeEMC(toRemove); + return toRemove; + } }