diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java index 5e18bfa08..184dd51a3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java @@ -39,10 +39,10 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; -public final class ActuallyAdditionsAPI{ +public final class ActuallyAdditionsAPI { public static final String MOD_ID = "actuallyadditions"; - public static final String API_ID = MOD_ID+"api"; + public static final String API_ID = MOD_ID + "api"; public static final String API_VERSION = "34"; public static final List CRUSHER_RECIPES = new ArrayList<>(); @@ -116,7 +116,7 @@ public final class ActuallyAdditionsAPI{ * @param oreName The ore's name * @param weight The ore's weight */ - public static void addMiningLensStoneOre(String oreName, int weight){ + public static void addMiningLensStoneOre(String oreName, int weight) { STONE_ORES.add(new WeightedOre(oreName, weight)); } @@ -127,7 +127,7 @@ public final class ActuallyAdditionsAPI{ * @param oreName The ore's name * @param weight The ore's weight */ - public static void addMiningLensNetherOre(String oreName, int weight){ + public static void addMiningLensNetherOre(String oreName, int weight) { NETHERRACK_ORES.add(new WeightedOre(oreName, weight)); } @@ -139,7 +139,7 @@ public final class ActuallyAdditionsAPI{ * @param outputTwo The second output as an ItemStack (can be ItemStack.EMPTY if there should be none) * @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time) */ - public static void addCrusherRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance){ + public static void addCrusherRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance) { CRUSHER_RECIPES.add(new CrusherRecipe(Ingredient.fromStacks(input), outputOne, outputTwo.isEmpty() ? ItemStack.EMPTY : outputTwo, outputTwoChance)); } @@ -151,7 +151,7 @@ public final class ActuallyAdditionsAPI{ * @param outputTwo The second output as an ItemStack (can be ItemStack.EMPTY if there should be none) * @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time) */ - public static void addCrusherRecipe(Ingredient input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance){ + public static void addCrusherRecipe(Ingredient input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance) { CRUSHER_RECIPES.add(new CrusherRecipe(input, outputOne, outputTwo.isEmpty() ? ItemStack.EMPTY : outputTwo, outputTwoChance)); } @@ -166,13 +166,13 @@ public final class ActuallyAdditionsAPI{ * @param outputTwoAmounts The amount of the second output, will be equal for all entries in the list * @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time) */ - public static boolean addCrusherRecipes(List inputs, List outputOnes, int outputOneAmounts, List outputTwos, int outputTwoAmounts, int outputTwoChance){ + public static boolean addCrusherRecipes(List inputs, List outputOnes, int outputOneAmounts, List outputTwos, int outputTwoAmounts, int outputTwoChance) { return methodHandler.addCrusherRecipes(inputs, outputOnes, outputOneAmounts, outputTwos, outputTwoAmounts, outputTwoChance); } //Same thing as above, but with ItemStack outputs. @Deprecated //Use Ingredient - public static boolean addCrusherRecipes(List inputs, ItemStack outputOne, int outputOneAmount, ItemStack outputTwo, int outputTwoAmount, int outputTwoChance){ + public static boolean addCrusherRecipes(List inputs, ItemStack outputOne, int outputOneAmount, ItemStack outputTwo, int outputTwoAmount, int outputTwoChance) { return methodHandler.addCrusherRecipes(inputs, outputOne, outputOneAmount, outputTwo, outputTwoAmount, outputTwoChance); } @@ -182,7 +182,7 @@ public final class ActuallyAdditionsAPI{ * @param fluidName The name of the fluid to be consumed * @param genAmount The amount of energy generated per operation */ - public static void addOilGenRecipe(String fluidName, int genAmount){ + public static void addOilGenRecipe(String fluidName, int genAmount) { addOilGenRecipe(fluidName, genAmount, 100); } @@ -192,7 +192,7 @@ public final class ActuallyAdditionsAPI{ * @param fluidName The name of the fluid to be consumed * @param genAmount The amount of energy generated per operation */ - public static void addOilGenRecipe(String fluidName, int genAmount, int genTime){ + public static void addOilGenRecipe(String fluidName, int genAmount, int genTime) { OIL_GENERATOR_RECIPES.add(new OilGenRecipe(fluidName, genAmount, genTime)); } @@ -205,7 +205,7 @@ public final class ActuallyAdditionsAPI{ * @param outputDisplay The block to display when there is output in the compost */ @Deprecated - public static void addCompostRecipe(ItemStack input, Block inputDisplay, ItemStack output, Block outputDisplay){ + public static void addCompostRecipe(ItemStack input, Block inputDisplay, ItemStack output, Block outputDisplay) { COMPOST_RECIPES.add(new CompostRecipe(input, inputDisplay, output, outputDisplay)); } @@ -217,7 +217,7 @@ public final class ActuallyAdditionsAPI{ * @param output The itemstack to be output from the compost once conversion finishes * @param outputDisplay The state to display when there is output in the compost */ - public static void addCompostRecipe(Ingredient input, IBlockState inputDisplay, ItemStack output, IBlockState outputDisplay){ + public static void addCompostRecipe(Ingredient input, IBlockState inputDisplay, ItemStack output, IBlockState outputDisplay) { COMPOST_RECIPES.add(new CompostRecipe(input, inputDisplay, output, outputDisplay)); } @@ -227,7 +227,7 @@ public final class ActuallyAdditionsAPI{ * @param stack The ItemStack to be returned * @param chance The chance (this is from WeightedRandom.Item) */ - public static void addBallOfFurReturnItem(ItemStack stack, int chance){ + public static void addBallOfFurReturnItem(ItemStack stack, int chance) { BALL_OF_FUR_RETURN_ITEMS.add(new BallOfFurReturn(stack, chance)); } @@ -239,16 +239,16 @@ public final class ActuallyAdditionsAPI{ * @param minAmount The minimum stacksize of the returned stack * @param maxAmount The maximum stacksize of the returned stack */ - public static void addTreasureChestLoot(ItemStack stack, int chance, int minAmount, int maxAmount){ + public static void addTreasureChestLoot(ItemStack stack, int chance, int minAmount, int maxAmount) { TREASURE_CHEST_LOOT.add(new TreasureChestLoot(stack, chance, minAmount, maxAmount)); } @Deprecated - public static void addEmpowererRecipe(ItemStack input, ItemStack output, ItemStack modifier1, ItemStack modifier2, ItemStack modifier3, ItemStack modifier4, int energyPerStand, int time, float[] particleColor){ + public static void addEmpowererRecipe(ItemStack input, ItemStack output, ItemStack modifier1, ItemStack modifier2, ItemStack modifier3, ItemStack modifier4, int energyPerStand, int time, float[] particleColor) { EMPOWERER_RECIPES.add(new EmpowererRecipe(input, output, modifier1, modifier2, modifier3, modifier4, energyPerStand, time, particleColor)); } - public static void addEmpowererRecipe(Ingredient input, ItemStack output, Ingredient modifier1, Ingredient modifier2, Ingredient modifier3, Ingredient modifier4, int energyPerStand, int time, float[] particleColor){ + public static void addEmpowererRecipe(Ingredient input, ItemStack output, Ingredient modifier1, Ingredient modifier2, Ingredient modifier3, Ingredient modifier4, int energyPerStand, int time, float[] particleColor) { EMPOWERER_RECIPES.add(new EmpowererRecipe(input, output, modifier1, modifier2, modifier3, modifier4, energyPerStand, time, particleColor)); } @@ -263,12 +263,12 @@ public final class ActuallyAdditionsAPI{ * Note how this always has to be the same instance of the lens type that the item also has for it to work! */ @Deprecated - public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse, LensConversion type){ + public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse, LensConversion type) { RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(new LensConversionRecipe(input, output, energyUse, type)); } @Deprecated - public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse){ + public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse) { addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion); } @@ -282,11 +282,11 @@ public final class ActuallyAdditionsAPI{ * @param type The type of lens used for the conversion. To use the default type, use method below. * Note how this always has to be the same instance of the lens type that the item also has for it to work! */ - public static void addReconstructorLensConversionRecipe(Ingredient input, ItemStack output, int energyUse, LensConversion type){ + public static void addReconstructorLensConversionRecipe(Ingredient input, ItemStack output, int energyUse, LensConversion type) { RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(new LensConversionRecipe(input, output, energyUse, type)); } - public static void addReconstructorLensConversionRecipe(Ingredient input, ItemStack output, int energyUse){ + public static void addReconstructorLensConversionRecipe(Ingredient input, ItemStack output, int energyUse) { addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion); } @@ -299,7 +299,7 @@ public final class ActuallyAdditionsAPI{ * @param item The item (or block's item) to add * @param changer The change mechanism */ - public static void addReconstructorLensColorChangeItem(Item item, IColorLensChanger changer){ + public static void addReconstructorLensColorChangeItem(Item item, IColorLensChanger changer) { RECONSTRUCTOR_LENS_COLOR_CHANGERS.put(item, changer); } @@ -308,7 +308,7 @@ public final class ActuallyAdditionsAPI{ * * @param ingredient The ingredient to add */ - public static void addCoffeeMachineIngredient(CoffeeIngredient ingredient){ + public static void addCoffeeMachineIngredient(CoffeeIngredient ingredient) { COFFEE_MACHINE_INGREDIENTS.add(ingredient); } @@ -317,7 +317,7 @@ public final class ActuallyAdditionsAPI{ * * @param entry The entry to add */ - public static void addBookletEntry(IBookletEntry entry){ + public static void addBookletEntry(IBookletEntry entry) { BOOKLET_ENTRIES.add(entry); } @@ -326,7 +326,7 @@ public final class ActuallyAdditionsAPI{ * * @param behavior The behavior to add */ - public static void addFarmerBehavior(IFarmerBehavior behavior){ + public static void addFarmerBehavior(IFarmerBehavior behavior) { FARMER_BEHAVIORS.add(behavior); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletChapter.java b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletChapter.java index d20994617..7e8ade57c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletChapter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletChapter.java @@ -14,7 +14,7 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public interface IBookletChapter{ +public interface IBookletChapter { IBookletPage[] getAllPages(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletEntry.java b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletEntry.java index 1656165a4..43b7683c9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletEntry.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletEntry.java @@ -10,12 +10,12 @@ package de.ellpeck.actuallyadditions.api.booklet; +import java.util.List; + import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.List; - -public interface IBookletEntry{ +public interface IBookletEntry { List getAllChapters(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletPage.java b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletPage.java index 663647332..9651ae51c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletPage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletPage.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.api.booklet; +import java.util.List; + import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; import net.minecraft.client.gui.GuiButton; import net.minecraft.item.ItemStack; @@ -17,9 +19,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.List; - -public interface IBookletPage{ +public interface IBookletPage { void getItemStacksForPage(List list); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/internal/GuiBookletBase.java b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/internal/GuiBookletBase.java index 8ea05d4b3..71c1af5ef 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/internal/GuiBookletBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/internal/GuiBookletBase.java @@ -10,13 +10,13 @@ package de.ellpeck.actuallyadditions.api.booklet.internal; +import java.util.List; + import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.item.ItemStack; -import java.util.List; - -public abstract class GuiBookletBase extends GuiScreen{ +public abstract class GuiBookletBase extends GuiScreen { public abstract void renderScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IAtomicReconstructor.java b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IAtomicReconstructor.java index 6feba7c5e..5fd2ad1a1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IAtomicReconstructor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IAtomicReconstructor.java @@ -19,7 +19,7 @@ import net.minecraft.util.EnumFacing; * This is not supposed to be implemented. * Can be cast to TileEntity. */ -public interface IAtomicReconstructor extends IEnergyTile{ +public interface IAtomicReconstructor extends IEnergyTile { Lens getLens(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IEnergyTile.java b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IEnergyTile.java index 07c44717b..cffde8875 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IEnergyTile.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IEnergyTile.java @@ -17,7 +17,7 @@ import net.minecraft.world.World; * This is not supposed to be implemented. * Can be cast to TileEntity. */ -public interface IEnergyTile{ +public interface IEnergyTile { BlockPos getPosition(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IFarmer.java b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IFarmer.java index fa7eab4a5..07f8b51bb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IFarmer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IFarmer.java @@ -10,18 +10,18 @@ package de.ellpeck.actuallyadditions.api.internal; +import java.util.List; + import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; -import java.util.List; - /** * This is a helper interface for IFarmerBehavior. *

* This is not supposed to be implemented. * Can be cast to TileEntity. */ -public interface IFarmer extends IEnergyTile{ +public interface IFarmer extends IEnergyTile { EnumFacing getOrientation(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java index e44b4a792..b6dd6c2ad 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java @@ -28,7 +28,7 @@ import net.minecraft.util.math.BlockPos; * Use ActuallyAdditionsAPI.methodHandler for calling * This is not supposed to be implemented. */ -public interface IMethodHandler{ +public interface IMethodHandler { boolean addEffectToStack(ItemStack stack, CoffeeIngredient ingredient); @@ -43,6 +43,7 @@ public interface IMethodHandler{ boolean invokeConversionLens(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile); boolean invokeReconstructor(IAtomicReconstructor tile); + boolean addCrusherRecipes(List inputs, List outputOnes, int outputOneAmounts, List outputTwos, int outputTwoAmounts, int outputTwoChance); @Deprecated //Use Ingredient input on AA API class diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/laser/IConnectionPair.java b/src/main/java/de/ellpeck/actuallyadditions/api/laser/IConnectionPair.java index d5ff87fbb..6155cab35 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/laser/IConnectionPair.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/laser/IConnectionPair.java @@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.api.laser; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; -public interface IConnectionPair{ +public interface IConnectionPair { void writeToNBT(NBTTagCompound compound); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/laser/ILaserRelayConnectionHandler.java b/src/main/java/de/ellpeck/actuallyadditions/api/laser/ILaserRelayConnectionHandler.java index 27cbbdb7e..700eed229 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/laser/ILaserRelayConnectionHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/laser/ILaserRelayConnectionHandler.java @@ -23,7 +23,7 @@ import net.minecraft.world.World; * The network system is built in a way that doesn't need the individual * positions to be Laser Relays, it relies only on BlockPos */ -public interface ILaserRelayConnectionHandler{ +public interface ILaserRelayConnectionHandler { ConcurrentSet getConnectionsFor(BlockPos relay, World world); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/laser/LaserType.java b/src/main/java/de/ellpeck/actuallyadditions/api/laser/LaserType.java index f229a4be7..38c125f95 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/laser/LaserType.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/laser/LaserType.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.api.laser; -public enum LaserType{ - ENERGY, ITEM, FLUID +public enum LaserType { + ENERGY, + ITEM, + FLUID } diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/laser/Network.java b/src/main/java/de/ellpeck/actuallyadditions/api/laser/Network.java index 0771bd272..5bfabd862 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/laser/Network.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/laser/Network.java @@ -12,22 +12,20 @@ package de.ellpeck.actuallyadditions.api.laser; import io.netty.util.internal.ConcurrentSet; -public class Network{ +public class Network { public final ConcurrentSet connections = new ConcurrentSet<>(); public int changeAmount; @Override - public String toString(){ + public String toString() { return this.connections.toString(); } @Override - public boolean equals(Object obj){ - if(obj instanceof Network){ - if(this.connections.equals(((Network)obj).connections)){ - return true; - } + public boolean equals(Object obj) { + if (obj instanceof Network) { + if (this.connections.equals(((Network) obj).connections)) { return true; } } return super.equals(obj); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/lens/ILensItem.java b/src/main/java/de/ellpeck/actuallyadditions/api/lens/ILensItem.java index 5c86eaeab..5fbb28388 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/lens/ILensItem.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/lens/ILensItem.java @@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.api.lens; /** * This is the base class for a Reconstructor Lens Item */ -public interface ILensItem{ +public interface ILensItem { /** * Returns the lens type that belongs to this lens item diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java b/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java index ad0551c52..b5ebb9c63 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java @@ -18,7 +18,7 @@ import net.minecraft.util.math.BlockPos; /** * This is the base class for a Reconstructor Lens Type (NOT THE ITEM!) */ -public abstract class Lens{ +public abstract class Lens { /** * Invokes the lens type's behavior on a block @@ -42,7 +42,7 @@ public abstract class Lens{ /** * @return If the lens can be invoked at the current time */ - public boolean canInvoke(IAtomicReconstructor tile, EnumFacing sideToShootTo, int energyUsePerShot){ + public boolean canInvoke(IAtomicReconstructor tile, EnumFacing sideToShootTo, int energyUsePerShot) { return true; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/lens/LensConversion.java b/src/main/java/de/ellpeck/actuallyadditions/api/lens/LensConversion.java index 5056923f4..195af9e34 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/lens/LensConversion.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/lens/LensConversion.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.api.lens; - import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import net.minecraft.block.state.IBlockState; @@ -23,20 +22,20 @@ import net.minecraft.util.math.BlockPos; * If you want to make a new type of conversion, just use your type in the recipe * If you want to use the default type of conversion, use ActuallyAdditionsAPI.lensDefaultConversion. */ -public class LensConversion extends Lens{ +public class LensConversion extends Lens { @Override - public boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile){ + public boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) { return ActuallyAdditionsAPI.methodHandler.invokeConversionLens(hitState, hitBlock, tile); } @Override - public float[] getColor(){ - return new float[]{27F/255F, 109F/255F, 1F}; + public float[] getColor() { + return new float[] { 27F / 255F, 109F / 255F, 1F }; } @Override - public int getDistance(){ + public int getDistance() { return 10; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/misc/IDisplayStandItem.java b/src/main/java/de/ellpeck/actuallyadditions/api/misc/IDisplayStandItem.java index 3af616b33..21605c82b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/misc/IDisplayStandItem.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/misc/IDisplayStandItem.java @@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.api.misc; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -public interface IDisplayStandItem{ +public interface IDisplayStandItem { boolean update(ItemStack stack, TileEntity tile, int elapsedTicks); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/misc/IGoggles.java b/src/main/java/de/ellpeck/actuallyadditions/api/misc/IGoggles.java index bac0cc4ab..6dfff7269 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/misc/IGoggles.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/misc/IGoggles.java @@ -10,7 +10,7 @@ package de.ellpeck.actuallyadditions.api.misc; -public interface IGoggles{ +public interface IGoggles { boolean displaySpectralMobs(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/BallOfFurReturn.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/BallOfFurReturn.java index 2fef1b060..ef77dc8ee 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/BallOfFurReturn.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/BallOfFurReturn.java @@ -13,11 +13,11 @@ package de.ellpeck.actuallyadditions.api.recipe; import net.minecraft.item.ItemStack; import net.minecraft.util.WeightedRandom; -public class BallOfFurReturn extends WeightedRandom.Item{ +public class BallOfFurReturn extends WeightedRandom.Item { public final ItemStack returnItem; - public BallOfFurReturn(ItemStack returnItem, int chance){ + public BallOfFurReturn(ItemStack returnItem, int chance) { super(chance); this.returnItem = returnItem; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java index 607f01b0c..5522e7318 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java @@ -15,7 +15,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; -public class CompostRecipe{ +public class CompostRecipe { protected final Ingredient input; protected final ItemStack output; @@ -27,7 +27,7 @@ public class CompostRecipe{ this(Ingredient.fromStacks(input), inputDisplay.getDefaultState(), output, outputDisplay.getDefaultState()); } - public CompostRecipe(Ingredient input, IBlockState inputDisplay, ItemStack output, IBlockState outputDisplay){ + public CompostRecipe(Ingredient input, IBlockState inputDisplay, ItemStack output, IBlockState outputDisplay) { this.input = input; this.output = output; this.inputDisplay = inputDisplay; diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/IColorLensChanger.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/IColorLensChanger.java index 229d813ce..876ea10f3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/IColorLensChanger.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/IColorLensChanger.java @@ -22,7 +22,7 @@ import net.minecraft.util.math.BlockPos; *

* See ColorLensChangerByDyeMeta for reference. */ -public interface IColorLensChanger{ +public interface IColorLensChanger { /** * Modifies the given item. diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/OilGenRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/OilGenRecipe.java index 89131ed41..51d4fc206 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/OilGenRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/OilGenRecipe.java @@ -10,7 +10,7 @@ package de.ellpeck.actuallyadditions.api.recipe; -public class OilGenRecipe{ +public class OilGenRecipe { public final String fluidName; public final int genAmount; @@ -22,7 +22,7 @@ public class OilGenRecipe{ * @param genAmount The power generated, in CF/t * @param genTime The length the fluid burns for, in seconds */ - public OilGenRecipe(String fluidName, int genAmount, int genTime){ + public OilGenRecipe(String fluidName, int genAmount, int genTime) { this.fluidName = fluidName; this.genAmount = genAmount; this.genTime = genTime; diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/TreasureChestLoot.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/TreasureChestLoot.java index 815a21ee5..3560bf1b6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/TreasureChestLoot.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/TreasureChestLoot.java @@ -13,13 +13,13 @@ package de.ellpeck.actuallyadditions.api.recipe; import net.minecraft.item.ItemStack; import net.minecraft.util.WeightedRandom; -public class TreasureChestLoot extends WeightedRandom.Item{ +public class TreasureChestLoot extends WeightedRandom.Item { public final ItemStack returnItem; public final int minAmount; public final int maxAmount; - public TreasureChestLoot(ItemStack returnItem, int chance, int minAmount, int maxAmount){ + public TreasureChestLoot(ItemStack returnItem, int chance, int minAmount, int maxAmount) { super(chance); this.returnItem = returnItem; this.minAmount = minAmount; diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/WeightedOre.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/WeightedOre.java index e881bf6f7..9cd0a93dd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/WeightedOre.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/WeightedOre.java @@ -12,11 +12,11 @@ package de.ellpeck.actuallyadditions.api.recipe; import net.minecraft.util.WeightedRandom; -public class WeightedOre extends WeightedRandom.Item{ +public class WeightedOre extends WeightedRandom.Item { public final String name; - public WeightedOre(String name, int weight){ + public WeightedOre(String name, int weight) { super(weight); this.name = name; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/tile/IPhantomTile.java b/src/main/java/de/ellpeck/actuallyadditions/api/tile/IPhantomTile.java index 856ff444e..a56c0ee07 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/tile/IPhantomTile.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/tile/IPhantomTile.java @@ -15,7 +15,7 @@ import net.minecraft.util.math.BlockPos; /** * Extending this will cause a TileEntity to be able to be connected via a Phantom Connector */ -public interface IPhantomTile{ +public interface IPhantomTile { /** * @return If the Phantom Tile is currently bound to anything diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ClientRegistryHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ClientRegistryHandler.java index b62665423..15401d56a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/ClientRegistryHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/ClientRegistryHandler.java @@ -1,5 +1,8 @@ package de.ellpeck.actuallyadditions.mod; +import java.util.HashMap; +import java.util.Map; + import de.ellpeck.actuallyadditions.mod.blocks.render.ActualCompostModel; import de.ellpeck.actuallyadditions.mod.blocks.render.CompostModel; import de.ellpeck.actuallyadditions.mod.blocks.render.IHasModel; @@ -17,17 +20,14 @@ import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import java.util.HashMap; -import java.util.Map; - -public class ClientRegistryHandler{ +public class ClientRegistryHandler { public static final Map MODEL_LOCATIONS_FOR_REGISTERING = new HashMap<>(); /** * (Excerpted from Tinkers' Construct with permission, thanks guys!) */ - private static void registerCustomFluidBlockRenderer(Fluid fluid){ + private static void registerCustomFluidBlockRenderer(Fluid fluid) { Block block = fluid.getBlock(); Item item = Item.getItemFromBlock(block); FluidStateMapper mapper = new FluidStateMapper(fluid); @@ -37,14 +37,14 @@ public class ClientRegistryHandler{ } @SubscribeEvent - public void onModelRegistry(ModelRegistryEvent event){ - for(Block block : RegistryHandler.BLOCKS_TO_REGISTER){ - if(block instanceof IHasModel){ - ((IHasModel)block).registerRendering(); + public void onModelRegistry(ModelRegistryEvent event) { + for (Block block : RegistryHandler.BLOCKS_TO_REGISTER) { + if (block instanceof IHasModel) { + ((IHasModel) block).registerRendering(); } } - for(Map.Entry entry : MODEL_LOCATIONS_FOR_REGISTERING.entrySet()){ + for (Map.Entry entry : MODEL_LOCATIONS_FOR_REGISTERING.entrySet()) { ModelLoader.setCustomModelResourceLocation(entry.getKey().getItem(), entry.getKey().getItemDamage(), entry.getValue()); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/RegistryHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/RegistryHandler.java index 446b14928..0f4ed0d25 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/RegistryHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/RegistryHandler.java @@ -1,5 +1,8 @@ package de.ellpeck.actuallyadditions.mod; +import java.util.ArrayList; +import java.util.List; + import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.crafting.InitCrafting; @@ -15,11 +18,8 @@ import net.minecraftforge.event.RegistryEvent.Register; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession; -import java.util.ArrayList; -import java.util.List; - //Class to wrap around the trainwreck that is the new registry system -public class RegistryHandler{ +public class RegistryHandler { public static final List BLOCKS_TO_REGISTER = new ArrayList<>(); public static final List ITEMS_TO_REGISTER = new ArrayList<>(); @@ -27,19 +27,19 @@ public class RegistryHandler{ public static final List RECIPES_TO_REGISTER = new ArrayList<>(); @SubscribeEvent - public void onBlockRegistry(Register event){ + public void onBlockRegistry(Register event) { InitBlocks.init(); - for(Block block : BLOCKS_TO_REGISTER){ + for (Block block : BLOCKS_TO_REGISTER) { event.getRegistry().register(block); } } @SubscribeEvent - public void onItemRegistry(Register event){ + public void onItemRegistry(Register event) { InitItems.init(); - for(Item item : ITEMS_TO_REGISTER){ + for (Item item : ITEMS_TO_REGISTER) { event.getRegistry().register(item); } ITEMS_TO_REGISTER.clear(); @@ -49,28 +49,28 @@ public class RegistryHandler{ } @SubscribeEvent - public void onVillagerRegistry(Register event){ + public void onVillagerRegistry(Register event) { InitVillager.init(); - if(ConfigBoolValues.JAM_VILLAGER_EXISTS.isEnabled()) event.getRegistry().register(InitVillager.jamProfession); - if(ConfigBoolValues.ENGINEER_VILLAGER_EXISTS.isEnabled()) event.getRegistry().register(InitVillager.engineerProfession); + if (ConfigBoolValues.JAM_VILLAGER_EXISTS.isEnabled()) event.getRegistry().register(InitVillager.jamProfession); + if (ConfigBoolValues.ENGINEER_VILLAGER_EXISTS.isEnabled()) event.getRegistry().register(InitVillager.engineerProfession); } @SubscribeEvent - public void onCraftingRegistry(Register event){ + public void onCraftingRegistry(Register event) { InitCrafting.init(); - for(IRecipe recipe : RECIPES_TO_REGISTER){ + for (IRecipe recipe : RECIPES_TO_REGISTER) { event.getRegistry().register(recipe); } RECIPES_TO_REGISTER.clear(); } @SubscribeEvent - public void onSoundRegistry(Register event){ + public void onSoundRegistry(Register event) { SoundHandler.init(); - for(SoundEvent sound : SOUNDS_TO_REGISTER){ + for (SoundEvent sound : SOUNDS_TO_REGISTER) { event.getRegistry().register(sound); } SOUNDS_TO_REGISTER.clear(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java index 2f3986fbe..df91f13ad 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.blocks; +import java.util.List; + import de.ellpeck.actuallyadditions.api.lens.ILensItem; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; @@ -47,14 +49,12 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.List; - -public class BlockAtomicReconstructor extends BlockContainerBase implements IHudDisplay{ +public class BlockAtomicReconstructor extends BlockContainerBase implements IHudDisplay { public static final int NAME_FLAVOR_AMOUNTS_1 = 12; public static final int NAME_FLAVOR_AMOUNTS_2 = 14; - public BlockAtomicReconstructor(String name){ + public BlockAtomicReconstructor(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(10F); @@ -63,36 +63,33 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { ItemStack heldItem = player.getHeldItem(hand); - if(this.tryToggleRedstone(world, pos, player)){ - return true; - } - if(!world.isRemote){ - TileEntityAtomicReconstructor reconstructor = (TileEntityAtomicReconstructor)world.getTileEntity(pos); - if(reconstructor != null){ - if(StackUtil.isValid(heldItem)){ + if (this.tryToggleRedstone(world, pos, player)) { return true; } + if (!world.isRemote) { + TileEntityAtomicReconstructor reconstructor = (TileEntityAtomicReconstructor) world.getTileEntity(pos); + if (reconstructor != null) { + if (StackUtil.isValid(heldItem)) { Item item = heldItem.getItem(); - if(item instanceof ILensItem && !StackUtil.isValid(reconstructor.inv.getStackInSlot(0))){ + if (item instanceof ILensItem && !StackUtil.isValid(reconstructor.inv.getStackInSlot(0))) { ItemStack toPut = heldItem.copy(); toPut.setCount(1); reconstructor.inv.setStackInSlot(0, toPut); player.inventory.decrStackSize(player.inventory.currentItem, 1); } //Shush, don't tell anyone! - else if(ConfigIntValues.ELEVEN.getValue() == 11 && item == Items.RECORD_11){ + else if (ConfigIntValues.ELEVEN.getValue() == 11 && item == Items.RECORD_11) { reconstructor.counter++; reconstructor.markDirty(); } - } - else{ + } else { ItemStack slot = reconstructor.inv.getStackInSlot(0); - if(StackUtil.isValid(slot)){ + if (StackUtil.isValid(slot)) { player.setHeldItem(hand, slot.copy()); reconstructor.inv.setStackInSlot(0, StackUtil.getEmpty()); } @@ -102,43 +99,41 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud return true; } - @Override - public TileEntity createNewTileEntity(World world, int i){ + public TileEntity createNewTileEntity(World world, int i) { return new TileEntityAtomicReconstructor(); } @Override @SideOnly(Side.CLIENT) - public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){ + public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution) { TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos()); - if(tile instanceof TileEntityAtomicReconstructor){ - ItemStack slot = ((TileEntityAtomicReconstructor)tile).inv.getStackInSlot(0); + if (tile instanceof TileEntityAtomicReconstructor) { + ItemStack slot = ((TileEntityAtomicReconstructor) tile).inv.getStackInSlot(0); String strg; - if(!StackUtil.isValid(slot)){ - strg = StringUtil.localize("info."+ActuallyAdditions.MODID+".noLens"); - } - else{ + if (!StackUtil.isValid(slot)) { + strg = StringUtil.localize("info." + ActuallyAdditions.MODID + ".noLens"); + } else { strg = slot.getItem().getItemStackDisplayName(slot); - AssetUtil.renderStackToGui(slot, resolution.getScaledWidth()/2+15, resolution.getScaledHeight()/2-19, 1F); + AssetUtil.renderStackToGui(slot, resolution.getScaledWidth() / 2 + 15, resolution.getScaledHeight() / 2 - 19, 1F); } - minecraft.fontRenderer.drawStringWithShadow(TextFormatting.YELLOW+""+TextFormatting.ITALIC+strg, resolution.getScaledWidth()/2+35, resolution.getScaledHeight()/2-15, StringUtil.DECIMAL_COLOR_WHITE); + minecraft.fontRenderer.drawStringWithShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + strg, resolution.getScaledWidth() / 2 + 35, resolution.getScaledHeight() / 2 - 15, StringUtil.DECIMAL_COLOR_WHITE); } } @Override - protected ItemBlockBase getItemBlock(){ + protected ItemBlockBase getItemBlock() { return new TheItemBlock(this); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){ + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) { int rotation = EnumFacing.getDirectionFromEntityLiving(pos, player).ordinal(); world.setBlockState(pos, this.getStateFromMeta(rotation), 2); @@ -146,77 +141,76 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta)); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(BlockDirectional.FACING).getIndex(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockDirectional.FACING); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirror){ + public IBlockState withMirror(IBlockState state, Mirror mirror) { return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING))); } - public static class TheItemBlock extends ItemBlockBase{ + public static class TheItemBlock extends ItemBlockBase { private long lastSysTime; private int toPick1; private int toPick2; - public TheItemBlock(Block block){ + public TheItemBlock(Block block) { super(block); this.setHasSubtypes(false); this.setMaxDamage(0); } - @Override - public String getTranslationKey(ItemStack stack){ + public String getTranslationKey(ItemStack stack) { return this.getTranslationKey(); } @Override - public int getMetadata(int damage){ + public int getMetadata(int damage) { return damage; } @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag advanced){ + public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag advanced) { long sysTime = System.currentTimeMillis(); - if(this.lastSysTime+3000 < sysTime){ + if (this.lastSysTime + 3000 < sysTime) { this.lastSysTime = sysTime; - if(world != null){ - this.toPick1 = world.rand.nextInt(NAME_FLAVOR_AMOUNTS_1)+1; - this.toPick2 = world.rand.nextInt(NAME_FLAVOR_AMOUNTS_2)+1; + if (world != null) { + this.toPick1 = world.rand.nextInt(NAME_FLAVOR_AMOUNTS_1) + 1; + this.toPick2 = world.rand.nextInt(NAME_FLAVOR_AMOUNTS_2) + 1; } } - String base = "tile."+ActuallyAdditions.MODID+"."+((BlockAtomicReconstructor)this.block).getBaseName()+".info."; - tooltip.add(StringUtil.localize(base+"1."+this.toPick1)+" "+StringUtil.localize(base+"2."+this.toPick2)); + String base = "tile." + ActuallyAdditions.MODID + "." + ((BlockAtomicReconstructor) this.block).getBaseName() + ".info."; + tooltip.add(StringUtil.localize(base + "1." + this.toPick1) + " " + StringUtil.localize(base + "2." + this.toPick2)); } } @Override - public boolean hasComparatorInputOverride(IBlockState state){ + public boolean hasComparatorInputOverride(IBlockState state) { return true; } @Override - public int getComparatorInputOverride(IBlockState blockState, World world, BlockPos pos){ + public int getComparatorInputOverride(IBlockState blockState, World world, BlockPos pos) { TileEntity t = world.getTileEntity(pos); int i = 0; if (t instanceof TileEntityAtomicReconstructor) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBatteryBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBatteryBox.java index e8f3685af..acaf5134d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBatteryBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBatteryBox.java @@ -28,9 +28,9 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockBatteryBox extends BlockContainerBase{ +public class BlockBatteryBox extends BlockContainerBase { - public BlockBatteryBox(String name){ + public BlockBatteryBox(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(1.5F); @@ -39,32 +39,31 @@ public class BlockBatteryBox extends BlockContainerBase{ } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return BlockSlabs.AABB_BOTTOM_HALF; } @Override - public TileEntity createNewTileEntity(World world, int meta){ + public TileEntity createNewTileEntity(World world, int meta) { return new TileEntityBatteryBox(); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityBatteryBox){ - TileEntityBatteryBox box = (TileEntityBatteryBox)tile; + if (tile instanceof TileEntityBatteryBox) { + TileEntityBatteryBox box = (TileEntityBatteryBox) tile; ItemStack stack = player.getHeldItem(hand); - if(StackUtil.isValid(stack)){ - if(stack.getItem() instanceof ItemBattery && !StackUtil.isValid(box.inv.getStackInSlot(0))){ + if (StackUtil.isValid(stack)) { + if (stack.getItem() instanceof ItemBattery && !StackUtil.isValid(box.inv.getStackInSlot(0))) { box.inv.setStackInSlot(0, stack.copy()); player.setHeldItem(hand, StackUtil.getEmpty()); return true; } - } - else{ + } else { ItemStack inSlot = box.inv.getStackInSlot(0); - if(StackUtil.isValid(inSlot)){ + if (StackUtil.isValid(inSlot)) { player.setHeldItem(hand, inSlot.copy()); box.inv.setStackInSlot(0, StackUtil.getEmpty()); return true; @@ -75,12 +74,12 @@ public class BlockBatteryBox extends BlockContainerBase{ } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBioReactor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBioReactor.java index d5eed9ea0..5a8779601 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBioReactor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBioReactor.java @@ -26,9 +26,9 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BlockBioReactor extends BlockContainerBase{ +public class BlockBioReactor extends BlockContainerBase { - public BlockBioReactor(String name){ + public BlockBioReactor(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); @@ -38,14 +38,14 @@ public class BlockBioReactor extends BlockContainerBase{ } @Override - public TileEntity createNewTileEntity(World worldIn, int meta){ + public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityBioReactor(); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(!world.isRemote){ - if(world.getTileEntity(pos) instanceof TileEntityBioReactor){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (!world.isRemote) { + if (world.getTileEntity(pos) instanceof TileEntityBioReactor) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.BIO_REACTOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } } @@ -53,7 +53,7 @@ public class BlockBioReactor extends BlockContainerBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBlackLotus.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBlackLotus.java index fef80f31d..c64dd7f0b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBlackLotus.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBlackLotus.java @@ -12,9 +12,9 @@ package de.ellpeck.actuallyadditions.mod.blocks; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBushBase; -public class BlockBlackLotus extends BlockBushBase{ +public class BlockBlackLotus extends BlockBushBase { - public BlockBlackLotus(String name){ + public BlockBlackLotus(String name) { super(name); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBreaker.java index 9d1a0a158..3b9e33e1c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBreaker.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.blocks; - import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; @@ -33,11 +32,11 @@ import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BlockBreaker extends BlockContainerBase{ +public class BlockBreaker extends BlockContainerBase { private final boolean isPlacer; - public BlockBreaker(boolean isPlacer, String name){ + public BlockBreaker(boolean isPlacer, String name) { super(Material.ROCK, name); this.isPlacer = isPlacer; this.setHarvestLevel("pickaxe", 0); @@ -46,20 +45,17 @@ public class BlockBreaker extends BlockContainerBase{ this.setSoundType(SoundType.STONE); } - @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return this.isPlacer ? new TileEntityPlacer() : new TileEntityBreaker(); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(this.tryToggleRedstone(world, pos, player)){ - return true; - } - if(!world.isRemote){ - TileEntityBreaker breaker = (TileEntityBreaker)world.getTileEntity(pos); - if(breaker != null){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (this.tryToggleRedstone(world, pos, player)) { return true; } + if (!world.isRemote) { + TileEntityBreaker breaker = (TileEntityBreaker) world.getTileEntity(pos); + if (breaker != null) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.BREAKER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } return true; @@ -68,12 +64,12 @@ public class BlockBreaker extends BlockContainerBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.UNCOMMON; } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){ + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) { int rotation = EnumFacing.getDirectionFromEntityLiving(pos, player).ordinal(); world.setBlockState(pos, this.getStateFromMeta(rotation), 2); @@ -81,27 +77,27 @@ public class BlockBreaker extends BlockContainerBase{ } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta)); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(BlockDirectional.FACING).getIndex(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockDirectional.FACING); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirror){ + public IBlockState withMirror(IBlockState state, Mirror mirror) { return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING))); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCanolaPress.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCanolaPress.java index 4f124f7a9..87c6d5848 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCanolaPress.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCanolaPress.java @@ -26,9 +26,9 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BlockCanolaPress extends BlockContainerBase{ +public class BlockCanolaPress extends BlockContainerBase { - public BlockCanolaPress(String name){ + public BlockCanolaPress(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(1.5F); @@ -37,26 +37,26 @@ public class BlockCanolaPress extends BlockContainerBase{ } @Override - public boolean isFullCube(IBlockState state){ + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityCanolaPress(); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float par7, float par8, float par9){ - if(!world.isRemote){ - TileEntityCanolaPress press = (TileEntityCanolaPress)world.getTileEntity(pos); - if(press != null){ - if(!this.tryUseItemOnTank(player, hand, press.tank)){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float par7, float par8, float par9) { + if (!world.isRemote) { + TileEntityCanolaPress press = (TileEntityCanolaPress) world.getTileEntity(pos); + if (press != null) { + if (!this.tryUseItemOnTank(player, hand, press.tank)) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.CANOLA_PRESS.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } } @@ -66,7 +66,7 @@ public class BlockCanolaPress extends BlockContainerBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java index 6ff8b82eb..1936246a3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.blocks; +import java.util.Random; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; @@ -25,17 +26,19 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.*; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.Random; +public class BlockCoalGenerator extends BlockContainerBase { -public class BlockCoalGenerator extends BlockContainerBase{ - - public BlockCoalGenerator(String name){ + public BlockCoalGenerator(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(1.5F); @@ -45,38 +48,38 @@ public class BlockCoalGenerator extends BlockContainerBase{ } @Override - public boolean isFullCube(IBlockState state){ + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityCoalGenerator(); } @Override @SideOnly(Side.CLIENT) - public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){ + public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityCoalGenerator){ - if(((TileEntityCoalGenerator)tile).currentBurnTime > 0){ - for(int i = 0; i < 5; i++){ - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D); + if (tile instanceof TileEntityCoalGenerator) { + if (((TileEntityCoalGenerator) tile).currentBurnTime > 0) { + for (int i = 0; i < 5; i++) { + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) pos.getX() + 0.5F, (double) pos.getY() + 1.0F, (double) pos.getZ() + 0.5F, 0.0D, 0.0D, 0.0D); } } } } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(!world.isRemote){ - TileEntityCoalGenerator press = (TileEntityCoalGenerator)world.getTileEntity(pos); - if(press != null){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (!world.isRemote) { + TileEntityCoalGenerator press = (TileEntityCoalGenerator) world.getTileEntity(pos); + if (press != null) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.COAL_GENERATOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } return true; @@ -85,39 +88,39 @@ public class BlockCoalGenerator extends BlockContainerBase{ } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){ + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) { world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2); super.onBlockPlacedBy(world, pos, state, player, stack); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta)); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockHorizontal.FACING); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirror){ + public IBlockState withMirror(IBlockState state, Mirror mirror) { return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING))); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoffeeMachine.java index f88112b2d..c6248a39e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoffeeMachine.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoffeeMachine.java @@ -34,11 +34,11 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockCoffeeMachine extends BlockContainerBase{ +public class BlockCoffeeMachine extends BlockContainerBase { - private static final AxisAlignedBB AABB = new AxisAlignedBB(0.0625, 0, 0.0625, 1-0.0625, 1-0.0625*2, 1-0.0625); + private static final AxisAlignedBB AABB = new AxisAlignedBB(0.0625, 0, 0.0625, 1 - 0.0625, 1 - 0.0625 * 2, 1 - 0.0625); - public BlockCoffeeMachine(String name){ + public BlockCoffeeMachine(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(1.5F); @@ -47,26 +47,26 @@ public class BlockCoffeeMachine extends BlockContainerBase{ } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return AABB; } @Override - public boolean isFullCube(IBlockState state){ + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing f6, float f7, float f8, float f9){ - if(!world.isRemote){ - TileEntityCoffeeMachine machine = (TileEntityCoffeeMachine)world.getTileEntity(pos); - if(machine != null){ - if(!this.tryUseItemOnTank(player, hand, machine.tank)){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing f6, float f7, float f8, float f9) { + if (!world.isRemote) { + TileEntityCoffeeMachine machine = (TileEntityCoffeeMachine) world.getTileEntity(pos); + if (machine != null) { + if (!this.tryUseItemOnTank(player, hand, machine.tank)) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.COFFEE_MACHINE.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } } @@ -75,31 +75,30 @@ public class BlockCoffeeMachine extends BlockContainerBase{ return true; } - @Override - public TileEntity createNewTileEntity(World world, int meta){ + public TileEntity createNewTileEntity(World world, int meta) { return new TileEntityCoffeeMachine(); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){ - int rotation = MathHelper.floor(player.rotationYaw*4.0F/360.0F+0.5D) & 3; + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) { + int rotation = MathHelper.floor(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; - if(rotation == 0){ + if (rotation == 0) { world.setBlockState(pos, this.getStateFromMeta(0), 2); } - if(rotation == 1){ + if (rotation == 1) { world.setBlockState(pos, this.getStateFromMeta(3), 2); } - if(rotation == 2){ + if (rotation == 2) { world.setBlockState(pos, this.getStateFromMeta(1), 2); } - if(rotation == 3){ + if (rotation == 3) { world.setBlockState(pos, this.getStateFromMeta(2), 2); } @@ -107,27 +106,27 @@ public class BlockCoffeeMachine extends BlockContainerBase{ } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta)); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockHorizontal.FACING); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirror){ + public IBlockState withMirror(IBlockState state, Mirror mirror) { return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING))); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockColoredLamp.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockColoredLamp.java index 6e8a92a7d..069ff7d28 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockColoredLamp.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockColoredLamp.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.blocks; +import java.util.Random; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; @@ -38,15 +39,13 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.oredict.OreDictionary; -import java.util.Random; - -public class BlockColoredLamp extends BlockBase{ +public class BlockColoredLamp extends BlockBase { public static final TheColoredLampColors[] ALL_LAMP_TYPES = TheColoredLampColors.values(); public static final PropertyEnum TYPE = PropertyEnum.create("type", TheColoredLampColors.class); public final boolean isOn; - public BlockColoredLamp(boolean isOn, String name){ + public BlockColoredLamp(boolean isOn, String name) { super(Material.REDSTONE_LIGHT, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(0.5F); @@ -55,37 +54,37 @@ public class BlockColoredLamp extends BlockBase{ } @Override - public Item getItemDropped(IBlockState state, Random rand, int par3){ + public Item getItemDropped(IBlockState state, Random rand, int par3) { return Item.getItemFromBlock(InitBlocks.blockColoredLamp); } @Override - public int damageDropped(IBlockState state){ + public int damageDropped(IBlockState state) { return this.getMetaFromState(state); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); //Turning On - if(hand == EnumHand.MAIN_HAND && stack.isEmpty()){ + if (hand == EnumHand.MAIN_HAND && stack.isEmpty()) { world.setBlockState(pos, (this.isOn ? InitBlocks.blockColoredLamp : InitBlocks.blockColoredLampOn).getDefaultState().withProperty(TYPE, state.getValue(TYPE)), 2); world.notifyLightSet(pos); return true; } - if(StackUtil.isValid(stack)){ + if (StackUtil.isValid(stack)) { //Changing Colors int[] oreIDs = OreDictionary.getOreIDs(stack); - if(oreIDs.length > 0){ - for(int oreID : oreIDs){ + if (oreIDs.length > 0) { + for (int oreID : oreIDs) { String name = OreDictionary.getOreName(oreID); TheColoredLampColors color = TheColoredLampColors.getColorFromDyeName(name); - if(color != null){ - if(this.getMetaFromState(state) != color.ordinal()){ - if(!world.isRemote){ + if (color != null) { + if (this.getMetaFromState(state) != color.ordinal()) { + if (!world.isRemote) { world.setBlockState(pos, this.getStateFromMeta(color.ordinal()), 2); - if(!player.capabilities.isCreativeMode){ + if (!player.capabilities.isCreativeMode) { player.inventory.decrStackSize(player.inventory.currentItem, 1); } } @@ -100,71 +99,67 @@ public class BlockColoredLamp extends BlockBase{ @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(CreativeTabs tab, NonNullList list){ - for(int j = 0; j < ALL_LAMP_TYPES.length; j++){ + public void getSubBlocks(CreativeTabs tab, NonNullList list) { + for (int j = 0; j < ALL_LAMP_TYPES.length; j++) { list.add(new ItemStack(this, 1, j)); } } @Override - public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos){ + public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { return this.isOn ? 15 : 0; } @Override - protected ItemBlockBase getItemBlock(){ + protected ItemBlockBase getItemBlock() { return new TheItemBlock(this); } @Override - public void registerRendering(){ - for(int i = 0; i < ALL_LAMP_TYPES.length; i++){ - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName()+"="+ALL_LAMP_TYPES[i].regName); + public void registerRendering() { + for (int i = 0; i < ALL_LAMP_TYPES.length; i++) { + ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName() + "=" + ALL_LAMP_TYPES[i].regName); } } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(TYPE, TheColoredLampColors.values()[meta]); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(TYPE).ordinal(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, TYPE); } - public static class TheItemBlock extends ItemBlockBase{ + public static class TheItemBlock extends ItemBlockBase { - public TheItemBlock(Block block){ + public TheItemBlock(Block block) { super(block); this.setHasSubtypes(true); this.setMaxDamage(0); } - @Override - public String getItemStackDisplayName(ItemStack stack){ - if(stack.getItemDamage() >= ALL_LAMP_TYPES.length){ - return StringUtil.BUGGED_ITEM_NAME; - } - if(Util.isClient()) return super.getItemStackDisplayName(stack)+(((BlockColoredLamp)this.block).isOn ? " ("+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".onSuffix.desc")+")" : ""); + public String getItemStackDisplayName(ItemStack stack) { + if (stack.getItemDamage() >= ALL_LAMP_TYPES.length) { return StringUtil.BUGGED_ITEM_NAME; } + if (Util.isClient()) return super.getItemStackDisplayName(stack) + (((BlockColoredLamp) this.block).isOn ? " (" + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".onSuffix.desc") + ")" : ""); else return super.getItemStackDisplayName(stack); } - @Override - public String getTranslationKey(ItemStack stack){ - return InitBlocks.blockColoredLamp.getTranslationKey()+"_"+ALL_LAMP_TYPES[stack.getItemDamage()].regName; + public String getTranslationKey(ItemStack stack) { + return InitBlocks.blockColoredLamp.getTranslationKey() + "_" + ALL_LAMP_TYPES[stack.getItemDamage()].regName; } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystalCluster.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystalCluster.java index ab43b8d16..7579e7717 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystalCluster.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystalCluster.java @@ -10,6 +10,10 @@ package de.ellpeck.actuallyadditions.mod.blocks; +import java.util.Random; + +import org.apache.commons.lang3.ArrayUtils; + import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; import de.ellpeck.actuallyadditions.mod.gen.WorldGenLushCaves; import de.ellpeck.actuallyadditions.mod.items.InitItems; @@ -37,15 +41,12 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import org.apache.commons.lang3.ArrayUtils; -import java.util.Random; - -public class BlockCrystalCluster extends BlockBase implements IColorProvidingBlock, IColorProvidingItem{ +public class BlockCrystalCluster extends BlockBase implements IColorProvidingBlock, IColorProvidingItem { private final TheCrystals crystal; - public BlockCrystalCluster(String name, TheCrystals crystal){ + public BlockCrystalCluster(String name, TheCrystals crystal) { super(Material.GLASS, name); this.crystal = crystal; @@ -57,89 +58,89 @@ public class BlockCrystalCluster extends BlockBase implements IColorProvidingBlo } @Override - public boolean isFullCube(IBlockState state){ + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int meta, EntityLivingBase base){ + public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int meta, EntityLivingBase base) { return this.getStateFromMeta(side.ordinal()); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta)); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(BlockDirectional.FACING).getIndex(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockDirectional.FACING); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirror){ + public IBlockState withMirror(IBlockState state, Mirror mirror) { return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING))); } @Override @SideOnly(Side.CLIENT) - public IBlockColor getBlockColor(){ + public IBlockColor getBlockColor() { return (state, world, pos, tintIndex) -> BlockCrystalCluster.this.crystal.clusterColor; } @Override - public BlockRenderLayer getRenderLayer(){ + public BlockRenderLayer getRenderLayer() { return BlockRenderLayer.TRANSLUCENT; } @Override @SideOnly(Side.CLIENT) - public IItemColor getItemColor(){ + public IItemColor getItemColor() { return (stack, tintIndex) -> BlockCrystalCluster.this.crystal.clusterColor; } @Override - public Item getItemDropped(IBlockState state, Random rand, int fortune){ + public Item getItemDropped(IBlockState state, Random rand, int fortune) { return InitItems.itemCrystalShard; } @Override - public int damageDropped(IBlockState state){ + public int damageDropped(IBlockState state) { return ArrayUtils.indexOf(WorldGenLushCaves.CRYSTAL_CLUSTERS, this); } @Override - public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player){ + public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { return new ItemStack(this); } @Override - public int quantityDropped(Random random){ - return random.nextInt(5)+2; + public int quantityDropped(Random random) { + return random.nextInt(5) + 2; } @Override - public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player){ + public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) { return true; } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDirectionalBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDirectionalBreaker.java index 837488b7b..81f3ca8a4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDirectionalBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDirectionalBreaker.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.blocks; - import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; @@ -32,9 +31,9 @@ import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BlockDirectionalBreaker extends BlockContainerBase{ +public class BlockDirectionalBreaker extends BlockContainerBase { - public BlockDirectionalBreaker(String name){ + public BlockDirectionalBreaker(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(1.5F); @@ -42,20 +41,17 @@ public class BlockDirectionalBreaker extends BlockContainerBase{ this.setSoundType(SoundType.STONE); } - @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityDirectionalBreaker(); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(this.tryToggleRedstone(world, pos, player)){ - return true; - } - if(!world.isRemote){ - TileEntityDirectionalBreaker breaker = (TileEntityDirectionalBreaker)world.getTileEntity(pos); - if(breaker != null){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (this.tryToggleRedstone(world, pos, player)) { return true; } + if (!world.isRemote) { + TileEntityDirectionalBreaker breaker = (TileEntityDirectionalBreaker) world.getTileEntity(pos); + if (breaker != null) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DIRECTIONAL_BREAKER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } return true; @@ -64,12 +60,12 @@ public class BlockDirectionalBreaker extends BlockContainerBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){ + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) { int rotation = EnumFacing.getDirectionFromEntityLiving(pos, player).ordinal(); world.setBlockState(pos, this.getStateFromMeta(rotation), 2); @@ -77,27 +73,27 @@ public class BlockDirectionalBreaker extends BlockContainerBase{ } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta)); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(BlockDirectional.FACING).getIndex(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockDirectional.FACING); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirror){ + public IBlockState withMirror(IBlockState state, Mirror mirror) { return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING))); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java index 6abd656c9..4b4eaa83a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java @@ -62,7 +62,7 @@ public class BlockDisplayStand extends BlockContainerBase { ItemStack toPut = heldItem.copy(); toPut.setCount(1); stand.inv.setStackInSlot(0, toPut); - if(!player.capabilities.isCreativeMode) heldItem.shrink(1); + if (!player.capabilities.isCreativeMode) heldItem.shrink(1); return true; } else if (ItemUtil.canBeStacked(heldItem, display)) { int maxTransfer = Math.min(display.getCount(), heldItem.getMaxStackSize() - heldItem.getCount()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java index 839eceb01..f03a4f159 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java @@ -31,9 +31,9 @@ import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BlockDropper extends BlockContainerBase{ +public class BlockDropper extends BlockContainerBase { - public BlockDropper(String name){ + public BlockDropper(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(1.5F); @@ -41,20 +41,17 @@ public class BlockDropper extends BlockContainerBase{ this.setSoundType(SoundType.STONE); } - @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityDropper(); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(this.tryToggleRedstone(world, pos, player)){ - return true; - } - if(!world.isRemote){ - TileEntityDropper dropper = (TileEntityDropper)world.getTileEntity(pos); - if(dropper != null){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (this.tryToggleRedstone(world, pos, player)) { return true; } + if (!world.isRemote) { + TileEntityDropper dropper = (TileEntityDropper) world.getTileEntity(pos); + if (dropper != null) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DROPPER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } return true; @@ -63,12 +60,12 @@ public class BlockDropper extends BlockContainerBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){ + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) { int rotation = EnumFacing.getDirectionFromEntityLiving(pos, player).ordinal(); world.setBlockState(pos, this.getStateFromMeta(rotation), 2); @@ -76,27 +73,27 @@ public class BlockDropper extends BlockContainerBase{ } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta)); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(BlockDirectional.FACING).getIndex(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockDirectional.FACING); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirror){ + public IBlockState withMirror(IBlockState state, Mirror mirror) { return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING))); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEmpowerer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEmpowerer.java index 093e9aba2..4d4c8dba2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEmpowerer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEmpowerer.java @@ -28,9 +28,9 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockEmpowerer extends BlockContainerBase{ +public class BlockEmpowerer extends BlockContainerBase { - public BlockEmpowerer(String name){ + public BlockEmpowerer(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); @@ -40,33 +40,32 @@ public class BlockEmpowerer extends BlockContainerBase{ } @Override - public TileEntity createNewTileEntity(World worldIn, int meta){ + public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityEmpowerer(); } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return BlockSlabs.AABB_BOTTOM_HALF; } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { ItemStack heldItem = player.getHeldItem(hand); - if(!world.isRemote){ - TileEntityEmpowerer empowerer = (TileEntityEmpowerer)world.getTileEntity(pos); - if(empowerer != null){ + if (!world.isRemote) { + TileEntityEmpowerer empowerer = (TileEntityEmpowerer) world.getTileEntity(pos); + if (empowerer != null) { ItemStack stackThere = empowerer.inv.getStackInSlot(0); - if(StackUtil.isValid(heldItem)){ - if(!StackUtil.isValid(stackThere) && TileEntityEmpowerer.isPossibleInput(heldItem)){ + if (StackUtil.isValid(heldItem)) { + if (!StackUtil.isValid(stackThere) && TileEntityEmpowerer.isPossibleInput(heldItem)) { ItemStack toPut = heldItem.copy(); toPut.setCount(1); empowerer.inv.setStackInSlot(0, toPut); - if(!player.capabilities.isCreativeMode) heldItem.shrink(1); + if (!player.capabilities.isCreativeMode) heldItem.shrink(1); return true; - } - else if(ItemUtil.canBeStacked(heldItem, stackThere)){ - int maxTransfer = Math.min(stackThere.getCount(), heldItem.getMaxStackSize()-heldItem.getCount()); - if(maxTransfer > 0){ + } else if (ItemUtil.canBeStacked(heldItem, stackThere)) { + int maxTransfer = Math.min(stackThere.getCount(), heldItem.getMaxStackSize() - heldItem.getCount()); + if (maxTransfer > 0) { player.setHeldItem(hand, StackUtil.grow(heldItem, maxTransfer)); ItemStack newStackThere = stackThere.copy(); newStackThere = StackUtil.shrink(newStackThere, maxTransfer); @@ -74,9 +73,8 @@ public class BlockEmpowerer extends BlockContainerBase{ return true; } } - } - else{ - if(StackUtil.isValid(stackThere)){ + } else { + if (StackUtil.isValid(stackThere)) { player.setHeldItem(hand, stackThere.copy()); empowerer.inv.setStackInSlot(0, StackUtil.getEmpty()); return true; @@ -84,19 +82,18 @@ public class BlockEmpowerer extends BlockContainerBase{ } } return false; - } - else{ + } else { return true; } } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEnergizer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEnergizer.java index 7fe9be9e4..13464a703 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEnergizer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEnergizer.java @@ -27,11 +27,11 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BlockEnergizer extends BlockContainerBase{ +public class BlockEnergizer extends BlockContainerBase { private final boolean isEnergizer; - public BlockEnergizer(boolean isEnergizer, String name){ + public BlockEnergizer(boolean isEnergizer, String name) { super(Material.ROCK, name); this.isEnergizer = isEnergizer; this.setHarvestLevel("pickaxe", 0); @@ -40,24 +40,22 @@ public class BlockEnergizer extends BlockContainerBase{ this.setSoundType(SoundType.STONE); } - @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return this.isEnergizer ? new TileEntityEnergizer() : new TileEntityEnervator(); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(!world.isRemote){ - if(this.isEnergizer){ - TileEntityEnergizer energizer = (TileEntityEnergizer)world.getTileEntity(pos); - if(energizer != null){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (!world.isRemote) { + if (this.isEnergizer) { + TileEntityEnergizer energizer = (TileEntityEnergizer) world.getTileEntity(pos); + if (energizer != null) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.ENERGIZER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } - } - else{ - TileEntityEnervator energizer = (TileEntityEnervator)world.getTileEntity(pos); - if(energizer != null){ + } else { + TileEntityEnervator energizer = (TileEntityEnervator) world.getTileEntity(pos); + if (energizer != null) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.ENERVATOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } } @@ -67,7 +65,7 @@ public class BlockEnergizer extends BlockContainerBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java index 89209bc36..991d50970 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java @@ -31,9 +31,9 @@ import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BlockFarmer extends BlockContainerBase{ +public class BlockFarmer extends BlockContainerBase { - public BlockFarmer(String name){ + public BlockFarmer(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(1.5F); @@ -41,17 +41,16 @@ public class BlockFarmer extends BlockContainerBase{ this.setSoundType(SoundType.STONE); } - @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityFarmer(); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(!world.isRemote){ - TileEntityFarmer farmer = (TileEntityFarmer)world.getTileEntity(pos); - if(farmer != null){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (!world.isRemote) { + TileEntityFarmer farmer = (TileEntityFarmer) world.getTileEntity(pos); + if (farmer != null) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FARMER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } return true; @@ -60,39 +59,39 @@ public class BlockFarmer extends BlockContainerBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){ + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) { world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2); super.onBlockPlacedBy(world, pos, state, player, stack); } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta)); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockHorizontal.FACING); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirror){ + public IBlockState withMirror(IBlockState state, Mirror mirror) { return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING))); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java index 51853a13a..525bdd781 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java @@ -26,9 +26,9 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BlockFeeder extends BlockContainerBase{ +public class BlockFeeder extends BlockContainerBase { - public BlockFeeder(String name){ + public BlockFeeder(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(0.5F); @@ -36,17 +36,16 @@ public class BlockFeeder extends BlockContainerBase{ this.setSoundType(SoundType.STONE); } - @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityFeeder(); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(!world.isRemote){ - TileEntityFeeder feeder = (TileEntityFeeder)world.getTileEntity(pos); - if(feeder != null){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (!world.isRemote) { + TileEntityFeeder feeder = (TileEntityFeeder) world.getTileEntity(pos); + if (feeder != null) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FEEDER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } return true; @@ -55,7 +54,7 @@ public class BlockFeeder extends BlockContainerBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.UNCOMMON; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java index 5434e63f7..925f3cd4e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java @@ -26,9 +26,9 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BlockFermentingBarrel extends BlockContainerBase{ +public class BlockFermentingBarrel extends BlockContainerBase { - public BlockFermentingBarrel(String name){ + public BlockFermentingBarrel(String name) { super(Material.WOOD, name); this.setHarvestLevel("axe", 0); this.setHardness(0.5F); @@ -37,26 +37,26 @@ public class BlockFermentingBarrel extends BlockContainerBase{ } @Override - public boolean isFullCube(IBlockState state){ + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityFermentingBarrel(); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(!world.isRemote){ - TileEntityFermentingBarrel press = (TileEntityFermentingBarrel)world.getTileEntity(pos); - if(press != null){ - if(!this.tryUseItemOnTank(player, hand, press.canolaTank) && !this.tryUseItemOnTank(player, hand, press.oilTank)){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (!world.isRemote) { + TileEntityFermentingBarrel press = (TileEntityFermentingBarrel) world.getTileEntity(pos); + if (press != null) { + if (!this.tryUseItemOnTank(player, hand, press.canolaTank) && !this.tryUseItemOnTank(player, hand, press.oilTank)) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FERMENTING_BARREL.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } } @@ -66,7 +66,7 @@ public class BlockFermentingBarrel extends BlockContainerBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java index 610e09bd1..9c01f5ced 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.blocks; - import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; @@ -27,9 +26,9 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BlockFireworkBox extends BlockContainerBase{ +public class BlockFireworkBox extends BlockContainerBase { - public BlockFireworkBox(String name){ + public BlockFireworkBox(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(1.5F); @@ -38,13 +37,12 @@ public class BlockFireworkBox extends BlockContainerBase{ } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(this.tryToggleRedstone(world, pos, player)){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (this.tryToggleRedstone(world, pos, player)) { return true; - } - else if(!world.isRemote){ - TileEntityFireworkBox grinder = (TileEntityFireworkBox)world.getTileEntity(pos); - if(grinder != null){ + } else if (!world.isRemote) { + TileEntityFireworkBox grinder = (TileEntityFireworkBox) world.getTileEntity(pos); + if (grinder != null) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FIREWORK_BOX.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } } @@ -52,12 +50,12 @@ public class BlockFireworkBox extends BlockContainerBase{ } @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityFireworkBox(); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFishingNet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFishingNet.java index c0f7048a5..a7ee0d164 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFishingNet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFishingNet.java @@ -23,11 +23,11 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockFishingNet extends BlockContainerBase{ +public class BlockFishingNet extends BlockContainerBase { private static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 1, 0.0625, 1); - public BlockFishingNet(String name){ + public BlockFishingNet(String name) { super(Material.WOOD, name); this.setHarvestLevel("axe", 0); this.setHardness(0.5F); @@ -36,28 +36,27 @@ public class BlockFishingNet extends BlockContainerBase{ } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return AABB; } - @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityFishingNet(); } @Override - public boolean isFullCube(IBlockState state){ + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java index a36e0f15d..45e343c0c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.blocks; - import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; @@ -33,11 +32,11 @@ import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BlockFluidCollector extends BlockContainerBase{ +public class BlockFluidCollector extends BlockContainerBase { private final boolean isPlacer; - public BlockFluidCollector(boolean isPlacer, String name){ + public BlockFluidCollector(boolean isPlacer, String name) { super(Material.ROCK, name); this.isPlacer = isPlacer; this.setHarvestLevel("pickaxe", 0); @@ -46,21 +45,18 @@ public class BlockFluidCollector extends BlockContainerBase{ this.setSoundType(SoundType.STONE); } - @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return this.isPlacer ? new TileEntityFluidPlacer() : new TileEntityFluidCollector(); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(this.tryToggleRedstone(world, pos, player)){ - return true; - } - if(!world.isRemote){ - TileEntityFluidCollector collector = (TileEntityFluidCollector)world.getTileEntity(pos); - if(collector != null){ - if(!this.tryUseItemOnTank(player, hand, collector.tank)){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (this.tryToggleRedstone(world, pos, player)) { return true; } + if (!world.isRemote) { + TileEntityFluidCollector collector = (TileEntityFluidCollector) world.getTileEntity(pos); + if (collector != null) { + if (!this.tryUseItemOnTank(player, hand, collector.tank)) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FLUID_COLLECTOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } } @@ -70,12 +66,12 @@ public class BlockFluidCollector extends BlockContainerBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){ + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) { int rotation = EnumFacing.getDirectionFromEntityLiving(pos, player).ordinal(); world.setBlockState(pos, this.getStateFromMeta(rotation), 2); @@ -83,27 +79,27 @@ public class BlockFluidCollector extends BlockContainerBase{ } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta)); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(BlockDirectional.FACING).getIndex(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockDirectional.FACING); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirror){ + public IBlockState withMirror(IBlockState state, Mirror mirror) { return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING))); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceDouble.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceDouble.java index 547d34b19..fcf5f7749 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceDouble.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceDouble.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.blocks; +import java.util.List; +import java.util.Random; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase; @@ -29,7 +32,11 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.*; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.IBlockAccess; @@ -37,14 +44,11 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.List; -import java.util.Random; - -public class BlockFurnaceDouble extends BlockContainerBase{ +public class BlockFurnaceDouble extends BlockContainerBase { public static final PropertyBool IS_ON = PropertyBool.create("on"); - public BlockFurnaceDouble(String name){ + public BlockFurnaceDouble(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(1.5F); @@ -53,27 +57,26 @@ public class BlockFurnaceDouble extends BlockContainerBase{ this.setTickRandomly(true); } - @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityFurnaceDouble(); } @Override @SideOnly(Side.CLIENT) - public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){ - if(state.getValue(IS_ON)){ - for(int i = 0; i < 5; i++){ - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D); + public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { + if (state.getValue(IS_ON)) { + for (int i = 0; i < 5; i++) { + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) pos.getX() + 0.5F, (double) pos.getY() + 1.0F, (double) pos.getZ() + 0.5F, 0.0D, 0.0D, 0.0D); } } } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(!world.isRemote){ - TileEntityFurnaceDouble furnace = (TileEntityFurnaceDouble)world.getTileEntity(pos); - if(furnace != null){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (!world.isRemote) { + TileEntityFurnaceDouble furnace = (TileEntityFurnaceDouble) world.getTileEntity(pos); + if (furnace != null) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FURNACE_DOUBLE.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } return true; @@ -82,64 +85,64 @@ public class BlockFurnaceDouble extends BlockContainerBase{ } @Override - public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos){ + public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { return state.getValue(IS_ON) ? 12 : 0; } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.UNCOMMON; } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){ + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) { world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2); super.onBlockPlacedBy(world, pos, state, player, stack); } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { boolean isOn = meta >= 4; - EnumFacing facing = EnumFacing.byHorizontalIndex(isOn ? meta-4 : meta); + EnumFacing facing = EnumFacing.byHorizontalIndex(isOn ? meta - 4 : meta); return this.getDefaultState().withProperty(BlockHorizontal.FACING, facing).withProperty(IS_ON, isOn); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { int meta = state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); - return state.getValue(IS_ON) ? meta+4 : meta; + return state.getValue(IS_ON) ? meta + 4 : meta; } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockHorizontal.FACING, IS_ON); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirror){ + public IBlockState withMirror(IBlockState state, Mirror mirror) { return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING))); } @Override - protected ItemBlockBase getItemBlock(){ + protected ItemBlockBase getItemBlock() { return new TheItemBlock(this); } - public static class TheItemBlock extends ItemBlockBase{ + public static class TheItemBlock extends ItemBlockBase { - public TheItemBlock(Block block){ + public TheItemBlock(Block block) { super(block); } @Override - public void addInformation(ItemStack stack, World playerIn, List tooltip, ITooltipFlag advanced){ - tooltip.add(TextFormatting.ITALIC+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".previouslyDoubleFurnace")); + public void addInformation(ItemStack stack, World playerIn, List tooltip, ITooltipFlag advanced) { + tooltip.add(TextFormatting.ITALIC + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".previouslyDoubleFurnace")); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceSolar.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceSolar.java index 3824bb801..1a2be9d5c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceSolar.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceSolar.java @@ -23,11 +23,11 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockFurnaceSolar extends BlockContainerBase{ +public class BlockFurnaceSolar extends BlockContainerBase { - private static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 1, 6*0.0625, 1); + private static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 1, 6 * 0.0625, 1); - public BlockFurnaceSolar(String name){ + public BlockFurnaceSolar(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(1.5F); @@ -36,28 +36,27 @@ public class BlockFurnaceSolar extends BlockContainerBase{ } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return AABB; } - @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityFurnaceSolar(); } @Override - public boolean isFullCube(IBlockState state){ + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.UNCOMMON; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGeneric.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGeneric.java index fad2818f1..a7c1a01c3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGeneric.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGeneric.java @@ -16,13 +16,13 @@ import net.minecraft.block.material.Material; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; -public class BlockGeneric extends BlockBase{ +public class BlockGeneric extends BlockBase { - public BlockGeneric(String name){ + public BlockGeneric(String name) { this(name, Material.ROCK, SoundType.STONE, 1.5F, 10.0F, "pickaxe", 0); } - public BlockGeneric(String name, Material material, SoundType sound, float hardness, float resistance, String harvestTool, int harvestLevel){ + public BlockGeneric(String name, Material material, SoundType sound, float hardness, float resistance, String harvestTool, int harvestLevel) { super(material, name); this.setHarvestLevel(harvestTool, harvestLevel); this.setHardness(hardness); @@ -31,7 +31,7 @@ public class BlockGeneric extends BlockBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.COMMON; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java index e15879654..76b8205c7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java @@ -45,11 +45,11 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.items.IItemHandlerModifiable; -public class BlockGiantChest extends BlockContainerBase{ +public class BlockGiantChest extends BlockContainerBase { public final int type; - public BlockGiantChest(String name, int type){ + public BlockGiantChest(String name, int type) { super(Material.WOOD, name); this.type = type; @@ -61,8 +61,8 @@ public class BlockGiantChest extends BlockContainerBase{ } @Override - public TileEntity createNewTileEntity(World world, int par2){ - switch(this.type){ + public TileEntity createNewTileEntity(World world, int par2) { + switch (this.type) { case 1: return new TileEntityGiantChestMedium(); case 2: @@ -73,20 +73,20 @@ public class BlockGiantChest extends BlockContainerBase{ } @Override - public boolean isFullCube(IBlockState state){ + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(!world.isRemote){ - TileEntityGiantChest chest = (TileEntityGiantChest)world.getTileEntity(pos); - if(chest != null){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (!world.isRemote) { + TileEntityGiantChest chest = (TileEntityGiantChest) world.getTileEntity(pos); + if (chest != null) { chest.fillWithLoot(player); player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.GIANT_CHEST.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } @@ -96,21 +96,21 @@ public class BlockGiantChest extends BlockContainerBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entity, ItemStack stack){ - if(stack.getTagCompound() != null){ + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entity, ItemStack stack) { + if (stack.getTagCompound() != null) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityGiantChest){ + if (tile instanceof TileEntityGiantChest) { NBTTagList list = stack.getTagCompound().getTagList("Items", 10); - IItemHandlerModifiable inv = ((TileEntityGiantChest)tile).inv; + IItemHandlerModifiable inv = ((TileEntityGiantChest) tile).inv; - for(int i = 0; i < list.tagCount(); i++){ + for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound compound = list.getCompoundTagAt(i); - if(compound != null && compound.hasKey("id")){ + if (compound != null && compound.hasKey("id")) { inv.setStackInSlot(i, new ItemStack(list.getCompoundTagAt(i))); } } @@ -120,31 +120,30 @@ public class BlockGiantChest extends BlockContainerBase{ super.onBlockPlacedBy(world, pos, state, entity, stack); } - @Override - public void getDrops(NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune){ + public void getDrops(NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { super.getDrops(drops, world, pos, state, fortune); TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityGiantChest){ - ItemStackHandlerAA slots = ((TileEntityGiantChest)tile).inv; + if (tile instanceof TileEntityGiantChest) { + ItemStackHandlerAA slots = ((TileEntityGiantChest) tile).inv; int place = ItemUtil.getPlaceAt(slots.getItems(), new ItemStack(InitItems.itemCrateKeeper), false); - if(place >= 0){ + if (place >= 0) { NBTTagList list = new NBTTagList(); - for(int i = 0; i < slots.getSlots(); i++){ + for (int i = 0; i < slots.getSlots(); i++) { //Destroy the keeper - if(i != place){ + if (i != place) { NBTTagCompound compound = new NBTTagCompound(); - if(StackUtil.isValid(slots.getStackInSlot(i))){ + if (StackUtil.isValid(slots.getStackInSlot(i))) { slots.getStackInSlot(i).writeToNBT(compound); } list.appendTag(compound); } } - if(list.tagCount() > 0){ + if (list.tagCount() > 0) { ItemStack stackInQuestion = drops.get(0); - if(StackUtil.isValid(stackInQuestion)){ - if(stackInQuestion.getTagCompound() == null){ + if (StackUtil.isValid(stackInQuestion)) { + if (stackInQuestion.getTagCompound() == null) { stackInQuestion.setTagCompound(new NBTTagCompound()); } stackInQuestion.getTagCompound().setTag("Items", list); @@ -161,29 +160,28 @@ public class BlockGiantChest extends BlockContainerBase{ } @Override - protected ItemBlockBase getItemBlock(){ + protected ItemBlockBase getItemBlock() { return new TheItemBlock(this); } - public static class TheItemBlock extends ItemBlockBase{ + public static class TheItemBlock extends ItemBlockBase { - public TheItemBlock(Block block){ + public TheItemBlock(Block block) { super(block); } @Override - public void addInformation(ItemStack stack, World playerIn, List tooltip, ITooltipFlag advanced){ - int type = this.block instanceof BlockGiantChest ? ((BlockGiantChest)this.block).type : -1; - if(type == 2){ - tooltip.add(TextFormatting.ITALIC+StringUtil.localize("container."+ActuallyAdditions.MODID+".giantChestLarge.desc")); - } - else if(type == 0){ - tooltip.add(TextFormatting.ITALIC+StringUtil.localize("container."+ActuallyAdditions.MODID+".giantChest.desc")); + public void addInformation(ItemStack stack, World playerIn, List tooltip, ITooltipFlag advanced) { + int type = this.block instanceof BlockGiantChest ? ((BlockGiantChest) this.block).type : -1; + if (type == 2) { + tooltip.add(TextFormatting.ITALIC + StringUtil.localize("container." + ActuallyAdditions.MODID + ".giantChestLarge.desc")); + } else if (type == 0) { + tooltip.add(TextFormatting.ITALIC + StringUtil.localize("container." + ActuallyAdditions.MODID + ".giantChest.desc")); } } @Override - public NBTTagCompound getNBTShareTag(ItemStack stack){ + public NBTTagCompound getNBTShareTag(ItemStack stack) { return null; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGrinder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGrinder.java index 2d58344af..86877e50c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGrinder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGrinder.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.blocks; +import java.util.Random; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; @@ -32,13 +34,11 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.Random; - -public class BlockGrinder extends BlockContainerBase{ +public class BlockGrinder extends BlockContainerBase { private final boolean isDouble; - public BlockGrinder(boolean isDouble, String name){ + public BlockGrinder(boolean isDouble, String name) { super(Material.ROCK, name); this.isDouble = isDouble; this.setHarvestLevel("pickaxe", 0); @@ -49,28 +49,28 @@ public class BlockGrinder extends BlockContainerBase{ } @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return this.isDouble ? new TileEntityGrinderDouble() : new TileEntityGrinder(); } @Override @SideOnly(Side.CLIENT) - public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){ - if(state.getValue(BlockFurnaceDouble.IS_ON)){ - for(int i = 0; i < 5; i++){ - double xRand = rand.nextDouble()/0.75D-0.5D; - double zRand = rand.nextDouble()/0.75D-0.5D; - world.spawnParticle(EnumParticleTypes.CRIT, (double)pos.getX()+0.4F, (double)pos.getY()+0.8F, (double)pos.getZ()+0.4F, xRand, 0.5D, zRand); + public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { + if (state.getValue(BlockFurnaceDouble.IS_ON)) { + for (int i = 0; i < 5; i++) { + double xRand = rand.nextDouble() / 0.75D - 0.5D; + double zRand = rand.nextDouble() / 0.75D - 0.5D; + world.spawnParticle(EnumParticleTypes.CRIT, (double) pos.getX() + 0.4F, (double) pos.getY() + 0.8F, (double) pos.getZ() + 0.4F, xRand, 0.5D, zRand); } - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) pos.getX() + 0.5F, (double) pos.getY() + 1.0F, (double) pos.getZ() + 0.5F, 0.0D, 0.0D, 0.0D); } } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(!world.isRemote){ - TileEntityGrinder grinder = (TileEntityGrinder)world.getTileEntity(pos); - if(grinder != null){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (!world.isRemote) { + TileEntityGrinder grinder = (TileEntityGrinder) world.getTileEntity(pos); + if (grinder != null) { player.openGui(ActuallyAdditions.INSTANCE, this.isDouble ? GuiHandler.GuiTypes.GRINDER_DOUBLE.ordinal() : GuiHandler.GuiTypes.GRINDER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } return true; @@ -79,34 +79,33 @@ public class BlockGrinder extends BlockContainerBase{ } @Override - public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos){ + public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { return this.getMetaFromState(state) == 1 ? 12 : 0; } @Override - public int damageDropped(IBlockState state){ + public int damageDropped(IBlockState state) { return 0; } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } - @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { boolean isOn = meta == 1; return this.getDefaultState().withProperty(BlockFurnaceDouble.IS_ON, isOn); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(BlockFurnaceDouble.IS_ON) ? 1 : 0; } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockFurnaceDouble.IS_ON); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockHeatCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockHeatCollector.java index d8c6d9a03..8f61f1494 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockHeatCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockHeatCollector.java @@ -19,9 +19,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class BlockHeatCollector extends BlockContainerBase{ +public class BlockHeatCollector extends BlockContainerBase { - public BlockHeatCollector(String name){ + public BlockHeatCollector(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(2.5F); @@ -29,14 +29,13 @@ public class BlockHeatCollector extends BlockContainerBase{ this.setSoundType(SoundType.STONE); } - @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityHeatCollector(); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.UNCOMMON; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockInputter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockInputter.java index 514510738..835db5e1f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockInputter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockInputter.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.blocks; +import java.util.Random; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; @@ -32,15 +33,13 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import java.util.Random; - -public class BlockInputter extends BlockContainerBase{ +public class BlockInputter extends BlockContainerBase { public static final int NAME_FLAVOR_AMOUNTS = 15; public final boolean isAdvanced; - public BlockInputter(boolean isAdvanced, String name){ + public BlockInputter(boolean isAdvanced, String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(1.5F); @@ -50,17 +49,16 @@ public class BlockInputter extends BlockContainerBase{ this.isAdvanced = isAdvanced; } - @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return this.isAdvanced ? new TileEntityInputterAdvanced() : new TileEntityInputter(); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(!world.isRemote){ - TileEntityInputter inputter = (TileEntityInputter)world.getTileEntity(pos); - if(inputter != null){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (!world.isRemote) { + TileEntityInputter inputter = (TileEntityInputter) world.getTileEntity(pos); + if (inputter != null) { player.openGui(ActuallyAdditions.INSTANCE, this.isAdvanced ? GuiHandler.GuiTypes.INPUTTER_ADVANCED.ordinal() : GuiHandler.GuiTypes.INPUTTER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } return true; @@ -69,52 +67,49 @@ public class BlockInputter extends BlockContainerBase{ } @Override - protected ItemBlockBase getItemBlock(){ + protected ItemBlockBase getItemBlock() { return new TheItemBlock(this); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } - public static class TheItemBlock extends ItemBlockBase{ + public static class TheItemBlock extends ItemBlockBase { private final Random rand = new Random(); private long lastSysTime; private int toPick; - public TheItemBlock(Block block){ + public TheItemBlock(Block block) { super(block); this.setHasSubtypes(false); this.setMaxDamage(0); } - @Override - public String getTranslationKey(ItemStack stack){ + public String getTranslationKey(ItemStack stack) { return this.getTranslationKey(); } @Override - public int getMetadata(int damage){ + public int getMetadata(int damage) { return damage; } - @Override - public String getItemStackDisplayName(ItemStack stack){ - if(Util.isClient()) { + public String getItemStackDisplayName(ItemStack stack) { + if (Util.isClient()) { long sysTime = System.currentTimeMillis(); - if(this.lastSysTime+5000 < sysTime){ + if (this.lastSysTime + 5000 < sysTime) { this.lastSysTime = sysTime; - this.toPick = this.rand.nextInt(NAME_FLAVOR_AMOUNTS)+1; + this.toPick = this.rand.nextInt(NAME_FLAVOR_AMOUNTS) + 1; } - return StringUtil.localize(this.getTranslationKey()+".name")+" ("+StringUtil.localize("tile."+ActuallyAdditions.MODID+".block_inputter.add."+this.toPick+".name")+")"; - } - else return super.getItemStackDisplayName(stack); + return StringUtil.localize(this.getTranslationKey() + ".name") + " (" + StringUtil.localize("tile." + ActuallyAdditions.MODID + ".block_inputter.add." + this.toPick + ".name") + ")"; + } else return super.getItemStackDisplayName(stack); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemRepairer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemRepairer.java index 720095438..23201504f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemRepairer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemRepairer.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.blocks; - import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; @@ -28,9 +27,9 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockItemRepairer extends BlockContainerBase{ +public class BlockItemRepairer extends BlockContainerBase { - public BlockItemRepairer(String name){ + public BlockItemRepairer(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(20.0F); @@ -39,17 +38,16 @@ public class BlockItemRepairer extends BlockContainerBase{ this.setTickRandomly(true); } - @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityItemRepairer(); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(!world.isRemote){ - TileEntityItemRepairer repairer = (TileEntityItemRepairer)world.getTileEntity(pos); - if(repairer != null){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (!world.isRemote) { + TileEntityItemRepairer repairer = (TileEntityItemRepairer) world.getTileEntity(pos); + if (repairer != null) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.REPAIRER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } return true; @@ -58,12 +56,12 @@ public class BlockItemRepairer extends BlockContainerBase{ } @Override - public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos){ + public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { return this.getMetaFromState(state) == 1 ? 12 : 0; } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemViewer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemViewer.java index 749306fe5..a983c8b4b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemViewer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemViewer.java @@ -19,9 +19,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class BlockItemViewer extends BlockContainerBase{ +public class BlockItemViewer extends BlockContainerBase { - public BlockItemViewer(String name){ + public BlockItemViewer(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(1.5F); @@ -30,12 +30,12 @@ public class BlockItemViewer extends BlockContainerBase{ } @Override - public TileEntity createNewTileEntity(World worldIn, int meta){ + public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityItemViewer(); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemViewerHopping.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemViewerHopping.java index e651e73a2..fbd86a2f1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemViewerHopping.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemViewerHopping.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.blocks; +import java.util.List; + import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewerHopping; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.BlockStateContainer; @@ -28,10 +30,8 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.List; - //Most of this is just copied from BlockHopper, no credit taken. Or clue what it is. -public class BlockItemViewerHopping extends BlockItemViewer{ +public class BlockItemViewerHopping extends BlockItemViewer { public static final PropertyDirection FACING = PropertyDirection.create("facing", facing -> facing != EnumFacing.UP); @@ -41,18 +41,18 @@ public class BlockItemViewerHopping extends BlockItemViewer{ private static final AxisAlignedBB WEST_AABB = new AxisAlignedBB(0.875D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); private static final AxisAlignedBB EAST_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.125D, 1.0D, 1.0D); - public BlockItemViewerHopping(String name){ + public BlockItemViewerHopping(String name) { super(name); } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return FULL_BLOCK_AABB; } @Override @Deprecated - public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, Entity entityIn, boolean someBool){ + public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, Entity entityIn, boolean someBool) { addCollisionBoxToList(pos, entityBox, collidingBoxes, BASE_AABB); addCollisionBoxToList(pos, entityBox, collidingBoxes, EAST_AABB); addCollisionBoxToList(pos, entityBox, collidingBoxes, WEST_AABB); @@ -61,64 +61,64 @@ public class BlockItemViewerHopping extends BlockItemViewer{ } @Override - public TileEntity createNewTileEntity(World worldIn, int meta){ + public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityItemViewerHopping(); } @Override - public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer){ + public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { EnumFacing opp = facing.getOpposite(); return this.getDefaultState().withProperty(FACING, opp == EnumFacing.UP ? EnumFacing.DOWN : opp); } @Override //was isFullyOpaque, not sure if correct change. - public boolean isNormalCube(IBlockState state){ + public boolean isNormalCube(IBlockState state) { return true; } @Override - public boolean isFullCube(IBlockState state){ + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side){ + public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { return true; } @Override - public BlockRenderLayer getRenderLayer(){ + public BlockRenderLayer getRenderLayer() { return BlockRenderLayer.CUTOUT_MIPPED; } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(FACING, EnumFacing.byIndex(meta)); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(FACING).getIndex(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, FACING); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate(state.getValue(FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirror){ + public IBlockState withMirror(IBlockState state, Mirror mirror) { return this.withRotation(state, mirror.toRotation(state.getValue(FACING))); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLampPowerer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLampPowerer.java index 10b8e84c3..188b736c9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLampPowerer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLampPowerer.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.blocks; +import java.util.ArrayList; +import java.util.List; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; @@ -28,12 +30,9 @@ import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import java.util.ArrayList; -import java.util.List; +public class BlockLampPowerer extends BlockBase { -public class BlockLampPowerer extends BlockBase{ - - public BlockLampPowerer(String name){ + public BlockLampPowerer(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(1.5F); @@ -42,43 +41,42 @@ public class BlockLampPowerer extends BlockBase{ } @Override - public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos otherPos){ + public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos otherPos) { this.updateLamp(worldIn, pos); } @Override - public void onBlockAdded(World world, BlockPos pos, IBlockState state){ + public void onBlockAdded(World world, BlockPos pos, IBlockState state) { this.updateLamp(world, pos); } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){ + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) { int rotation = EnumFacing.getDirectionFromEntityLiving(pos, player).ordinal(); world.setBlockState(pos, this.getStateFromMeta(rotation), 2); super.onBlockPlacedBy(world, pos, state, player, stack); } - private void updateLamp(World world, BlockPos pos){ - if(!world.isRemote){ + private void updateLamp(World world, BlockPos pos) { + if (!world.isRemote) { IBlockState state = world.getBlockState(pos); BlockPos coords = pos.offset(WorldUtil.getDirectionByPistonRotation(state)); this.updateLampsAtPos(world, coords, world.getRedstonePowerFromNeighbors(pos) > 0, new ArrayList()); } } - private void updateLampsAtPos(World world, BlockPos pos, boolean powered, List updatedAlready){ + private void updateLampsAtPos(World world, BlockPos pos, boolean powered, List updatedAlready) { IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); - if(block instanceof BlockColoredLamp){ + if (block instanceof BlockColoredLamp) { boolean isOn = ((BlockColoredLamp) block).isOn; - if(powered){ - if(!isOn){ + if (powered) { + if (!isOn) { world.setBlockState(pos, InitBlocks.blockColoredLampOn.getDefaultState().withProperty(BlockColoredLamp.TYPE, state.getValue(BlockColoredLamp.TYPE)), 2); } - } - else{ - if(isOn){ + } else { + if (isOn) { world.setBlockState(pos, InitBlocks.blockColoredLamp.getDefaultState().withProperty(BlockColoredLamp.TYPE, state.getValue(BlockColoredLamp.TYPE)), 2); } } @@ -87,10 +85,10 @@ public class BlockLampPowerer extends BlockBase{ } } - private void updateSurrounding(World world, BlockPos pos, boolean powered, List updatedAlready){ - for(EnumFacing side : EnumFacing.values()){ + private void updateSurrounding(World world, BlockPos pos, boolean powered, List updatedAlready) { + for (EnumFacing side : EnumFacing.values()) { BlockPos offset = pos.offset(side); - if(!updatedAlready.contains(offset)){ + if (!updatedAlready.contains(offset)) { updatedAlready.add(pos); this.updateLampsAtPos(world, offset, powered, updatedAlready); } @@ -98,32 +96,32 @@ public class BlockLampPowerer extends BlockBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta)); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(BlockDirectional.FACING).getIndex(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockDirectional.FACING); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirror){ + public IBlockState withMirror(IBlockState state, Mirror mirror) { return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING))); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java index 5bdba1eef..847de97a2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java @@ -19,7 +19,13 @@ import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.items.ItemEngineerGoggles; import de.ellpeck.actuallyadditions.mod.items.ItemLaserRelayUpgrade; import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench; -import de.ellpeck.actuallyadditions.mod.tile.*; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergy; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergyAdvanced; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergyExtreme; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayFluids; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItem; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItemWhitelist; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil; import net.minecraft.block.BlockDirectional; @@ -52,20 +58,20 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{ +public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay { //This took way too much fiddling around. I'm not good with numbers. - private static final float F = 1/16F; - private static final AxisAlignedBB AABB_UP = new AxisAlignedBB(2*F, 0, 2*F, 1-2*F, 10*F, 1-2*F); - private static final AxisAlignedBB AABB_DOWN = new AxisAlignedBB(2*F, 6*F, 2*F, 1-2*F, 1, 1-2*F); - private static final AxisAlignedBB AABB_NORTH = new AxisAlignedBB(2*F, 2*F, 6*F, 1-2*F, 1-2*F, 1); - private static final AxisAlignedBB AABB_EAST = new AxisAlignedBB(0, 2*F, 2*F, 1-6*F, 1-2*F, 1-2*F); - private static final AxisAlignedBB AABB_SOUTH = new AxisAlignedBB(2*F, 2*F, 0, 1-2*F, 1-2*F, 1-6*F); - private static final AxisAlignedBB AABB_WEST = new AxisAlignedBB(6*F, 2*F, 2*F, 1, 1-2*F, 1-2*F); + private static final float F = 1 / 16F; + private static final AxisAlignedBB AABB_UP = new AxisAlignedBB(2 * F, 0, 2 * F, 1 - 2 * F, 10 * F, 1 - 2 * F); + private static final AxisAlignedBB AABB_DOWN = new AxisAlignedBB(2 * F, 6 * F, 2 * F, 1 - 2 * F, 1, 1 - 2 * F); + private static final AxisAlignedBB AABB_NORTH = new AxisAlignedBB(2 * F, 2 * F, 6 * F, 1 - 2 * F, 1 - 2 * F, 1); + private static final AxisAlignedBB AABB_EAST = new AxisAlignedBB(0, 2 * F, 2 * F, 1 - 6 * F, 1 - 2 * F, 1 - 2 * F); + private static final AxisAlignedBB AABB_SOUTH = new AxisAlignedBB(2 * F, 2 * F, 0, 1 - 2 * F, 1 - 2 * F, 1 - 6 * F); + private static final AxisAlignedBB AABB_WEST = new AxisAlignedBB(6 * F, 2 * F, 2 * F, 1, 1 - 2 * F, 1 - 2 * F); private final Type type; - public BlockLaserRelay(String name, Type type){ + public BlockLaserRelay(String name, Type type) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(1.5F); @@ -74,22 +80,22 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{ this.type = type; - if(this.type.ordinal() == 0){ + if (this.type.ordinal() == 0) { MinecraftForge.EVENT_BUS.register(this); } } @SubscribeEvent - public void onBlockRightClick(PlayerInteractEvent.RightClickBlock event){ + public void onBlockRightClick(PlayerInteractEvent.RightClickBlock event) { EntityPlayer player = event.getEntityPlayer(); World world = event.getWorld(); ItemStack stack = event.getItemStack(); BlockPos pos = event.getPos(); - if(player != null && world != null && StackUtil.isValid(stack) && pos != null){ + if (player != null && world != null && StackUtil.isValid(stack) && pos != null) { IBlockState state = event.getWorld().getBlockState(pos); - if(state != null && state.getBlock() instanceof BlockLaserRelay){ - if(player.isSneaking()){ + if (state != null && state.getBlock() instanceof BlockLaserRelay) { + if (player.isSneaking()) { event.setUseBlock(Event.Result.ALLOW); } } @@ -97,8 +103,8 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{ } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ - switch(this.getMetaFromState(state)){ + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + switch (this.getMetaFromState(state)) { case 1: return AABB_UP; case 2: @@ -115,67 +121,66 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{ } @Override - public boolean isFullCube(IBlockState state){ + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int meta, EntityLivingBase base){ + public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int meta, EntityLivingBase base) { return this.getStateFromMeta(side.ordinal()); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta)); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(BlockDirectional.FACING).getIndex(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockDirectional.FACING); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(BlockDirectional.FACING, rot.rotate(state.getValue(BlockDirectional.FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirror){ + public IBlockState withMirror(IBlockState state, Mirror mirror) { return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING))); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { ItemStack stack = player.getHeldItem(hand); TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityLaserRelay){ - TileEntityLaserRelay relay = (TileEntityLaserRelay)tile; + if (tile instanceof TileEntityLaserRelay) { + TileEntityLaserRelay relay = (TileEntityLaserRelay) tile; - if(StackUtil.isValid(stack)){ - if(stack.getItem() instanceof ItemLaserWrench){ + if (StackUtil.isValid(stack)) { + if (stack.getItem() instanceof ItemLaserWrench) { return false; - } - else if(stack.getItem() == ConfigValues.itemCompassConfigurator){ - if(!world.isRemote){ + } else if (stack.getItem() == ConfigValues.itemCompassConfigurator) { + if (!world.isRemote) { relay.onCompassAction(player); Network network = relay.getNetwork(); - if(network != null){ + if (network != null) { network.changeAmount++; } @@ -184,12 +189,11 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{ } return true; - } - else if(stack.getItem() instanceof ItemLaserRelayUpgrade){ + } else if (stack.getItem() instanceof ItemLaserRelayUpgrade) { ItemStack inRelay = relay.inv.getStackInSlot(0); - if(!StackUtil.isValid(inRelay)){ - if(!world.isRemote){ - if(!player.isCreative()){ + if (!StackUtil.isValid(inRelay)) { + if (!world.isRemote) { + if (!player.isCreative()) { player.setHeldItem(hand, StackUtil.shrink(stack, 1)); } @@ -203,13 +207,13 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{ } } - if(player.isSneaking()){ + if (player.isSneaking()) { ItemStack inRelay = relay.inv.getStackInSlot(0).copy(); - if(StackUtil.isValid(inRelay)){ - if(!world.isRemote){ + if (StackUtil.isValid(inRelay)) { + if (!world.isRemote) { relay.inv.setStackInSlot(0, StackUtil.getEmpty()); - if(!player.inventory.addItemStackToInventory(inRelay)){ + if (!player.inventory.addItemStackToInventory(inRelay)) { player.entityDropItem(inRelay, 0); } } @@ -217,8 +221,8 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{ } } - if(relay instanceof TileEntityLaserRelayItemWhitelist){ - if(!world.isRemote){ + if (relay instanceof TileEntityLaserRelayItemWhitelist) { + if (!world.isRemote) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.LASER_RELAY_ITEM_WHITELIST.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } return true; @@ -228,8 +232,8 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{ } @Override - public TileEntity createNewTileEntity(World world, int i){ - switch(this.type){ + public TileEntity createNewTileEntity(World world, int i) { + switch (this.type) { case ITEM: return new TileEntityLaserRelayItem(); case ITEM_WHITELIST: @@ -247,28 +251,27 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{ @Override @SideOnly(Side.CLIENT) - public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){ - if(posHit != null && posHit.getBlockPos() != null && minecraft.world != null){ + public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution) { + if (posHit != null && posHit.getBlockPos() != null && minecraft.world != null) { boolean wearing = ItemEngineerGoggles.isWearing(player); - if(wearing || StackUtil.isValid(stack)){ + if (wearing || StackUtil.isValid(stack)) { boolean compass = stack.getItem() == ConfigValues.itemCompassConfigurator; - if(wearing || compass || stack.getItem() instanceof ItemLaserWrench){ + if (wearing || compass || stack.getItem() instanceof ItemLaserWrench) { TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos()); - if(tile instanceof TileEntityLaserRelay){ - TileEntityLaserRelay relay = (TileEntityLaserRelay)tile; + if (tile instanceof TileEntityLaserRelay) { + TileEntityLaserRelay relay = (TileEntityLaserRelay) tile; String strg = relay.getExtraDisplayString(); - minecraft.fontRenderer.drawStringWithShadow(strg, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE); + minecraft.fontRenderer.drawStringWithShadow(strg, resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 5, StringUtil.DECIMAL_COLOR_WHITE); String expl; - if(compass){ + if (compass) { expl = relay.getCompassDisplayString(); - } - else{ - expl = TextFormatting.GRAY.toString()+TextFormatting.ITALIC+StringUtil.localizeFormatted("info."+ActuallyAdditions.MODID+".laserRelay.mode.noCompasss", StringUtil.localize(ConfigValues.itemCompassConfigurator.getTranslationKey()+".name")); + } else { + expl = TextFormatting.GRAY.toString() + TextFormatting.ITALIC + StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".laserRelay.mode.noCompasss", StringUtil.localize(ConfigValues.itemCompassConfigurator.getTranslationKey() + ".name")); } - StringUtil.drawSplitString(minecraft.fontRenderer, expl, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+15, Integer.MAX_VALUE, StringUtil.DECIMAL_COLOR_WHITE, true); + StringUtil.drawSplitString(minecraft.fontRenderer, expl, resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 15, Integer.MAX_VALUE, StringUtil.DECIMAL_COLOR_WHITE, true); } } } @@ -276,7 +279,7 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{ } @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ + public void breakBlock(World world, BlockPos pos, IBlockState state) { super.breakBlock(world, pos, state); ActuallyAdditionsAPI.connectionHandler.removeRelayFromNetwork(pos, world); @@ -287,7 +290,7 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{ return BlockFaceShape.UNDEFINED; } - public enum Type{ + public enum Type { ENERGY_BASIC, ENERGY_ADVANCED, ENERGY_EXTREME, diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLavaFactoryController.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLavaFactoryController.java index b4f7c03ea..9f845eddf 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLavaFactoryController.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLavaFactoryController.java @@ -27,9 +27,9 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class BlockLavaFactoryController extends BlockContainerBase implements IHudDisplay{ +public class BlockLavaFactoryController extends BlockContainerBase implements IHudDisplay { - public BlockLavaFactoryController(String name){ + public BlockLavaFactoryController(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(4.5F); @@ -37,28 +37,26 @@ public class BlockLavaFactoryController extends BlockContainerBase implements IH this.setSoundType(SoundType.STONE); } - @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityLavaFactoryController(); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override @SideOnly(Side.CLIENT) - public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){ - TileEntityLavaFactoryController factory = (TileEntityLavaFactoryController)minecraft.world.getTileEntity(posHit.getBlockPos()); - if(factory != null){ + public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution) { + TileEntityLavaFactoryController factory = (TileEntityLavaFactoryController) minecraft.world.getTileEntity(posHit.getBlockPos()); + if (factory != null) { int state = factory.isMultiblock(); - if(state == TileEntityLavaFactoryController.NOT_MULTI){ - StringUtil.drawSplitString(minecraft.fontRenderer, StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".factory.notPart.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE, true); - } - else if(state == TileEntityLavaFactoryController.HAS_AIR || state == TileEntityLavaFactoryController.HAS_LAVA){ - StringUtil.drawSplitString(minecraft.fontRenderer, StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".factory.works.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE, true); + if (state == TileEntityLavaFactoryController.NOT_MULTI) { + StringUtil.drawSplitString(minecraft.fontRenderer, StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".factory.notPart.desc"), resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 5, 200, StringUtil.DECIMAL_COLOR_WHITE, true); + } else if (state == TileEntityLavaFactoryController.HAS_AIR || state == TileEntityLavaFactoryController.HAS_LAVA) { + StringUtil.drawSplitString(minecraft.fontRenderer, StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".factory.works.desc"), resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 5, 200, StringUtil.DECIMAL_COLOR_WHITE, true); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLeafGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLeafGenerator.java index 689ce2f6f..45fd23b00 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLeafGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLeafGenerator.java @@ -19,9 +19,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class BlockLeafGenerator extends BlockContainerBase{ +public class BlockLeafGenerator extends BlockContainerBase { - public BlockLeafGenerator(String name){ + public BlockLeafGenerator(String name) { super(Material.IRON, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(5.0F); @@ -29,14 +29,13 @@ public class BlockLeafGenerator extends BlockContainerBase{ this.setSoundType(SoundType.METAL); } - @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityLeafGenerator(); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMiner.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMiner.java index 201b611f7..eeddbd8e3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMiner.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMiner.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.blocks; - import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; @@ -33,9 +32,9 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class BlockMiner extends BlockContainerBase implements IHudDisplay{ +public class BlockMiner extends BlockContainerBase implements IHudDisplay { - public BlockMiner(String name){ + public BlockMiner(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(8F); @@ -44,15 +43,15 @@ public class BlockMiner extends BlockContainerBase implements IHudDisplay{ } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(!world.isRemote){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (!world.isRemote) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityMiner){ + if (tile instanceof TileEntityMiner) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.MINER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } } @@ -60,24 +59,23 @@ public class BlockMiner extends BlockContainerBase implements IHudDisplay{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } - @Override - public TileEntity createNewTileEntity(World world, int i){ + public TileEntity createNewTileEntity(World world, int i) { return new TileEntityMiner(); } @Override @SideOnly(Side.CLIENT) - public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){ + public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution) { TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos()); - if(tile instanceof TileEntityMiner){ - TileEntityMiner miner = (TileEntityMiner)tile; - String info = miner.checkY == 0 ? "Done Mining!" : miner.checkY == -1 ? "Calculating positions..." : "Mining at "+(miner.getPos().getX()+miner.checkX)+", "+miner.checkY+", "+(miner.getPos().getZ()+miner.checkZ)+"."; - minecraft.fontRenderer.drawStringWithShadow(info, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2-20, StringUtil.DECIMAL_COLOR_WHITE); + if (tile instanceof TileEntityMiner) { + TileEntityMiner miner = (TileEntityMiner) tile; + String info = miner.checkY == 0 ? "Done Mining!" : miner.checkY == -1 ? "Calculating positions..." : "Mining at " + (miner.getPos().getX() + miner.checkX) + ", " + miner.checkY + ", " + (miner.getPos().getZ() + miner.checkZ) + "."; + minecraft.fontRenderer.drawStringWithShadow(info, resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 - 20, StringUtil.DECIMAL_COLOR_WHITE); } } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMisc.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMisc.java index 947fd870d..6d5173b11 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMisc.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMisc.java @@ -25,12 +25,12 @@ import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; -public class BlockMisc extends BlockBase{ +public class BlockMisc extends BlockBase { public static final TheMiscBlocks[] ALL_MISC_BLOCKS = TheMiscBlocks.values(); public static final PropertyEnum TYPE = PropertyEnum.create("type", TheMiscBlocks.class); - public BlockMisc(String name){ + public BlockMisc(String name) { super(Material.ROCK, name); this.setHardness(1.5F); this.setResistance(10.0F); @@ -38,66 +38,65 @@ public class BlockMisc extends BlockBase{ } @Override - public int damageDropped(IBlockState state){ + public int damageDropped(IBlockState state) { return this.getMetaFromState(state); } @Override - public void getSubBlocks(CreativeTabs tab, NonNullList list){ - for(int j = 0; j < ALL_MISC_BLOCKS.length; j++){ + public void getSubBlocks(CreativeTabs tab, NonNullList list) { + for (int j = 0; j < ALL_MISC_BLOCKS.length; j++) { list.add(new ItemStack(this, 1, j)); } } @Override - protected ItemBlockBase getItemBlock(){ + protected ItemBlockBase getItemBlock() { return new TheItemBlock(this); } @Override - public void registerRendering(){ - for(int i = 0; i < ALL_MISC_BLOCKS.length; i++){ - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName()+"="+ALL_MISC_BLOCKS[i].name); + public void registerRendering() { + for (int i = 0; i < ALL_MISC_BLOCKS.length; i++) { + ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName() + "=" + ALL_MISC_BLOCKS[i].name); } } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return stack.getItemDamage() >= ALL_MISC_BLOCKS.length ? EnumRarity.COMMON : ALL_MISC_BLOCKS[stack.getItemDamage()].rarity; } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(TYPE, TheMiscBlocks.values()[meta]); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(TYPE).ordinal(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, TYPE); } - public static class TheItemBlock extends ItemBlockBase{ + public static class TheItemBlock extends ItemBlockBase { - public TheItemBlock(Block block){ + public TheItemBlock(Block block) { super(block); this.setHasSubtypes(true); this.setMaxDamage(0); } - @Override - public String getTranslationKey(ItemStack stack){ - return stack.getItemDamage() >= ALL_MISC_BLOCKS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey()+"_"+ALL_MISC_BLOCKS[stack.getItemDamage()].name; + public String getTranslationKey(ItemStack stack) { + return stack.getItemDamage() >= ALL_MISC_BLOCKS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey() + "_" + ALL_MISC_BLOCKS[stack.getItemDamage()].name; } @Override public int getItemBurnTime(ItemStack stack) { - if(stack.getMetadata() == TheMiscBlocks.CHARCOAL_BLOCK.ordinal()) return 16000; + if (stack.getMetadata() == TheMiscBlocks.CHARCOAL_BLOCK.ordinal()) return 16000; return super.getItemBurnTime(stack); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockOilGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockOilGenerator.java index a31ae296b..627c78098 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockOilGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockOilGenerator.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.blocks; +import java.util.Random; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; @@ -25,17 +26,19 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.*; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.Random; +public class BlockOilGenerator extends BlockContainerBase { -public class BlockOilGenerator extends BlockContainerBase{ - - public BlockOilGenerator(String name){ + public BlockOilGenerator(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(1.5F); @@ -45,39 +48,39 @@ public class BlockOilGenerator extends BlockContainerBase{ } @Override - public boolean isFullCube(IBlockState state){ + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityOilGenerator(); } @Override @SideOnly(Side.CLIENT) - public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){ + public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityOilGenerator){ - if(((TileEntityOilGenerator)tile).currentBurnTime > 0){ - for(int i = 0; i < 5; i++){ - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D); + if (tile instanceof TileEntityOilGenerator) { + if (((TileEntityOilGenerator) tile).currentBurnTime > 0) { + for (int i = 0; i < 5; i++) { + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double) pos.getX() + 0.5F, (double) pos.getY() + 1.0F, (double) pos.getZ() + 0.5F, 0.0D, 0.0D, 0.0D); } } } } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(!world.isRemote){ - TileEntityOilGenerator generator = (TileEntityOilGenerator)world.getTileEntity(pos); - if(generator != null){ - if(!this.tryUseItemOnTank(player, hand, generator.tank)){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (!world.isRemote) { + TileEntityOilGenerator generator = (TileEntityOilGenerator) world.getTileEntity(pos); + if (generator != null) { + if (!this.tryUseItemOnTank(player, hand, generator.tank)) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.OIL_GENERATOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } } @@ -87,39 +90,39 @@ public class BlockOilGenerator extends BlockContainerBase{ } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){ + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) { world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2); super.onBlockPlacedBy(world, pos, state, player, stack); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta)); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockHorizontal.FACING); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirror){ + public IBlockState withMirror(IBlockState state, Mirror mirror) { return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING))); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java index b15045676..ac75396c7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java @@ -13,7 +13,12 @@ package de.ellpeck.actuallyadditions.mod.blocks; import de.ellpeck.actuallyadditions.api.tile.IPhantomTile; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.tile.*; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomBreaker; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomEnergyface; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomItemface; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomLiquiface; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomPlacer; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomRedstoneface; import de.ellpeck.actuallyadditions.mod.util.StringUtil; import net.minecraft.block.Block; import net.minecraft.block.SoundType; @@ -38,11 +43,11 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class BlockPhantom extends BlockContainerBase implements IHudDisplay{ +public class BlockPhantom extends BlockContainerBase implements IHudDisplay { public final Type type; - public BlockPhantom(Type type, String name){ + public BlockPhantom(Type type, String name) { super(Material.ROCK, name); this.type = type; this.setHarvestLevel("pickaxe", 0); @@ -52,40 +57,36 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{ } @Override - public boolean canProvidePower(IBlockState state){ + public boolean canProvidePower(IBlockState state) { return this.type == Type.REDSTONEFACE; } @Override - public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side){ - if(this.type == Type.REDSTONEFACE){ + public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { + if (this.type == Type.REDSTONEFACE) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityPhantomRedstoneface){ - return ((TileEntityPhantomRedstoneface)tile).providesWeak[side.ordinal()]; - } + if (tile instanceof TileEntityPhantomRedstoneface) { return ((TileEntityPhantomRedstoneface) tile).providesWeak[side.ordinal()]; } } return 0; } @Override - public int getStrongPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side){ - if(this.type == Type.REDSTONEFACE){ + public int getStrongPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { + if (this.type == Type.REDSTONEFACE) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityPhantomRedstoneface){ - return ((TileEntityPhantomRedstoneface)tile).providesStrong[side.ordinal()]; - } + if (tile instanceof TileEntityPhantomRedstoneface) { return ((TileEntityPhantomRedstoneface) tile).providesStrong[side.ordinal()]; } } return 0; } @Override - public boolean shouldDropInventory(World world, BlockPos pos){ + public boolean shouldDropInventory(World world, BlockPos pos) { return this.type == Type.PLACER || this.type == Type.BREAKER; } @Override - public TileEntity createNewTileEntity(World world, int par2){ - switch(this.type){ + public TileEntity createNewTileEntity(World world, int par2) { + switch (this.type) { case PLACER: return new TileEntityPhantomPlacer(); case BREAKER: @@ -102,55 +103,51 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{ } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ){ - if(this.tryToggleRedstone(world, pos, player)){ - return true; - } - if(!world.isRemote){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + if (this.tryToggleRedstone(world, pos, player)) { return true; } + if (!world.isRemote) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof IPhantomTile && ((IPhantomTile)tile).getGuiID() != -1){ - player.openGui(ActuallyAdditions.INSTANCE, ((IPhantomTile)tile).getGuiID(), world, pos.getX(), pos.getY(), pos.getZ()); + if (tile instanceof IPhantomTile && ((IPhantomTile) tile).getGuiID() != -1) { + player.openGui(ActuallyAdditions.INSTANCE, ((IPhantomTile) tile).getGuiID(), world, pos.getX(), pos.getY(), pos.getZ()); } } return true; } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } @Override @SideOnly(Side.CLIENT) - public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){ + public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution) { TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos()); - if(tile != null){ - if(tile instanceof IPhantomTile){ - IPhantomTile phantom = (IPhantomTile)tile; - minecraft.fontRenderer.drawStringWithShadow(TextFormatting.GOLD+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".blockPhantomRange.desc")+": "+phantom.getRange(), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2-40, StringUtil.DECIMAL_COLOR_WHITE); - if(phantom.hasBoundPosition()){ + if (tile != null) { + if (tile instanceof IPhantomTile) { + IPhantomTile phantom = (IPhantomTile) tile; + minecraft.fontRenderer.drawStringWithShadow(TextFormatting.GOLD + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".blockPhantomRange.desc") + ": " + phantom.getRange(), resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 - 40, StringUtil.DECIMAL_COLOR_WHITE); + if (phantom.hasBoundPosition()) { int distance = MathHelper.ceil(new Vec3d(posHit.getBlockPos()).distanceTo(new Vec3d(phantom.getBoundPosition()))); IBlockState state = minecraft.world.getBlockState(phantom.getBoundPosition()); Block block = state.getBlock(); Item item = Item.getItemFromBlock(block); String name = item == null ? "Something Unrecognizable" : item.getItemStackDisplayName(new ItemStack(block, 1, block.getMetaFromState(state))); - StringUtil.drawSplitString(minecraft.fontRenderer, StringUtil.localizeFormatted("tooltip."+ActuallyAdditions.MODID+".phantom.blockInfo.desc", name, phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ(), distance), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2-30, 200, StringUtil.DECIMAL_COLOR_WHITE, true); + StringUtil.drawSplitString(minecraft.fontRenderer, StringUtil.localizeFormatted("tooltip." + ActuallyAdditions.MODID + ".phantom.blockInfo.desc", name, phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ(), distance), resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 - 30, 200, StringUtil.DECIMAL_COLOR_WHITE, true); - if(phantom.isBoundThingInRange()){ - StringUtil.drawSplitString(minecraft.fontRenderer, TextFormatting.DARK_GREEN+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".phantom.connectedRange.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, 200, StringUtil.DECIMAL_COLOR_WHITE, true); + if (phantom.isBoundThingInRange()) { + StringUtil.drawSplitString(minecraft.fontRenderer, TextFormatting.DARK_GREEN + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".phantom.connectedRange.desc"), resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 25, 200, StringUtil.DECIMAL_COLOR_WHITE, true); + } else { + StringUtil.drawSplitString(minecraft.fontRenderer, TextFormatting.DARK_RED + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".phantom.connectedNoRange.desc"), resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 25, 200, StringUtil.DECIMAL_COLOR_WHITE, true); } - else{ - StringUtil.drawSplitString(minecraft.fontRenderer, TextFormatting.DARK_RED+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".phantom.connectedNoRange.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, 200, StringUtil.DECIMAL_COLOR_WHITE, true); - } - } - else{ - minecraft.fontRenderer.drawStringWithShadow(TextFormatting.RED+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".phantom.notConnected.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, StringUtil.DECIMAL_COLOR_WHITE); + } else { + minecraft.fontRenderer.drawStringWithShadow(TextFormatting.RED + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".phantom.notConnected.desc"), resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 25, StringUtil.DECIMAL_COLOR_WHITE); } } } } - public enum Type{ + public enum Type { FACE, PLACER, BREAKER, diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantomBooster.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantomBooster.java index 6a7372deb..e025e96b6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantomBooster.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantomBooster.java @@ -23,11 +23,11 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockPhantomBooster extends BlockContainerBase{ +public class BlockPhantomBooster extends BlockContainerBase { - private static final AxisAlignedBB AABB = new AxisAlignedBB(2*0.0625, 0, 2*0.0625, 1-2*0.0625, 1, 1-2*0.0625); + private static final AxisAlignedBB AABB = new AxisAlignedBB(2 * 0.0625, 0, 2 * 0.0625, 1 - 2 * 0.0625, 1, 1 - 2 * 0.0625); - public BlockPhantomBooster(String name){ + public BlockPhantomBooster(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(1.5F); @@ -36,28 +36,27 @@ public class BlockPhantomBooster extends BlockContainerBase{ } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return AABB; } @Override - public boolean isFullCube(IBlockState state){ + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } - @Override - public TileEntity createNewTileEntity(World world, int i){ + public TileEntity createNewTileEntity(World world, int i) { return new TileEntityPhantomBooster(); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPlayerInterface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPlayerInterface.java index e8a9791b2..a39029e2c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPlayerInterface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPlayerInterface.java @@ -30,9 +30,9 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class BlockPlayerInterface extends BlockContainerBase implements IHudDisplay{ +public class BlockPlayerInterface extends BlockContainerBase implements IHudDisplay { - public BlockPlayerInterface(String name){ + public BlockPlayerInterface(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(4.5F); @@ -41,21 +41,21 @@ public class BlockPlayerInterface extends BlockContainerBase implements IHudDisp } @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityPlayerInterface(); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){ + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityPlayerInterface){ - TileEntityPlayerInterface face = (TileEntityPlayerInterface)tile; - if(face.connectedPlayer == null){ + if (tile instanceof TileEntityPlayerInterface) { + TileEntityPlayerInterface face = (TileEntityPlayerInterface) tile; + if (face.connectedPlayer == null) { face.connectedPlayer = player.getUniqueID(); face.playerName = player.getName(); face.markDirty(); @@ -68,14 +68,14 @@ public class BlockPlayerInterface extends BlockContainerBase implements IHudDisp @Override @SideOnly(Side.CLIENT) - public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){ + public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution) { TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos()); - if(tile != null){ - if(tile instanceof TileEntityPlayerInterface){ - TileEntityPlayerInterface face = (TileEntityPlayerInterface)tile; + if (tile != null) { + if (tile instanceof TileEntityPlayerInterface) { + TileEntityPlayerInterface face = (TileEntityPlayerInterface) tile; String name = face.playerName == null ? "Unknown" : face.playerName; - minecraft.fontRenderer.drawStringWithShadow("Bound to: "+TextFormatting.RED+name, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE); - minecraft.fontRenderer.drawStringWithShadow("UUID: "+TextFormatting.DARK_GREEN+face.connectedPlayer, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+15, StringUtil.DECIMAL_COLOR_WHITE); + minecraft.fontRenderer.drawStringWithShadow("Bound to: " + TextFormatting.RED + name, resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 5, StringUtil.DECIMAL_COLOR_WHITE); + minecraft.fontRenderer.drawStringWithShadow("UUID: " + TextFormatting.DARK_GREEN + face.connectedPlayer, resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 15, StringUtil.DECIMAL_COLOR_WHITE); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java index dfcecd375..b2731cc15 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java @@ -26,9 +26,9 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BlockRangedCollector extends BlockContainerBase{ +public class BlockRangedCollector extends BlockContainerBase { - public BlockRangedCollector(String name){ + public BlockRangedCollector(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(1.5F); @@ -36,20 +36,17 @@ public class BlockRangedCollector extends BlockContainerBase{ this.setSoundType(SoundType.STONE); } - @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityRangedCollector(); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(this.tryToggleRedstone(world, pos, player)){ - return true; - } - if(!world.isRemote){ - TileEntityRangedCollector breaker = (TileEntityRangedCollector)world.getTileEntity(pos); - if(breaker != null){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (this.tryToggleRedstone(world, pos, player)) { return true; } + if (!world.isRemote) { + TileEntityRangedCollector breaker = (TileEntityRangedCollector) world.getTileEntity(pos); + if (breaker != null) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.RANGED_COLLECTOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } return true; @@ -58,7 +55,7 @@ public class BlockRangedCollector extends BlockContainerBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockShockSuppressor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockShockSuppressor.java index d599c551c..d316d4c9f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockShockSuppressor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockShockSuppressor.java @@ -10,6 +10,10 @@ package de.ellpeck.actuallyadditions.mod.blocks; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityShockSuppressor; import net.minecraft.block.SoundType; @@ -24,13 +28,9 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.world.ExplosionEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +public class BlockShockSuppressor extends BlockContainerBase { -public class BlockShockSuppressor extends BlockContainerBase{ - - public BlockShockSuppressor(String name){ + public BlockShockSuppressor(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(20.0F); @@ -41,29 +41,29 @@ public class BlockShockSuppressor extends BlockContainerBase{ } @SubscribeEvent - public void onExplosion(ExplosionEvent.Detonate event){ + public void onExplosion(ExplosionEvent.Detonate event) { World world = event.getWorld(); - if(!world.isRemote){ + if (!world.isRemote) { List affectedBlocks = event.getAffectedBlocks(); List affectedEntities = event.getAffectedEntities(); - int rangeSq = TileEntityShockSuppressor.RANGE*TileEntityShockSuppressor.RANGE; + int rangeSq = TileEntityShockSuppressor.RANGE * TileEntityShockSuppressor.RANGE; int use = TileEntityShockSuppressor.USE_PER; - for(TileEntityShockSuppressor suppressor : TileEntityShockSuppressor.SUPPRESSORS){ - if(!suppressor.isRedstonePowered){ + for (TileEntityShockSuppressor suppressor : TileEntityShockSuppressor.SUPPRESSORS) { + if (!suppressor.isRedstonePowered) { BlockPos supPos = suppressor.getPos(); List entitiesToRemove = new ArrayList<>(); List posesToRemove = new ArrayList<>(); - for(BlockPos pos : affectedBlocks){ - if(pos.distanceSq(supPos) <= rangeSq){ + for (BlockPos pos : affectedBlocks) { + if (pos.distanceSq(supPos) <= rangeSq) { posesToRemove.add(pos); } } - for(Entity entity : affectedEntities){ - if(entity.getPositionVector().squareDistanceTo(supPos.getX(), supPos.getY(), supPos.getZ()) <= rangeSq){ + for (Entity entity : affectedEntities) { + if (entity.getPositionVector().squareDistanceTo(supPos.getX(), supPos.getY(), supPos.getZ()) <= rangeSq) { entitiesToRemove.add(entity); } } @@ -71,21 +71,19 @@ public class BlockShockSuppressor extends BlockContainerBase{ Collections.shuffle(entitiesToRemove); Collections.shuffle(posesToRemove); - for(BlockPos pos : posesToRemove){ - if(suppressor.storage.getEnergyStored() >= use){ + for (BlockPos pos : posesToRemove) { + if (suppressor.storage.getEnergyStored() >= use) { suppressor.storage.extractEnergyInternal(use, false); affectedBlocks.remove(pos); - } - else{ + } else { break; } } - for(Entity entity : entitiesToRemove){ - if(suppressor.storage.getEnergyStored() >= use){ + for (Entity entity : entitiesToRemove) { + if (suppressor.storage.getEnergyStored() >= use) { suppressor.storage.extractEnergyInternal(use, false); affectedEntities.remove(entity); - } - else{ + } else { break; } } @@ -95,12 +93,12 @@ public class BlockShockSuppressor extends BlockContainerBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } @Override - public TileEntity createNewTileEntity(World worldIn, int meta){ + public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityShockSuppressor(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSlabs.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSlabs.java index 100d1dc41..cae57665b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSlabs.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSlabs.java @@ -33,18 +33,18 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class BlockSlabs extends BlockBase{ +public class BlockSlabs extends BlockBase { public static final AxisAlignedBB AABB_BOTTOM_HALF = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.5D, 1.0D); private static final AxisAlignedBB AABB_TOP_HALF = new AxisAlignedBB(0.0D, 0.5D, 0.0D, 1.0D, 1.0D, 1.0D); private final IBlockState fullBlockState; - public BlockSlabs(String name, Block fullBlock){ + public BlockSlabs(String name, Block fullBlock) { this(name, fullBlock.getDefaultState()); } - public BlockSlabs(String name, IBlockState fullBlockState){ + public BlockSlabs(String name, IBlockState fullBlockState) { super(fullBlockState.getMaterial(), name); this.setHardness(1.5F); this.setResistance(10.0F); @@ -52,79 +52,75 @@ public class BlockSlabs extends BlockBase{ } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isFullCube(IBlockState state){ + public boolean isFullCube(IBlockState state) { return false; } @Override - public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer){ - if(facing.ordinal() == 1){ - return this.getStateFromMeta(meta); - } - if(facing.ordinal() == 0 || hitY >= 0.5F){ - return this.getStateFromMeta(meta+1); - } + public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { + if (facing.ordinal() == 1) { return this.getStateFromMeta(meta); } + if (facing.ordinal() == 0 || hitY >= 0.5F) { return this.getStateFromMeta(meta + 1); } return this.getStateFromMeta(meta); } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP ? AABB_TOP_HALF : AABB_BOTTOM_HALF; } @Override - protected ItemBlockBase getItemBlock(){ + protected ItemBlockBase getItemBlock() { return new TheItemBlock(this); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.COMMON; } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(BlockSlab.HALF, meta == 0 ? BlockSlab.EnumBlockHalf.BOTTOM : BlockSlab.EnumBlockHalf.TOP); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM ? 0 : 1; } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockSlab.HALF); } - public static class TheItemBlock extends ItemBlockBase{ + public static class TheItemBlock extends ItemBlockBase { - public TheItemBlock(Block block){ + public TheItemBlock(Block block) { super(block); this.setHasSubtypes(false); this.setMaxDamage(0); } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){ + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); - if(StackUtil.isValid(stack) && player.canPlayerEdit(pos.offset(facing), facing, stack)){ + if (StackUtil.isValid(stack) && player.canPlayerEdit(pos.offset(facing), facing, stack)) { IBlockState state = world.getBlockState(pos); - if(state.getBlock() == this.block){ - BlockSlabs theBlock = (BlockSlabs)this.block; - if(facing == EnumFacing.UP && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM || facing == EnumFacing.DOWN && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP){ + if (state.getBlock() == this.block) { + BlockSlabs theBlock = (BlockSlabs) this.block; + if (facing == EnumFacing.UP && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM || facing == EnumFacing.DOWN && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP) { IBlockState newState = theBlock.fullBlockState; AxisAlignedBB bound = newState.getCollisionBoundingBox(world, pos); - if(bound != Block.NULL_AABB && world.checkNoEntityCollision(bound.offset(pos)) && world.setBlockState(pos, newState, 11)){ + if (bound != Block.NULL_AABB && world.checkNoEntityCollision(bound.offset(pos)) && world.setBlockState(pos, newState, 11)) { SoundType soundtype = theBlock.fullBlockState.getBlock().getSoundType(theBlock.fullBlockState, world, pos, player); - world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F); + world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); player.setHeldItem(hand, StackUtil.shrink(stack, 1)); } @@ -133,37 +129,34 @@ public class BlockSlabs extends BlockBase{ } return this.tryPlace(player, stack, hand, world, pos.offset(facing)) ? EnumActionResult.SUCCESS : super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ); - } - else{ + } else { return EnumActionResult.FAIL; } } @Override @SideOnly(Side.CLIENT) - public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack){ + public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack) { IBlockState state = worldIn.getBlockState(pos); - if(state.getBlock() == this.block){ - if(side == EnumFacing.UP && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM || side == EnumFacing.DOWN && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP){ - return true; - } + if (state.getBlock() == this.block) { + if (side == EnumFacing.UP && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM || side == EnumFacing.DOWN && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP) { return true; } } return worldIn.getBlockState(pos.offset(side)).getBlock() == this.block || super.canPlaceBlockOnSide(worldIn, pos, side, player, stack); } - private boolean tryPlace(EntityPlayer player, ItemStack stack, EnumHand hand, World world, BlockPos pos){ + private boolean tryPlace(EntityPlayer player, ItemStack stack, EnumHand hand, World world, BlockPos pos) { IBlockState iblockstate = world.getBlockState(pos); - if(iblockstate.getBlock() == this.block){ - BlockSlabs theBlock = (BlockSlabs)this.block; + if (iblockstate.getBlock() == this.block) { + BlockSlabs theBlock = (BlockSlabs) this.block; IBlockState newState = theBlock.fullBlockState; AxisAlignedBB bound = newState.getCollisionBoundingBox(world, pos); - if(bound != Block.NULL_AABB && world.checkNoEntityCollision(bound.offset(pos)) && world.setBlockState(pos, newState, 11)){ + if (bound != Block.NULL_AABB && world.checkNoEntityCollision(bound.offset(pos)) && world.setBlockState(pos, newState, 11)) { SoundType soundtype = theBlock.fullBlockState.getBlock().getSoundType(theBlock.fullBlockState, world, pos, player); - world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F); + world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); player.setHeldItem(hand, StackUtil.shrink(stack, 1)); } @@ -174,9 +167,8 @@ public class BlockSlabs extends BlockBase{ return false; } - @Override - public String getTranslationKey(ItemStack stack){ + public String getTranslationKey(ItemStack stack) { return this.getTranslationKey(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSmileyCloud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSmileyCloud.java index 3d0b4bd21..fceb06cf8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSmileyCloud.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSmileyCloud.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.blocks; +import java.util.Random; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; @@ -25,17 +26,19 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.*; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.Random; +public class BlockSmileyCloud extends BlockContainerBase { -public class BlockSmileyCloud extends BlockContainerBase{ - - public BlockSmileyCloud(String name){ + public BlockSmileyCloud(String name) { super(Material.CLOTH, name); this.setHardness(0.5F); this.setResistance(5.0F); @@ -44,33 +47,33 @@ public class BlockSmileyCloud extends BlockContainerBase{ } @Override - public boolean isFullCube(IBlockState state){ + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override @SideOnly(Side.CLIENT) - public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){ - if(world.rand.nextInt(30) == 0){ - for(int i = 0; i < 2; i++){ - double d = world.rand.nextGaussian()*0.02D; - double d1 = world.rand.nextGaussian()*0.02D; - double d2 = world.rand.nextGaussian()*0.02D; - world.spawnParticle(EnumParticleTypes.HEART, pos.getX()+world.rand.nextFloat(), pos.getY()+0.65+world.rand.nextFloat(), pos.getZ()+world.rand.nextFloat(), d, d1, d2); + public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { + if (world.rand.nextInt(30) == 0) { + for (int i = 0; i < 2; i++) { + double d = world.rand.nextGaussian() * 0.02D; + double d1 = world.rand.nextGaussian() * 0.02D; + double d2 = world.rand.nextGaussian() * 0.02D; + world.spawnParticle(EnumParticleTypes.HEART, pos.getX() + world.rand.nextFloat(), pos.getY() + 0.65 + world.rand.nextFloat(), pos.getZ() + world.rand.nextFloat(), d, d1, d2); } } } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing f6, float f7, float f8, float f9){ - if(!world.isRemote){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing f6, float f7, float f8, float f9) { + if (!world.isRemote) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntitySmileyCloud){ + if (tile instanceof TileEntitySmileyCloud) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.CLOUD.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); //TheAchievements.NAME_SMILEY_CLOUD.get(player); @@ -79,46 +82,45 @@ public class BlockSmileyCloud extends BlockContainerBase{ return true; } - @Override - public TileEntity createNewTileEntity(World world, int meta){ + public TileEntity createNewTileEntity(World world, int meta) { return new TileEntitySmileyCloud(); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){ + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) { world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2); super.onBlockPlacedBy(world, pos, state, player, stack); } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta)); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockHorizontal.FACING); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirror){ + public IBlockState withMirror(IBlockState state, Mirror mirror) { return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING))); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTinyTorch.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTinyTorch.java index c7a35301c..8e073169b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTinyTorch.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTinyTorch.java @@ -10,6 +10,10 @@ package de.ellpeck.actuallyadditions.mod.blocks; +import java.util.Random; + +import javax.annotation.Nullable; + import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; import net.minecraft.block.Block; import net.minecraft.block.BlockTorch; @@ -19,7 +23,11 @@ import net.minecraft.block.state.BlockFaceShape; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.*; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.Mirror; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -27,12 +35,9 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import javax.annotation.Nullable; -import java.util.Random; - //Copied from BlockTorch. //I have no idea what all of this means. -public class BlockTinyTorch extends BlockBase{ +public class BlockTinyTorch extends BlockBase { //Thanks to xdjackiexd for these. //Man, I hate numbers. @@ -42,7 +47,7 @@ public class BlockTinyTorch extends BlockBase{ private static final AxisAlignedBB TORCH_WEST_AABB = new AxisAlignedBB(0.8125D, 0.25D, 0.4375D, 1.0D, 0.5625D, 0.5625D); private static final AxisAlignedBB TORCH_EAST_AABB = new AxisAlignedBB(0.0D, 0.25D, 0.4375D, 0.1875D, 0.5625D, 0.5625D); - public BlockTinyTorch(String name){ + public BlockTinyTorch(String name) { super(Material.CIRCUITS, name); this.setDefaultState(this.blockState.getBaseState().withProperty(BlockTorch.FACING, EnumFacing.UP)); this.setTickRandomly(true); @@ -53,8 +58,8 @@ public class BlockTinyTorch extends BlockBase{ } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ - switch(state.getValue(BlockTorch.FACING)){ + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + switch (state.getValue(BlockTorch.FACING)) { case EAST: return TORCH_EAST_AABB; case WEST: @@ -70,22 +75,22 @@ public class BlockTinyTorch extends BlockBase{ @Nullable @Override - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos){ + public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) { return NULL_AABB; } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isFullCube(IBlockState state){ + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean isNormalCube(IBlockState state){ + public boolean isNormalCube(IBlockState state) { return false; } @@ -94,38 +99,33 @@ public class BlockTinyTorch extends BlockBase{ return BlockFaceShape.UNDEFINED; } - private boolean canPlaceOn(World worldIn, BlockPos pos){ + private boolean canPlaceOn(World worldIn, BlockPos pos) { IBlockState state = worldIn.getBlockState(pos); return state.isSideSolid(worldIn, pos, EnumFacing.UP) || state.getBlock().canPlaceTorchOnTop(state, worldIn, pos); } @Override - public boolean canPlaceBlockAt(World worldIn, BlockPos pos){ - for(EnumFacing enumfacing : BlockTorch.FACING.getAllowedValues()){ - if(this.canPlaceAt(worldIn, pos, enumfacing)){ - return true; - } + public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { + for (EnumFacing enumfacing : BlockTorch.FACING.getAllowedValues()) { + if (this.canPlaceAt(worldIn, pos, enumfacing)) { return true; } } return false; } - private boolean canPlaceAt(World worldIn, BlockPos pos, EnumFacing facing){ + private boolean canPlaceAt(World worldIn, BlockPos pos, EnumFacing facing) { BlockPos blockpos = pos.offset(facing.getOpposite()); boolean flag = facing.getAxis().isHorizontal(); return flag && worldIn.isSideSolid(blockpos, facing, true) || facing.equals(EnumFacing.UP) && this.canPlaceOn(worldIn, blockpos); } @Override - public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer){ - if(this.canPlaceAt(worldIn, pos, facing)){ + public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { + if (this.canPlaceAt(worldIn, pos, facing)) { return this.getDefaultState().withProperty(BlockTorch.FACING, facing); - } - else{ - for(EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL){ - if(worldIn.isSideSolid(pos.offset(enumfacing.getOpposite()), enumfacing, true)){ - return this.getDefaultState().withProperty(BlockTorch.FACING, enumfacing); - } + } else { + for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) { + if (worldIn.isSideSolid(pos.offset(enumfacing.getOpposite()), enumfacing, true)) { return this.getDefaultState().withProperty(BlockTorch.FACING, enumfacing); } } return this.getDefaultState(); @@ -133,49 +133,45 @@ public class BlockTinyTorch extends BlockBase{ } @Override - public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state){ + public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { this.checkForDrop(worldIn, pos, state); } @Override - public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos otherPos){ + public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos otherPos) { this.onNeighborChangeInternal(worldIn, pos, state); } - protected boolean onNeighborChangeInternal(World worldIn, BlockPos pos, IBlockState state){ - if(!this.checkForDrop(worldIn, pos, state)){ + protected boolean onNeighborChangeInternal(World worldIn, BlockPos pos, IBlockState state) { + if (!this.checkForDrop(worldIn, pos, state)) { return true; - } - else{ + } else { EnumFacing enumfacing = state.getValue(BlockTorch.FACING); EnumFacing.Axis axis = enumfacing.getAxis(); EnumFacing enumfacing1 = enumfacing.getOpposite(); boolean flag = false; - if(axis.isHorizontal() && !worldIn.isSideSolid(pos.offset(enumfacing1), enumfacing, true)){ + if (axis.isHorizontal() && !worldIn.isSideSolid(pos.offset(enumfacing1), enumfacing, true)) { flag = true; - } - else if(axis.isVertical() && !this.canPlaceOn(worldIn, pos.offset(enumfacing1))){ + } else if (axis.isVertical() && !this.canPlaceOn(worldIn, pos.offset(enumfacing1))) { flag = true; } - if(flag){ + if (flag) { this.dropBlockAsItem(worldIn, pos, state, 0); worldIn.setBlockToAir(pos); return true; - } - else{ + } else { return false; } } } - protected boolean checkForDrop(World worldIn, BlockPos pos, IBlockState state){ - if(state.getBlock() == this && this.canPlaceAt(worldIn, pos, state.getValue(BlockTorch.FACING))){ + protected boolean checkForDrop(World worldIn, BlockPos pos, IBlockState state) { + if (state.getBlock() == this && this.canPlaceAt(worldIn, pos, state.getValue(BlockTorch.FACING))) { return true; - } - else{ - if(worldIn.getBlockState(pos).getBlock() == this){ + } else { + if (worldIn.getBlockState(pos).getBlock() == this) { this.dropBlockAsItem(worldIn, pos, state, 0); worldIn.setBlockToAir(pos); } @@ -186,19 +182,18 @@ public class BlockTinyTorch extends BlockBase{ @Override @SideOnly(Side.CLIENT) - public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand){ - if(rand.nextBoolean()){ + public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { + if (rand.nextBoolean()) { EnumFacing enumfacing = stateIn.getValue(BlockTorch.FACING); - double d0 = pos.getX()+0.5D; - double d1 = pos.getY()+0.4D; - double d2 = pos.getZ()+0.5D; + double d0 = pos.getX() + 0.5D; + double d1 = pos.getY() + 0.4D; + double d2 = pos.getZ() + 0.5D; - if(enumfacing.getAxis().isHorizontal()){ + if (enumfacing.getAxis().isHorizontal()) { EnumFacing enumfacing1 = enumfacing.getOpposite(); - worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0+0.35D*enumfacing1.getXOffset(), d1+0.22D, d2+0.35D*enumfacing1.getZOffset(), 0.0D, 0.0D, 0.0D); - worldIn.spawnParticle(EnumParticleTypes.FLAME, d0+0.35D*enumfacing1.getXOffset(), d1+0.22D, d2+0.35D*enumfacing1.getZOffset(), 0.0D, 0.0D, 0.0D); - } - else{ + worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + 0.35D * enumfacing1.getXOffset(), d1 + 0.22D, d2 + 0.35D * enumfacing1.getZOffset(), 0.0D, 0.0D, 0.0D); + worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + 0.35D * enumfacing1.getXOffset(), d1 + 0.22D, d2 + 0.35D * enumfacing1.getZOffset(), 0.0D, 0.0D, 0.0D); + } else { worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D); worldIn.spawnParticle(EnumParticleTypes.FLAME, d0, d1, d2, 0.0D, 0.0D, 0.0D); } @@ -206,10 +201,10 @@ public class BlockTinyTorch extends BlockBase{ } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = this.getDefaultState(); - switch(meta){ + switch (meta) { case 1: iblockstate = iblockstate.withProperty(BlockTorch.FACING, EnumFacing.EAST); break; @@ -231,15 +226,15 @@ public class BlockTinyTorch extends BlockBase{ } @Override - public BlockRenderLayer getRenderLayer(){ + public BlockRenderLayer getRenderLayer() { return BlockRenderLayer.CUTOUT; } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { int i = 0; - switch(state.getValue(BlockTorch.FACING)){ + switch (state.getValue(BlockTorch.FACING)) { case EAST: i = i | 1; break; @@ -262,17 +257,17 @@ public class BlockTinyTorch extends BlockBase{ } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(BlockTorch.FACING, rot.rotate(state.getValue(BlockTorch.FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirrorIn){ + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation(state.getValue(BlockTorch.FACING))); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockTorch.FACING); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTreasureChest.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTreasureChest.java index 6fab55ca4..c215183f9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTreasureChest.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTreasureChest.java @@ -41,9 +41,9 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class BlockTreasureChest extends BlockBase{ +public class BlockTreasureChest extends BlockBase { - public BlockTreasureChest(String name){ + public BlockTreasureChest(String name) { super(Material.WOOD, name); this.setHarvestLevel("axe", 0); this.setHardness(300.0F); @@ -54,25 +54,25 @@ public class BlockTreasureChest extends BlockBase{ @Override @SideOnly(Side.CLIENT) - public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){ - for(int i = 0; i < 2; i++){ - for(float f = 0; f <= 3; f += 0.5){ + public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { + for (int i = 0; i < 2; i++) { + for (float f = 0; f <= 3; f += 0.5) { float particleX = rand.nextFloat(); float particleZ = rand.nextFloat(); - world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, (double)pos.getX()+particleX, (double)pos.getY()+f+1, (double)pos.getZ()+particleZ, 0.0D, 0.2D, 0.0D); + world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, (double) pos.getX() + particleX, (double) pos.getY() + f + 1, (double) pos.getZ() + particleZ, 0.0D, 0.2D, 0.0D); } } } @Override - public Item getItemDropped(IBlockState state, Random rand, int par3){ + public Item getItemDropped(IBlockState state, Random rand, int par3) { return Items.AIR; } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(!world.isRemote){ - world.playSound(null, pos, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.2F, world.rand.nextFloat()*0.1F+0.9F); + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (!world.isRemote) { + world.playSound(null, pos, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.2F, world.rand.nextFloat() * 0.1F + 0.9F); this.dropItems(world, pos); world.setBlockToAir(pos); @@ -82,62 +82,62 @@ public class BlockTreasureChest extends BlockBase{ } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){ + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) { world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2); super.onBlockPlacedBy(world, pos, state, player, stack); } @Override - public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player){ + public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) { return false; } - private void dropItems(World world, BlockPos pos){ - for(int i = 0; i < MathHelper.getInt(world.rand, 3, 6); i++){ + private void dropItems(World world, BlockPos pos) { + for (int i = 0; i < MathHelper.getInt(world.rand, 3, 6); i++) { TreasureChestLoot theReturn = WeightedRandom.getRandomItem(world.rand, ActuallyAdditionsAPI.TREASURE_CHEST_LOOT); ItemStack itemStack = theReturn.returnItem.copy(); itemStack.setCount(MathHelper.getInt(world.rand, theReturn.minAmount, theReturn.maxAmount)); - float dX = world.rand.nextFloat()*0.8F+0.1F; - float dY = world.rand.nextFloat()*0.8F+0.1F; - float dZ = world.rand.nextFloat()*0.8F+0.1F; - EntityItem entityItem = new EntityItem(world, pos.getX()+dX, pos.getY()+dY, pos.getZ()+dZ, itemStack); + float dX = world.rand.nextFloat() * 0.8F + 0.1F; + float dY = world.rand.nextFloat() * 0.8F + 0.1F; + float dZ = world.rand.nextFloat() * 0.8F + 0.1F; + EntityItem entityItem = new EntityItem(world, pos.getX() + dX, pos.getY() + dY, pos.getZ() + dZ, itemStack); float factor = 0.05F; - entityItem.motionX = world.rand.nextGaussian()*factor; - entityItem.motionY = world.rand.nextGaussian()*factor+0.2F; - entityItem.motionZ = world.rand.nextGaussian()*factor; + entityItem.motionX = world.rand.nextGaussian() * factor; + entityItem.motionY = world.rand.nextGaussian() * factor + 0.2F; + entityItem.motionZ = world.rand.nextGaussian() * factor; world.spawnEntity(entityItem); } } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta)); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockHorizontal.FACING); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirror){ + public IBlockState withMirror(IBlockState state, Mirror mirror) { return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING))); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWallAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWallAA.java index 7b40fc035..9d1b1af2a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWallAA.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWallAA.java @@ -28,13 +28,13 @@ import net.minecraft.world.IBlockAccess; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class BlockWallAA extends BlockBase{ +public class BlockWallAA extends BlockBase { - protected static final AxisAlignedBB[] AABB_BY_INDEX = new AxisAlignedBB[]{new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.3125D, 0.0D, 0.0D, 0.6875D, 0.875D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.3125D, 1.0D, 0.875D, 0.6875D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D)}; - protected static final AxisAlignedBB[] CLIP_AABB_BY_INDEX = new AxisAlignedBB[]{AABB_BY_INDEX[0].setMaxY(1.5D), AABB_BY_INDEX[1].setMaxY(1.5D), AABB_BY_INDEX[2].setMaxY(1.5D), AABB_BY_INDEX[3].setMaxY(1.5D), AABB_BY_INDEX[4].setMaxY(1.5D), AABB_BY_INDEX[5].setMaxY(1.5D), AABB_BY_INDEX[6].setMaxY(1.5D), AABB_BY_INDEX[7].setMaxY(1.5D), AABB_BY_INDEX[8].setMaxY(1.5D), AABB_BY_INDEX[9].setMaxY(1.5D), AABB_BY_INDEX[10].setMaxY(1.5D), AABB_BY_INDEX[11].setMaxY(1.5D), AABB_BY_INDEX[12].setMaxY(1.5D), AABB_BY_INDEX[13].setMaxY(1.5D), AABB_BY_INDEX[14].setMaxY(1.5D), AABB_BY_INDEX[15].setMaxY(1.5D)}; + protected static final AxisAlignedBB[] AABB_BY_INDEX = new AxisAlignedBB[] { new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.3125D, 0.0D, 0.0D, 0.6875D, 0.875D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.3125D, 1.0D, 0.875D, 0.6875D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D) }; + protected static final AxisAlignedBB[] CLIP_AABB_BY_INDEX = new AxisAlignedBB[] { AABB_BY_INDEX[0].setMaxY(1.5D), AABB_BY_INDEX[1].setMaxY(1.5D), AABB_BY_INDEX[2].setMaxY(1.5D), AABB_BY_INDEX[3].setMaxY(1.5D), AABB_BY_INDEX[4].setMaxY(1.5D), AABB_BY_INDEX[5].setMaxY(1.5D), AABB_BY_INDEX[6].setMaxY(1.5D), AABB_BY_INDEX[7].setMaxY(1.5D), AABB_BY_INDEX[8].setMaxY(1.5D), AABB_BY_INDEX[9].setMaxY(1.5D), AABB_BY_INDEX[10].setMaxY(1.5D), AABB_BY_INDEX[11].setMaxY(1.5D), AABB_BY_INDEX[12].setMaxY(1.5D), AABB_BY_INDEX[13].setMaxY(1.5D), AABB_BY_INDEX[14].setMaxY(1.5D), AABB_BY_INDEX[15].setMaxY(1.5D) }; @SuppressWarnings("deprecation") - public BlockWallAA(String name, Block blocc){ + public BlockWallAA(String name, Block blocc) { super(blocc.getDefaultState().getMaterial(), name); this.setHardness(1.5F); this.setResistance(10F); @@ -42,22 +42,22 @@ public class BlockWallAA extends BlockBase{ this.setDefaultState(this.blockState.getBaseState().withProperty(BlockWall.UP, false).withProperty(BlockWall.NORTH, false).withProperty(BlockWall.EAST, false).withProperty(BlockWall.SOUTH, false).withProperty(BlockWall.WEST, false)); } - private static int yesThisIsCopyPastedFromBlockWallAndIHaveNoIdeaWhatThisMethodDoes(IBlockState state){ + private static int yesThisIsCopyPastedFromBlockWallAndIHaveNoIdeaWhatThisMethodDoes(IBlockState state) { int i = 0; - if(state.getValue(BlockWall.NORTH)){ + if (state.getValue(BlockWall.NORTH)) { i |= 1 << EnumFacing.NORTH.getHorizontalIndex(); } - if(state.getValue(BlockWall.EAST)){ + if (state.getValue(BlockWall.EAST)) { i |= 1 << EnumFacing.EAST.getHorizontalIndex(); } - if(state.getValue(BlockWall.SOUTH)){ + if (state.getValue(BlockWall.SOUTH)) { i |= 1 << EnumFacing.SOUTH.getHorizontalIndex(); } - if(state.getValue(BlockWall.WEST)){ + if (state.getValue(BlockWall.WEST)) { i |= 1 << EnumFacing.WEST.getHorizontalIndex(); } @@ -65,7 +65,7 @@ public class BlockWallAA extends BlockBase{ } @Override - public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos){ + public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { boolean flag = this.canConnectTo(worldIn, pos.north()); boolean flag1 = this.canConnectTo(worldIn, pos.east()); boolean flag2 = this.canConnectTo(worldIn, pos.south()); @@ -75,65 +75,63 @@ public class BlockWallAA extends BlockBase{ } @Override - public boolean isFullCube(IBlockState state){ + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean isPassable(IBlockAccess worldIn, BlockPos pos){ + public boolean isPassable(IBlockAccess worldIn, BlockPos pos) { return false; } @Override @SideOnly(Side.CLIENT) @Deprecated - public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side){ + public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { return side != EnumFacing.DOWN || super.shouldSideBeRendered(blockState, blockAccess, pos, side); } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){ + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { state = this.getActualState(state, source, pos); return AABB_BY_INDEX[yesThisIsCopyPastedFromBlockWallAndIHaveNoIdeaWhatThisMethodDoes(state)]; } @Override - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos){ + public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) { blockState = this.getActualState(blockState, worldIn, pos); return CLIP_AABB_BY_INDEX[yesThisIsCopyPastedFromBlockWallAndIHaveNoIdeaWhatThisMethodDoes(blockState)]; } @Override - public boolean isOpaqueCube(IBlockState state){ + public boolean isOpaqueCube(IBlockState state) { return false; } @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(CreativeTabs tab, NonNullList list){ + public void getSubBlocks(CreativeTabs tab, NonNullList list) { list.add(new ItemStack(this, 1, 0)); } - public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos){ + public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos) { IBlockState state = worldIn.getBlockState(pos); Block block = state.getBlock(); return block != Blocks.BARRIER && (!(block != this && !(block instanceof BlockFenceGate)) || state.getMaterial().isOpaque() && state.isFullCube() && state.getMaterial() != Material.GOURD); } - @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState(); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return 0; } - @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockWall.UP, BlockWall.NORTH, BlockWall.EAST, BlockWall.WEST, BlockWall.SOUTH); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWildPlant.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWildPlant.java index 5cf9ef7e6..05acfc1dd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWildPlant.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWildPlant.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.blocks; - import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBushBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant; @@ -35,98 +34,96 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockWildPlant extends BlockBushBase{ +public class BlockWildPlant extends BlockBushBase { public static final TheWildPlants[] ALL_WILD_PLANTS = TheWildPlants.values(); public static final PropertyEnum TYPE = PropertyEnum.create("type", TheWildPlants.class); - public BlockWildPlant(String name){ + public BlockWildPlant(String name) { super(name); this.setSoundType(SoundType.PLANT); } @Override - public boolean canBlockStay(World world, BlockPos pos, IBlockState state){ + public boolean canBlockStay(World world, BlockPos pos, IBlockState state) { BlockPos offset = pos.down(); IBlockState offsetState = world.getBlockState(offset); Block offsetBlock = offsetState.getBlock(); return state.getValue(TYPE) == TheWildPlants.RICE ? offsetState.getMaterial() == Material.WATER : offsetBlock.canSustainPlant(offsetState, world, offset, EnumFacing.UP, this); } - @Override - public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player){ + public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { BlockPlant normal = (BlockPlant) state.getValue(TYPE).getNormalVersion(); return new ItemStack(normal.seedItem); } @Override - public void getSubBlocks(CreativeTabs tab, NonNullList list){ - for(int j = 0; j < ALL_WILD_PLANTS.length; j++){ + public void getSubBlocks(CreativeTabs tab, NonNullList list) { + for (int j = 0; j < ALL_WILD_PLANTS.length; j++) { list.add(new ItemStack(this, 1, j)); } } @Override - public void getDrops(NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune){ + public void getDrops(NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { Block normal = state.getValue(TYPE).getNormalVersion(); normal.getDrops(drops, world, pos, normal.getDefaultState().withProperty(BlockCrops.AGE, 7), fortune); } @Override - public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player){ + public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) { return false; } @Override - protected ItemBlockBase getItemBlock(){ + protected ItemBlockBase getItemBlock() { return new TheItemBlock(this); } @Override - public boolean shouldAddCreative(){ + public boolean shouldAddCreative() { return false; } @Override - public void registerRendering(){ - for(int i = 0; i < ALL_WILD_PLANTS.length; i++){ - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName()+"="+ALL_WILD_PLANTS[i].getName()); + public void registerRendering() { + for (int i = 0; i < ALL_WILD_PLANTS.length; i++) { + ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName() + "=" + ALL_WILD_PLANTS[i].getName()); } } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(TYPE, TheWildPlants.values()[meta]); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(TYPE).ordinal(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, TYPE); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return stack.getItemDamage() >= ALL_WILD_PLANTS.length ? EnumRarity.COMMON : ALL_WILD_PLANTS[stack.getItemDamage()].getRarity(); } - public static class TheItemBlock extends ItemBlockBase{ + public static class TheItemBlock extends ItemBlockBase { - public TheItemBlock(Block block){ + public TheItemBlock(Block block) { super(block); this.setHasSubtypes(true); this.setMaxDamage(0); } - @Override - public String getTranslationKey(ItemStack stack){ - return stack.getItemDamage() >= ALL_WILD_PLANTS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey()+"_"+ALL_WILD_PLANTS[stack.getItemDamage()].getName(); + public String getTranslationKey(ItemStack stack) { + return stack.getItemDamage() >= ALL_WILD_PLANTS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey() + "_" + ALL_WILD_PLANTS[stack.getItemDamage()].getName(); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java index f431d7821..a92040a78 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.blocks; - import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; @@ -32,9 +31,9 @@ import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BlockXPSolidifier extends BlockContainerBase{ +public class BlockXPSolidifier extends BlockContainerBase { - public BlockXPSolidifier(String name){ + public BlockXPSolidifier(String name) { super(Material.ROCK, name); this.setHarvestLevel("pickaxe", 0); this.setHardness(2.5F); @@ -42,17 +41,16 @@ public class BlockXPSolidifier extends BlockContainerBase{ this.setSoundType(SoundType.STONE); } - @Override - public TileEntity createNewTileEntity(World world, int par2){ + public TileEntity createNewTileEntity(World world, int par2) { return new TileEntityXPSolidifier(); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ - if(!world.isRemote){ - TileEntityXPSolidifier solidifier = (TileEntityXPSolidifier)world.getTileEntity(pos); - if(solidifier != null){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) { + if (!world.isRemote) { + TileEntityXPSolidifier solidifier = (TileEntityXPSolidifier) world.getTileEntity(pos); + if (solidifier != null) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.XP_SOLIDIFIER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } return true; @@ -61,39 +59,39 @@ public class BlockXPSolidifier extends BlockContainerBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){ + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) { world.setBlockState(pos, state.withProperty(BlockHorizontal.FACING, player.getHorizontalFacing().getOpposite()), 2); super.onBlockPlacedBy(world, pos, state, player, stack); } @Override - public IBlockState getStateFromMeta(int meta){ + public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta)); } @Override - public int getMetaFromState(IBlockState state){ + public int getMetaFromState(IBlockState state) { return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); } @Override - protected BlockStateContainer createBlockState(){ + protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, BlockHorizontal.FACING); } @Override - public IBlockState withRotation(IBlockState state, Rotation rot){ + public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(BlockHorizontal.FACING, rot.rotate(state.getValue(BlockHorizontal.FACING))); } @Override - public IBlockState withMirror(IBlockState state, Mirror mirror){ + public IBlockState withMirror(IBlockState state, Mirror mirror) { return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING))); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/IHudDisplay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/IHudDisplay.java index 26b7c7be2..f6c9e50c1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/IHudDisplay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/IHudDisplay.java @@ -18,7 +18,7 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public interface IHudDisplay{ +public interface IHudDisplay { @SideOnly(Side.CLIENT) void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/InitBlocks.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/InitBlocks.java index b536d3ef0..f2d793a71 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/InitBlocks.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/InitBlocks.java @@ -18,7 +18,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks; import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; import net.minecraft.block.Block; -public final class InitBlocks{ +public final class InitBlocks { public static Block blockCompost; public static Block blockMisc; @@ -116,7 +116,7 @@ public final class InitBlocks{ public static Block blockCrystalClusterEmerald; public static Block blockCrystalClusterIron; - public static void init(){ + public static void init() { ActuallyAdditions.LOGGER.info("Initializing Blocks..."); blockCrystalClusterRedstone = new BlockCrystalCluster("block_crystal_cluster_redstone", TheCrystals.REDSTONE); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockBase.java index 8d583c365..188487c12 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockBase.java @@ -19,40 +19,40 @@ import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraftforge.common.IRarity; -public class BlockBase extends Block implements ItemBlockBase.ICustomRarity, IHasModel{ +public class BlockBase extends Block implements ItemBlockBase.ICustomRarity, IHasModel { private final String name; - public BlockBase(Material material, String name){ + public BlockBase(Material material, String name) { super(material); this.name = name; this.register(); } - private void register(){ + private void register() { ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative()); } - protected String getBaseName(){ + protected String getBaseName() { return this.name; } - protected ItemBlockBase getItemBlock(){ + protected ItemBlockBase getItemBlock() { return new ItemBlockBase(this); } - public boolean shouldAddCreative(){ + public boolean shouldAddCreative() { return true; } @Override - public void registerRendering(){ + public void registerRendering() { ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); } @Override - public IRarity getRarity(ItemStack stack){ + public IRarity getRarity(ItemStack stack) { return EnumRarity.COMMON; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockBushBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockBushBase.java index be5d71e36..76baf232e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockBushBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockBushBase.java @@ -18,40 +18,40 @@ import net.minecraft.block.SoundType; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; -public class BlockBushBase extends BlockBush implements ItemBlockBase.ICustomRarity, IHasModel{ +public class BlockBushBase extends BlockBush implements ItemBlockBase.ICustomRarity, IHasModel { private final String name; - public BlockBushBase(String name){ + public BlockBushBase(String name) { this.name = name; this.setSoundType(SoundType.PLANT); this.register(); } - private void register(){ + private void register() { ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative()); } - protected String getBaseName(){ + protected String getBaseName() { return this.name; } - protected ItemBlockBase getItemBlock(){ + protected ItemBlockBase getItemBlock() { return new ItemBlockBase(this); } - public boolean shouldAddCreative(){ + public boolean shouldAddCreative() { return true; } @Override - public void registerRendering(){ + public void registerRendering() { ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.COMMON; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java index 40057005b..61e6680ad 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java @@ -10,6 +10,12 @@ package de.ellpeck.actuallyadditions.mod.blocks.base; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import javax.annotation.Nullable; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.render.IHasModel; import de.ellpeck.actuallyadditions.mod.config.ConfigValues; @@ -42,55 +48,50 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidUtil; -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -public abstract class BlockContainerBase extends BlockContainer implements ItemBlockBase.ICustomRarity, IHasModel{ +public abstract class BlockContainerBase extends BlockContainer implements ItemBlockBase.ICustomRarity, IHasModel { private final String name; - public BlockContainerBase(Material material, String name){ + public BlockContainerBase(Material material, String name) { super(material); this.name = name; this.register(); } - private void register(){ + private void register() { ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative()); } - protected String getBaseName(){ + protected String getBaseName() { return this.name; } - protected ItemBlockBase getItemBlock(){ + protected ItemBlockBase getItemBlock() { return new ItemBlockBase(this); } - public boolean shouldAddCreative(){ + public boolean shouldAddCreative() { return true; } @Override - public void registerRendering(){ + public void registerRendering() { ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.COMMON; } - private void dropInventory(World world, BlockPos position){ - if(!world.isRemote){ + private void dropInventory(World world, BlockPos position) { + if (!world.isRemote) { TileEntity aTile = world.getTileEntity(position); - if(aTile instanceof TileEntityInventoryBase){ - TileEntityInventoryBase tile = (TileEntityInventoryBase)aTile; - if(tile.inv.getSlots() > 0){ - for(int i = 0; i < tile.inv.getSlots(); i++){ + if (aTile instanceof TileEntityInventoryBase) { + TileEntityInventoryBase tile = (TileEntityInventoryBase) aTile; + if (tile.inv.getSlots() > 0) { + for (int i = 0; i < tile.inv.getSlots(); i++) { this.dropSlotFromInventory(i, tile, world, position); } } @@ -98,28 +99,28 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB } } - private void dropSlotFromInventory(int i, TileEntityInventoryBase tile, World world, BlockPos pos){ + private void dropSlotFromInventory(int i, TileEntityInventoryBase tile, World world, BlockPos pos) { ItemStack stack = tile.inv.getStackInSlot(i); - if(StackUtil.isValid(stack)){ - float dX = world.rand.nextFloat()*0.8F+0.1F; - float dY = world.rand.nextFloat()*0.8F+0.1F; - float dZ = world.rand.nextFloat()*0.8F+0.1F; - EntityItem entityItem = new EntityItem(world, pos.getX()+dX, pos.getY()+dY, pos.getZ()+dZ, stack.copy()); + if (StackUtil.isValid(stack)) { + float dX = world.rand.nextFloat() * 0.8F + 0.1F; + float dY = world.rand.nextFloat() * 0.8F + 0.1F; + float dZ = world.rand.nextFloat() * 0.8F + 0.1F; + EntityItem entityItem = new EntityItem(world, pos.getX() + dX, pos.getY() + dY, pos.getZ() + dZ, stack.copy()); float factor = 0.05F; - entityItem.motionX = world.rand.nextGaussian()*factor; - entityItem.motionY = world.rand.nextGaussian()*factor+0.2F; - entityItem.motionZ = world.rand.nextGaussian()*factor; + entityItem.motionX = world.rand.nextGaussian() * factor; + entityItem.motionY = world.rand.nextGaussian() * factor + 0.2F; + entityItem.motionZ = world.rand.nextGaussian() * factor; world.spawnEntity(entityItem); } } - public boolean tryToggleRedstone(World world, BlockPos pos, EntityPlayer player){ + public boolean tryToggleRedstone(World world, BlockPos pos, EntityPlayer player) { ItemStack stack = player.getHeldItemMainhand(); - if(StackUtil.isValid(stack) && stack.getItem() == ConfigValues.itemRedstoneTorchConfigurator){ + if (StackUtil.isValid(stack) && stack.getItem() == ConfigValues.itemRedstoneTorchConfigurator) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityBase){ - TileEntityBase base = (TileEntityBase)tile; - if(!world.isRemote && base.isRedstoneToggle()){ + if (tile instanceof TileEntityBase) { + TileEntityBase base = (TileEntityBase) tile; + if (!world.isRemote && base.isRedstoneToggle()) { base.isPulseMode = !base.isPulseMode; base.markDirty(); base.sendUpdate(); @@ -131,82 +132,81 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB } @Override - public void updateTick(World world, BlockPos pos, IBlockState state, Random random){ - if(!world.isRemote){ + public void updateTick(World world, BlockPos pos, IBlockState state, Random random) { + if (!world.isRemote) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityBase){ - TileEntityBase base = (TileEntityBase)tile; - if(base.respondsToPulses()){ + if (tile instanceof TileEntityBase) { + TileEntityBase base = (TileEntityBase) tile; + if (base.respondsToPulses()) { base.activateOnPulse(); } } } } - public void neighborsChangedCustom(World world, BlockPos pos){ + public void neighborsChangedCustom(World world, BlockPos pos) { this.updateRedstoneState(world, pos); TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityBase){ - TileEntityBase base = (TileEntityBase)tile; - if(base.shouldSaveDataOnChangeOrWorldStart()){ + if (tile instanceof TileEntityBase) { + TileEntityBase base = (TileEntityBase) tile; + if (base.shouldSaveDataOnChangeOrWorldStart()) { base.saveDataOnChangeOrWorldStart(); } } } @Override - public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos otherPos){ + public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos otherPos) { this.neighborsChangedCustom(worldIn, pos); } @Override - public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor){ + public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) { super.onNeighborChange(world, pos, neighbor); - if(world instanceof World){ - this.neighborsChangedCustom((World)world, pos); + if (world instanceof World) { + this.neighborsChangedCustom((World) world, pos); } } - public void updateRedstoneState(World world, BlockPos pos){ - if(!world.isRemote){ + public void updateRedstoneState(World world, BlockPos pos) { + if (!world.isRemote) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityBase){ - TileEntityBase base = (TileEntityBase)tile; + if (tile instanceof TileEntityBase) { + TileEntityBase base = (TileEntityBase) tile; boolean powered = world.getRedstonePowerFromNeighbors(pos) > 0; boolean wasPowered = base.isRedstonePowered; - if(powered && !wasPowered){ - if(base.respondsToPulses()){ + if (powered && !wasPowered) { + if (base.respondsToPulses()) { world.scheduleUpdate(pos, this, this.tickRate(world)); } base.setRedstonePowered(true); - } - else if(!powered && wasPowered){ + } else if (!powered && wasPowered) { base.setRedstonePowered(false); } } } } - protected boolean tryUseItemOnTank(EntityPlayer player, EnumHand hand, FluidTank tank){ + protected boolean tryUseItemOnTank(EntityPlayer player, EnumHand hand, FluidTank tank) { ItemStack heldItem = player.getHeldItem(hand); return StackUtil.isValid(heldItem) && FluidUtil.interactWithFluidHandler(player, hand, tank); } @Override - public void onBlockAdded(World world, BlockPos pos, IBlockState state){ + public void onBlockAdded(World world, BlockPos pos, IBlockState state) { this.updateRedstoneState(world, pos); } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entity, ItemStack stack){ - if(stack.hasTagCompound()){ + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entity, ItemStack stack) { + if (stack.hasTagCompound()) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityBase){ - TileEntityBase base = (TileEntityBase)tile; + if (tile instanceof TileEntityBase) { + TileEntityBase base = (TileEntityBase) tile; NBTTagCompound compound = stack.getTagCompound().getCompoundTag("Data"); - if(compound != null){ + if (compound != null) { base.readSyncableNBT(compound, TileEntityBase.NBTType.SAVE_BLOCK); } } @@ -214,56 +214,54 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB } @Override - public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player){ - if(!player.capabilities.isCreativeMode){ + public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) { + if (!player.capabilities.isCreativeMode) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityBase && ((TileEntityBase)tile).stopFromDropping){ - player.sendMessage(new TextComponentTranslation("info."+ActuallyAdditions.MODID+".machineBroke").setStyle(new Style().setColor(TextFormatting.RED))); + if (tile instanceof TileEntityBase && ((TileEntityBase) tile).stopFromDropping) { + player.sendMessage(new TextComponentTranslation("info." + ActuallyAdditions.MODID + ".machineBroke").setStyle(new Style().setColor(TextFormatting.RED))); } } } @Override - public boolean hasComparatorInputOverride(IBlockState state){ + public boolean hasComparatorInputOverride(IBlockState state) { return true; } @Override - public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos){ + public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityBase){ - return ((TileEntityBase)tile).getComparatorStrength(); - } + if (tile instanceof TileEntityBase) { return ((TileEntityBase) tile).getComparatorStrength(); } return 0; } @Override - public void getDrops(NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune){ + public void getDrops(NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityBase){ - TileEntityBase base = (TileEntityBase)tile; - if(!base.stopFromDropping){ + if (tile instanceof TileEntityBase) { + TileEntityBase base = (TileEntityBase) tile; + if (!base.stopFromDropping) { NBTTagCompound data = new NBTTagCompound(); base.writeSyncableNBT(data, TileEntityBase.NBTType.SAVE_BLOCK); //Remove unnecessarily saved default values to avoid unstackability List keysToRemove = new ArrayList<>(); - for(String key : data.getKeySet()){ + for (String key : data.getKeySet()) { NBTBase tag = data.getTag(key); //Remove only ints because they are the most common ones //Add else if below here to remove more types - if(tag instanceof NBTTagInt){ - if(((NBTTagInt)tag).getInt() == 0){ + if (tag instanceof NBTTagInt) { + if (((NBTTagInt) tag).getInt() == 0) { keysToRemove.add(key); } } } - for(String key : keysToRemove){ + for (String key : keysToRemove) { data.removeTag(key); } ItemStack stack = new ItemStack(this.getItemDropped(state, tile.getWorld().rand, fortune), 1, this.damageDropped(state)); - if(!data.isEmpty()){ + if (!data.isEmpty()) { stack.setTagCompound(new NBTTagCompound()); stack.getTagCompound().setTag("Data", data); } @@ -287,20 +285,20 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB } @Override - public EnumBlockRenderType getRenderType(IBlockState state){ + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - if(this.shouldDropInventory(world, pos)){ + public void breakBlock(World world, BlockPos pos, IBlockState state) { + if (this.shouldDropInventory(world, pos)) { this.dropInventory(world, pos); } super.breakBlock(world, pos, state); } - public boolean shouldDropInventory(World world, BlockPos pos){ + public boolean shouldDropInventory(World world, BlockPos pos) { return true; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockFluidFlowing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockFluidFlowing.java index 67a8bd7da..bb60986d5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockFluidFlowing.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockFluidFlowing.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.blocks.base; - import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import net.minecraft.block.material.Material; import net.minecraft.item.EnumRarity; @@ -21,11 +20,11 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.Fluid; -public class BlockFluidFlowing extends BlockFluidClassic implements ItemBlockBase.ICustomRarity{ +public class BlockFluidFlowing extends BlockFluidClassic implements ItemBlockBase.ICustomRarity { private final String name; - public BlockFluidFlowing(Fluid fluid, Material material, String unlocalizedName){ + public BlockFluidFlowing(Fluid fluid, Material material, String unlocalizedName) { super(fluid, material); this.name = unlocalizedName; this.displacements.put(this, false); @@ -33,34 +32,34 @@ public class BlockFluidFlowing extends BlockFluidClassic implements ItemBlockBas this.register(); } - private void register(){ + private void register() { ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative()); } - protected String getBaseName(){ + protected String getBaseName() { return this.name; } - protected ItemBlockBase getItemBlock(){ + protected ItemBlockBase getItemBlock() { return new ItemBlockBase(this); } - public boolean shouldAddCreative(){ + public boolean shouldAddCreative() { return false; } @Override - public boolean canDisplace(IBlockAccess world, BlockPos pos){ + public boolean canDisplace(IBlockAccess world, BlockPos pos) { return !world.getBlockState(pos).getMaterial().isLiquid() && super.canDisplace(world, pos); } @Override - public boolean displaceIfPossible(World world, BlockPos pos){ + public boolean displaceIfPossible(World world, BlockPos pos) { return !world.getBlockState(pos).getMaterial().isLiquid() && super.displaceIfPossible(world, pos); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockPlant.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockPlant.java index 1b21fbea6..239e9f0d5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockPlant.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockPlant.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.blocks.base; +import java.util.Random; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.render.IHasModel; import de.ellpeck.actuallyadditions.mod.util.ItemUtil; @@ -29,9 +31,7 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.EnumPlantType; -import java.util.Random; - -public class BlockPlant extends BlockCrops implements ItemBlockBase.ICustomRarity, IHasModel{ +public class BlockPlant extends BlockCrops implements ItemBlockBase.ICustomRarity, IHasModel { private final String name; private final int minDropAmount; @@ -40,72 +40,72 @@ public class BlockPlant extends BlockCrops implements ItemBlockBase.ICustomRarit private Item returnItem; private int returnMeta; - public BlockPlant(String name, int minDropAmount, int addDropAmount){ + public BlockPlant(String name, int minDropAmount, int addDropAmount) { this.name = name; this.minDropAmount = minDropAmount; this.addDropAmount = addDropAmount; this.register(); } - public void doStuff(Item seedItem, Item returnItem, int returnMeta){ + public void doStuff(Item seedItem, Item returnItem, int returnMeta) { this.seedItem = seedItem; this.returnItem = returnItem; this.returnMeta = returnMeta; } - private void register(){ + private void register() { ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative()); } - protected String getBaseName(){ + protected String getBaseName() { return this.name; } - protected ItemBlockBase getItemBlock(){ + protected ItemBlockBase getItemBlock() { return new ItemBlockBase(this); } - public boolean shouldAddCreative(){ + public boolean shouldAddCreative() { return false; } @Override - public void registerRendering(){ + public void registerRendering() { ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override - public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos){ + public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) { return EnumPlantType.Crop; } @Override - public int damageDropped(IBlockState state){ + public int damageDropped(IBlockState state) { return this.getMetaFromState(state) >= 7 ? this.returnMeta : 0; } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){ - if(this.getMetaFromState(state) >= 7){ - if(!world.isRemote){ + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + if (this.getMetaFromState(state) >= 7) { + if (!world.isRemote) { NonNullList drops = NonNullList.create(); this.getDrops(drops, world, pos, state, 0); boolean deductedSeedSize = false; - for(ItemStack drop : drops){ - if(StackUtil.isValid(drop)){ - if(drop.getItem() == this.seedItem && !deductedSeedSize){ + for (ItemStack drop : drops) { + if (StackUtil.isValid(drop)) { + if (drop.getItem() == this.seedItem && !deductedSeedSize) { drop.shrink(1); deductedSeedSize = true; } - if(StackUtil.isValid(drop)){ - EntityItem entity = new EntityItem(world, pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, drop); + if (StackUtil.isValid(drop)) { + EntityItem entity = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, drop); world.spawnEntity(entity); } } @@ -119,24 +119,23 @@ public class BlockPlant extends BlockCrops implements ItemBlockBase.ICustomRarit } @Override - public Item getSeed(){ + public Item getSeed() { return this.seedItem; } @Override - public int quantityDropped(IBlockState state, int fortune, Random random){ - return this.getMetaFromState(state) >= 7 ? random.nextInt(this.addDropAmount)+this.minDropAmount : super.quantityDropped(state, fortune, random); + public int quantityDropped(IBlockState state, int fortune, Random random) { + return this.getMetaFromState(state) >= 7 ? random.nextInt(this.addDropAmount) + this.minDropAmount : super.quantityDropped(state, fortune, random); } @Override - public Item getCrop(){ + public Item getCrop() { return this.returnItem; } @Override - public Item getItemDropped(IBlockState state, Random rand, int par3){ + public Item getItemDropped(IBlockState state, Random rand, int par3) { return this.getMetaFromState(state) >= 7 ? this.getCrop() : this.getSeed(); } - } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockStair.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockStair.java index 501dc48da..a6e551508 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockStair.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockStair.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.blocks.base; - import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.render.IHasModel; import de.ellpeck.actuallyadditions.mod.util.ItemUtil; @@ -20,15 +19,15 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; -public class BlockStair extends BlockStairs implements ItemBlockBase.ICustomRarity, IHasModel{ +public class BlockStair extends BlockStairs implements ItemBlockBase.ICustomRarity, IHasModel { private final String name; - public BlockStair(Block block, String name){ + public BlockStair(Block block, String name) { this(block.getDefaultState(), name); } - public BlockStair(IBlockState state, String name){ + public BlockStair(IBlockState state, String name) { super(state); this.name = name; this.setLightOpacity(0); @@ -36,29 +35,29 @@ public class BlockStair extends BlockStairs implements ItemBlockBase.ICustomRari this.register(); } - private void register(){ + private void register() { ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative()); } - protected String getBaseName(){ + protected String getBaseName() { return this.name; } - protected ItemBlockBase getItemBlock(){ + protected ItemBlockBase getItemBlock() { return new ItemBlockBase(this); } - public boolean shouldAddCreative(){ + public boolean shouldAddCreative() { return true; } @Override - public void registerRendering(){ + public void registerRendering() { ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.COMMON; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/metalists/TheColoredLampColors.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/metalists/TheColoredLampColors.java index 46e751f26..f5b770254 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/metalists/TheColoredLampColors.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/metalists/TheColoredLampColors.java @@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.blocks.metalists; import net.minecraft.util.IStringSerializable; -public enum TheColoredLampColors implements IStringSerializable{ +public enum TheColoredLampColors implements IStringSerializable { WHITE("White", "white"), ORANGE("Orange", "orange"), @@ -34,20 +34,18 @@ public enum TheColoredLampColors implements IStringSerializable{ public final String regName; public final String oreName; - TheColoredLampColors(String oreName, String regName){ + TheColoredLampColors(String oreName, String regName) { this.oreName = oreName; this.regName = regName; } - public static TheColoredLampColors getColorFromDyeName(String color){ - if(color.substring(0, 3).equals("dye")){ + public static TheColoredLampColors getColorFromDyeName(String color) { + if (color.substring(0, 3).equals("dye")) { String actualName = color.substring(3); - for(int i = 0; i < values().length; i++){ + for (int i = 0; i < values().length; i++) { String aName = values()[i].oreName; - if(aName != null){ - if(aName.equalsIgnoreCase(actualName)){ - return values()[i]; - } + if (aName != null) { + if (aName.equalsIgnoreCase(actualName)) { return values()[i]; } } } } @@ -55,7 +53,7 @@ public enum TheColoredLampColors implements IStringSerializable{ } @Override - public String getName(){ + public String getName() { return this.regName; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/metalists/TheMiscBlocks.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/metalists/TheMiscBlocks.java index 976ba8217..a2fa35316 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/metalists/TheMiscBlocks.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/metalists/TheMiscBlocks.java @@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.blocks.metalists; import net.minecraft.item.EnumRarity; import net.minecraft.util.IStringSerializable; -public enum TheMiscBlocks implements IStringSerializable{ +public enum TheMiscBlocks implements IStringSerializable { QUARTZ_PILLAR("black_quartz_pillar", EnumRarity.RARE), QUARTZ_CHISELED("black_quartz_chiseled", EnumRarity.RARE), @@ -29,13 +29,13 @@ public enum TheMiscBlocks implements IStringSerializable{ public final String name; public final EnumRarity rarity; - TheMiscBlocks(String name, EnumRarity rarity){ + TheMiscBlocks(String name, EnumRarity rarity) { this.name = name; this.rarity = rarity; } @Override - public String getName(){ + public String getName() { return this.name; } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/IHasModel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/IHasModel.java index f46f8e199..115b8ab14 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/IHasModel.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/IHasModel.java @@ -1,6 +1,6 @@ package de.ellpeck.actuallyadditions.mod.blocks.render; -public interface IHasModel{ +public interface IHasModel { public void registerRendering(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderBatteryBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderBatteryBox.java index 5078aa142..081dac388 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderBatteryBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderBatteryBox.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.blocks.render; +import java.text.NumberFormat; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.items.ItemBattery; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBatteryBox; @@ -26,21 +28,17 @@ import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.text.NumberFormat; - @SideOnly(Side.CLIENT) -public class RenderBatteryBox extends TileEntitySpecialRenderer{ +public class RenderBatteryBox extends TileEntitySpecialRenderer { @Override - public void render(TileEntityBatteryBox tile, double x, double y, double z, float par5, int par6, float f){ - if(!(tile instanceof TileEntityBatteryBox)){ - return; - } + public void render(TileEntityBatteryBox tile, double x, double y, double z, float par5, int par6, float f) { + if (!(tile instanceof TileEntityBatteryBox)) { return; } ItemStack stack = tile.inv.getStackInSlot(0); - if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery){ + if (StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery) { GlStateManager.pushMatrix(); - GlStateManager.translate((float)x+0.5F, (float)y+1F, (float)z+0.5F); + GlStateManager.translate((float) x + 0.5F, (float) y + 1F, (float) z + 0.5F); GlStateManager.pushMatrix(); @@ -48,17 +46,17 @@ public class RenderBatteryBox extends TileEntitySpecialRenderer{ +public class RenderDisplayStand extends TileEntitySpecialRenderer { @Override - public void render(TileEntityDisplayStand tile, double x, double y, double z, float par5, int par6, float f){ - if(!(tile instanceof TileEntityDisplayStand)){ - return; - } + public void render(TileEntityDisplayStand tile, double x, double y, double z, float par5, int par6, float f) { + if (!(tile instanceof TileEntityDisplayStand)) { return; } ItemStack stack = tile.inv.getStackInSlot(0); - if(StackUtil.isValid(stack)){ + if (StackUtil.isValid(stack)) { GlStateManager.pushMatrix(); - GlStateManager.translate((float)x+0.5F, (float)y+1F, (float)z+0.5F); + GlStateManager.translate((float) x + 0.5F, (float) y + 1F, (float) z + 0.5F); - double boop = Minecraft.getSystemTime()/800D; - GlStateManager.translate(0D, Math.sin(boop%(2*Math.PI))*0.065, 0D); - GlStateManager.rotate((float)(boop*40D%360), 0, 1, 0); + double boop = Minecraft.getSystemTime() / 800D; + GlStateManager.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.065, 0D); + GlStateManager.rotate((float) (boop * 40D % 360), 0, 1, 0); float scale = stack.getItem() instanceof ItemBlock ? 0.85F : 0.65F; GlStateManager.scale(scale, scale, scale); - try{ + try { AssetUtil.renderItemInWorld(stack); - } - catch(Exception e){ - ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in a display stand! The item is "+stack.getItem().getRegistryName()+"!", e); + } catch (Exception e) { + ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in a display stand! The item is " + stack.getItem().getRegistryName() + "!", e); } GlStateManager.popMatrix(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderEmpowerer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderEmpowerer.java index 7dc0ed2db..65a6398de 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderEmpowerer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderEmpowerer.java @@ -27,29 +27,26 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class RenderEmpowerer extends TileEntitySpecialRenderer{ +public class RenderEmpowerer extends TileEntitySpecialRenderer { @Override - public void render(TileEntityEmpowerer tile, double x, double y, double z, float par5, int par6, float f){ - if(!(tile instanceof TileEntityEmpowerer)){ - return; - } + public void render(TileEntityEmpowerer tile, double x, double y, double z, float par5, int par6, float f) { + if (!(tile instanceof TileEntityEmpowerer)) { return; } ItemStack stack = tile.inv.getStackInSlot(0); - if(StackUtil.isValid(stack)){ + if (StackUtil.isValid(stack)) { GlStateManager.pushMatrix(); - GlStateManager.translate((float)x+0.5F, (float)y+1F, (float)z+0.5F); + GlStateManager.translate((float) x + 0.5F, (float) y + 1F, (float) z + 0.5F); - double boop = Minecraft.getSystemTime()/800D; - GlStateManager.translate(0D, Math.sin(boop%(2*Math.PI))*0.065, 0D); - GlStateManager.rotate((float)(boop*40D%360), 0, 1, 0); + double boop = Minecraft.getSystemTime() / 800D; + GlStateManager.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.065, 0D); + GlStateManager.rotate((float) (boop * 40D % 360), 0, 1, 0); float scale = stack.getItem() instanceof ItemBlock ? 0.85F : 0.65F; GlStateManager.scale(scale, scale, scale); - try{ + try { AssetUtil.renderItemInWorld(stack); - } - catch(Exception e){ + } catch (Exception e) { ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in an empowerer! The item is " + stack.getItem().getRegistryName() + ":" + stack.getMetadata() + "!", e); } @@ -57,14 +54,14 @@ public class RenderEmpowerer extends TileEntitySpecialRenderer= 0 && ActuallyAdditionsAPI.EMPOWERER_RECIPES.size() > index){ + if (index >= 0 && ActuallyAdditionsAPI.EMPOWERER_RECIPES.size() > index) { EmpowererRecipe recipe = ActuallyAdditionsAPI.EMPOWERER_RECIPES.get(index); - if(recipe != null){ - for(int i = 0; i < EnumFacing.HORIZONTALS.length; i++){ + if (recipe != null) { + for (int i = 0; i < EnumFacing.HORIZONTALS.length; i++) { EnumFacing facing = EnumFacing.HORIZONTALS[i]; BlockPos offset = tile.getPos().offset(facing, 3); - AssetUtil.renderLaser(tile.getPos().getX()+0.5, tile.getPos().getY()+0.5, tile.getPos().getZ()+0.5, offset.getX()+0.5, offset.getY()+0.95, offset.getZ()+0.5, 80, 1F, 0.1F, recipe.getParticleColors()); + AssetUtil.renderLaser(tile.getPos().getX() + 0.5, tile.getPos().getY() + 0.5, tile.getPos().getZ() + 0.5, offset.getX() + 0.5, offset.getY() + 0.95, offset.getZ() + 0.5, 80, 1F, 0.1F, recipe.getParticleColors()); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderLaserRelay.java index 4025fbc06..f38ed1c35 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderLaserRelay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderLaserRelay.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.blocks.render; - import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.laser.IConnectionPair; import de.ellpeck.actuallyadditions.api.laser.LaserType; @@ -33,16 +32,16 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class RenderLaserRelay extends TileEntitySpecialRenderer{ +public class RenderLaserRelay extends TileEntitySpecialRenderer { - private static final float[] COLOR = new float[]{1F, 0F, 0F}; - private static final float[] COLOR_ITEM = new float[]{0F, 124F/255F, 16F/255F}; - private static final float[] COLOR_FLUIDS = new float[]{0F, 97F/255F, 198F/255F}; - private static final float[] COLOR_INFRARED = new float[]{209F/255F, 179F/255F, 239F/255F}; + private static final float[] COLOR = new float[] { 1F, 0F, 0F }; + private static final float[] COLOR_ITEM = new float[] { 0F, 124F / 255F, 16F / 255F }; + private static final float[] COLOR_FLUIDS = new float[] { 0F, 97F / 255F, 198F / 255F }; + private static final float[] COLOR_INFRARED = new float[] { 209F / 255F, 179F / 255F, 239F / 255F }; @Override - public void render(TileEntityLaserRelay tile, double x, double y, double z, float par5, int par6, float f){ - if(tile instanceof TileEntityLaserRelay){ + public void render(TileEntityLaserRelay tile, double x, double y, double z, float par5, int par6, float f) { + if (tile instanceof TileEntityLaserRelay) { TileEntityLaserRelay relay = tile; boolean hasInvis = false; @@ -50,21 +49,21 @@ public class RenderLaserRelay extends TileEntitySpecialRenderer connections = ActuallyAdditionsAPI.connectionHandler.getConnectionsFor(tile.getPos(), tile.getWorld()); - if(connections != null && !connections.isEmpty()){ - for(IConnectionPair pair : connections){ - if(!pair.doesSuppressRender() && tile.getPos().equals(pair.getPositions()[0])){ + if (connections != null && !connections.isEmpty()) { + for (IConnectionPair pair : connections) { + if (!pair.doesSuppressRender() && tile.getPos().equals(pair.getPositions()[0])) { BlockPos first = tile.getPos(); BlockPos second = pair.getPositions()[1]; TileEntity secondTile = tile.getWorld().getTileEntity(second); - if(secondTile instanceof TileEntityLaserRelay){ - ItemStack secondUpgrade = ((TileEntityLaserRelay)secondTile).inv.getStackInSlot(0); + if (secondTile instanceof TileEntityLaserRelay) { + ItemStack secondUpgrade = ((TileEntityLaserRelay) secondTile).inv.getStackInSlot(0); boolean otherInvis = StackUtil.isValid(secondUpgrade) && secondUpgrade.getItem() == InitItems.itemLaserUpgradeInvisibility; - if(hasGoggles || !hasInvis || !otherInvis){ + if (hasGoggles || !hasInvis || !otherInvis) { float[] color = hasInvis && otherInvis ? COLOR_INFRARED : relay.type == LaserType.ITEM ? COLOR_ITEM : relay.type == LaserType.FLUID ? COLOR_FLUIDS : COLOR; - AssetUtil.renderLaser(first.getX()+0.5, first.getY()+0.5, first.getZ()+0.5, second.getX()+0.5, second.getY()+0.5, second.getZ()+0.5, 120, hasInvis && otherInvis ? 0.1F : 0.35F, 0.05, color); + AssetUtil.renderLaser(first.getX() + 0.5, first.getY() + 0.5, first.getZ() + 0.5, second.getX() + 0.5, second.getY() + 0.5, second.getZ() + 0.5, 120, hasInvis && otherInvis ? 0.1F : 0.35F, 0.05, color); } } } @@ -97,7 +96,7 @@ public class RenderLaserRelay extends TileEntitySpecialRenderer{ +public class RenderReconstructorLens extends TileEntitySpecialRenderer { @Override - public void render(TileEntityAtomicReconstructor tile, double x, double y, double z, float par5, int par6, float f){ - if(tile == null) return; + public void render(TileEntityAtomicReconstructor tile, double x, double y, double z, float par5, int par6, float f) { + if (tile == null) return; ItemStack stack = tile.inv.getStackInSlot(0); - if(StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem){ + if (StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem) { GlStateManager.pushMatrix(); - GlStateManager.translate((float)x+0.5F, (float)y-0.5F, (float)z+0.5F); + GlStateManager.translate((float) x + 0.5F, (float) y - 0.5F, (float) z + 0.5F); GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F); IBlockState state = tile.getWorld().getBlockState(tile.getPos()); int meta = state.getBlock().getMetaFromState(state); - if(meta == 0){ + if (meta == 0) { GlStateManager.translate(0F, -0.5F, 0F); GlStateManager.rotate(90F, 1F, 0F, 0F); } - if(meta == 1){ - GlStateManager.translate(0F, -1.5F-0.5F/16F, 0F); + if (meta == 1) { + GlStateManager.translate(0F, -1.5F - 0.5F / 16F, 0F); GlStateManager.rotate(90F, 1F, 0F, 0F); } - if(meta == 2){ + if (meta == 2) { GlStateManager.translate(0F, -1F, 0F); GlStateManager.translate(0F, 0F, -0.5F); } - if(meta == 3){ + if (meta == 3) { GlStateManager.translate(0F, -1F, 0F); - GlStateManager.translate(0F, 0F, 0.5F+0.5F/16F); + GlStateManager.translate(0F, 0F, 0.5F + 0.5F / 16F); } - if(meta == 4){ + if (meta == 4) { GlStateManager.translate(0F, -1F, 0F); - GlStateManager.translate(0.5F+0.5F/16F, 0F, 0F); + GlStateManager.translate(0.5F + 0.5F / 16F, 0F, 0F); GlStateManager.rotate(90F, 0F, 1F, 0F); } - if(meta == 5){ + if (meta == 5) { GlStateManager.translate(0F, -1F, 0F); GlStateManager.translate(-0.5F, 0F, 0F); GlStateManager.rotate(90F, 0F, 1F, 0F); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderSmileyCloud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderSmileyCloud.java index c94c61074..50c3d251b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderSmileyCloud.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderSmileyCloud.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.blocks.render; +import java.util.Locale; + import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import de.ellpeck.actuallyadditions.mod.misc.cloud.ISmileyCloudEasterEgg; import de.ellpeck.actuallyadditions.mod.misc.cloud.SmileyCloudEasterEggs; @@ -25,61 +27,58 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.Locale; - @SideOnly(Side.CLIENT) -public class RenderSmileyCloud extends TileEntitySpecialRenderer{ +public class RenderSmileyCloud extends TileEntitySpecialRenderer { @Override - public void render(TileEntitySmileyCloud theCloud, double x, double y, double z, float par5, int partial, float f){ - if(theCloud instanceof TileEntitySmileyCloud){ + public void render(TileEntitySmileyCloud theCloud, double x, double y, double z, float par5, int partial, float f) { + if (theCloud instanceof TileEntitySmileyCloud) { GlStateManager.pushMatrix(); - GlStateManager.translate((float)x+0.5F, (float)y-0.5F, (float)z+0.5F); + GlStateManager.translate((float) x + 0.5F, (float) y - 0.5F, (float) z + 0.5F); GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F); GlStateManager.translate(0.0F, -2F, 0.0F); - if(theCloud.name != null && !theCloud.name.isEmpty()){ + if (theCloud.name != null && !theCloud.name.isEmpty()) { boolean renderedEaster = false; - easterEggs: - for(ISmileyCloudEasterEgg cloud : SmileyCloudEasterEggs.CLOUD_STUFF){ - for(String triggerName : cloud.getTriggerNames()){ - if(triggerName != null && theCloud.name != null){ - if(triggerName.equalsIgnoreCase(theCloud.name)){ - GlStateManager.pushMatrix(); + easterEggs: for (ISmileyCloudEasterEgg cloud : SmileyCloudEasterEggs.CLOUD_STUFF) { + for (String triggerName : cloud.getTriggerNames()) { + if (triggerName != null && theCloud.name != null) { + if (triggerName.equalsIgnoreCase(theCloud.name)) { + GlStateManager.pushMatrix(); - IBlockState state = theCloud.getWorld().getBlockState(theCloud.getPos()); - if(state.getBlock() == InitBlocks.blockSmileyCloud){ - switch(state.getValue(BlockHorizontal.FACING)){ - case NORTH: - GlStateManager.rotate(180, 0, 1, 0); - break; - case EAST: - GlStateManager.rotate(270, 0, 1, 0); - break; - case WEST: - GlStateManager.rotate(90, 0, 1, 0); - break; - default: - break; - } + IBlockState state = theCloud.getWorld().getBlockState(theCloud.getPos()); + if (state.getBlock() == InitBlocks.blockSmileyCloud) { + switch (state.getValue(BlockHorizontal.FACING)) { + case NORTH: + GlStateManager.rotate(180, 0, 1, 0); + break; + case EAST: + GlStateManager.rotate(270, 0, 1, 0); + break; + case WEST: + GlStateManager.rotate(90, 0, 1, 0); + break; + default: + break; } - - cloud.renderExtra(0.0625F); - GlStateManager.popMatrix(); - - renderedEaster = true; - break easterEggs; } + + cloud.renderExtra(0.0625F); + GlStateManager.popMatrix(); + + renderedEaster = true; + break easterEggs; } } } + } String nameLower = theCloud.name.toLowerCase(Locale.ROOT); - if(SpecialRenderInit.SPECIAL_LIST.containsKey(nameLower)){ + if (SpecialRenderInit.SPECIAL_LIST.containsKey(nameLower)) { RenderSpecial render = SpecialRenderInit.SPECIAL_LIST.get(nameLower); - if(render != null){ + if (render != null) { GlStateManager.pushMatrix(); GlStateManager.translate(0F, renderedEaster ? 0.05F : 0.25F, 0F); GlStateManager.rotate(180F, 1.0F, 0.0F, 1.0F); @@ -92,9 +91,9 @@ public class RenderSmileyCloud extends TileEntitySpecialRenderer items = new ArrayList<>(); @@ -131,8 +131,8 @@ public final class InitBooklet{ List fluids = new ArrayList<>(); page.getFluidStacksForPage(fluids); - if(items != null && !items.isEmpty() || fluids != null && !fluids.isEmpty()){ - if(!ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.contains(page)){ + if (items != null && !items.isEmpty() || fluids != null && !fluids.isEmpty()) { + if (!ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.contains(page)) { ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.add(page); infoCount++; } @@ -158,31 +158,31 @@ public final class InitBooklet{ return prio2.compareTo(prio1); }); - ActuallyAdditions.LOGGER.info("Registered a total of "+chapCount+" booklet chapters, where "+infoCount+" out of "+pageCount+" booklet pages contain information about items or fluids!"); + ActuallyAdditions.LOGGER.info("Registered a total of " + chapCount + " booklet chapters, where " + infoCount + " out of " + pageCount + " booklet pages contain information about items or fluids!"); } - private static void initChapters(){ + private static void initChapters() { //Getting Started chaptersIntroduction[0] = new BookletChapter("bookTutorial", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemBooklet), new PageTextOnly(1), new PageTextOnly(2), new PageTextOnly(3), new PageCrafting(4, ItemCrafting.recipeBook).setNoText()); chaptersIntroduction[1] = new BookletChapter("videoGuide", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.YOUTUBE_ICON.ordinal()), new PageLinkButton(1, "https://www.youtube.com/watch?v=fhjz0Ew56pM"), new PageLinkButton(2, "https://www.youtube.com/playlist?list=PLJeFZ64pT89MrTRZYzD_rtHFajPVlt6cF")).setImportant(); new BookletChapter("intro", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemBooklet), new PageTextOnly(1), new PageTextOnly(2), new PageTextOnly(3)); ArrayList crystalPages = new ArrayList<>(); crystalPages.addAll(Arrays.asList(new PageTextOnly(1).addTextReplacement("", TileEntityAtomicReconstructor.ENERGY_USE), new PageTextOnly(2), new PageTextOnly(3), new PagePicture(4, "page_atomic_reconstructor", 0).setNoText(), new PageTextOnly(5), new PageCrafting(6, BlockCrafting.recipeAtomicReconstructor).setWildcard())); - for(int i = 0; i < LensRecipeHandler.MAIN_PAGE_RECIPES.size(); i++){ - crystalPages.add(new PageReconstructor(7+i, LensRecipeHandler.MAIN_PAGE_RECIPES.get(i)).setNoText()); + for (int i = 0; i < LensRecipeHandler.MAIN_PAGE_RECIPES.size(); i++) { + crystalPages.add(new PageReconstructor(7 + i, LensRecipeHandler.MAIN_PAGE_RECIPES.get(i)).setNoText()); } - crystalPages.add(new PageCrafting(crystalPages.size()+1, MiscCrafting.RECIPES_CRYSTALS).setNoText()); - crystalPages.add(new PageCrafting(crystalPages.size()+1, MiscCrafting.RECIPES_CRYSTAL_BLOCKS).setNoText()); + crystalPages.add(new PageCrafting(crystalPages.size() + 1, MiscCrafting.RECIPES_CRYSTALS).setNoText()); + crystalPages.add(new PageCrafting(crystalPages.size() + 1, MiscCrafting.RECIPES_CRYSTAL_BLOCKS).setNoText()); chaptersIntroduction[2] = new BookletChapter("engineerHouse", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(Items.EMERALD), new PageTextOnly(1), new PagePicture(2, "page_engineer_house", 145)); chaptersIntroduction[6] = new BookletChapter("crystals", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockAtomicReconstructor), crystalPages.toArray(new BookletPage[crystalPages.size()])).setSpecial(); chaptersIntroduction[5] = new BookletChapter("coalGen", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockCoalGenerator), new PageTextOnly(1).addTextReplacement("", TileEntityCoalGenerator.PRODUCE), new PageCrafting(2, BlockCrafting.recipeCoalGen).setWildcard().setNoText()); ArrayList empowererPages = new ArrayList<>(); empowererPages.addAll(Arrays.asList(new PageTextOnly(1), new PagePicture(2, "page_empowerer", 137), new PageCrafting(3, BlockCrafting.recipeEmpowerer), new PageCrafting(4, BlockCrafting.recipeDisplayStand))); - for(int i = 0; i < EmpowererHandler.MAIN_PAGE_RECIPES.size(); i++){ - empowererPages.add(new PageEmpowerer(7+i, EmpowererHandler.MAIN_PAGE_RECIPES.get(i)).setNoText()); + for (int i = 0; i < EmpowererHandler.MAIN_PAGE_RECIPES.size(); i++) { + empowererPages.add(new PageEmpowerer(7 + i, EmpowererHandler.MAIN_PAGE_RECIPES.get(i)).setNoText()); } - empowererPages.add(new PageCrafting(empowererPages.size()+1, MiscCrafting.RECIPES_EMPOWERED_CRYSTALS).setNoText()); - empowererPages.add(new PageCrafting(empowererPages.size()+1, MiscCrafting.RECIPES_EMPOWERED_CRYSTAL_BLOCKS).setNoText()); + empowererPages.add(new PageCrafting(empowererPages.size() + 1, MiscCrafting.RECIPES_EMPOWERED_CRYSTALS).setNoText()); + empowererPages.add(new PageCrafting(empowererPages.size() + 1, MiscCrafting.RECIPES_EMPOWERED_CRYSTAL_BLOCKS).setNoText()); new BookletChapter("empowerer", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitBlocks.blockEmpowerer), empowererPages.toArray(new BookletPage[empowererPages.size()])).setSpecial(); new BookletChapter("craftingIngs", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeCoil).setNoText(), new PageCrafting(3, ItemCrafting.recipeCoilAdvanced).setNoText(), new PageCrafting(4, BlockCrafting.recipeCase).setNoText(), new PageCrafting(5, BlockCrafting.recipeEnderPearlBlock).setNoText(), new PageCrafting(6, BlockCrafting.recipeEnderCase).setNoText(), new PageCrafting(7, ItemCrafting.recipeRing).setNoText(), new PageCrafting(8, ItemCrafting.recipeKnifeHandle).setNoText(), new PageCrafting(9, ItemCrafting.recipeKnifeBlade).setNoText(), new PageCrafting(10, ItemCrafting.recipeKnife).setNoText(), new PageCrafting(11, ItemCrafting.recipeDough).setNoText(), new PageCrafting(12, ItemCrafting.recipeRiceDough).setNoText(), new PageCrafting(13, BlockCrafting.recipeIronCase).setNoText(), new PageCrafting(14, ItemCrafting.recipeLens).setNoText()); chaptersIntroduction[4] = new BookletChapter("rf", ActuallyAdditionsAPI.entryGettingStarted, new ItemStack(Items.REDSTONE), new PageTextOnly(1), new PageTextOnly(2)).setImportant(); @@ -197,11 +197,11 @@ public final class InitBooklet{ new BookletChapter("cloud", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockSmileyCloud), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeSmileyCloud).setWildcard()).setSpecial(); new BookletChapter("coalStuff", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.TINY_COAL.ordinal()), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeTinyCoal).setNoText(), new PageCrafting(3, ItemCrafting.recipeTinyChar).setNoText(), new PageCrafting(4, BlockCrafting.recipeBlockChar).setNoText()); ArrayList lampPages = new ArrayList<>(); - lampPages.add(new PageTextOnly(lampPages.size()+1)); - lampPages.add(new PageTextOnly(lampPages.size()+1)); - lampPages.add(new PageCrafting(lampPages.size()+1, BlockCrafting.recipePowerer).setWildcard().setNoText()); - for(IRecipe recipe : BlockCrafting.RECIPES_LAMPS){ - lampPages.add(new PageCrafting(lampPages.size()+1, recipe).setNoText()); + lampPages.add(new PageTextOnly(lampPages.size() + 1)); + lampPages.add(new PageTextOnly(lampPages.size() + 1)); + lampPages.add(new PageCrafting(lampPages.size() + 1, BlockCrafting.recipePowerer).setWildcard().setNoText()); + for (IRecipe recipe : BlockCrafting.RECIPES_LAMPS) { + lampPages.add(new PageCrafting(lampPages.size() + 1, recipe).setNoText()); } new BookletChapter("lamps", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockColoredLampOn, 1, TheColoredLampColors.GREEN.ordinal()), lampPages.toArray(new BookletPage[lampPages.size()])); new BookletChapter("enderStar", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.ENDER_STAR.ordinal()), new PageCrafting(1, ItemCrafting.recipeEnderStar)); @@ -260,9 +260,9 @@ public final class InitBooklet{ list.add(new PageTextOnly(1).addTextReplacement("", TileEntityGrinder.ENERGY_USE)); list.add(new PageCrafting(2, BlockCrafting.recipeCrusher).setWildcard().setNoText()); list.add(new PageCrafting(3, BlockCrafting.recipeDoubleCrusher).setWildcard().setNoText()); - if(CrusherCrafting.recipeIronHorseArmor != null) list.add(new PageCrusherRecipe(4, CrusherCrafting.recipeIronHorseArmor).setNoText()); - if(CrusherCrafting.recipeGoldHorseArmor != null) list.add(new PageCrusherRecipe(5, CrusherCrafting.recipeGoldHorseArmor).setNoText()); - if(CrusherCrafting.recipeDiamondHorseArmor != null) list.add(new PageCrusherRecipe(6, CrusherCrafting.recipeDiamondHorseArmor).setNoText()); + if (CrusherCrafting.recipeIronHorseArmor != null) list.add(new PageCrusherRecipe(4, CrusherCrafting.recipeIronHorseArmor).setNoText()); + if (CrusherCrafting.recipeGoldHorseArmor != null) list.add(new PageCrusherRecipe(5, CrusherCrafting.recipeGoldHorseArmor).setNoText()); + if (CrusherCrafting.recipeDiamondHorseArmor != null) list.add(new PageCrusherRecipe(6, CrusherCrafting.recipeDiamondHorseArmor).setNoText()); new BookletChapterCrusher("crusher", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockGrinderDouble), list.toArray(new IBookletPage[0])); new BookletChapter("furnaceDouble", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockFurnaceDouble), new PageCrafting(1, BlockCrafting.recipeFurnace).setWildcard().addTextReplacement("", TileEntityFurnaceDouble.ENERGY_USE)); @@ -284,23 +284,23 @@ public final class InitBooklet{ //No RF Using Items chaptersIntroduction[9] = new BookletChapter("goggles", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemEngineerGoggles), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeGoggles).setNoText(), new PageCrafting(3, ItemCrafting.recipeGogglesAdvanced).setNoText()).setImportant(); new BookletChapter("bags", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemBag), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeBag), new PageCrafting(3, ItemCrafting.recipeVoidBag).setNoText()).setImportant(); - new BookletChapter("wings", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemWingsOfTheBats), new PageTextOnly(1).addItemsToPage(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BAT_WING.ordinal())).addTextReplacement("", ItemWingsOfTheBats.MAX_FLY_TIME/20), new PageCrafting(2, ItemCrafting.recipeWings).setNoText()).setSpecial(); + new BookletChapter("wings", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemWingsOfTheBats), new PageTextOnly(1).addItemsToPage(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BAT_WING.ordinal())).addTextReplacement("", ItemWingsOfTheBats.MAX_FLY_TIME / 20), new PageCrafting(2, ItemCrafting.recipeWings).setNoText()).setSpecial(); new BookletChapter("foods", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemFoods, 1, TheFoods.HAMBURGER.ordinal()), new PageCrafting(1, FoodCrafting.recipeBacon).setNoText(), new PageFurnace(2, new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE_BREAD.ordinal())).setNoText(), new PageCrafting(3, FoodCrafting.recipeHamburger).setNoText(), new PageCrafting(4, FoodCrafting.recipeBigCookie).setNoText(), new PageCrafting(5, FoodCrafting.recipeSubSandwich).setNoText(), new PageCrafting(6, FoodCrafting.recipeFrenchFry).setNoText(), new PageCrafting(7, FoodCrafting.recipeFrenchFries).setNoText(), new PageCrafting(8, FoodCrafting.recipeFishNChips).setNoText(), new PageCrafting(9, FoodCrafting.recipeCheese).setNoText(), new PageCrafting(10, FoodCrafting.recipePumpkinStew).setNoText(), new PageCrafting(11, FoodCrafting.recipeCarrotJuice).setNoText(), new PageCrafting(12, FoodCrafting.recipeSpaghetti).setNoText(), new PageCrafting(13, FoodCrafting.recipeNoodle).setNoText(), new PageCrafting(14, FoodCrafting.recipeChocolate).setNoText(), new PageCrafting(15, FoodCrafting.recipeChocolateCake).setNoText(), new PageCrafting(16, FoodCrafting.recipeToast).setNoText(), new PageFurnace(17, new ItemStack(InitItems.itemFoods, 1, TheFoods.BAGUETTE.ordinal())).setNoText(), new PageCrafting(18, FoodCrafting.recipeChocolateToast).setNoText(), new PageCrafting(1, FoodCrafting.recipePizza).setNoText()); new BookletChapter("leafBlower", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemLeafBlowerAdvanced), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeLeafBlower).setNoText(), new PageCrafting(3, ItemCrafting.recipeLeafBlowerAdvanced).setNoText()).setImportant(); new BookletChapter("playerProbe", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemPlayerProbe), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipePlayerProbe).setNoText()).setSpecial(); ArrayList aiotPages = new ArrayList<>(); - aiotPages.add(new PageTextOnly(aiotPages.size()+1)); - for(IRecipe recipe : ToolCrafting.RECIPES_PAXELS){ - aiotPages.add(new PageCrafting(aiotPages.size()+1, recipe).setWildcard().setNoText()); + aiotPages.add(new PageTextOnly(aiotPages.size() + 1)); + for (IRecipe recipe : ToolCrafting.RECIPES_PAXELS) { + aiotPages.add(new PageCrafting(aiotPages.size() + 1, recipe).setWildcard().setNoText()); } new BookletChapter("aiots", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.emeraldPaxel), aiotPages.toArray(new BookletPage[aiotPages.size()])).setImportant(); new BookletChapter("jams", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemJams), new PageTextOnly(1).addItemsToPage(new ItemStack(InitItems.itemJams, 1, Util.WILDCARD)), new PagePicture(2, "page_jam_house", 150), new PageTextOnly(3)); ArrayList potionRingPages = new ArrayList<>(); - potionRingPages.add(new PageTextOnly(potionRingPages.size()+1)); - for(IRecipe recipe : ItemCrafting.RECIPES_POTION_RINGS){ - potionRingPages.add(new PageCrafting(potionRingPages.size()+1, recipe).setNoText()); + potionRingPages.add(new PageTextOnly(potionRingPages.size() + 1)); + for (IRecipe recipe : ItemCrafting.RECIPES_POTION_RINGS) { + potionRingPages.add(new PageCrafting(potionRingPages.size() + 1, recipe).setNoText()); } new BookletChapter("potionRings", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemPotionRing), potionRingPages.toArray(new BookletPage[potionRingPages.size()])); new BookletChapter("spawnerChanger", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemSpawnerChanger), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeSpawnerChanger).setNoText()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/BookmarkButton.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/BookmarkButton.java index 8c6a06fbe..a58cb643b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/BookmarkButton.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/BookmarkButton.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.booklet.button; +import java.util.ArrayList; +import java.util.List; + import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; @@ -29,45 +32,40 @@ import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.ArrayList; -import java.util.List; - @SideOnly(Side.CLIENT) -public class BookmarkButton extends GuiButton{ +public class BookmarkButton extends GuiButton { private final GuiBooklet booklet; public IBookletPage assignedPage; - public BookmarkButton(int id, int x, int y, GuiBooklet booklet){ + public BookmarkButton(int id, int x, int y, GuiBooklet booklet) { super(id, x, y, 16, 16, ""); this.booklet = booklet; } - public void onPressed(){ - if(this.assignedPage != null){ - if(GuiScreen.isShiftKeyDown()){ + public void onPressed() { + if (this.assignedPage != null) { + if (GuiScreen.isShiftKeyDown()) { this.assignedPage = null; - } - else if(!(this.booklet instanceof GuiPage) || ((GuiPage)this.booklet).pages[0] != this.assignedPage){ + } else if (!(this.booklet instanceof GuiPage) || ((GuiPage) this.booklet).pages[0] != this.assignedPage) { GuiPage gui = BookletUtils.createPageGui(this.booklet.previousScreen, this.booklet, this.assignedPage); Minecraft.getMinecraft().displayGuiScreen(gui); } - } - else{ - if(this.booklet instanceof GuiPage){ - this.assignedPage = ((GuiPage)this.booklet).pages[0]; + } else { + if (this.booklet instanceof GuiPage) { + this.assignedPage = ((GuiPage) this.booklet).pages[0]; } } } @Override - public void drawButton(Minecraft minecraft, int x, int y, float f){ - if(this.visible){ + public void drawButton(Minecraft minecraft, int x, int y, float f) { + if (this.visible) { minecraft.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - this.hovered = x >= this.x && y >= this.y && x < this.x+this.width && y < this.y+this.height; + this.hovered = x >= this.x && y >= this.y && x < this.x + this.width && y < this.y + this.height; int k = this.getHoverState(this.hovered); - if(k == 0){ + if (k == 0) { k = 1; } @@ -75,39 +73,37 @@ public class BookmarkButton extends GuiButton{ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.blendFunc(770, 771); int renderHeight = 25; - this.drawTexturedModalRect(this.x, this.y, 224+(this.assignedPage == null ? 0 : 16), 14-renderHeight+k*renderHeight, this.width, renderHeight); + this.drawTexturedModalRect(this.x, this.y, 224 + (this.assignedPage == null ? 0 : 16), 14 - renderHeight + k * renderHeight, this.width, renderHeight); this.mouseDragged(minecraft, x, y); - if(this.assignedPage != null){ + if (this.assignedPage != null) { ItemStack display = this.assignedPage.getChapter().getDisplayItemStack(); - if(StackUtil.isValid(display)){ + if (StackUtil.isValid(display)) { GlStateManager.pushMatrix(); - AssetUtil.renderStackToGui(display, this.x+2, this.y+1, 0.725F); + AssetUtil.renderStackToGui(display, this.x + 2, this.y + 1, 0.725F); GlStateManager.popMatrix(); } } } } - public void drawHover(int mouseX, int mouseY){ - if(this.isMouseOver()){ + public void drawHover(int mouseX, int mouseY) { + if (this.isMouseOver()) { List list = new ArrayList<>(); - if(this.assignedPage != null){ + if (this.assignedPage != null) { IBookletChapter chapter = this.assignedPage.getChapter(); - list.add(TextFormatting.GOLD+chapter.getLocalizedName()+", Page "+(chapter.getPageIndex(this.assignedPage)+1)); - list.add(StringUtil.localize("booklet."+ActuallyAdditions.MODID+".bookmarkButton.bookmark.openDesc")); - list.add(TextFormatting.ITALIC+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".bookmarkButton.bookmark.removeDesc")); - } - else{ - list.add(TextFormatting.GOLD+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".bookmarkButton.noBookmark.name")); + list.add(TextFormatting.GOLD + chapter.getLocalizedName() + ", Page " + (chapter.getPageIndex(this.assignedPage) + 1)); + list.add(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.bookmark.openDesc")); + list.add(TextFormatting.ITALIC + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.bookmark.removeDesc")); + } else { + list.add(TextFormatting.GOLD + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.noBookmark.name")); - if(this.booklet instanceof GuiPage){ - list.add(StringUtil.localize("booklet."+ActuallyAdditions.MODID+".bookmarkButton.noBookmark.pageDesc")); - } - else{ - list.add(StringUtil.localize("booklet."+ActuallyAdditions.MODID+".bookmarkButton.noBookmark.notPageDesc")); + if (this.booklet instanceof GuiPage) { + list.add(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.noBookmark.pageDesc")); + } else { + list.add(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".bookmarkButton.noBookmark.notPageDesc")); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/EntryButton.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/EntryButton.java index 84dd4d16d..d3595ccf5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/EntryButton.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/EntryButton.java @@ -22,12 +22,12 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class EntryButton extends GuiButton{ +public class EntryButton extends GuiButton { private final GuiBookletBase gui; private final ItemStack stackToRender; - public EntryButton(GuiBookletBase gui, int id, int x, int y, int width, int height, String text, ItemStack stackToRender){ + public EntryButton(GuiBookletBase gui, int id, int x, int y, int width, int height, String text, ItemStack stackToRender) { super(id, x, y, width, height, text); this.gui = gui; StackUtil.isValid(stackToRender); @@ -35,32 +35,32 @@ public class EntryButton extends GuiButton{ } @Override - public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float f){ - if(this.visible){ + public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float f) { + if (this.visible) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x+this.width && mouseY < this.y+this.height; + this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.blendFunc(770, 771); this.mouseDragged(minecraft, mouseX, mouseY); int textOffsetX = 0; - if(StackUtil.isValid(this.stackToRender)){ + if (StackUtil.isValid(this.stackToRender)) { GlStateManager.pushMatrix(); - AssetUtil.renderStackToGui(this.stackToRender, this.x-4, this.y, 0.725F); + AssetUtil.renderStackToGui(this.stackToRender, this.x - 4, this.y, 0.725F); GlStateManager.popMatrix(); textOffsetX = 10; } float scale = this.gui.getMediumFontSize(); - if(this.hovered){ + if (this.hovered) { GlStateManager.pushMatrix(); - AssetUtil.drawHorizontalGradientRect(this.x+textOffsetX-1, this.y+this.height-1, this.x+(int)(minecraft.fontRenderer.getStringWidth(this.displayString)*scale)+textOffsetX+1, this.y+this.height, 0x80 << 24 | 22271, 22271, this.zLevel); + AssetUtil.drawHorizontalGradientRect(this.x + textOffsetX - 1, this.y + this.height - 1, this.x + (int) (minecraft.fontRenderer.getStringWidth(this.displayString) * scale) + textOffsetX + 1, this.y + this.height, 0x80 << 24 | 22271, 22271, this.zLevel); GlStateManager.popMatrix(); } - StringUtil.renderScaledAsciiString(minecraft.fontRenderer, this.displayString, this.x+textOffsetX, this.y+2+(this.height-8)/2, 0, false, scale); + StringUtil.renderScaledAsciiString(minecraft.fontRenderer, this.displayString, this.x + textOffsetX, this.y + 2 + (this.height - 8) / 2, 0, false, scale); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/TrialsButton.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/TrialsButton.java index 2549ec6cf..08b1e6400 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/TrialsButton.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/TrialsButton.java @@ -16,36 +16,34 @@ import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton; import de.ellpeck.actuallyadditions.mod.util.StringUtil; import net.minecraft.client.Minecraft; -public class TrialsButton extends TexturedButton{ +public class TrialsButton extends TexturedButton { private final boolean isTrials; - public TrialsButton(GuiBooklet gui){ - super(GuiBooklet.RES_LOC_GADGETS, -152000, gui.getGuiLeft()+gui.getSizeX(), gui.getGuiTop()+10, 0, 204, 52, 16); + public TrialsButton(GuiBooklet gui) { + super(GuiBooklet.RES_LOC_GADGETS, -152000, gui.getGuiLeft() + gui.getSizeX(), gui.getGuiTop() + 10, 0, 204, 52, 16); this.isTrials = gui.areTrialsOpened(); this.enabled = !this.isTrials; } @Override - public void drawButton(Minecraft minecraft, int x, int y, float f){ + public void drawButton(Minecraft minecraft, int x, int y, float f) { super.drawButton(minecraft, x, y, f); - if(this.visible){ - if(this.hovered || this.isTrials){ - this.drawCenteredString(minecraft.fontRenderer, StringUtil.localize("booklet."+ActuallyAdditions.MODID+".trialsButton.name"), this.x+(this.width-8)/2, this.y+(this.height-8)/2, 14737632); + if (this.visible) { + if (this.hovered || this.isTrials) { + this.drawCenteredString(minecraft.fontRenderer, StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".trialsButton.name"), this.x + (this.width - 8) / 2, this.y + (this.height - 8) / 2, 14737632); } } } @Override - protected int getHoverState(boolean mouseOver){ - if(mouseOver || this.isTrials){ + protected int getHoverState(boolean mouseOver) { + if (mouseOver || this.isTrials) { return 2; - } - else if(!this.enabled){ + } else if (!this.enabled) { return 0; - } - else{ + } else { return 1; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapter.java index 6a77a473e..23ce0eb15 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapter.java @@ -21,7 +21,7 @@ import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class BookletChapter implements IBookletChapter{ +public class BookletChapter implements IBookletChapter { public final IBookletPage[] pages; public final IBookletEntry entry; @@ -30,78 +30,76 @@ public class BookletChapter implements IBookletChapter{ private final int priority; public TextFormatting color; - public BookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages){ + public BookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages) { this(identifier, entry, displayStack, 0, pages); } - public BookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, int priority, IBookletPage... pages){ + public BookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, int priority, IBookletPage... pages) { this.pages = pages; this.identifier = identifier; this.entry = entry; this.displayStack = displayStack; - if(displayStack.getItem() instanceof IDisableableItem && ((IDisableableItem) displayStack.getItem()).isDisabled()) displayStack = ItemStack.EMPTY; + if (displayStack.getItem() instanceof IDisableableItem && ((IDisableableItem) displayStack.getItem()).isDisabled()) displayStack = ItemStack.EMPTY; this.priority = priority; this.color = TextFormatting.RESET; this.entry.addChapter(this); - for(IBookletPage page : this.pages){ + for (IBookletPage page : this.pages) { page.setChapter(this); } } @Override - public IBookletPage[] getAllPages(){ + public IBookletPage[] getAllPages() { return this.pages; } @Override @SideOnly(Side.CLIENT) - public String getLocalizedName(){ - return StringUtil.localize("booklet."+ActuallyAdditions.MODID+".chapter."+this.getIdentifier()+".name"); + public String getLocalizedName() { + return StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".chapter." + this.getIdentifier() + ".name"); } @Override @SideOnly(Side.CLIENT) - public String getLocalizedNameWithFormatting(){ - return this.color+this.getLocalizedName(); + public String getLocalizedNameWithFormatting() { + return this.color + this.getLocalizedName(); } @Override - public IBookletEntry getEntry(){ + public IBookletEntry getEntry() { return this.entry; } @Override - public ItemStack getDisplayItemStack(){ + public ItemStack getDisplayItemStack() { return this.displayStack; } @Override - public String getIdentifier(){ + public String getIdentifier() { return this.identifier; } @Override - public int getPageIndex(IBookletPage page){ - for(int i = 0; i < this.pages.length; i++){ - if(this.pages[i] == page){ - return i; - } + public int getPageIndex(IBookletPage page) { + for (int i = 0; i < this.pages.length; i++) { + if (this.pages[i] == page) { return i; } } return -1; } @Override - public int getSortingPriority(){ + public int getSortingPriority() { return this.priority; } - public BookletChapter setImportant(){ + public BookletChapter setImportant() { this.color = TextFormatting.DARK_GREEN; return this; } - public BookletChapter setSpecial(){ + public BookletChapter setSpecial() { this.color = TextFormatting.DARK_PURPLE; return this; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCoffee.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCoffee.java index fd811ddf1..ef051c904 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCoffee.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCoffee.java @@ -10,6 +10,10 @@ package de.ellpeck.actuallyadditions.mod.booklet.chapter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; @@ -19,23 +23,19 @@ import de.ellpeck.actuallyadditions.mod.booklet.page.PageCoffeeMachine; import de.ellpeck.actuallyadditions.mod.items.ItemCoffee; import net.minecraft.item.ItemStack; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +public class BookletChapterCoffee extends BookletChapter { -public class BookletChapterCoffee extends BookletChapter{ - - public BookletChapterCoffee(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages){ + public BookletChapterCoffee(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages) { super(identifier, entry, displayStack, getPages(pages)); } - private static IBookletPage[] getPages(IBookletPage... pages){ + private static IBookletPage[] getPages(IBookletPage... pages) { List allPages = new ArrayList<>(); allPages.addAll(Arrays.asList(pages)); - for(CoffeeIngredient ingredient : ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS){ - BookletPage page = new PageCoffeeMachine(allPages.size()+1, ingredient); - if(!(ingredient instanceof ItemCoffee.MilkIngredient)){ + for (CoffeeIngredient ingredient : ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS) { + BookletPage page = new PageCoffeeMachine(allPages.size() + 1, ingredient); + if (!(ingredient instanceof ItemCoffee.MilkIngredient)) { page.setNoText(); } allPages.add(page); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCrusher.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCrusher.java index da71a6c7a..8096cfac7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCrusher.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCrusher.java @@ -10,6 +10,10 @@ package de.ellpeck.actuallyadditions.mod.booklet.chapter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; @@ -17,22 +21,18 @@ import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrusherRecipe; import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting; import net.minecraft.item.ItemStack; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +public class BookletChapterCrusher extends BookletChapter { -public class BookletChapterCrusher extends BookletChapter{ - - public BookletChapterCrusher(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages){ + public BookletChapterCrusher(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages) { super(identifier, entry, displayStack, getPages(pages)); } - private static IBookletPage[] getPages(IBookletPage... pages){ + private static IBookletPage[] getPages(IBookletPage... pages) { List allPages = new ArrayList<>(); allPages.addAll(Arrays.asList(pages)); - for(CrusherRecipe recipe : CrusherCrafting.MISC_RECIPES){ - allPages.add(new PageCrusherRecipe(allPages.size()+1, recipe).setNoText()); + for (CrusherRecipe recipe : CrusherCrafting.MISC_RECIPES) { + allPages.add(new PageCrusherRecipe(allPages.size() + 1, recipe).setNoText()); } return allPages.toArray(new IBookletPage[allPages.size()]); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterTrials.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterTrials.java index 5a7336a7c..6a6db75c2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterTrials.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterTrials.java @@ -22,25 +22,25 @@ import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class BookletChapterTrials extends BookletChapter{ +public class BookletChapterTrials extends BookletChapter { - public BookletChapterTrials(String identifier, ItemStack displayStack, boolean secondPageText){ + public BookletChapterTrials(String identifier, ItemStack displayStack, boolean secondPageText) { super(identifier, ActuallyAdditionsAPI.entryTrials, displayStack, new PageTrials(1, false, true), new PageTrials(2, true, secondPageText)); } @Override @SideOnly(Side.CLIENT) - public String getLocalizedName(){ - return StringUtil.localize("booklet."+ActuallyAdditions.MODID+".trials."+this.getIdentifier()+".name"); + public String getLocalizedName() { + return StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".trials." + this.getIdentifier() + ".name"); } @Override @SideOnly(Side.CLIENT) - public String getLocalizedNameWithFormatting(){ + public String getLocalizedNameWithFormatting() { EntityPlayer player = Minecraft.getMinecraft().player; PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player); boolean completed = data.completedTrials.contains(this.getIdentifier()); - return (completed ? TextFormatting.DARK_GREEN : TextFormatting.DARK_RED)+TextFormatting.ITALIC.toString()+this.getLocalizedName(); + return (completed ? TextFormatting.DARK_GREEN : TextFormatting.DARK_RED) + TextFormatting.ITALIC.toString() + this.getLocalizedName(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntry.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntry.java index e9685e97d..a24e1261e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntry.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntry.java @@ -10,6 +10,10 @@ package de.ellpeck.actuallyadditions.mod.booklet.entry; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; @@ -25,22 +29,18 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -public class BookletEntry implements IBookletEntry{ +public class BookletEntry implements IBookletEntry { private final String identifier; private final int priority; private final List chapters = new ArrayList<>(); private TextFormatting color; - public BookletEntry(String identifier){ + public BookletEntry(String identifier) { this(identifier, 0); } - public BookletEntry(String identifier, int prio){ + public BookletEntry(String identifier, int prio) { this.identifier = identifier; this.priority = prio; ActuallyAdditionsAPI.addBookletEntry(this); @@ -49,19 +49,17 @@ public class BookletEntry implements IBookletEntry{ } @SideOnly(Side.CLIENT) - private static boolean fitsFilter(IBookletPage page, String searchBarText){ + private static boolean fitsFilter(IBookletPage page, String searchBarText) { Minecraft mc = Minecraft.getMinecraft(); List items = new ArrayList<>(); page.getItemStacksForPage(items); - if(!items.isEmpty()){ - for(ItemStack stack : items){ - if(StackUtil.isValid(stack)){ + if (!items.isEmpty()) { + for (ItemStack stack : items) { + if (StackUtil.isValid(stack)) { List tooltip = stack.getTooltip(mc.player, mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL); - for(String strg : tooltip){ - if(strg != null && strg.toLowerCase(Locale.ROOT).contains(searchBarText)){ - return true; - } + for (String strg : tooltip) { + if (strg != null && strg.toLowerCase(Locale.ROOT).contains(searchBarText)) { return true; } } } } @@ -69,13 +67,11 @@ public class BookletEntry implements IBookletEntry{ List fluids = new ArrayList<>(); page.getFluidStacksForPage(fluids); - if(!fluids.isEmpty()){ - for(FluidStack stack : fluids){ - if(stack != null){ + if (!fluids.isEmpty()) { + for (FluidStack stack : fluids) { + if (stack != null) { String strg = stack.getLocalizedName(); - if(strg != null && strg.toLowerCase(Locale.ROOT).contains(searchBarText)){ - return true; - } + if (strg != null && strg.toLowerCase(Locale.ROOT).contains(searchBarText)) { return true; } } } } @@ -84,46 +80,45 @@ public class BookletEntry implements IBookletEntry{ } @Override - public List getAllChapters(){ + public List getAllChapters() { return this.chapters; } @Override - public String getIdentifier(){ + public String getIdentifier() { return this.identifier; } @Override @SideOnly(Side.CLIENT) - public String getLocalizedName(){ - return StringUtil.localize("booklet."+ActuallyAdditions.MODID+".indexEntry."+this.getIdentifier()+".name"); + public String getLocalizedName() { + return StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".indexEntry." + this.getIdentifier() + ".name"); } @Override @SideOnly(Side.CLIENT) - public String getLocalizedNameWithFormatting(){ - return this.color+this.getLocalizedName(); + public String getLocalizedNameWithFormatting() { + return this.color + this.getLocalizedName(); } @Override - public void addChapter(IBookletChapter chapter){ + public void addChapter(IBookletChapter chapter) { this.chapters.add(chapter); } @Override @SideOnly(Side.CLIENT) - public List getChaptersForDisplay(String searchBarText){ - if(searchBarText != null && !searchBarText.isEmpty()){ + public List getChaptersForDisplay(String searchBarText) { + if (searchBarText != null && !searchBarText.isEmpty()) { String search = searchBarText.toLowerCase(Locale.ROOT); List fittingChapters = new ArrayList<>(); - for(IBookletChapter chapter : this.getAllChapters()){ - if(chapter.getLocalizedName().toLowerCase(Locale.ROOT).contains(search)){ + for (IBookletChapter chapter : this.getAllChapters()) { + if (chapter.getLocalizedName().toLowerCase(Locale.ROOT).contains(search)) { fittingChapters.add(chapter); - } - else{ - for(IBookletPage page : chapter.getAllPages()){ - if(fitsFilter(page, search)){ + } else { + for (IBookletPage page : chapter.getAllPages()) { + if (fitsFilter(page, search)) { fittingChapters.add(chapter); break; } @@ -132,29 +127,28 @@ public class BookletEntry implements IBookletEntry{ } return fittingChapters; - } - else{ + } else { return this.getAllChapters(); } } @Override - public int getSortingPriority(){ + public int getSortingPriority() { return this.priority; } @Override @SideOnly(Side.CLIENT) - public boolean visibleOnFrontPage(){ + public boolean visibleOnFrontPage() { return true; } - public BookletEntry setImportant(){ + public BookletEntry setImportant() { this.color = TextFormatting.DARK_GREEN; return this; } - public BookletEntry setSpecial(){ + public BookletEntry setSpecial() { this.color = TextFormatting.DARK_PURPLE; return this; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntryAllItems.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntryAllItems.java index 0036b945b..9db755d92 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntryAllItems.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntryAllItems.java @@ -10,24 +10,24 @@ package de.ellpeck.actuallyadditions.mod.booklet.entry; +import java.util.List; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; -import java.util.List; +public class BookletEntryAllItems extends BookletEntry { -public class BookletEntryAllItems extends BookletEntry{ - - public BookletEntryAllItems(String identifier){ + public BookletEntryAllItems(String identifier) { super(identifier, -Integer.MAX_VALUE); } @Override - public void addChapter(IBookletChapter chapter){ + public void addChapter(IBookletChapter chapter) { } @Override - public List getAllChapters(){ + public List getAllChapters() { return ActuallyAdditionsAPI.ALL_CHAPTERS; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntryTrials.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntryTrials.java index 15ddf4cda..dd3fc7ec8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntryTrials.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntryTrials.java @@ -10,14 +10,14 @@ package de.ellpeck.actuallyadditions.mod.booklet.entry; -public class BookletEntryTrials extends BookletEntry{ +public class BookletEntryTrials extends BookletEntry { - public BookletEntryTrials(String identifier){ + public BookletEntryTrials(String identifier) { super(identifier, -Integer.MAX_VALUE); } @Override - public boolean visibleOnFrontPage(){ + public boolean visibleOnFrontPage() { return false; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiBooklet.java index 52f61d568..bdfc6ee57 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiBooklet.java @@ -10,6 +10,14 @@ package de.ellpeck.actuallyadditions.mod.booklet.gui; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; @@ -30,16 +38,9 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import org.apache.commons.lang3.ArrayUtils; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; @SideOnly(Side.CLIENT) -public abstract class GuiBooklet extends GuiBookletBase{ +public abstract class GuiBooklet extends GuiBookletBase { public static final int BUTTONS_PER_PAGE = 12; public static final ResourceLocation RES_LOC_GUI = AssetUtil.getBookletGuiLocation("gui_booklet"); @@ -62,7 +63,7 @@ public abstract class GuiBooklet extends GuiBookletBase{ private float mediumFontSize; private float largeFontSize; - public GuiBooklet(GuiScreen previousScreen, GuiBookletBase parentPage){ + public GuiBooklet(GuiScreen previousScreen, GuiBookletBase parentPage) { this.previousScreen = previousScreen; this.parentPage = parentPage; @@ -70,65 +71,63 @@ public abstract class GuiBooklet extends GuiBookletBase{ this.ySize = 180; } - private static float getFontSize(String lang, ConfigIntValues config, float defaultValue){ + private static float getFontSize(String lang, ConfigIntValues config, float defaultValue) { int conf = config.getValue(); - if(conf <= 0){ - try{ - return Float.parseFloat(StringUtil.localize("booklet."+ActuallyAdditions.MODID+".fontSize."+lang)); - } - catch(Exception e){ + if (conf <= 0) { + try { + return Float.parseFloat(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".fontSize." + lang)); + } catch (Exception e) { return defaultValue; } - } - else{ - return conf/100F; + } else { + return conf / 100F; } } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.guiLeft = (this.width-this.xSize)/2; - this.guiTop = (this.height-this.ySize)/2; + this.guiLeft = (this.width - this.xSize) / 2; + this.guiTop = (this.height - this.ySize) / 2; this.smallFontSize = getFontSize("small", ConfigIntValues.FONT_SIZE_SMALL, 0.5F); this.mediumFontSize = getFontSize("medium", ConfigIntValues.FONT_SIZE_MEDIUM, 0.75F); this.largeFontSize = getFontSize("large", ConfigIntValues.FONT_SIZE_LARGE, 0.8F); - if(this.hasPageLeftButton()){ - List hoverText = Arrays.asList(TextFormatting.GOLD+"Previous Page", TextFormatting.ITALIC+"Or scroll up"); - this.buttonLeft = new TexturedButton(RES_LOC_GADGETS, -2000, this.guiLeft-12, this.guiTop+this.ySize-8, 18, 54, 18, 10, hoverText); + if (this.hasPageLeftButton()) { + List hoverText = Arrays.asList(TextFormatting.GOLD + "Previous Page", TextFormatting.ITALIC + "Or scroll up"); + this.buttonLeft = new TexturedButton(RES_LOC_GADGETS, -2000, this.guiLeft - 12, this.guiTop + this.ySize - 8, 18, 54, 18, 10, hoverText); this.buttonList.add(this.buttonLeft); } - if(this.hasPageRightButton()){ - List hoverText = Arrays.asList(TextFormatting.GOLD+"Next Page", TextFormatting.ITALIC+"Or scroll down"); - this.buttonRight = new TexturedButton(RES_LOC_GADGETS, -2001, this.guiLeft+this.xSize-6, this.guiTop+this.ySize-8, 0, 54, 18, 10, hoverText); + if (this.hasPageRightButton()) { + List hoverText = Arrays.asList(TextFormatting.GOLD + "Next Page", TextFormatting.ITALIC + "Or scroll down"); + this.buttonRight = new TexturedButton(RES_LOC_GADGETS, -2001, this.guiLeft + this.xSize - 6, this.guiTop + this.ySize - 8, 0, 54, 18, 10, hoverText); this.buttonList.add(this.buttonRight); } - if(this.hasBackButton()){ - List hoverText = Arrays.asList(TextFormatting.GOLD+"Go Back", TextFormatting.ITALIC+"Or right-click", TextFormatting.ITALIC.toString()+TextFormatting.GRAY+"Hold Shift for Main Page"); - this.buttonBack = new TexturedButton(RES_LOC_GADGETS, -2002, this.guiLeft-15, this.guiTop-3, 36, 54, 18, 10, hoverText); + if (this.hasBackButton()) { + List hoverText = Arrays.asList(TextFormatting.GOLD + "Go Back", TextFormatting.ITALIC + "Or right-click", TextFormatting.ITALIC.toString() + TextFormatting.GRAY + "Hold Shift for Main Page"); + this.buttonBack = new TexturedButton(RES_LOC_GADGETS, -2002, this.guiLeft - 15, this.guiTop - 3, 36, 54, 18, 10, hoverText); this.buttonList.add(this.buttonBack); } - if(this.hasSearchBar()){ - this.searchField = new GuiTextField(-420, this.fontRenderer, this.guiLeft+this.xSize+2, this.guiTop+this.ySize-40+2, 64, 12); + if (this.hasSearchBar()) { + this.searchField = new GuiTextField(-420, this.fontRenderer, this.guiLeft + this.xSize + 2, this.guiTop + this.ySize - 40 + 2, 64, 12); this.searchField.setMaxStringLength(50); this.searchField.setEnableBackgroundDrawing(false); } - if(this.hasBookmarkButtons()){ + if (this.hasBookmarkButtons()) { PlayerSave data = PlayerData.getDataFromPlayer(this.mc.player); - int xStart = this.guiLeft+this.xSize/2-16*this.bookmarkButtons.length/2; - for(int i = 0; i < this.bookmarkButtons.length; i++){ - this.bookmarkButtons[i] = new BookmarkButton(1337+i, xStart+i*16, this.guiTop+this.ySize, this); + int xStart = this.guiLeft + this.xSize / 2 - 16 * this.bookmarkButtons.length / 2; + for (int i = 0; i < this.bookmarkButtons.length; i++) { + this.bookmarkButtons[i] = new BookmarkButton(1337 + i, xStart + i * 16, this.guiTop + this.ySize, this); this.buttonList.add(this.bookmarkButtons[i]); - if(data.bookmarks[i] != null){ + if (data.bookmarks[i] != null) { this.bookmarkButtons[i].assignedPage = data.bookmarks[i]; } } @@ -139,50 +138,50 @@ public abstract class GuiBooklet extends GuiBookletBase{ } @Override - public void onGuiClosed(){ + public void onGuiClosed() { super.onGuiClosed(); //Don't cache the parent GUI, otherwise it opens again when you close the cached book! this.previousScreen = null; - if(this.mc.player == null) return; + if (this.mc.player == null) return; PlayerSave data = PlayerData.getDataFromPlayer(this.mc.player); data.lastOpenBooklet = this; boolean change = false; - for(int i = 0; i < this.bookmarkButtons.length; i++){ - if(data.bookmarks[i] != this.bookmarkButtons[i].assignedPage){ + for (int i = 0; i < this.bookmarkButtons.length; i++) { + if (data.bookmarks[i] != this.bookmarkButtons[i].assignedPage) { data.bookmarks[i] = this.bookmarkButtons[i].assignedPage; change = true; } } - if(change){ + if (change) { PacketHandlerHelper.sendPlayerDataToServer(true, 0); } } @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks){ + public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawScreenPre(mouseX, mouseY, partialTicks); super.drawScreen(mouseX, mouseY, partialTicks); this.drawScreenPost(mouseX, mouseY, partialTicks); } - public void drawScreenPre(int mouseX, int mouseY, float partialTicks){ + public void drawScreenPre(int mouseX, int mouseY, float partialTicks) { GlStateManager.color(1F, 1F, 1F); this.mc.getTextureManager().bindTexture(RES_LOC_GUI); drawModalRectWithCustomSizedTexture(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize, 512, 512); - if(this.hasSearchBar()){ + if (this.hasSearchBar()) { this.mc.getTextureManager().bindTexture(RES_LOC_GADGETS); - this.drawTexturedModalRect(this.guiLeft+this.xSize, this.guiTop+this.ySize-40, 188, 0, 68, 14); + this.drawTexturedModalRect(this.guiLeft + this.xSize, this.guiTop + this.ySize - 40, 188, 0, 68, 14); boolean unicodeBefore = this.fontRenderer.getUnicodeFlag(); this.fontRenderer.setUnicodeFlag(true); - if(!this.searchField.isFocused() && (this.searchField.getText() == null || this.searchField.getText().isEmpty())){ - this.fontRenderer.drawString(TextFormatting.ITALIC+StringUtil.localize("info."+ActuallyAdditions.MODID+".booklet.searchField"), this.guiLeft+this.xSize+2, this.guiTop+this.ySize-40+2, 0xFFFFFF, false); + if (!this.searchField.isFocused() && (this.searchField.getText() == null || this.searchField.getText().isEmpty())) { + this.fontRenderer.drawString(TextFormatting.ITALIC + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.searchField"), this.guiLeft + this.xSize + 2, this.guiTop + this.ySize - 40 + 2, 0xFFFFFF, false); } this.searchField.drawTextBox(); @@ -191,41 +190,39 @@ public abstract class GuiBooklet extends GuiBookletBase{ } } - public void drawScreenPost(int mouseX, int mouseY, float partialTicks){ - for(GuiButton button : this.buttonList){ - if(button instanceof BookmarkButton){ - ((BookmarkButton)button).drawHover(mouseX, mouseY); - } - else if(button instanceof TexturedButton){ - ((TexturedButton)button).drawHover(mouseX, mouseY); + public void drawScreenPost(int mouseX, int mouseY, float partialTicks) { + for (GuiButton button : this.buttonList) { + if (button instanceof BookmarkButton) { + ((BookmarkButton) button).drawHover(mouseX, mouseY); + } else if (button instanceof TexturedButton) { + ((TexturedButton) button).drawHover(mouseX, mouseY); } } } @Override - protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException{ + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); - if(this.hasSearchBar()){ + if (this.hasSearchBar()) { this.searchField.mouseClicked(mouseX, mouseY, mouseButton); } - if(mouseButton == 1 && this.hasBackButton()){ + if (mouseButton == 1 && this.hasBackButton()) { this.onBackButtonPressed(); } } @Override - public void handleMouseInput() throws IOException{ + public void handleMouseInput() throws IOException { int wheel = Mouse.getEventDWheel(); - if(wheel != 0){ - if(wheel < 0){ - if(this.hasPageRightButton()){ + if (wheel != 0) { + if (wheel < 0) { + if (this.hasPageRightButton()) { this.onPageRightButtonPressed(); } - } - else if(wheel > 0){ - if(this.hasPageLeftButton()){ + } else if (wheel > 0) { + if (this.hasPageLeftButton()) { this.onPageLeftButtonPressed(); } } @@ -234,151 +231,145 @@ public abstract class GuiBooklet extends GuiBookletBase{ } @Override - public void updateScreen(){ + public void updateScreen() { super.updateScreen(); - if(this.hasSearchBar()){ + if (this.hasSearchBar()) { this.searchField.updateCursorCounter(); } } @Override - public boolean doesGuiPauseGame(){ + public boolean doesGuiPauseGame() { return false; } - public boolean hasPageLeftButton(){ + public boolean hasPageLeftButton() { return false; } - public void onPageLeftButtonPressed(){ + public void onPageLeftButtonPressed() { } - public boolean hasPageRightButton(){ + public boolean hasPageRightButton() { return false; } - public void onPageRightButtonPressed(){ + public void onPageRightButtonPressed() { } - public boolean areTrialsOpened(){ + public boolean areTrialsOpened() { return false; } - public boolean hasBackButton(){ + public boolean hasBackButton() { return false; } - public void onBackButtonPressed(){ + public void onBackButtonPressed() { this.mc.displayGuiScreen(new GuiMainPage(this.previousScreen)); } - public boolean hasSearchBar(){ + public boolean hasSearchBar() { return true; } - public boolean hasBookmarkButtons(){ + public boolean hasBookmarkButtons() { return true; } @Override - public float getSmallFontSize(){ + public float getSmallFontSize() { return this.smallFontSize; } @Override - public float getMediumFontSize(){ + public float getMediumFontSize() { return this.mediumFontSize; } @Override - public float getLargeFontSize(){ + public float getLargeFontSize() { return this.largeFontSize; } - public void onSearchBarChanged(String searchBarText){ + public void onSearchBarChanged(String searchBarText) { GuiBookletBase parent = !(this instanceof GuiEntry) ? this : this.parentPage; this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, parent, ActuallyAdditionsAPI.entryAllAndSearch, 0, searchBarText, true)); } @Override - protected void actionPerformed(GuiButton button) throws IOException{ - if(this.hasPageLeftButton() && button == this.buttonLeft){ + protected void actionPerformed(GuiButton button) throws IOException { + if (this.hasPageLeftButton() && button == this.buttonLeft) { this.onPageLeftButtonPressed(); - } - else if(this.hasPageRightButton() && button == this.buttonRight){ + } else if (this.hasPageRightButton() && button == this.buttonRight) { this.onPageRightButtonPressed(); - } - else if(this.hasBackButton() && button == this.buttonBack){ + } else if (this.hasBackButton() && button == this.buttonBack) { this.onBackButtonPressed(); } - if(button == this.buttonTrials){ + if (button == this.buttonTrials) { this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, this, ActuallyAdditionsAPI.entryTrials, 0, "", false)); - } - else if(this.hasBookmarkButtons() && button instanceof BookmarkButton){ + } else if (this.hasBookmarkButtons() && button instanceof BookmarkButton) { int index = ArrayUtils.indexOf(this.bookmarkButtons, button); - if(index >= 0){ + if (index >= 0) { this.bookmarkButtons[index].onPressed(); } - } - else{ + } else { super.actionPerformed(button); } } @Override - protected void keyTyped(char typedChar, int key) throws IOException{ - if(key == Keyboard.KEY_ESCAPE || key == this.mc.gameSettings.keyBindInventory.getKeyCode() && (!this.hasSearchBar() || !this.searchField.isFocused())){ + protected void keyTyped(char typedChar, int key) throws IOException { + if (key == Keyboard.KEY_ESCAPE || key == this.mc.gameSettings.keyBindInventory.getKeyCode() && (!this.hasSearchBar() || !this.searchField.isFocused())) { this.mc.displayGuiScreen(this.previousScreen); - } - else if(this.hasSearchBar() & this.searchField.isFocused()){ + } else if (this.hasSearchBar() & this.searchField.isFocused()) { String lastText = this.searchField.getText(); this.searchField.textboxKeyTyped(typedChar, key); - if(!lastText.equals(this.searchField.getText())){ + if (!lastText.equals(this.searchField.getText())) { this.onSearchBarChanged(this.searchField.getText()); } - } - else{ + } else { super.keyTyped(typedChar, key); } } @Override - public void renderScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale){ + public void renderScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale) { StringUtil.renderScaledAsciiString(this.fontRenderer, text, x, y, color, shadow, scale); } @Override - public void renderSplitScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale, int length){ + public void renderSplitScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale, int length) { StringUtil.renderSplitScaledAsciiString(this.fontRenderer, text, x, y, color, shadow, scale, length); } @Override - public List getButtonList(){ + public List getButtonList() { return this.buttonList; } @Override - public int getGuiLeft(){ + public int getGuiLeft() { return this.guiLeft; } @Override - public int getGuiTop(){ + public int getGuiTop() { return this.guiTop; } @Override - public int getSizeX(){ + public int getSizeX() { return this.xSize; } @Override - public int getSizeY(){ + public int getSizeY() { return this.ySize; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java index 7c68e21a4..95f8c058c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.booklet.gui; +import java.io.IOException; +import java.util.List; + import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; @@ -23,11 +26,8 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.io.IOException; -import java.util.List; - @SideOnly(Side.CLIENT) -public class GuiEntry extends GuiBooklet{ +public class GuiEntry extends GuiBooklet { //The page in the entry. Say you have 2 more chapters than fit on one double page, then those 2 would be displayed on entryPage 1 instead. private final int entryPage; @@ -37,7 +37,7 @@ public class GuiEntry extends GuiBooklet{ private final String searchText; private final boolean focusSearch; - public GuiEntry(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletEntry entry, int entryPage, String search, boolean focusSearch){ + public GuiEntry(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletEntry entry, int entryPage, String search, boolean focusSearch) { super(previousScreen, parentPage); this.entryPage = entryPage; this.entry = entry; @@ -45,57 +45,55 @@ public class GuiEntry extends GuiBooklet{ this.focusSearch = focusSearch; this.chapters = entry.getChaptersForDisplay(search); - if(!this.chapters.isEmpty()){ - IBookletChapter lastChap = this.chapters.get(this.chapters.size()-1); - this.pageAmount = lastChap == null ? 1 : calcEntryPage(this.entry, lastChap, this.searchText)+1; - } - else{ + if (!this.chapters.isEmpty()) { + IBookletChapter lastChap = this.chapters.get(this.chapters.size() - 1); + this.pageAmount = lastChap == null ? 1 : calcEntryPage(this.entry, lastChap, this.searchText) + 1; + } else { this.pageAmount = 1; } } - public GuiEntry(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletEntry entry, IBookletChapter chapterForPageCalc, String search, boolean focusSearch){ + public GuiEntry(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletEntry entry, IBookletChapter chapterForPageCalc, String search, boolean focusSearch) { this(previousScreen, parentPage, entry, calcEntryPage(entry, chapterForPageCalc, search), search, focusSearch); } - private static int calcEntryPage(IBookletEntry entry, IBookletChapter chapterForPageCalc, String search){ + private static int calcEntryPage(IBookletEntry entry, IBookletChapter chapterForPageCalc, String search) { int index = entry.getChaptersForDisplay(search).indexOf(chapterForPageCalc); - return index/(BUTTONS_PER_PAGE*2); + return index / (BUTTONS_PER_PAGE * 2); } @Override - public void drawScreenPre(int mouseX, int mouseY, float partialTicks){ + public void drawScreenPre(int mouseX, int mouseY, float partialTicks) { super.drawScreenPre(mouseX, mouseY, partialTicks); String name = this.entry.getLocalizedName(); - this.fontRenderer.drawString(name, this.guiLeft+this.xSize/2-this.fontRenderer.getStringWidth(name)/2, this.guiTop-1, 0xFFFFFF, true); + this.fontRenderer.drawString(name, this.guiLeft + this.xSize / 2 - this.fontRenderer.getStringWidth(name) / 2, this.guiTop - 1, 0xFFFFFF, true); - for(int i = 0; i < 2; i++){ - String pageStrg = "Page "+(this.entryPage*2+i+1)+"/"+this.pageAmount*2; - this.renderScaledAsciiString(pageStrg, this.guiLeft+25+i*136, this.guiTop+this.ySize-7, 0xFFFFFF, false, this.getLargeFontSize()); + for (int i = 0; i < 2; i++) { + String pageStrg = "Page " + (this.entryPage * 2 + i + 1) + "/" + this.pageAmount * 2; + this.renderScaledAsciiString(pageStrg, this.guiLeft + 25 + i * 136, this.guiTop + this.ySize - 7, 0xFFFFFF, false, this.getLargeFontSize()); } } @Override - public void initGui(){ + public void initGui() { super.initGui(); - if(this.hasSearchBar() && this.searchText != null){ + if (this.hasSearchBar() && this.searchText != null) { this.searchField.setText(this.searchText); - if(this.focusSearch){ + if (this.focusSearch) { this.searchField.setFocused(true); } } - int idOffset = this.entryPage*BUTTONS_PER_PAGE*2; - for(int x = 0; x < 2; x++){ - for(int y = 0; y < BUTTONS_PER_PAGE; y++){ - int id = y+x*BUTTONS_PER_PAGE; - if(this.chapters.size() > id+idOffset){ - IBookletChapter chapter = this.chapters.get(id+idOffset); - this.buttonList.add(new EntryButton(this, id, this.guiLeft+14+x*142, this.guiTop+11+y*13, 115, 10, chapter.getLocalizedNameWithFormatting(), chapter.getDisplayItemStack())); - } - else{ + int idOffset = this.entryPage * BUTTONS_PER_PAGE * 2; + for (int x = 0; x < 2; x++) { + for (int y = 0; y < BUTTONS_PER_PAGE; y++) { + int id = y + x * BUTTONS_PER_PAGE; + if (this.chapters.size() > id + idOffset) { + IBookletChapter chapter = this.chapters.get(id + idOffset); + this.buttonList.add(new EntryButton(this, id, this.guiLeft + 14 + x * 142, this.guiTop + 11 + y * 13, 115, 10, chapter.getLocalizedNameWithFormatting(), chapter.getDisplayItemStack())); + } else { return; } } @@ -103,67 +101,65 @@ public class GuiEntry extends GuiBooklet{ } @Override - protected void actionPerformed(GuiButton button) throws IOException{ - if(button instanceof EntryButton){ - int actualId = button.id+this.entryPage*BUTTONS_PER_PAGE*2; + protected void actionPerformed(GuiButton button) throws IOException { + if (button instanceof EntryButton) { + int actualId = button.id + this.entryPage * BUTTONS_PER_PAGE * 2; - if(this.chapters.size() > actualId){ + if (this.chapters.size() > actualId) { IBookletChapter chapter = this.chapters.get(actualId); - if(chapter != null){ + if (chapter != null) { IBookletPage[] pages = chapter.getAllPages(); - if(pages != null && pages.length > 0){ + if (pages != null && pages.length > 0) { this.mc.displayGuiScreen(BookletUtils.createPageGui(this.previousScreen, this, pages[0])); } } } - } - else{ + } else { super.actionPerformed(button); } } @Override - public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer){ + public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer) { } @Override - public boolean hasPageLeftButton(){ + public boolean hasPageLeftButton() { return this.entryPage > 0; } @Override - public void onPageLeftButtonPressed(){ - this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, this.parentPage, this.entry, this.entryPage-1, this.searchText, this.searchField.isFocused())); + public void onPageLeftButtonPressed() { + this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, this.parentPage, this.entry, this.entryPage - 1, this.searchText, this.searchField.isFocused())); } @Override - public boolean hasPageRightButton(){ - return !this.chapters.isEmpty() && this.entryPage < this.pageAmount-1; + public boolean hasPageRightButton() { + return !this.chapters.isEmpty() && this.entryPage < this.pageAmount - 1; } @Override - public void onPageRightButtonPressed(){ - this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, this.parentPage, this.entry, this.entryPage+1, this.searchText, this.searchField.isFocused())); + public void onPageRightButtonPressed() { + this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, this.parentPage, this.entry, this.entryPage + 1, this.searchText, this.searchField.isFocused())); } @Override - public boolean hasBackButton(){ + public boolean hasBackButton() { return true; } @Override - public void onBackButtonPressed(){ - if(!isShiftKeyDown()){ + public void onBackButtonPressed() { + if (!isShiftKeyDown()) { this.mc.displayGuiScreen(this.parentPage); - } - else{ + } else { super.onBackButtonPressed(); } } @Override - public boolean areTrialsOpened(){ + public boolean areTrialsOpened() { return this.entry instanceof BookletEntryTrials; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiMainPage.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiMainPage.java index 2b0be116b..e6f687e88 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiMainPage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiMainPage.java @@ -10,6 +10,10 @@ package de.ellpeck.actuallyadditions.mod.booklet.gui; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; @@ -30,61 +34,11 @@ import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - //TODO Fix achievement button @SideOnly(Side.CLIENT) -public class GuiMainPage extends GuiBooklet{ +public class GuiMainPage extends GuiBooklet { - private static final String[] QUOTES = new String[]{ - "Actually Additions, to me, is quite magical in a way.@Saphrym", - "Actually quite cool. Lots of nice little additions.@Direwolf20", - "Mod Dev quite rude and arrogant@Bubb1e0seven", - "A whimsical breath of fresh air in a stuffy tech-mod world.@mezz", - "User-friendly :3@TheMeeep", - "A lot of stuff, some of it really good.@Narubion", - "I like the bookmarks.@Vazkii", - "It's got some stuff I guess.@Ellpeck", - "Actually Additions should be included in every new modpack that includes any form of tech.@YasminEndusa", - "A mod that basically lets you do what ever the heck you want.@Ristelle", - "TINY TORCHES!! BABY TORCHES!! Somebody actually finally did it!!@Soaryn", - "Balanced mod wich makes things different - in a good way.@garantiertnicht", - "The mod everyone needs, but not everyone knows@Brewpl", - "The in-game documentation is the best I’ve seen. I especially love the JEI integration. Even a derp like me can figure it out.@dannydjdk", - "The second best mod I've ever used.@mmaas44", - "The Fermenting Barrel is one of my favorite textures.@amadornes", - "Smiley Clouds is the reason for fascism in 2016.@raoulvdberge", - "The worms are an awesome idea!@greenking", - "Can I use that mod in my pack?@Ibraheem", - "Hello, love the mod.@SuntannedDuck2", - "Quick! Have all the fun before they nerf it!@JuddMan03", - "I have a feeling Actually Additions is also like Extra Utilities with Random things smashed together why is it...@lesslighter", - "Leaf eater... munchdew... hummm@EiOs", - "There is no such thing as canola seeds.@AlBoVa", - "This mod is cancer, BRUTAL EXPENSIVE POWER usage..Just, cancer.@KoJo", - "Spaghetti is spaghetti, and noodles are noodles.@robsonld04", - "The Actually Additions name is actually true. It's actually great!@asiekierka", - "Such a great mod@jsdeveloper", - "That mod is kind of funny.@Anonymous", - "Actually Additions is a lot of fun.@Anonymous", - "Is Actually Additions still fugly?@Anonymous", - "I like it, but it's so small.@Anonymous", - "It has a couple of blocks I like, but overall it's just a mess.@Anonymous", - "Direwolf's 1.10 playthrough is just him shilling Actually Additions@Anonymous", - "We thought about sending the author a bunch of pizzas to his adress@Anonymous", - "It's op as heck.@billofbong0", - "Actually AdditionsってマイクラMODすごく良いのに日本人で遊んでる人あんまいないっぽい@stay_uk", - "Actually Additions is OP. Not like my favorite combination of mods, Project E + Magic Crops + Draconic Evolution.@Anonymous", - "To be perfectly honest, I never actually realized how much content Actually Additions has before.@Ellpeck", - "I don't blame you, I actually downgraded to Actually Additions.@PvtSeaCow", - "It is lonely because there is no device to fly items with the laser in the 1.7.10 version.@Google Translate", - "始めまして。日本人です。このMODは本当に素晴らしい!ただ、1.7.10ヴァージョンだと、レーザーでアイテムを飛ばす装置がないので寂しいです。@Anonymous", - "Some verses found in older translations, such as the KJV were actually additions made by later copyists.@Pat_Joel", - "I can't place filters into Laser Relays, but the mod is very cool.@LP_Jakob", - "Am I good enough to be an Actually Additions tool?@deanwhufc" - }; + private static final String[] QUOTES = new String[] { "Actually Additions, to me, is quite magical in a way.@Saphrym", "Actually quite cool. Lots of nice little additions.@Direwolf20", "Mod Dev quite rude and arrogant@Bubb1e0seven", "A whimsical breath of fresh air in a stuffy tech-mod world.@mezz", "User-friendly :3@TheMeeep", "A lot of stuff, some of it really good.@Narubion", "I like the bookmarks.@Vazkii", "It's got some stuff I guess.@Ellpeck", "Actually Additions should be included in every new modpack that includes any form of tech.@YasminEndusa", "A mod that basically lets you do what ever the heck you want.@Ristelle", "TINY TORCHES!! BABY TORCHES!! Somebody actually finally did it!!@Soaryn", "Balanced mod wich makes things different - in a good way.@garantiertnicht", "The mod everyone needs, but not everyone knows@Brewpl", "The in-game documentation is the best I’ve seen. I especially love the JEI integration. Even a derp like me can figure it out.@dannydjdk", "The second best mod I've ever used.@mmaas44", "The Fermenting Barrel is one of my favorite textures.@amadornes", "Smiley Clouds is the reason for fascism in 2016.@raoulvdberge", "The worms are an awesome idea!@greenking", "Can I use that mod in my pack?@Ibraheem", "Hello, love the mod.@SuntannedDuck2", "Quick! Have all the fun before they nerf it!@JuddMan03", "I have a feeling Actually Additions is also like Extra Utilities with Random things smashed together why is it...@lesslighter", "Leaf eater... munchdew... hummm@EiOs", "There is no such thing as canola seeds.@AlBoVa", "This mod is cancer, BRUTAL EXPENSIVE POWER usage..Just, cancer.@KoJo", "Spaghetti is spaghetti, and noodles are noodles.@robsonld04", "The Actually Additions name is actually true. It's actually great!@asiekierka", "Such a great mod@jsdeveloper", "That mod is kind of funny.@Anonymous", "Actually Additions is a lot of fun.@Anonymous", "Is Actually Additions still fugly?@Anonymous", "I like it, but it's so small.@Anonymous", "It has a couple of blocks I like, but overall it's just a mess.@Anonymous", "Direwolf's 1.10 playthrough is just him shilling Actually Additions@Anonymous", "We thought about sending the author a bunch of pizzas to his adress@Anonymous", "It's op as heck.@billofbong0", "Actually AdditionsってマイクラMODすごく良いのに日本人で遊んでる人あんまいないっぽい@stay_uk", "Actually Additions is OP. Not like my favorite combination of mods, Project E + Magic Crops + Draconic Evolution.@Anonymous", "To be perfectly honest, I never actually realized how much content Actually Additions has before.@Ellpeck", "I don't blame you, I actually downgraded to Actually Additions.@PvtSeaCow", "It is lonely because there is no device to fly items with the laser in the 1.7.10 version.@Google Translate", "始めまして。日本人です。このMODは本当に素晴らしい!ただ、1.7.10ヴァージョンだと、レーザーでアイテムを飛ばす装置がないので寂しいです。@Anonymous", "Some verses found in older translations, such as the KJV were actually additions made by later copyists.@Pat_Joel", "I can't place filters into Laser Relays, but the mod is very cool.@LP_Jakob", "Am I good enough to be an Actually Additions tool?@deanwhufc" }; //private TexturedButton achievementButton; private TexturedButton configButton; @@ -98,15 +52,15 @@ public class GuiMainPage extends GuiBooklet{ private List quote; private String quoteGuy; - public GuiMainPage(GuiScreen previousScreen){ + public GuiMainPage(GuiScreen previousScreen) { super(previousScreen, null); } - private static List getDisplayedEntries(){ + private static List getDisplayedEntries() { List displayed = new ArrayList<>(); - for(IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES){ - if(entry.visibleOnFrontPage()){ + for (IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES) { + if (entry.visibleOnFrontPage()) { displayed.add(entry); } } @@ -115,129 +69,110 @@ public class GuiMainPage extends GuiBooklet{ } @Override - public void initGui(){ + public void initGui() { super.initGui(); int flavor = 1; - if(this.mc.world.rand.nextFloat() <= 0.1){ + if (this.mc.world.rand.nextFloat() <= 0.1) { flavor = MathHelper.getInt(this.mc.world.rand, 2, 7); } - this.bookletName = "info."+ActuallyAdditions.MODID+".booklet.manualName.1."+flavor; + this.bookletName = "info." + ActuallyAdditions.MODID + ".booklet.manualName.1." + flavor; String usedQuote = QUOTES[this.mc.world.rand.nextInt(QUOTES.length)]; String[] quoteSplit = usedQuote.split("@"); - if(quoteSplit.length == 2){ + if (quoteSplit.length == 2) { this.quote = this.fontRenderer.listFormattedStringToWidth(quoteSplit[0], 120); this.quoteGuy = quoteSplit[1]; } String playerName = this.mc.player.getName(); - if(playerName.equalsIgnoreCase("dqmhose")){ + if (playerName.equalsIgnoreCase("dqmhose")) { this.bookletEdition = "Pants Edition"; - } - else if(playerName.equalsIgnoreCase("TwoOfEight") || playerName.equalsIgnoreCase("BootyToast")){ + } else if (playerName.equalsIgnoreCase("TwoOfEight") || playerName.equalsIgnoreCase("BootyToast")) { this.bookletEdition = "Illustrator's Edition"; - } - else if(playerName.equalsIgnoreCase("KittyVanCat")){ + } else if (playerName.equalsIgnoreCase("KittyVanCat")) { this.bookletEdition = "Cat's Edition"; - } - else if(playerName.equalsIgnoreCase("canitzp")){ + } else if (playerName.equalsIgnoreCase("canitzp")) { this.bookletEdition = "P's Edition"; - } - else if(playerName.equalsIgnoreCase("direwolf20")){ + } else if (playerName.equalsIgnoreCase("direwolf20")) { this.bookletEdition = "Edition 20"; - } - else if(playerName.equalsIgnoreCase("dannydjdk") || playerName.equalsIgnoreCase("andrew_period")){ + } else if (playerName.equalsIgnoreCase("dannydjdk") || playerName.equalsIgnoreCase("andrew_period")) { this.bookletEdition = "Derp's Edition"; - } - else if(playerName.equalsIgnoreCase("mezz")){ + } else if (playerName.equalsIgnoreCase("mezz")) { this.bookletEdition = "Just Enough Editions"; - } - else if(playerName.equalsIgnoreCase("amadornes")){ + } else if (playerName.equalsIgnoreCase("amadornes")) { this.bookletEdition = "Beard's Edition"; - } - else if(playerName.equalsIgnoreCase("raoul")){ + } else if (playerName.equalsIgnoreCase("raoul")) { this.bookletEdition = "Giraffe's Edition"; - } - else if(playerName.equalsIgnoreCase("ellpeck") || playerName.equalsIgnoreCase("profprospector")){ + } else if (playerName.equalsIgnoreCase("ellpeck") || playerName.equalsIgnoreCase("profprospector")) { String[] colors = new String[15]; - for(int i = 0; i < colors.length; i++){ - colors[i] = TextFormatting.fromColorIndex(this.mc.world.rand.nextInt(15)).toString()+TextFormatting.ITALIC; + for (int i = 0; i < colors.length; i++) { + colors[i] = TextFormatting.fromColorIndex(this.mc.world.rand.nextInt(15)).toString() + TextFormatting.ITALIC; } - this.bookletEdition = String.format("%sC%so%sl%so%sr%sf%su%sl %sE%sd%si%st%si%so%sn", (Object[])colors); - } - else if(playerName.equalsIgnoreCase("oitsjustjose")){ + this.bookletEdition = String.format("%sC%so%sl%so%sr%sf%su%sl %sE%sd%si%st%si%so%sn", (Object[]) colors); + } else if (playerName.equalsIgnoreCase("oitsjustjose")) { this.bookletEdition = "oitsjustanedition"; - } - else if(playerName.equalsIgnoreCase("xbony2")){ + } else if (playerName.equalsIgnoreCase("xbony2")) { this.bookletEdition = "Naughty Edition"; - } - else if(playerName.equalsIgnoreCase("themattabase")){ + } else if (playerName.equalsIgnoreCase("themattabase")) { this.bookletEdition = "Withered Edition"; - } - else if(playerName.equalsIgnoreCase("robsonld04")){ + } else if (playerName.equalsIgnoreCase("robsonld04")) { this.bookletEdition = "Modpack Edition"; - } - else if(playerName.equalsIgnoreCase("snowshock35")){ + } else if (playerName.equalsIgnoreCase("snowshock35")) { this.bookletEdition = "Edition 35"; - } - else if(playerName.equalsIgnoreCase("asiekierka")){ + } else if (playerName.equalsIgnoreCase("asiekierka")) { this.bookletEdition = "‽ Edition"; - } - else if(playerName.equalsIgnoreCase("elucent")){ + } else if (playerName.equalsIgnoreCase("elucent")) { this.bookletEdition = ""; - } - else{ - if(Util.isDevVersion()){ + } else { + if (Util.isDevVersion()) { this.bookletEdition = "Dev's Edition"; - } - else{ - this.bookletEdition = StringUtil.localize("info."+ActuallyAdditions.MODID+".booklet.edition")+" "+Util.getMajorModVersion(); + } else { + this.bookletEdition = StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.edition") + " " + Util.getMajorModVersion(); } } List configText = new ArrayList<>(); - configText.add(TextFormatting.GOLD+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".configButton.name")); - configText.addAll(this.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("booklet."+ActuallyAdditions.MODID+".configButton.desc", ActuallyAdditions.NAME).replaceAll("\\\\n", "\n"), 200)); - this.configButton = new TexturedButton(RES_LOC_GADGETS, -388, this.guiLeft+16, this.guiTop+this.ySize-30, 188, 14, 16, 16, configText); + configText.add(TextFormatting.GOLD + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".configButton.name")); + configText.addAll(this.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("booklet." + ActuallyAdditions.MODID + ".configButton.desc", ActuallyAdditions.NAME).replaceAll("\\\\n", "\n"), 200)); + this.configButton = new TexturedButton(RES_LOC_GADGETS, -388, this.guiLeft + 16, this.guiTop + this.ySize - 30, 188, 14, 16, 16, configText); this.buttonList.add(this.configButton); List achievementText = new ArrayList<>(); - achievementText.add(TextFormatting.GOLD+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".achievementButton.name")); - achievementText.addAll(this.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("booklet."+ActuallyAdditions.MODID+".achievementButton.desc", ActuallyAdditions.NAME), 200)); + achievementText.add(TextFormatting.GOLD + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".achievementButton.name")); + achievementText.addAll(this.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("booklet." + ActuallyAdditions.MODID + ".achievementButton.desc", ActuallyAdditions.NAME), 200)); //this.achievementButton = new TexturedButton(RES_LOC_GADGETS, -389, this.guiLeft+36, this.guiTop+this.ySize-30, 204, 14, 16, 16, achievementText); //this.buttonList.add(this.achievementButton); PlayerSave data = PlayerData.getDataFromPlayer(this.mc.player); - if(!data.didBookTutorial){ + if (!data.didBookTutorial) { this.showTutorial = true; - this.tutorialButton = new GuiButton(666666, this.guiLeft+140/2-50, this.guiTop+146, 100, 20, "Please click me <3"); + this.tutorialButton = new GuiButton(666666, this.guiLeft + 140 / 2 - 50, this.guiTop + 146, 100, 20, "Please click me <3"); this.buttonList.add(this.tutorialButton); this.configButton.visible = false; //this.achievementButton.visible = false; } - for(int i = 0; i < BUTTONS_PER_PAGE; i++){ + for (int i = 0; i < BUTTONS_PER_PAGE; i++) { List displayed = getDisplayedEntries(); - if(displayed.size() > i){ + if (displayed.size() > i) { IBookletEntry entry = displayed.get(i); - this.buttonList.add(new EntryButton(this, i, this.guiLeft+156, this.guiTop+11+i*13, 115, 10, "- "+entry.getLocalizedNameWithFormatting(), ItemStack.EMPTY)); - } - else{ + this.buttonList.add(new EntryButton(this, i, this.guiLeft + 156, this.guiTop + 11 + i * 13, 115, 10, "- " + entry.getLocalizedNameWithFormatting(), ItemStack.EMPTY)); + } else { return; } } } @Override - protected void actionPerformed(GuiButton button) throws IOException{ - if(button instanceof EntryButton){ + protected void actionPerformed(GuiButton button) throws IOException { + if (button instanceof EntryButton) { List displayed = getDisplayedEntries(); - if(displayed.size() > button.id){ + if (displayed.size() > button.id) { IBookletEntry entry = displayed.get(button.id); - if(entry != null){ + if (entry != null) { this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, this, entry, 0, "", false)); } } @@ -246,14 +181,13 @@ public class GuiMainPage extends GuiBooklet{ GuiScreen achievements = new GuiAAAchievements(this, this.mc.player.getStatFileWriter()); this.mc.displayGuiScreen(achievements); }*/ - else if(button == this.configButton){ + else if (button == this.configButton) { GuiScreen config = new GuiConfiguration(this); this.mc.displayGuiScreen(config); - } - else if(this.showTutorial && button == this.tutorialButton){ - if(this.hasBookmarkButtons()){ - if(!isShiftKeyDown()){ - for(int i = 0; i < InitBooklet.chaptersIntroduction.length; i++){ + } else if (this.showTutorial && button == this.tutorialButton) { + if (this.hasBookmarkButtons()) { + if (!isShiftKeyDown()) { + for (int i = 0; i < InitBooklet.chaptersIntroduction.length; i++) { this.bookmarkButtons[i].assignedPage = InitBooklet.chaptersIntroduction[i].getAllPages()[0]; } } @@ -267,40 +201,38 @@ public class GuiMainPage extends GuiBooklet{ data.didBookTutorial = true; PacketHandlerHelper.sendPlayerDataToServer(false, 1); } - } - else{ + } else { super.actionPerformed(button); } } @Override - public void drawScreenPre(int mouseX, int mouseY, float partialTicks){ + public void drawScreenPre(int mouseX, int mouseY, float partialTicks) { super.drawScreenPre(mouseX, mouseY, partialTicks); - String strg = TextFormatting.DARK_GREEN+StringUtil.localize(this.bookletName); - this.fontRenderer.drawString(strg, this.guiLeft+72-this.fontRenderer.getStringWidth(strg)/2-3, this.guiTop+19, 0); - strg = TextFormatting.DARK_GREEN+StringUtil.localize("info."+ActuallyAdditions.MODID+".booklet.manualName.2"); - this.fontRenderer.drawString(strg, this.guiLeft+72-this.fontRenderer.getStringWidth(strg)/2-3, this.guiTop+19+this.fontRenderer.FONT_HEIGHT, 0); + String strg = TextFormatting.DARK_GREEN + StringUtil.localize(this.bookletName); + this.fontRenderer.drawString(strg, this.guiLeft + 72 - this.fontRenderer.getStringWidth(strg) / 2 - 3, this.guiTop + 19, 0); + strg = TextFormatting.DARK_GREEN + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.manualName.2"); + this.fontRenderer.drawString(strg, this.guiLeft + 72 - this.fontRenderer.getStringWidth(strg) / 2 - 3, this.guiTop + 19 + this.fontRenderer.FONT_HEIGHT, 0); - strg = TextFormatting.GOLD+TextFormatting.ITALIC.toString()+this.bookletEdition; - this.fontRenderer.drawString(strg, this.guiLeft+72-this.fontRenderer.getStringWidth(strg)/2-3, this.guiTop+40, 0); + strg = TextFormatting.GOLD + TextFormatting.ITALIC.toString() + this.bookletEdition; + this.fontRenderer.drawString(strg, this.guiLeft + 72 - this.fontRenderer.getStringWidth(strg) / 2 - 3, this.guiTop + 40, 0); - if(this.showTutorial){ - String text = TextFormatting.BLUE+"It looks like this is the first time you are using this manual. \nIf you click the button below, some useful bookmarks will be stored at the bottom of the GUI. You should definitely check them out to get started with "+ActuallyAdditions.NAME+"! \nIf you don't want this, shift-click the button."; - this.renderSplitScaledAsciiString(text, this.guiLeft+11, this.guiTop+55, 0, false, this.getMediumFontSize(), 120); - } - else if(this.quote != null && !this.quote.isEmpty() && this.quoteGuy != null){ + if (this.showTutorial) { + String text = TextFormatting.BLUE + "It looks like this is the first time you are using this manual. \nIf you click the button below, some useful bookmarks will be stored at the bottom of the GUI. You should definitely check them out to get started with " + ActuallyAdditions.NAME + "! \nIf you don't want this, shift-click the button."; + this.renderSplitScaledAsciiString(text, this.guiLeft + 11, this.guiTop + 55, 0, false, this.getMediumFontSize(), 120); + } else if (this.quote != null && !this.quote.isEmpty() && this.quoteGuy != null) { int quoteSize = this.quote.size(); - for(int i = 0; i < quoteSize; i++){ - this.renderScaledAsciiString(TextFormatting.ITALIC+this.quote.get(i), this.guiLeft+25, this.guiTop+90+i*8, 0, false, this.getMediumFontSize()); + for (int i = 0; i < quoteSize; i++) { + this.renderScaledAsciiString(TextFormatting.ITALIC + this.quote.get(i), this.guiLeft + 25, this.guiTop + 90 + i * 8, 0, false, this.getMediumFontSize()); } - this.renderScaledAsciiString("- "+this.quoteGuy, this.guiLeft+60, this.guiTop+93+quoteSize*8, 0, false, this.getLargeFontSize()); + this.renderScaledAsciiString("- " + this.quoteGuy, this.guiLeft + 60, this.guiTop + 93 + quoteSize * 8, 0, false, this.getLargeFontSize()); } } @Override - public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer){ + public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer) { } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiPage.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiPage.java index da71fc87e..6d04a301f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiPage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiPage.java @@ -10,6 +10,13 @@ package de.ellpeck.actuallyadditions.mod.booklet.gui; +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; @@ -26,15 +33,8 @@ import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.awt.*; -import java.io.IOException; -import java.net.URI; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - @SideOnly(Side.CLIENT) -public class GuiPage extends GuiBooklet{ +public class GuiPage extends GuiBooklet { public final IBookletPage[] pages = new IBookletPage[2]; private final List itemDisplays = new ArrayList<>(); @@ -42,7 +42,7 @@ public class GuiPage extends GuiBooklet{ private GuiButton buttonViewOnline; - public GuiPage(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletPage page1, IBookletPage page2){ + public GuiPage(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletPage page1, IBookletPage page2) { super(previousScreen, parentPage); this.pages[0] = page1; @@ -50,62 +50,60 @@ public class GuiPage extends GuiBooklet{ } @Override - public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException{ + public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); - for(ItemDisplay display : this.itemDisplays){ + for (ItemDisplay display : this.itemDisplays) { display.onMousePress(mouseButton, mouseX, mouseY); } - for(IBookletPage page : this.pages){ - if(page != null){ + for (IBookletPage page : this.pages) { + if (page != null) { page.mouseClicked(this, mouseX, mouseY, mouseButton); } } } @Override - public void mouseReleased(int mouseX, int mouseY, int state){ + public void mouseReleased(int mouseX, int mouseY, int state) { super.mouseReleased(mouseX, mouseY, state); - for(IBookletPage page : this.pages){ - if(page != null){ + for (IBookletPage page : this.pages) { + if (page != null) { page.mouseReleased(this, mouseX, mouseY, state); } } } @Override - public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick){ + public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); - for(IBookletPage page : this.pages){ - if(page != null){ + for (IBookletPage page : this.pages) { + if (page != null) { page.mouseClickMove(this, mouseX, mouseY, clickedMouseButton, timeSinceLastClick); } } } @Override - public void actionPerformed(GuiButton button) throws IOException{ - if(button == this.buttonViewOnline){ + public void actionPerformed(GuiButton button) throws IOException { + if (button == this.buttonViewOnline) { List links = this.getWebLinks(); - if(Desktop.isDesktopSupported()){ - for(String link : links){ - try{ + if (Desktop.isDesktopSupported()) { + for (String link : links) { + try { Desktop.getDesktop().browse(new URI(link)); - } - catch(Exception e){ + } catch (Exception e) { ActuallyAdditions.LOGGER.error("Couldn't open website from Booklet page!", e); } } } - } - else{ + } else { super.actionPerformed(button); - for(IBookletPage page : this.pages){ - if(page != null){ + for (IBookletPage page : this.pages) { + if (page != null) { page.actionPerformed(this, button); } } @@ -113,31 +111,31 @@ public class GuiPage extends GuiBooklet{ } @Override - public void initGui(){ + public void initGui() { this.itemDisplays.clear(); super.initGui(); List links = this.getWebLinks(); - if(links != null && !links.isEmpty()){ - this.buttonViewOnline = new TexturedButton(RES_LOC_GADGETS, -782822, this.guiLeft+this.xSize-24, this.guiTop+this.ySize-25, 0, 172, 16, 16, Collections.singletonList(TextFormatting.GOLD+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".onlineButton.name"))); + if (links != null && !links.isEmpty()) { + this.buttonViewOnline = new TexturedButton(RES_LOC_GADGETS, -782822, this.guiLeft + this.xSize - 24, this.guiTop + this.ySize - 25, 0, 172, 16, 16, Collections.singletonList(TextFormatting.GOLD + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".onlineButton.name"))); this.buttonList.add(this.buttonViewOnline); } - for(int i = 0; i < this.pages.length; i++){ + for (int i = 0; i < this.pages.length; i++) { IBookletPage page = this.pages[i]; - if(page != null){ - page.initGui(this, this.guiLeft+6+i*142, this.guiTop+7); + if (page != null) { + page.initGui(this, this.guiLeft + 6 + i * 142, this.guiTop + 7); } } } - private List getWebLinks(){ + private List getWebLinks() { List links = new ArrayList<>(); - for(IBookletPage page : this.pages){ - if(page != null){ + for (IBookletPage page : this.pages) { + if (page != null) { String link = page.getWebLink(); - if(link != null && !links.contains(link)){ + if (link != null && !links.contains(link)) { links.add(link); } } @@ -147,13 +145,13 @@ public class GuiPage extends GuiBooklet{ } @Override - public void updateScreen(){ + public void updateScreen() { super.updateScreen(); - for(int i = 0; i < this.pages.length; i++){ + for (int i = 0; i < this.pages.length; i++) { IBookletPage page = this.pages[i]; - if(page != null){ - page.updateScreen(this, this.guiLeft+6+i*142, this.guiTop+7, this.pageTimer); + if (page != null) { + page.updateScreen(this, this.guiLeft + 6 + i * 142, this.guiTop + 7, this.pageTimer); } } @@ -161,51 +159,51 @@ public class GuiPage extends GuiBooklet{ } @Override - public void drawScreenPre(int mouseX, int mouseY, float partialTicks){ + public void drawScreenPre(int mouseX, int mouseY, float partialTicks) { super.drawScreenPre(mouseX, mouseY, partialTicks); - if(this.pages[0] != null){ + if (this.pages[0] != null) { IBookletChapter chapter = this.pages[0].getChapter(); String name = chapter.getLocalizedName(); - this.fontRenderer.drawString(name, this.guiLeft+this.xSize/2-this.fontRenderer.getStringWidth(name)/2, this.guiTop-1, 0xFFFFFF, true); + this.fontRenderer.drawString(name, this.guiLeft + this.xSize / 2 - this.fontRenderer.getStringWidth(name) / 2, this.guiTop - 1, 0xFFFFFF, true); } - for(int i = 0; i < this.pages.length; i++){ + for (int i = 0; i < this.pages.length; i++) { IBookletPage page = this.pages[i]; - if(page != null){ + if (page != null) { IBookletChapter chapter = this.pages[i].getChapter(); - String pageStrg = "Page "+(chapter.getPageIndex(this.pages[i])+1)+"/"+chapter.getAllPages().length; - this.renderScaledAsciiString(pageStrg, this.guiLeft+25+i*136, this.guiTop+this.ySize-7, 0xFFFFFF, false, this.getLargeFontSize()); + String pageStrg = "Page " + (chapter.getPageIndex(this.pages[i]) + 1) + "/" + chapter.getAllPages().length; + this.renderScaledAsciiString(pageStrg, this.guiLeft + 25 + i * 136, this.guiTop + this.ySize - 7, 0xFFFFFF, false, this.getLargeFontSize()); GlStateManager.color(1F, 1F, 1F); - page.drawScreenPre(this, this.guiLeft+6+i*142, this.guiTop+7, mouseX, mouseY, partialTicks); + page.drawScreenPre(this, this.guiLeft + 6 + i * 142, this.guiTop + 7, mouseX, mouseY, partialTicks); } } - for(ItemDisplay display : this.itemDisplays){ + for (ItemDisplay display : this.itemDisplays) { display.drawPre(); } } @Override - public void drawScreenPost(int mouseX, int mouseY, float partialTicks){ + public void drawScreenPost(int mouseX, int mouseY, float partialTicks) { super.drawScreenPost(mouseX, mouseY, partialTicks); - for(int i = 0; i < this.pages.length; i++){ + for (int i = 0; i < this.pages.length; i++) { IBookletPage page = this.pages[i]; - if(page != null){ + if (page != null) { GlStateManager.color(1F, 1F, 1F); - page.drawScreenPost(this, this.guiLeft+6+i*142, this.guiTop+7, mouseX, mouseY, partialTicks); + page.drawScreenPost(this, this.guiLeft + 6 + i * 142, this.guiTop + 7, mouseX, mouseY, partialTicks); } } - for(ItemDisplay display : this.itemDisplays){ + for (ItemDisplay display : this.itemDisplays) { display.drawPost(mouseX, mouseY); } } @Override - public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer){ - for(ItemDisplay display : this.itemDisplays){ - if(display.x == x && display.y == y && display.scale == scale){ + public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer) { + for (ItemDisplay display : this.itemDisplays) { + if (display.x == x && display.y == y && display.scale == scale) { display.stack = renderedStack; return; } @@ -215,27 +213,25 @@ public class GuiPage extends GuiBooklet{ } @Override - public boolean hasPageLeftButton(){ + public boolean hasPageLeftButton() { IBookletPage page = this.pages[0]; - if(page != null){ + if (page != null) { IBookletChapter chapter = page.getChapter(); - if(chapter != null){ - return chapter.getPageIndex(page) > 0; - } + if (chapter != null) { return chapter.getPageIndex(page) > 0; } } return false; } @Override - public void onPageLeftButtonPressed(){ + public void onPageLeftButtonPressed() { IBookletPage page = this.pages[0]; - if(page != null){ + if (page != null) { IBookletChapter chapter = page.getChapter(); - if(chapter != null){ + if (chapter != null) { IBookletPage[] pages = chapter.getAllPages(); - int pageNumToOpen = chapter.getPageIndex(page)-1; - if(pageNumToOpen >= 0 && pageNumToOpen < pages.length){ + int pageNumToOpen = chapter.getPageIndex(page) - 1; + if (pageNumToOpen >= 0 && pageNumToOpen < pages.length) { this.mc.displayGuiScreen(BookletUtils.createPageGui(this.previousScreen, this.parentPage, pages[pageNumToOpen])); } } @@ -243,29 +239,29 @@ public class GuiPage extends GuiBooklet{ } @Override - public boolean hasPageRightButton(){ + public boolean hasPageRightButton() { IBookletPage page = this.pages[1]; - if(page != null){ + if (page != null) { IBookletChapter chapter = page.getChapter(); - if(chapter != null){ + if (chapter != null) { int pageIndex = chapter.getPageIndex(page); int pageAmount = chapter.getAllPages().length; - return pageIndex+1 < pageAmount; + return pageIndex + 1 < pageAmount; } } return false; } @Override - public void onPageRightButtonPressed(){ + public void onPageRightButtonPressed() { IBookletPage page = this.pages[1]; - if(page != null){ + if (page != null) { IBookletChapter chapter = page.getChapter(); - if(chapter != null){ + if (chapter != null) { IBookletPage[] pages = chapter.getAllPages(); - int pageNumToOpen = chapter.getPageIndex(page)+1; - if(pageNumToOpen >= 0 && pageNumToOpen < pages.length){ + int pageNumToOpen = chapter.getPageIndex(page) + 1; + if (pageNumToOpen >= 0 && pageNumToOpen < pages.length) { this.mc.displayGuiScreen(BookletUtils.createPageGui(this.previousScreen, this.parentPage, pages[pageNumToOpen])); } } @@ -273,16 +269,15 @@ public class GuiPage extends GuiBooklet{ } @Override - public boolean hasBackButton(){ + public boolean hasBackButton() { return true; } @Override - public void onBackButtonPressed(){ - if(!isShiftKeyDown()){ + public void onBackButtonPressed() { + if (!isShiftKeyDown()) { this.mc.displayGuiScreen(this.parentPage); - } - else{ + } else { super.onBackButtonPressed(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/BookletUtils.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/BookletUtils.java index 9fcf8fb7f..4f63ddfd8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/BookletUtils.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/BookletUtils.java @@ -26,17 +26,15 @@ import net.minecraft.util.NonNullList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public final class BookletUtils{ +public final class BookletUtils { - public static IBookletPage findFirstPageForStack(ItemStack stack){ - for(IBookletPage page : ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA){ + public static IBookletPage findFirstPageForStack(ItemStack stack) { + for (IBookletPage page : ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA) { List stacks = NonNullList.create(); page.getItemStacksForPage(stacks); - if(stacks != null && !stacks.isEmpty()){ - for(ItemStack pageStack : stacks){ - if(ItemUtil.areItemsEqual(pageStack, stack, true)){ - return page; - } + if (stacks != null && !stacks.isEmpty()) { + for (ItemStack pageStack : stacks) { + if (ItemUtil.areItemsEqual(pageStack, stack, true)) { return page; } } } } @@ -44,7 +42,7 @@ public final class BookletUtils{ } @SideOnly(Side.CLIENT) - public static GuiPage createBookletGuiFromPage(GuiScreen previousScreen, IBookletPage page){ + public static GuiPage createBookletGuiFromPage(GuiScreen previousScreen, IBookletPage page) { GuiMainPage mainPage = new GuiMainPage(previousScreen); IBookletChapter chapter = page.getChapter(); @@ -54,7 +52,7 @@ public final class BookletUtils{ } @SideOnly(Side.CLIENT) - public static GuiPage createPageGui(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletPage page){ + public static GuiPage createPageGui(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletPage page) { IBookletChapter chapter = page.getChapter(); IBookletPage[] allPages = chapter.getAllPages(); @@ -62,25 +60,22 @@ public final class BookletUtils{ IBookletPage page1; IBookletPage page2; - if(page.shouldBeOnLeftSide()){ + if (page.shouldBeOnLeftSide()) { page1 = page; - page2 = pageIndex >= allPages.length-1 ? null : allPages[pageIndex+1]; - } - else{ - page1 = pageIndex <= 0 ? null : allPages[pageIndex-1]; + page2 = pageIndex >= allPages.length - 1 ? null : allPages[pageIndex + 1]; + } else { + page1 = pageIndex <= 0 ? null : allPages[pageIndex - 1]; page2 = page; } return new GuiPage(previousScreen, parentPage, page1, page2); } - public static IBookletPage getBookletPageById(String id){ - if(id != null){ - for(IBookletChapter chapter : ActuallyAdditionsAPI.ALL_CHAPTERS){ - for(IBookletPage page : chapter.getAllPages()){ - if(id.equals(page.getIdentifier())){ - return page; - } + public static IBookletPage getBookletPageById(String id) { + if (id != null) { + for (IBookletChapter chapter : ActuallyAdditionsAPI.ALL_CHAPTERS) { + for (IBookletPage page : chapter.getAllPages()) { + if (id.equals(page.getIdentifier())) { return page; } } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPage.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPage.java index 771fb57d0..79a663369 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPage.java @@ -10,6 +10,12 @@ package de.ellpeck.actuallyadditions.mod.booklet.page; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; @@ -24,9 +30,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.*; - -public class BookletPage implements IBookletPage{ +public class BookletPage implements IBookletPage { protected final HashMap textReplacements = new HashMap<>(); protected final int localizationKey; @@ -36,164 +40,162 @@ public class BookletPage implements IBookletPage{ protected IBookletChapter chapter; protected boolean hasNoText; - public BookletPage(int localizationKey){ + public BookletPage(int localizationKey) { this(localizationKey, 0); } - public BookletPage(int localizationKey, int priority){ + public BookletPage(int localizationKey, int priority) { this.localizationKey = localizationKey; this.priority = priority; } @Override - public void getItemStacksForPage(List list){ + public void getItemStacksForPage(List list) { list.addAll(this.itemsForPage); } @Override - public void getFluidStacksForPage(List list){ + public void getFluidStacksForPage(List list) { list.addAll(this.fluidsForPage); } @Override - public IBookletChapter getChapter(){ + public IBookletChapter getChapter() { return this.chapter; } @Override - public void setChapter(IBookletChapter chapter){ + public void setChapter(IBookletChapter chapter) { this.chapter = chapter; } @Override @SideOnly(Side.CLIENT) - public String getInfoText(){ - if(this.hasNoText){ - return null; - } + public String getInfoText() { + if (this.hasNoText) { return null; } String base = StringUtil.localize(this.getLocalizationKey()); - base = base.replaceAll("", TextFormatting.DARK_GREEN+""); - base = base.replaceAll("", TextFormatting.BLUE+""); - base = base.replaceAll("", TextFormatting.BLACK+""); + base = base.replaceAll("", TextFormatting.DARK_GREEN + ""); + base = base.replaceAll("", TextFormatting.BLUE + ""); + base = base.replaceAll("", TextFormatting.BLACK + ""); base = base.replaceAll("", "\n"); - base = base.replaceAll("", TextFormatting.ITALIC+""); - base = base.replaceAll("", TextFormatting.DARK_RED+""+TextFormatting.UNDERLINE); //This is fucking important so go read it now + base = base.replaceAll("", TextFormatting.ITALIC + ""); + base = base.replaceAll("", TextFormatting.DARK_RED + "" + TextFormatting.UNDERLINE); //This is fucking important so go read it now - for(Map.Entry entry : this.textReplacements.entrySet()){ + for (Map.Entry entry : this.textReplacements.entrySet()) { base = base.replaceAll(entry.getKey(), entry.getValue()); } return base; } @SideOnly(Side.CLIENT) - protected String getLocalizationKey(){ - return "booklet."+ActuallyAdditions.MODID+".chapter."+this.chapter.getIdentifier()+".text."+this.localizationKey; + protected String getLocalizationKey() { + return "booklet." + ActuallyAdditions.MODID + ".chapter." + this.chapter.getIdentifier() + ".text." + this.localizationKey; } @Override @SideOnly(Side.CLIENT) - public void mouseClicked(GuiBookletBase gui, int mouseX, int mouseY, int mouseButton){ + public void mouseClicked(GuiBookletBase gui, int mouseX, int mouseY, int mouseButton) { } @Override @SideOnly(Side.CLIENT) - public void mouseReleased(GuiBookletBase gui, int mouseX, int mouseY, int state){ + public void mouseReleased(GuiBookletBase gui, int mouseX, int mouseY, int state) { } @Override @SideOnly(Side.CLIENT) - public void mouseClickMove(GuiBookletBase gui, int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick){ + public void mouseClickMove(GuiBookletBase gui, int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { } @Override @SideOnly(Side.CLIENT) - public void actionPerformed(GuiBookletBase gui, GuiButton button){ + public void actionPerformed(GuiBookletBase gui, GuiButton button) { } @Override @SideOnly(Side.CLIENT) - public void initGui(GuiBookletBase gui, int startX, int startY){ + public void initGui(GuiBookletBase gui, int startX, int startY) { } @Override @SideOnly(Side.CLIENT) - public void updateScreen(GuiBookletBase gui, int startX, int startY, int pageTimer){ + public void updateScreen(GuiBookletBase gui, int startX, int startY, int pageTimer) { } @Override @SideOnly(Side.CLIENT) - public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){ + public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { } @Override @SideOnly(Side.CLIENT) - public void drawScreenPost(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){ + public void drawScreenPost(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { } @Override - public boolean shouldBeOnLeftSide(){ - return (this.chapter.getPageIndex(this)+1)%2 != 0; + public boolean shouldBeOnLeftSide() { + return (this.chapter.getPageIndex(this) + 1) % 2 != 0; } @Override - public String getIdentifier(){ - return this.chapter.getIdentifier()+"."+this.chapter.getPageIndex(this); + public String getIdentifier() { + return this.chapter.getIdentifier() + "." + this.chapter.getPageIndex(this); } @Override - public String getWebLink(){ - return "http://ellpeck.de/actaddmanual#"+this.chapter.getIdentifier(); + public String getWebLink() { + return "http://ellpeck.de/actaddmanual#" + this.chapter.getIdentifier(); } - public BookletPage setNoText(){ + public BookletPage setNoText() { this.hasNoText = true; return this; } - public BookletPage addFluidToPage(Fluid fluid){ + public BookletPage addFluidToPage(Fluid fluid) { this.fluidsForPage.add(new FluidStack(fluid, 1)); return this; } - public BookletPage addItemsToPage(Block... blocks){ - for(Block block : blocks){ + public BookletPage addItemsToPage(Block... blocks) { + for (Block block : blocks) { this.addItemsToPage(new ItemStack(block)); } return this; } - public BookletPage addItemsToPage(ItemStack... stacks){ + public BookletPage addItemsToPage(ItemStack... stacks) { Collections.addAll(this.itemsForPage, stacks); return this; } @Override - public BookletPage addTextReplacement(String key, String value){ + public BookletPage addTextReplacement(String key, String value) { this.textReplacements.put(key, value); return this; } @Override - public BookletPage addTextReplacement(String key, float value){ + public BookletPage addTextReplacement(String key, float value) { return this.addTextReplacement(key, Float.toString(value)); } @Override - public BookletPage addTextReplacement(String key, int value){ + public BookletPage addTextReplacement(String key, int value) { return this.addTextReplacement(key, Integer.toString(value)); } @Override - public int getSortingPriority(){ + public int getSortingPriority() { return this.priority; } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/ItemDisplay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/ItemDisplay.java index 0e206869d..e43f9a044 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/ItemDisplay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/ItemDisplay.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.booklet.page; +import java.util.List; + import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet; @@ -27,9 +29,7 @@ import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.List; - -public class ItemDisplay{ +public class ItemDisplay { public final int x; public final int y; @@ -38,7 +38,7 @@ public class ItemDisplay{ private final IBookletPage page; public ItemStack stack; - public ItemDisplay(GuiPage gui, int x, int y, float scale, ItemStack stack, boolean shouldTryTransfer){ + public ItemDisplay(GuiPage gui, int x, int y, float scale, ItemStack stack, boolean shouldTryTransfer) { this.gui = gui; this.x = x; this.y = y; @@ -48,30 +48,29 @@ public class ItemDisplay{ } @SideOnly(Side.CLIENT) - public void drawPre(){ + public void drawPre() { AssetUtil.renderStackToGui(this.stack, this.x, this.y, this.scale); } @SideOnly(Side.CLIENT) - public void drawPost(int mouseX, int mouseY){ - if(this.isHovered(mouseX, mouseY)){ + public void drawPost(int mouseX, int mouseY) { + if (this.isHovered(mouseX, mouseY)) { Minecraft mc = this.gui.mc; boolean flagBefore = mc.fontRenderer.getUnicodeFlag(); mc.fontRenderer.setUnicodeFlag(false); List list = this.stack.getTooltip(mc.player, mc.gameSettings.advancedItemTooltips ? TooltipFlags.ADVANCED : TooltipFlags.NORMAL); - for(int k = 0; k < list.size(); ++k){ - if(k == 0){ - list.set(k, this.stack.getItem().getForgeRarity(this.stack).getColor()+list.get(k)); - } - else{ - list.set(k, TextFormatting.GRAY+list.get(k)); + for (int k = 0; k < list.size(); ++k) { + if (k == 0) { + list.set(k, this.stack.getItem().getForgeRarity(this.stack).getColor() + list.get(k)); + } else { + list.set(k, TextFormatting.GRAY + list.get(k)); } } - if(this.page != null && this.page != this.gui.pages[0] && this.page != this.gui.pages[1]){ - list.add(TextFormatting.GOLD+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".clickToSeeRecipe")); + if (this.page != null && this.page != this.gui.pages[0] && this.page != this.gui.pages[1]) { + list.add(TextFormatting.GOLD + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".clickToSeeRecipe")); } GuiUtils.drawHoveringText(list, mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRenderer); @@ -80,9 +79,9 @@ public class ItemDisplay{ } } - public void onMousePress(int button, int mouseX, int mouseY){ - if(button == 0 && this.isHovered(mouseX, mouseY)){ - if(this.page != null && this.page != this.gui.pages[0] && this.page != this.gui.pages[1]){ + public void onMousePress(int button, int mouseX, int mouseY) { + if (button == 0 && this.isHovered(mouseX, mouseY)) { + if (this.page != null && this.page != this.gui.pages[0] && this.page != this.gui.pages[1]) { this.gui.mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F)); GuiBooklet gui = BookletUtils.createPageGui(this.gui.previousScreen, this.gui, this.page); @@ -91,7 +90,7 @@ public class ItemDisplay{ } } - public boolean isHovered(int mouseX, int mouseY){ - return mouseX >= this.x && mouseY >= this.y && mouseX < this.x+16*this.scale && mouseY < this.y+16*this.scale; + public boolean isHovered(int mouseX, int mouseY) { + return mouseX >= this.x && mouseY >= this.y && mouseX < this.x + 16 * this.scale && mouseY < this.y + 16 * this.scale; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCoffeeMachine.java index e11f3b7c3..b4e120eef 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCoffeeMachine.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCoffeeMachine.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.booklet.page; +import java.util.List; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; @@ -21,9 +23,7 @@ import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.List; - -public class PageCoffeeMachine extends BookletPage{ +public class PageCoffeeMachine extends BookletPage { private final CoffeeIngredient ingredient; private final ItemStack outcome; @@ -31,7 +31,7 @@ public class PageCoffeeMachine extends BookletPage{ private int rotate = 0; private final ItemStack[] stacks; - public PageCoffeeMachine(int localizationKey, CoffeeIngredient ingredient){ + public PageCoffeeMachine(int localizationKey, CoffeeIngredient ingredient) { super(localizationKey); this.ingredient = ingredient; this.stacks = ingredient.getInput().getMatchingStacks(); @@ -42,34 +42,34 @@ public class PageCoffeeMachine extends BookletPage{ @Override @SideOnly(Side.CLIENT) - public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){ + public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); - GuiUtils.drawTexturedModalRect(startX+5, startY+10, 0, 74, 117, 72, 0); + GuiUtils.drawTexturedModalRect(startX + 5, startY + 10, 0, 74, 117, 72, 0); - gui.renderScaledAsciiString("(Coffee Maker Recipe)", startX+6, startY+78, 0, false, gui.getMediumFontSize()); - gui.renderSplitScaledAsciiString("Hover over this to see the effect!", startX+5, startY+51, 0, false, gui.getSmallFontSize(), 35); + gui.renderScaledAsciiString("(Coffee Maker Recipe)", startX + 6, startY + 78, 0, false, gui.getMediumFontSize()); + gui.renderSplitScaledAsciiString("Hover over this to see the effect!", startX + 5, startY + 51, 0, false, gui.getSmallFontSize(), 35); - PageTextOnly.renderTextToPage(gui, this, startX+6, startY+90); + PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 90); - if(this.counter++ % 50 == 0) gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX+5+82, startY+10+1, 1F, true); + if (this.counter++ % 50 == 0) gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX + 5 + 82, startY + 10 + 1, 1F, true); } @Override @SideOnly(Side.CLIENT) - public void initGui(GuiBookletBase gui, int startX, int startY){ + public void initGui(GuiBookletBase gui, int startX, int startY) { super.initGui(gui, startX, startY); - gui.addOrModifyItemRenderer(this.stacks[0], startX+5+82, startY+10+1, 1F, true); - gui.addOrModifyItemRenderer(this.outcome, startX+5+36, startY+10+42, 1F, false); + gui.addOrModifyItemRenderer(this.stacks[0], startX + 5 + 82, startY + 10 + 1, 1F, true); + gui.addOrModifyItemRenderer(this.outcome, startX + 5 + 36, startY + 10 + 42, 1F, false); - gui.addOrModifyItemRenderer(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()), startX+5+37, startY+10+1, 1F, true); - gui.addOrModifyItemRenderer(new ItemStack(InitItems.itemCoffee), startX+5+1, startY+10+1, 1F, true); + gui.addOrModifyItemRenderer(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()), startX + 5 + 37, startY + 10 + 1, 1F, true); + gui.addOrModifyItemRenderer(new ItemStack(InitItems.itemCoffee), startX + 5 + 1, startY + 10 + 1, 1F, true); } @Override - public void getItemStacksForPage(List list){ + public void getItemStacksForPage(List list) { super.getItemStacksForPage(list); list.add(this.outcome); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrafting.java index 00f07bf91..b24cf77e0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrafting.java @@ -32,90 +32,89 @@ import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; -public class PageCrafting extends BookletPage{ +public class PageCrafting extends BookletPage { private final List recipes; private int recipeAt; private String recipeTypeLocKey; private boolean isWildcard; - public PageCrafting(int localizationKey, int priority, List recipes){ + public PageCrafting(int localizationKey, int priority, List recipes) { super(localizationKey, priority); this.recipes = recipes; } - public PageCrafting(int localizationKey, List recipes){ + public PageCrafting(int localizationKey, List recipes) { this(localizationKey, 0, recipes); } - public PageCrafting(int localizationKey, IRecipe... recipes){ + public PageCrafting(int localizationKey, IRecipe... recipes) { this(localizationKey, 0, recipes); } - - public PageCrafting(int localizationKey, int priority, IRecipe... recipes){ + public PageCrafting(int localizationKey, int priority, IRecipe... recipes) { this(localizationKey, priority, Arrays.asList(recipes)); } - public BookletPage setWildcard(){ + public BookletPage setWildcard() { this.isWildcard = true; return this; } @Override @SideOnly(Side.CLIENT) - public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){ + public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); - GuiUtils.drawTexturedModalRect(startX+5, startY+6, 20, 0, 116, 54, 0); + GuiUtils.drawTexturedModalRect(startX + 5, startY + 6, 20, 0, 116, 54, 0); - gui.renderScaledAsciiString("("+StringUtil.localize(this.recipeTypeLocKey)+")", startX+6, startY+65, 0, false, gui.getMediumFontSize()); + gui.renderScaledAsciiString("(" + StringUtil.localize(this.recipeTypeLocKey) + ")", startX + 6, startY + 65, 0, false, gui.getMediumFontSize()); - PageTextOnly.renderTextToPage(gui, this, startX+6, startY+80); + PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 80); } @Override @SideOnly(Side.CLIENT) - public void updateScreen(GuiBookletBase gui, int startX, int startY, int pageTimer){ + public void updateScreen(GuiBookletBase gui, int startX, int startY, int pageTimer) { super.updateScreen(gui, startX, startY, pageTimer); - if(pageTimer%20 == 0){ + if (pageTimer % 20 == 0) { this.findRecipe(gui, startX, startY); } } - private void findRecipe(GuiBookletBase gui, int startX, int startY){ - if(!this.recipes.isEmpty()){ + private void findRecipe(GuiBookletBase gui, int startX, int startY) { + if (!this.recipes.isEmpty()) { IRecipe recipe = this.recipes.get(this.recipeAt); - if(recipe != null){ + if (recipe != null) { this.setupRecipe(gui, recipe, startX, startY); } this.recipeAt++; - if(this.recipeAt >= this.recipes.size()){ + if (this.recipeAt >= this.recipes.size()) { this.recipeAt = 0; } } } @Override - public void initGui(GuiBookletBase gui, int startX, int startY){ + public void initGui(GuiBookletBase gui, int startX, int startY) { super.initGui(gui, startX, startY); this.findRecipe(gui, startX, startY); } @Override - public void getItemStacksForPage(List list){ + public void getItemStacksForPage(List list) { super.getItemStacksForPage(list); - if(!this.recipes.isEmpty()){ - for(IRecipe recipe : this.recipes){ - if(recipe != null){ + if (!this.recipes.isEmpty()) { + for (IRecipe recipe : this.recipes) { + if (recipe != null) { ItemStack output = recipe.getRecipeOutput(); - if(StackUtil.isValid(output)){ + if (StackUtil.isValid(output)) { ItemStack copy = output.copy(); - if(this.isWildcard){ + if (this.isWildcard) { copy.setItemDamage(Util.WILDCARD); } list.add(copy); @@ -125,73 +124,68 @@ public class PageCrafting extends BookletPage{ } } - private void setupRecipe(GuiBookletBase gui, IRecipe recipe, int startX, int startY){ + private void setupRecipe(GuiBookletBase gui, IRecipe recipe, int startX, int startY) { Ingredient[] ings = new Ingredient[9]; int width = 3; int height = 3; - if(recipe instanceof BlankRecipe){ - this.recipeTypeLocKey = "tooltip."+ActuallyAdditions.MODID+".disabled"; - gui.addOrModifyItemRenderer(recipe.getRecipeOutput(), startX+100, startY+25, 1F, false); + if (recipe instanceof BlankRecipe) { + this.recipeTypeLocKey = "tooltip." + ActuallyAdditions.MODID + ".disabled"; + gui.addOrModifyItemRenderer(recipe.getRecipeOutput(), startX + 100, startY + 25, 1F, false); return; - } - else if(recipe instanceof ShapedRecipes){ - ShapedRecipes shaped = (ShapedRecipes)recipe; + } else if (recipe instanceof ShapedRecipes) { + ShapedRecipes shaped = (ShapedRecipes) recipe; width = shaped.recipeWidth; height = shaped.recipeHeight; ings = shaped.recipeItems.toArray(new Ingredient[shaped.recipeItems.size()]); - this.recipeTypeLocKey = "booklet."+ActuallyAdditions.MODID+".shapedRecipe"; - } - else if(recipe instanceof ShapelessRecipes){ - ShapelessRecipes shapeless = (ShapelessRecipes)recipe; - for(int i = 0; i < shapeless.recipeItems.size(); i++){ + this.recipeTypeLocKey = "booklet." + ActuallyAdditions.MODID + ".shapedRecipe"; + } else if (recipe instanceof ShapelessRecipes) { + ShapelessRecipes shapeless = (ShapelessRecipes) recipe; + for (int i = 0; i < shapeless.recipeItems.size(); i++) { ings[i] = shapeless.recipeItems.get(i); } - this.recipeTypeLocKey = "booklet."+ActuallyAdditions.MODID+".shapelessRecipe"; - } - else if(recipe instanceof ShapedOreRecipe){ - ShapedOreRecipe shaped = (ShapedOreRecipe)recipe; - try{ + this.recipeTypeLocKey = "booklet." + ActuallyAdditions.MODID + ".shapelessRecipe"; + } else if (recipe instanceof ShapedOreRecipe) { + ShapedOreRecipe shaped = (ShapedOreRecipe) recipe; + try { width = RefHelp.getPrivateValue(ShapedOreRecipe.class, shaped, 4); height = RefHelp.getPrivateValue(ShapedOreRecipe.class, shaped, 5); - } - catch(Exception e){ + } catch (Exception e) { ActuallyAdditions.LOGGER.error("Something went wrong trying to get the Crafting Recipe in the booklet to display!", e); } - for(int i = 0; i < shaped.getIngredients().size(); i++){ + for (int i = 0; i < shaped.getIngredients().size(); i++) { ings[i] = shaped.getIngredients().get(i); } - this.recipeTypeLocKey = "booklet."+ActuallyAdditions.MODID+".shapedOreRecipe"; - } - else if(recipe instanceof ShapelessOreRecipe){ - ShapelessOreRecipe shapeless = (ShapelessOreRecipe)recipe; - for(int i = 0; i < shapeless.getIngredients().size(); i++){ + this.recipeTypeLocKey = "booklet." + ActuallyAdditions.MODID + ".shapedOreRecipe"; + } else if (recipe instanceof ShapelessOreRecipe) { + ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe; + for (int i = 0; i < shapeless.getIngredients().size(); i++) { ings[i] = shapeless.getIngredients().get(i); } - this.recipeTypeLocKey = "booklet."+ActuallyAdditions.MODID+".shapelessOreRecipe"; + this.recipeTypeLocKey = "booklet." + ActuallyAdditions.MODID + ".shapelessOreRecipe"; } - for(int x = 0; x < width; x++){ - for(int y = 0; y < height; y++){ - Ingredient ing = ings[y*width+x]; - if(ing != null){ + for (int x = 0; x < width; x++) { + for (int y = 0; y < height; y++) { + Ingredient ing = ings[y * width + x]; + if (ing != null) { ItemStack[] stacks = ing.getMatchingStacks(); - if(stacks != null && stacks.length > 0){ + if (stacks != null && stacks.length > 0) { ItemStack stack = stacks[0]; - if(StackUtil.isValid(stack)){ + if (StackUtil.isValid(stack)) { ItemStack copy = stack.copy(); copy.setCount(1); - if(copy.getItemDamage() == Util.WILDCARD){ + if (copy.getItemDamage() == Util.WILDCARD) { copy.setItemDamage(0); } - gui.addOrModifyItemRenderer(copy, startX+6+x*18, startY+7+y*18, 1F, true); + gui.addOrModifyItemRenderer(copy, startX + 6 + x * 18, startY + 7 + y * 18, 1F, true); } } } } } - gui.addOrModifyItemRenderer(recipe.getRecipeOutput(), startX+100, startY+25, 1F, false); + gui.addOrModifyItemRenderer(recipe.getRecipeOutput(), startX + 100, startY + 25, 1F, false); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrusherRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrusherRecipe.java index b32fc2092..44153a1cc 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrusherRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrusherRecipe.java @@ -23,14 +23,14 @@ import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class PageCrusherRecipe extends BookletPage{ +public class PageCrusherRecipe extends BookletPage { private final CrusherRecipe recipe; private int counter = 0; private int rotate = 0; private final ItemStack[] stacks; - public PageCrusherRecipe(int localizationKey, CrusherRecipe recipe){ + public PageCrusherRecipe(int localizationKey, CrusherRecipe recipe) { super(localizationKey); this.recipe = recipe; this.stacks = recipe.getInput().getMatchingStacks(); @@ -38,42 +38,42 @@ public class PageCrusherRecipe extends BookletPage{ @Override @SideOnly(Side.CLIENT) - public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){ + public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); - GuiUtils.drawTexturedModalRect(startX+38, startY+6, 136, 0, 52, 74, 0); + GuiUtils.drawTexturedModalRect(startX + 38, startY + 6, 136, 0, 52, 74, 0); - gui.renderScaledAsciiString("("+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".crusherRecipe")+")", startX+36, startY+85, 0, false, gui.getMediumFontSize()); + gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".crusherRecipe") + ")", startX + 36, startY + 85, 0, false, gui.getMediumFontSize()); - PageTextOnly.renderTextToPage(gui, this, startX+6, startY+100); + PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 100); - if(this.counter++ % 50 == 0) gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX+38+18, startY+6+1, 1F, true); + if (this.counter++ % 50 == 0) gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX + 38 + 18, startY + 6 + 1, 1F, true); } @Override @SideOnly(Side.CLIENT) - public void initGui(GuiBookletBase gui, int startX, int startY){ + public void initGui(GuiBookletBase gui, int startX, int startY) { super.initGui(gui, startX, startY); - if(this.recipe != null){ - gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX+38+18, startY+6+1, 1F, true); - gui.addOrModifyItemRenderer(this.recipe.getOutputOne(), startX+38+4, startY+6+53, 1F, false); + if (this.recipe != null) { + gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX + 38 + 18, startY + 6 + 1, 1F, true); + gui.addOrModifyItemRenderer(this.recipe.getOutputOne(), startX + 38 + 4, startY + 6 + 53, 1F, false); - if(StackUtil.isValid(this.recipe.getOutputTwo())){ - gui.addOrModifyItemRenderer(this.recipe.getOutputTwo(), startX+38+30, startY+6+53, 1F, false); + if (StackUtil.isValid(this.recipe.getOutputTwo())) { + gui.addOrModifyItemRenderer(this.recipe.getOutputTwo(), startX + 38 + 30, startY + 6 + 53, 1F, false); } } } @Override - public void getItemStacksForPage(List list){ + public void getItemStacksForPage(List list) { super.getItemStacksForPage(list); - if(this.recipe != null){ + if (this.recipe != null) { list.add(this.recipe.getOutputOne()); - if(StackUtil.isValid(this.recipe.getOutputTwo())){ + if (StackUtil.isValid(this.recipe.getOutputTwo())) { list.add(this.recipe.getOutputTwo()); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageEmpowerer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageEmpowerer.java index 8a1dbfdd0..b0ad58294 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageEmpowerer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageEmpowerer.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.booklet.page; +import java.util.List; + import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; @@ -20,9 +22,7 @@ import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.List; - -public class PageEmpowerer extends BookletPage{ +public class PageEmpowerer extends BookletPage { private final EmpowererRecipe recipe; private int counter = 0; @@ -33,10 +33,10 @@ public class PageEmpowerer extends BookletPage{ ItemStack[] stand3; ItemStack[] stand4; - public PageEmpowerer(int localizationKey, EmpowererRecipe recipe){ + public PageEmpowerer(int localizationKey, EmpowererRecipe recipe) { super(localizationKey); this.recipe = recipe; - if(recipe != null) { + if (recipe != null) { this.inputs = recipe.getInput().getMatchingStacks(); this.stand1 = recipe.getStandOne().getMatchingStacks(); this.stand2 = recipe.getStandTwo().getMatchingStacks(); @@ -47,57 +47,57 @@ public class PageEmpowerer extends BookletPage{ @Override @SideOnly(Side.CLIENT) - public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){ + public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); - GuiUtils.drawTexturedModalRect(startX+5, startY+10, 117, 74, 116, 72, 0); + GuiUtils.drawTexturedModalRect(startX + 5, startY + 10, 117, 74, 116, 72, 0); - gui.renderScaledAsciiString("("+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".empowererRecipe")+")", startX+6, startY+85, 0, false, gui.getMediumFontSize()); + gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".empowererRecipe") + ")", startX + 6, startY + 85, 0, false, gui.getMediumFontSize()); - PageTextOnly.renderTextToPage(gui, this, startX+6, startY+100); - if(this.recipe != null) this.updateInputs(gui, startX, startY); + PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 100); + if (this.recipe != null) this.updateInputs(gui, startX, startY); } @Override @SideOnly(Side.CLIENT) - public void initGui(GuiBookletBase gui, int startX, int startY){ + public void initGui(GuiBookletBase gui, int startX, int startY) { super.initGui(gui, startX, startY); - if(this.recipe != null){ - gui.addOrModifyItemRenderer(this.stand1[0], startX+5+26, startY+10+1, 1F, true); - gui.addOrModifyItemRenderer(this.stand2[0], startX+5+1, startY+10+26, 1F, true); - gui.addOrModifyItemRenderer(this.stand3[0], startX+5+51, startY+10+26, 1F, true); - gui.addOrModifyItemRenderer(this.stand4[0], startX+5+26, startY+10+51, 1F, true); + if (this.recipe != null) { + gui.addOrModifyItemRenderer(this.stand1[0], startX + 5 + 26, startY + 10 + 1, 1F, true); + gui.addOrModifyItemRenderer(this.stand2[0], startX + 5 + 1, startY + 10 + 26, 1F, true); + gui.addOrModifyItemRenderer(this.stand3[0], startX + 5 + 51, startY + 10 + 26, 1F, true); + gui.addOrModifyItemRenderer(this.stand4[0], startX + 5 + 26, startY + 10 + 51, 1F, true); - gui.addOrModifyItemRenderer(this.inputs[0], startX+5+26, startY+10+26, 1F, true); - gui.addOrModifyItemRenderer(this.recipe.getOutput(), startX+5+96, startY+10+26, 1F, false); + gui.addOrModifyItemRenderer(this.inputs[0], startX + 5 + 26, startY + 10 + 26, 1F, true); + gui.addOrModifyItemRenderer(this.recipe.getOutput(), startX + 5 + 96, startY + 10 + 26, 1F, false); } } private void updateInputs(GuiBookletBase gui, int startX, int startY) { - if(this.counter++ % 50 == 0) { + if (this.counter++ % 50 == 0) { this.rotate++; - gui.addOrModifyItemRenderer(this.stand1[this.rotate % this.stand1.length], startX+5+26, startY+10+1, 1F, true); - gui.addOrModifyItemRenderer(this.stand2[this.rotate % this.stand2.length], startX+5+1, startY+10+26, 1F, true); - gui.addOrModifyItemRenderer(this.stand3[this.rotate % this.stand3.length], startX+5+51, startY+10+26, 1F, true); - gui.addOrModifyItemRenderer(this.stand4[this.rotate % this.stand4.length], startX+5+26, startY+10+51, 1F, true); + gui.addOrModifyItemRenderer(this.stand1[this.rotate % this.stand1.length], startX + 5 + 26, startY + 10 + 1, 1F, true); + gui.addOrModifyItemRenderer(this.stand2[this.rotate % this.stand2.length], startX + 5 + 1, startY + 10 + 26, 1F, true); + gui.addOrModifyItemRenderer(this.stand3[this.rotate % this.stand3.length], startX + 5 + 51, startY + 10 + 26, 1F, true); + gui.addOrModifyItemRenderer(this.stand4[this.rotate % this.stand4.length], startX + 5 + 26, startY + 10 + 51, 1F, true); - gui.addOrModifyItemRenderer(this.inputs[this.rotate % this.inputs.length], startX+5+26, startY+10+26, 1F, true); + gui.addOrModifyItemRenderer(this.inputs[this.rotate % this.inputs.length], startX + 5 + 26, startY + 10 + 26, 1F, true); } } @Override - public void getItemStacksForPage(List list){ + public void getItemStacksForPage(List list) { super.getItemStacksForPage(list); - if(this.recipe != null){ + if (this.recipe != null) { list.add(this.recipe.getOutput()); } } @Override - public int getSortingPriority(){ + public int getSortingPriority() { return 20; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageFurnace.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageFurnace.java index 1c9c5e51c..862905caa 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageFurnace.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageFurnace.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.booklet.page; +import java.util.List; +import java.util.Map; + import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet; @@ -21,31 +24,26 @@ import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.List; -import java.util.Map; - -public class PageFurnace extends BookletPage{ +public class PageFurnace extends BookletPage { private final ItemStack input; private final ItemStack output; - public PageFurnace(int localizationKey, ItemStack output){ + public PageFurnace(int localizationKey, ItemStack output) { this(localizationKey, output, 0); } - public PageFurnace(int localizationKey, ItemStack output, int priority){ + public PageFurnace(int localizationKey, ItemStack output, int priority) { super(localizationKey, priority); this.output = output; this.input = getInputForOutput(output); } - private static ItemStack getInputForOutput(ItemStack output){ - for(Map.Entry entry : FurnaceRecipes.instance().getSmeltingList().entrySet()){ + private static ItemStack getInputForOutput(ItemStack output) { + for (Map.Entry entry : FurnaceRecipes.instance().getSmeltingList().entrySet()) { ItemStack stack = entry.getValue(); - if(StackUtil.isValid(stack)){ - if(stack.isItemEqual(output)){ - return entry.getKey(); - } + if (StackUtil.isValid(stack)) { + if (stack.isItemEqual(output)) { return entry.getKey(); } } } return ItemStack.EMPTY; @@ -53,28 +51,28 @@ public class PageFurnace extends BookletPage{ @Override @SideOnly(Side.CLIENT) - public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){ + public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); - GuiUtils.drawTexturedModalRect(startX+23, startY+10, 0, 146, 80, 26, 0); + GuiUtils.drawTexturedModalRect(startX + 23, startY + 10, 0, 146, 80, 26, 0); - gui.renderScaledAsciiString("("+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".furnaceRecipe")+")", startX+32, startY+42, 0, false, gui.getMediumFontSize()); + gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".furnaceRecipe") + ")", startX + 32, startY + 42, 0, false, gui.getMediumFontSize()); - PageTextOnly.renderTextToPage(gui, this, startX+6, startY+57); + PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 57); } @Override @SideOnly(Side.CLIENT) - public void initGui(GuiBookletBase gui, int startX, int startY){ + public void initGui(GuiBookletBase gui, int startX, int startY) { super.initGui(gui, startX, startY); - gui.addOrModifyItemRenderer(this.input, startX+23+1, startY+10+5, 1F, true); - gui.addOrModifyItemRenderer(this.output, startX+23+59, startY+10+5, 1F, false); + gui.addOrModifyItemRenderer(this.input, startX + 23 + 1, startY + 10 + 5, 1F, true); + gui.addOrModifyItemRenderer(this.output, startX + 23 + 59, startY + 10 + 5, 1F, false); } @Override - public void getItemStacksForPage(List list){ + public void getItemStacksForPage(List list) { super.getItemStacksForPage(list); list.add(this.output); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageLinkButton.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageLinkButton.java index 04a95680e..7b5ab3d8c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageLinkButton.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageLinkButton.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.booklet.page; +import java.awt.Desktop; +import java.net.URI; + import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.util.StringUtil; @@ -17,17 +20,14 @@ import net.minecraft.client.gui.GuiButton; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.awt.*; -import java.net.URI; - -public class PageLinkButton extends BookletPage{ +public class PageLinkButton extends BookletPage { public static int nextButtonId = 23782; private final int buttonId; private final String link; - public PageLinkButton(int localizationKey, String link){ + public PageLinkButton(int localizationKey, String link) { super(localizationKey); this.link = link; @@ -37,33 +37,31 @@ public class PageLinkButton extends BookletPage{ @Override @SideOnly(Side.CLIENT) - public void initGui(GuiBookletBase gui, int startX, int startY){ + public void initGui(GuiBookletBase gui, int startX, int startY) { super.initGui(gui, startX, startY); - gui.getButtonList().add(new GuiButton(this.buttonId, startX+125/2-50, startY+130, 100, 20, StringUtil.localize("booklet."+ActuallyAdditions.MODID+".chapter."+this.chapter.getIdentifier()+".button."+this.localizationKey))); + gui.getButtonList().add(new GuiButton(this.buttonId, startX + 125 / 2 - 50, startY + 130, 100, 20, StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".chapter." + this.chapter.getIdentifier() + ".button." + this.localizationKey))); } @Override @SideOnly(Side.CLIENT) - public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){ + public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); - PageTextOnly.renderTextToPage(gui, this, startX+6, startY+5); + PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 5); } @Override @SideOnly(Side.CLIENT) - public void actionPerformed(GuiBookletBase gui, GuiButton button){ - if(button.id == this.buttonId){ - if(Desktop.isDesktopSupported()){ - try{ + public void actionPerformed(GuiBookletBase gui, GuiButton button) { + if (button.id == this.buttonId) { + if (Desktop.isDesktopSupported()) { + try { Desktop.getDesktop().browse(new URI(this.link)); - } - catch(Exception e){ + } catch (Exception e) { ActuallyAdditions.LOGGER.error("Couldn't open website from Link Button page!", e); } } - } - else{ + } else { super.actionPerformed(gui, button); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PagePicture.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PagePicture.java index 6722d505c..c4c1e16f9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PagePicture.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PagePicture.java @@ -18,30 +18,30 @@ import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class PagePicture extends BookletPage{ +public class PagePicture extends BookletPage { private final ResourceLocation resLoc; private final int yTextOffset; - public PagePicture(int localizationKey, ResourceLocation resLoc, int yTextOffset, int priority){ + public PagePicture(int localizationKey, ResourceLocation resLoc, int yTextOffset, int priority) { super(localizationKey, priority); this.resLoc = resLoc; this.yTextOffset = yTextOffset; } - public PagePicture(int localizationKey, ResourceLocation resLoc, int yTextOffset){ + public PagePicture(int localizationKey, ResourceLocation resLoc, int yTextOffset) { super(localizationKey); this.yTextOffset = yTextOffset; this.resLoc = resLoc; } - public PagePicture(int localizationKey, String pictureLocation, int yTextOffset){ + public PagePicture(int localizationKey, String pictureLocation, int yTextOffset) { this(localizationKey, AssetUtil.getBookletGuiLocation(pictureLocation), yTextOffset); } @Override @SideOnly(Side.CLIENT) - public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){ + public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); gui.mc.getTextureManager().bindTexture(this.resLoc); @@ -49,11 +49,11 @@ public class PagePicture extends BookletPage{ GlStateManager.pushMatrix(); GlStateManager.enableBlend(); GlStateManager.disableAlpha(); - GuiUtils.drawTexturedModalRect(startX-6, startY-7, 0, 0, 256, 256, 0); + GuiUtils.drawTexturedModalRect(startX - 6, startY - 7, 0, 0, 256, 256, 0); GlStateManager.disableBlend(); GlStateManager.enableAlpha(); GlStateManager.popMatrix(); - PageTextOnly.renderTextToPage(gui, this, startX+6, startY-7+this.yTextOffset); + PageTextOnly.renderTextToPage(gui, this, startX + 6, startY - 7 + this.yTextOffset); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageReconstructor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageReconstructor.java index 64fb54a7e..46770d7b0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageReconstructor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageReconstructor.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.booklet.page; +import java.util.List; + import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; @@ -21,9 +23,7 @@ import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.List; - -public class PageReconstructor extends BookletPage{ +public class PageReconstructor extends BookletPage { private final LensConversionRecipe recipe; private boolean isWildcard; @@ -31,60 +31,59 @@ public class PageReconstructor extends BookletPage{ private int rotate = 0; private ItemStack[] stacks; - - public PageReconstructor(int localizationKey, LensConversionRecipe recipe){ + public PageReconstructor(int localizationKey, LensConversionRecipe recipe) { super(localizationKey); this.recipe = recipe; - if(recipe != null) this.stacks = recipe.getInput().getMatchingStacks(); + if (recipe != null) this.stacks = recipe.getInput().getMatchingStacks(); } @Override @SideOnly(Side.CLIENT) - public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){ + public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); gui.mc.getTextureManager().bindTexture(GuiBooklet.RES_LOC_GADGETS); - GuiUtils.drawTexturedModalRect(startX+30, startY+10, 80, 146, 68, 48, 0); + GuiUtils.drawTexturedModalRect(startX + 30, startY + 10, 80, 146, 68, 48, 0); - gui.renderScaledAsciiString("("+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".reconstructorRecipe")+")", startX+6, startY+63, 0, false, gui.getMediumFontSize()); + gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".reconstructorRecipe") + ")", startX + 6, startY + 63, 0, false, gui.getMediumFontSize()); - PageTextOnly.renderTextToPage(gui, this, startX+6, startY+88); - if(this.recipe != null){ - if(this.counter++ % 50 == 0) gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX+30+1, startY+10+13, 1F, true); + PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 88); + if (this.recipe != null) { + if (this.counter++ % 50 == 0) gui.addOrModifyItemRenderer(this.stacks[this.rotate++ % this.stacks.length], startX + 30 + 1, startY + 10 + 13, 1F, true); } } @Override @SideOnly(Side.CLIENT) - public void initGui(GuiBookletBase gui, int startX, int startY){ + public void initGui(GuiBookletBase gui, int startX, int startY) { super.initGui(gui, startX, startY); - if(this.recipe != null){ - gui.addOrModifyItemRenderer(this.stacks[0], startX+30+1, startY+10+13, 1F, true); - gui.addOrModifyItemRenderer(this.recipe.getOutput(), startX+30+47, startY+10+13, 1F, false); + if (this.recipe != null) { + gui.addOrModifyItemRenderer(this.stacks[0], startX + 30 + 1, startY + 10 + 13, 1F, true); + gui.addOrModifyItemRenderer(this.recipe.getOutput(), startX + 30 + 47, startY + 10 + 13, 1F, false); } } @Override - public void getItemStacksForPage(List list){ + public void getItemStacksForPage(List list) { super.getItemStacksForPage(list); - if(this.recipe != null){ + if (this.recipe != null) { ItemStack copy = this.recipe.getOutput().copy(); - if(this.isWildcard){ + if (this.isWildcard) { copy.setItemDamage(Util.WILDCARD); } list.add(copy); } } - public BookletPage setWildcard(){ + public BookletPage setWildcard() { this.isWildcard = true; return this; } @Override - public int getSortingPriority(){ + public int getSortingPriority() { return 20; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTextOnly.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTextOnly.java index c40d0a615..226a98354 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTextOnly.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTextOnly.java @@ -14,28 +14,28 @@ import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class PageTextOnly extends BookletPage{ +public class PageTextOnly extends BookletPage { - public PageTextOnly(int localizationKey, int priority){ + public PageTextOnly(int localizationKey, int priority) { super(localizationKey, priority); } - public PageTextOnly(int localizationKey){ + public PageTextOnly(int localizationKey) { super(localizationKey); } @SideOnly(Side.CLIENT) - public static void renderTextToPage(GuiBookletBase gui, BookletPage page, int x, int y){ + public static void renderTextToPage(GuiBookletBase gui, BookletPage page, int x, int y) { String text = page.getInfoText(); - if(text != null && !text.isEmpty()){ + if (text != null && !text.isEmpty()) { gui.renderSplitScaledAsciiString(text, x, y, 0, false, gui.getMediumFontSize(), 120); } } @Override @SideOnly(Side.CLIENT) - public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){ + public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); - renderTextToPage(gui, this, startX+6, startY+5); + renderTextToPage(gui, this, startX + 6, startY + 5); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTrials.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTrials.java index 91c11d7a6..4ea7c338b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTrials.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTrials.java @@ -23,35 +23,34 @@ import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class PageTrials extends BookletPage{ +public class PageTrials extends BookletPage { private final int buttonId; @SideOnly(Side.CLIENT) private GuiButton button; - public PageTrials(int localizationKey, boolean button, boolean text){ + public PageTrials(int localizationKey, boolean button, boolean text) { super(localizationKey); - if(!text){ + if (!text) { this.setNoText(); } - if(button){ + if (button) { this.buttonId = PageLinkButton.nextButtonId; PageLinkButton.nextButtonId++; - } - else{ + } else { this.buttonId = -1; } } @Override @SideOnly(Side.CLIENT) - public void initGui(GuiBookletBase gui, int startX, int startY){ + public void initGui(GuiBookletBase gui, int startX, int startY) { super.initGui(gui, startX, startY); - if(this.buttonId >= 0){ - this.button = new GuiButton(this.buttonId, startX+125/2-50, startY+120, 100, 20, ""); + if (this.buttonId >= 0) { + this.button = new GuiButton(this.buttonId, startX + 125 / 2 - 50, startY + 120, 100, 20, ""); gui.getButtonList().add(this.button); this.updateButton(); } @@ -59,53 +58,50 @@ public class PageTrials extends BookletPage{ @Override @SideOnly(Side.CLIENT) - public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){ + public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks) { super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); - PageTextOnly.renderTextToPage(gui, this, startX+6, startY+5); + PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 5); } @Override @SideOnly(Side.CLIENT) - protected String getLocalizationKey(){ - return "booklet."+ActuallyAdditions.MODID+".trials."+this.chapter.getIdentifier()+".text."+this.localizationKey; + protected String getLocalizationKey() { + return "booklet." + ActuallyAdditions.MODID + ".trials." + this.chapter.getIdentifier() + ".text." + this.localizationKey; } @Override @SideOnly(Side.CLIENT) - public void actionPerformed(GuiBookletBase gui, GuiButton button){ - if(this.buttonId >= 0 && button.id == this.buttonId){ + public void actionPerformed(GuiBookletBase gui, GuiButton button) { + if (this.buttonId >= 0 && button.id == this.buttonId) { EntityPlayer player = Minecraft.getMinecraft().player; PlayerSave data = PlayerData.getDataFromPlayer(player); String id = this.chapter.getIdentifier(); boolean completed = data.completedTrials.contains(id); - if(completed){ + if (completed) { data.completedTrials.remove(id); - } - else{ + } else { data.completedTrials.add(id); } this.updateButton(); PacketHandlerHelper.sendPlayerDataToServer(false, 2); - } - else{ + } else { super.actionPerformed(gui, button); } } @SideOnly(Side.CLIENT) - private void updateButton(){ - if(this.buttonId >= 0 && this.button != null){ + private void updateButton() { + if (this.buttonId >= 0 && this.button != null) { EntityPlayer player = Minecraft.getMinecraft().player; PlayerSave data = PlayerData.getDataFromPlayer(player); boolean completed = data.completedTrials.contains(this.chapter.getIdentifier()); - if(completed){ - this.button.displayString = TextFormatting.DARK_GREEN+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".trialFinishButton.completed.name"); - } - else{ - this.button.displayString = TextFormatting.DARK_RED+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".trialFinishButton.uncompleted.name"); + if (completed) { + this.button.displayString = TextFormatting.DARK_GREEN + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".trialFinishButton.completed.name"); + } else { + this.button.displayString = TextFormatting.DARK_RED + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".trialFinishButton.uncompleted.name"); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigCategories.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigCategories.java index 3ee27cd20..9662114fd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigCategories.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigCategories.java @@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.config; import java.util.Locale; -public enum ConfigCategories{ +public enum ConfigCategories { TOOL_VALUES("Tool Values", "Values for Tools"), MACHINE_VALUES("Machine Values", "Values for Machines"), @@ -23,7 +23,7 @@ public enum ConfigCategories{ public final String name; public final String comment; - ConfigCategories(String name, String comment){ + ConfigCategories(String name, String comment) { this.name = name.toLowerCase(Locale.ROOT); this.comment = comment; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigValues.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigValues.java index b684f4346..ca7da86e9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigValues.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigValues.java @@ -21,42 +21,42 @@ import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.config.Configuration; -public final class ConfigValues{ +public final class ConfigValues { public static Item itemRedstoneTorchConfigurator; public static Item itemCompassConfigurator; - public static void defineConfigValues(Configuration config){ - for(ConfigIntValues currConf : ConfigIntValues.values()){ + public static void defineConfigValues(Configuration config) { + for (ConfigIntValues currConf : ConfigIntValues.values()) { currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc, currConf.min, currConf.max).getInt(); } - for(ConfigBoolValues currConf : ConfigBoolValues.values()){ + for (ConfigBoolValues currConf : ConfigBoolValues.values()) { currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getBoolean(); } - for(ConfigIntListValues currConf : ConfigIntListValues.values()){ + for (ConfigIntListValues currConf : ConfigIntListValues.values()) { currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getIntList(); } - for(ConfigStringListValues currConf : ConfigStringListValues.values()){ + for (ConfigStringListValues currConf : ConfigStringListValues.values()) { currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getStringList(); } parseConfiguratorConfig(); } - private static void parseConfiguratorConfig(){ + private static void parseConfiguratorConfig() { itemRedstoneTorchConfigurator = null; itemCompassConfigurator = null; String[] conf = ConfigStringListValues.CONFIGURE_ITEMS.getValue(); - if(conf.length == 2){ + if (conf.length == 2) { itemRedstoneTorchConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[0])); itemCompassConfigurator = Item.REGISTRY.getObject(new ResourceLocation(conf[1])); } - if(itemRedstoneTorchConfigurator == null || itemCompassConfigurator == null){ + if (itemRedstoneTorchConfigurator == null || itemCompassConfigurator == null) { ActuallyAdditions.LOGGER.error("Parsing the Configuration Items config failed, reverting back to the default settings!"); itemRedstoneTorchConfigurator = Item.getItemFromBlock(Blocks.REDSTONE_TORCH); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigurationHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigurationHandler.java index 5d231078f..b850f6704 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigurationHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigurationHandler.java @@ -10,19 +10,19 @@ package de.ellpeck.actuallyadditions.mod.config; +import java.io.File; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.client.event.ConfigChangedEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import java.io.File; - -public class ConfigurationHandler{ +public class ConfigurationHandler { public static Configuration config; - public ConfigurationHandler(File configFile){ + public ConfigurationHandler(File configFile) { ActuallyAdditions.LOGGER.info("Grabbing Configurations..."); MinecraftForge.EVENT_BUS.register(this); @@ -33,17 +33,17 @@ public class ConfigurationHandler{ redefineConfigs(); } - public static void redefineConfigs(){ + public static void redefineConfigs() { ConfigValues.defineConfigValues(config); - if(config.hasChanged()){ + if (config.hasChanged()) { config.save(); } } @SubscribeEvent - public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event){ - if(event.getModID().equalsIgnoreCase(ActuallyAdditions.MODID)){ + public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) { + if (event.getModID().equalsIgnoreCase(ActuallyAdditions.MODID)) { redefineConfigs(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiConfiguration.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiConfiguration.java index 40a832024..2d1dfea2f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiConfiguration.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiConfiguration.java @@ -10,25 +10,24 @@ package de.ellpeck.actuallyadditions.mod.config; +import java.util.ArrayList; +import java.util.List; + +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.config.ConfigElement; import net.minecraftforge.fml.client.config.GuiConfig; import net.minecraftforge.fml.client.config.IConfigElement; -import java.util.ArrayList; -import java.util.List; +public class GuiConfiguration extends GuiConfig { -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; - -public class GuiConfiguration extends GuiConfig{ - - public GuiConfiguration(GuiScreen parentScreen){ + public GuiConfiguration(GuiScreen parentScreen) { super(parentScreen, getConfigElements(), ActuallyAdditions.MODID, false, false, GuiConfig.getAbridgedConfigPath(ConfigurationHandler.config.toString())); } - private static List getConfigElements(){ + private static List getConfigElements() { List list = new ArrayList<>(); - for(int i = 0; i < ConfigCategories.values().length; i++){ + for (int i = 0; i < ConfigCategories.values().length; i++) { ConfigCategories cat = ConfigCategories.values()[i]; ConfigurationHandler.config.setCategoryComment(cat.name, cat.comment); list.add(new ConfigElement(ConfigurationHandler.config.getCategory(cat.name))); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiFactory.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiFactory.java index 1b676feac..627e6a1bb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiFactory.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiFactory.java @@ -10,31 +10,31 @@ package de.ellpeck.actuallyadditions.mod.config; +import java.util.Set; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.fml.client.IModGuiFactory; -import java.util.Set; - -public class GuiFactory implements IModGuiFactory{ +public class GuiFactory implements IModGuiFactory { @Override - public void initialize(Minecraft minecraftInstance){ + public void initialize(Minecraft minecraftInstance) { } @Override - public boolean hasConfigGui(){ + public boolean hasConfigGui() { return true; } @Override - public GuiScreen createConfigGui(GuiScreen parentScreen){ + public GuiScreen createConfigGui(GuiScreen parentScreen) { return new GuiConfiguration(parentScreen); } @Override - public Set runtimeGuiCategories(){ + public Set runtimeGuiCategories() { return null; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigBoolValues.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigBoolValues.java index 27ee33fd3..a98742258 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigBoolValues.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigBoolValues.java @@ -12,16 +12,32 @@ package de.ellpeck.actuallyadditions.mod.config.values; import de.ellpeck.actuallyadditions.mod.config.ConfigCategories; -public enum ConfigBoolValues{ +public enum ConfigBoolValues { - JAM_VILLAGER_EXISTS("Jam Villager: Existence", ConfigCategories.WORLD_GEN, true, "Should the Jam Villager and his House generate in the world?"), + JAM_VILLAGER_EXISTS( + "Jam Villager: Existence", + ConfigCategories.WORLD_GEN, + true, + "Should the Jam Villager and his House generate in the world?"), CROP_FIELD_EXISTS("Crop Field: Existence", ConfigCategories.WORLD_GEN, true, "Should Custom Crop Fields exist?"), - ENGINEER_VILLAGER_EXISTS("Engineer Villager: Existence", ConfigCategories.WORLD_GEN, true, "Should the Engineer Villager and his House generate in the worl?"), + ENGINEER_VILLAGER_EXISTS( + "Engineer Villager: Existence", + ConfigCategories.WORLD_GEN, + true, + "Should the Engineer Villager and his House generate in the worl?"), GENERATE_QUARTZ("Black Quartz", ConfigCategories.WORLD_GEN, true, "Shold Black Quartz generate in the world?"), - DO_UPDATE_CHECK("Do Update Check", ConfigCategories.OTHER, true, "If true, Actually Additions Checks for updates on World Load."), - UPDATE_CHECK_VERSION_SPECIFIC("Version Specific Update Checker", ConfigCategories.OTHER, true, "If true, Actually Additions' Update Checker searches for updates for the Minecraft Version you currently play on."), + DO_UPDATE_CHECK( + "Do Update Check", + ConfigCategories.OTHER, + true, + "If true, Actually Additions Checks for updates on World Load."), + UPDATE_CHECK_VERSION_SPECIFIC( + "Version Specific Update Checker", + ConfigCategories.OTHER, + true, + "If true, Actually Additions' Update Checker searches for updates for the Minecraft Version you currently play on."), DO_CAT_DROPS("Do Cat Drops", ConfigCategories.OTHER, true, "If true, Cats drop Hairy Balls Occasionally."), WORMS("Worms", ConfigCategories.OTHER, true, "If true, worms will drop from tilling the soil."), @@ -31,36 +47,103 @@ public enum ConfigBoolValues{ DO_FLAX_GEN("Flax Gen", ConfigCategories.WORLD_GEN, true, "Should Flax generate in the World?"), DO_COFFEE_GEN("Coffee Gen", ConfigCategories.WORLD_GEN, true, "Should Coffee Plants generate in the World?"), DO_LOTUS_GEN("Black Lotus Gen", ConfigCategories.WORLD_GEN, true, "Should Black Lotus generate in the World?"), - DO_TREASURE_CHEST_GEN("Treasure Chest Gen", ConfigCategories.WORLD_GEN, true, "Should Treasure Chests generate in the World?"), - DO_CRYSTAL_CLUSTERS("Crystal Clusters in Lush Caves", ConfigCategories.WORLD_GEN, true, "If Crystal Clusters should generate in Lush Caves"), + DO_TREASURE_CHEST_GEN( + "Treasure Chest Gen", + ConfigCategories.WORLD_GEN, + true, + "Should Treasure Chests generate in the World?"), + DO_CRYSTAL_CLUSTERS( + "Crystal Clusters in Lush Caves", + ConfigCategories.WORLD_GEN, + true, + "If Crystal Clusters should generate in Lush Caves"), DO_SPIDER_DROPS("Spider Cobweb Drop", ConfigCategories.MOB_DROPS, true, "Should Cobwebs drop from spiders?"), DO_BAT_DROPS("Bat Wing Drop", ConfigCategories.MOB_DROPS, true, "Should Bat wings drop from Bats?"), - DO_XP_DROPS("Solidified XP Drop", ConfigCategories.MOB_DROPS, true, "If true, Mobs will randomly drop solidified XP occasionally."), + DO_XP_DROPS( + "Solidified XP Drop", + ConfigCategories.MOB_DROPS, + true, + "If true, Mobs will randomly drop solidified XP occasionally."), - CTRL_EXTRA_INFO("Advanced Info", ConfigCategories.OTHER, true, "Show Advanced Item Info when holding Control on every Item."), - CTRL_INFO_FOR_EXTRA_INFO("Advanced Info Tooltips", ConfigCategories.OTHER, true, "Show the 'Press Control for more Info'-Text on Item Tooltips"), + CTRL_EXTRA_INFO( + "Advanced Info", + ConfigCategories.OTHER, + true, + "Show Advanced Item Info when holding Control on every Item."), + CTRL_INFO_FOR_EXTRA_INFO( + "Advanced Info Tooltips", + ConfigCategories.OTHER, + true, + "Show the 'Press Control for more Info'-Text on Item Tooltips"), - SHOW_BOOKLET_INFO("Booklet Quick Opening Info", ConfigCategories.TOOL_VALUES, true, "If true,'Press key for more information' text should show when the item has a page in the booklet"), - GIVE_BOOKLET_ON_FIRST_CRAFT("Give Booklet on First Craft", ConfigCategories.OTHER, true, "If true, the booklet should be given to the player when he first crafts something from the Mod"), + SHOW_BOOKLET_INFO( + "Booklet Quick Opening Info", + ConfigCategories.TOOL_VALUES, + true, + "If true,'Press key for more information' text should show when the item has a page in the booklet"), + GIVE_BOOKLET_ON_FIRST_CRAFT( + "Give Booklet on First Craft", + ConfigCategories.OTHER, + true, + "If true, the booklet should be given to the player when he first crafts something from the Mod"), - DUNGEON_LOOT("Village and Dungeon Loot", ConfigCategories.OTHER, true, "Should Actually Additions Loot generate in dungeons?"), - GEN_LUSH_CAVES("Generate Lush Caves", ConfigCategories.WORLD_GEN, true, "Should caves with trees and grass randomly generate underground?"), + DUNGEON_LOOT( + "Village and Dungeon Loot", + ConfigCategories.OTHER, + true, + "Should Actually Additions Loot generate in dungeons?"), + GEN_LUSH_CAVES( + "Generate Lush Caves", + ConfigCategories.WORLD_GEN, + true, + "Should caves with trees and grass randomly generate underground?"), - WATER_BOWL("Water Bowl", ConfigCategories.OTHER, true, "Should right-clicking a bowl on water blocks create a water bowl?"), - WATER_BOWL_LOSS("Water Bowl Spilling", ConfigCategories.OTHER, true, "Should the water bowl spill if you don't sneak while using it?"), + WATER_BOWL( + "Water Bowl", + ConfigCategories.OTHER, + true, + "Should right-clicking a bowl on water blocks create a water bowl?"), + WATER_BOWL_LOSS( + "Water Bowl Spilling", + ConfigCategories.OTHER, + true, + "Should the water bowl spill if you don't sneak while using it?"), TINY_COAL_STUFF("Tiny Coal", ConfigCategories.OTHER, true, "Should Tiny Coal and Tiny Charcoal be craftable"), - LASER_RELAY_LOSS("Laser Relay Energy Loss", ConfigCategories.MACHINE_VALUES, true, "If Energy Laser Relays should have energy loss"), + LASER_RELAY_LOSS( + "Laser Relay Energy Loss", + ConfigCategories.MACHINE_VALUES, + true, + "If Energy Laser Relays should have energy loss"), - SUPER_DUPER_HARD_MODE("Super Duper Hard Recipes", ConfigCategories.OTHER, false, "Turn this on to make recipes for items from the mod really hard. (This is a joke feature poking fun at the whole FTB Infinity Expert Mode style of playing. You shouldn't really turn this on as it makes the mod completely unplayable.)"), - MOST_BLAND_PERSON_EVER("No Colored Item Names", ConfigCategories.OTHER, false, "If you want to be really boring and lame, you can turn on this setting to disable colored names on Actually Additions items. Because why would you want things to look pretty anyways, right?"), + SUPER_DUPER_HARD_MODE( + "Super Duper Hard Recipes", + ConfigCategories.OTHER, + false, + "Turn this on to make recipes for items from the mod really hard. (This is a joke feature poking fun at the whole FTB Infinity Expert Mode style of playing. You shouldn't really turn this on as it makes the mod completely unplayable.)"), + MOST_BLAND_PERSON_EVER( + "No Colored Item Names", + ConfigCategories.OTHER, + false, + "If you want to be really boring and lame, you can turn on this setting to disable colored names on Actually Additions items. Because why would you want things to look pretty anyways, right?"), - COLOR_LENS_USES_OREDICT("Color Lens Oredict", ConfigCategories.OTHER, false, "If true, the Lens of Color will attempt to pull from the oredict instead of only using vanilla dyes."), - SOLID_XP_ALWAYS_ORBS("Solid XP Orbs", ConfigCategories.OTHER, false, "If true, Solidified Experience will always spawn orbs, even for regular players."), - - ORE_GEN_DIM_WHITELIST("Ore Gen Whitelist", ConfigCategories.WORLD_GEN, false, "If true, the ore gen dimension blacklist will be treated as a whitelist."); + COLOR_LENS_USES_OREDICT( + "Color Lens Oredict", + ConfigCategories.OTHER, + false, + "If true, the Lens of Color will attempt to pull from the oredict instead of only using vanilla dyes."), + SOLID_XP_ALWAYS_ORBS( + "Solid XP Orbs", + ConfigCategories.OTHER, + false, + "If true, Solidified Experience will always spawn orbs, even for regular players."), + ORE_GEN_DIM_WHITELIST( + "Ore Gen Whitelist", + ConfigCategories.WORLD_GEN, + false, + "If true, the ore gen dimension blacklist will be treated as a whitelist."); public final String name; public final String category; @@ -69,14 +152,14 @@ public enum ConfigBoolValues{ public boolean currentValue; - ConfigBoolValues(String name, ConfigCategories category, boolean defaultValue, String desc){ + ConfigBoolValues(String name, ConfigCategories category, boolean defaultValue, String desc) { this.name = name; this.category = category.name; this.defaultValue = defaultValue; this.desc = desc; } - public boolean isEnabled(){ + public boolean isEnabled() { return this.currentValue; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntListValues.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntListValues.java index a704d135f..8283bbaf3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntListValues.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntListValues.java @@ -12,12 +12,28 @@ package de.ellpeck.actuallyadditions.mod.config.values; import de.ellpeck.actuallyadditions.mod.config.ConfigCategories; -public enum ConfigIntListValues{ +public enum ConfigIntListValues { - ORE_GEN_DIMENSION_BLACKLIST("OreGen Dimension Blacklist", ConfigCategories.WORLD_GEN, new int[0], "The list of IDs that Actually Additions OreGen (Ex: Black Quartz) is banned in. This also applies for other world gen like lush caves."), - PLANT_DIMENSION_BLACKLIST("Plant Blacklist", ConfigCategories.WORLD_GEN, new int[0], "The list of IDs of the dimensions that Actually Additions Plants (Rice for example) are banned in."), - OIL_POWER("Oil Gen: Power Values", ConfigCategories.MACHINE_VALUES, new int[]{40, 80, 100, 120}, "The amount of power that the 4 tiers of oils generate in CF/t. Ordered."), - OIL_TIME("Oil Gen: Time Values", ConfigCategories.MACHINE_VALUES, new int[]{100, 120, 280, 400}, "The amount of time that the 4 tiers of oils work for in seconds. Ordered."); + ORE_GEN_DIMENSION_BLACKLIST( + "OreGen Dimension Blacklist", + ConfigCategories.WORLD_GEN, + new int[0], + "The list of IDs that Actually Additions OreGen (Ex: Black Quartz) is banned in. This also applies for other world gen like lush caves."), + PLANT_DIMENSION_BLACKLIST( + "Plant Blacklist", + ConfigCategories.WORLD_GEN, + new int[0], + "The list of IDs of the dimensions that Actually Additions Plants (Rice for example) are banned in."), + OIL_POWER( + "Oil Gen: Power Values", + ConfigCategories.MACHINE_VALUES, + new int[] { 40, 80, 100, 120 }, + "The amount of power that the 4 tiers of oils generate in CF/t. Ordered."), + OIL_TIME( + "Oil Gen: Time Values", + ConfigCategories.MACHINE_VALUES, + new int[] { 100, 120, 280, 400 }, + "The amount of time that the 4 tiers of oils work for in seconds. Ordered."); public final String name; public final String category; @@ -26,14 +42,14 @@ public enum ConfigIntListValues{ public int[] currentValue; - ConfigIntListValues(String name, ConfigCategories category, int[] defaultValue, String desc){ + ConfigIntListValues(String name, ConfigCategories category, int[] defaultValue, String desc) { this.name = name; this.category = category.name; this.defaultValue = defaultValue; this.desc = desc; } - public int[] getValue(){ + public int[] getValue() { return this.currentValue; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntValues.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntValues.java index cfb96c68d..64ece6f2d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntValues.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntValues.java @@ -12,27 +12,93 @@ package de.ellpeck.actuallyadditions.mod.config.values; import de.ellpeck.actuallyadditions.mod.config.ConfigCategories; -public enum ConfigIntValues{ +public enum ConfigIntValues { RICE_AMOUNT("Rice: Amount", ConfigCategories.WORLD_GEN, 15, 1, 100, "The Amount of Rice generating"), CANOLA_AMOUNT("Canola: Amount", ConfigCategories.WORLD_GEN, 10, 1, 50, "The Amount of Canola generating"), FLAX_AMOUNT("Flax: Amount", ConfigCategories.WORLD_GEN, 8, 1, 50, "The Amount of Flax generating"), COFFEE_AMOUNT("Coffee: Amount", ConfigCategories.WORLD_GEN, 6, 1, 50, "The Amount of Coffee generating"), - BLACK_LOTUS_AMOUNT("Black Lotus: Amount", ConfigCategories.WORLD_GEN, 14, 1, 50, "The Amount of Black Lotus generating"), - LUSH_CAVE_CHANCE("Lush Caves: Chance", ConfigCategories.WORLD_GEN, 20, 1, 100, "The chances for lush caves to generate. The lower the number, the higher the chances."), - WORMS_DIE_TIME("Worm Death Time", ConfigCategories.OTHER, 0, 0, 10000000, "The amount of ticks it takes for a worm to die. When at 0 ticks, it will not die."), + BLACK_LOTUS_AMOUNT( + "Black Lotus: Amount", + ConfigCategories.WORLD_GEN, + 14, + 1, + 50, + "The Amount of Black Lotus generating"), + LUSH_CAVE_CHANCE( + "Lush Caves: Chance", + ConfigCategories.WORLD_GEN, + 20, + 1, + 100, + "The chances for lush caves to generate. The lower the number, the higher the chances."), + WORMS_DIE_TIME( + "Worm Death Time", + ConfigCategories.OTHER, + 0, + 0, + 10000000, + "The amount of ticks it takes for a worm to die. When at 0 ticks, it will not die."), - TILE_ENTITY_UPDATE_INTERVAL("Tile Entities: Update Interval", ConfigCategories.OTHER, 5, 1, 100, "The amount of ticks waited before a TileEntity sends an additional Update to the Client"), - CTRL_INFO_NBT_CHAR_LIMIT("Advanced Info NBT Character Limit", ConfigCategories.OTHER, 1000, 0, 100000000, "The maximum amount of characters that is displayed by the NBT view of the CTRL Advanced Info. Set to a zero to have no limit"), + TILE_ENTITY_UPDATE_INTERVAL( + "Tile Entities: Update Interval", + ConfigCategories.OTHER, + 5, + 1, + 100, + "The amount of ticks waited before a TileEntity sends an additional Update to the Client"), + CTRL_INFO_NBT_CHAR_LIMIT( + "Advanced Info NBT Character Limit", + ConfigCategories.OTHER, + 1000, + 0, + 100000000, + "The maximum amount of characters that is displayed by the NBT view of the CTRL Advanced Info. Set to a zero to have no limit"), - FONT_SIZE_SMALL("Booklet Small Font Size", ConfigCategories.OTHER, 0, 0, 500, "The size of the booklet's small font in percent. Set to 0 to use defaults from the lang file."), - FONT_SIZE_MEDIUM("Booklet Medium Font Size", ConfigCategories.OTHER, 0, 0, 500, "The size of the booklet's medium font in percent. Set to 0 to use defaults from the lang file."), - FONT_SIZE_LARGE("Booklet Large Font Size", ConfigCategories.OTHER, 0, 0, 500, "The size of the booklet's large font in percent. Set to 0 to use defaults from the lang file."), + FONT_SIZE_SMALL( + "Booklet Small Font Size", + ConfigCategories.OTHER, + 0, + 0, + 500, + "The size of the booklet's small font in percent. Set to 0 to use defaults from the lang file."), + FONT_SIZE_MEDIUM( + "Booklet Medium Font Size", + ConfigCategories.OTHER, + 0, + 0, + 500, + "The size of the booklet's medium font in percent. Set to 0 to use defaults from the lang file."), + FONT_SIZE_LARGE( + "Booklet Large Font Size", + ConfigCategories.OTHER, + 0, + 0, + 500, + "The size of the booklet's large font in percent. Set to 0 to use defaults from the lang file."), ELEVEN("What is 11", ConfigCategories.OTHER, 11, 0, 12, "11?"), - FUR_CHANCE("Fur Drop Chance", ConfigCategories.OTHER, 5000, 1, Integer.MAX_VALUE, "The 1/n drop chance, per tick, for a fur ball to be dropped."), - RECONSTRUCTOR_POWER("Atomic Reconstructor Power", ConfigCategories.MACHINE_VALUES, 300000, 300000, Integer.MAX_VALUE, "The amount of power the atomic reconstructor can store."), - FARMER_AREA("Farmer Area", ConfigCategories.MACHINE_VALUES, 9, 1, Integer.MAX_VALUE, "The size of the farmer's farming area. Default is 9x9, must be an odd number."); + FUR_CHANCE( + "Fur Drop Chance", + ConfigCategories.OTHER, + 5000, + 1, + Integer.MAX_VALUE, + "The 1/n drop chance, per tick, for a fur ball to be dropped."), + RECONSTRUCTOR_POWER( + "Atomic Reconstructor Power", + ConfigCategories.MACHINE_VALUES, + 300000, + 300000, + Integer.MAX_VALUE, + "The amount of power the atomic reconstructor can store."), + FARMER_AREA( + "Farmer Area", + ConfigCategories.MACHINE_VALUES, + 9, + 1, + Integer.MAX_VALUE, + "The size of the farmer's farming area. Default is 9x9, must be an odd number."); public final String name; public final String category; @@ -43,7 +109,7 @@ public enum ConfigIntValues{ public int currentValue; - ConfigIntValues(String name, ConfigCategories category, int defaultValue, int min, int max, String desc){ + ConfigIntValues(String name, ConfigCategories category, int defaultValue, int min, int max, String desc) { this.name = name; this.category = category.name; this.defaultValue = defaultValue; @@ -52,7 +118,7 @@ public enum ConfigIntValues{ this.desc = desc; } - public int getValue(){ + public int getValue() { return this.currentValue; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigStringListValues.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigStringListValues.java index 7aa1d6d37..1cfaf21cf 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigStringListValues.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigStringListValues.java @@ -12,21 +12,73 @@ package de.ellpeck.actuallyadditions.mod.config.values; import de.ellpeck.actuallyadditions.mod.config.ConfigCategories; -public enum ConfigStringListValues{ +public enum ConfigStringListValues { - CONFIGURE_ITEMS("Configuration Items", ConfigCategories.OTHER, new String[]{"minecraft:redstone_torch", "minecraft:compass"}, "The non-Actually Additions items that are used to configure blocks from the mod. The first one is the Redstone Torch used to configure the Redstone Mode, and the second one is the Compass used to configure Laser Relays. If another mod overrides usage of either one of these items, you can change the registry name of the used items (using blocks is not possible) here."), - CRUSHER_RECIPE_EXCEPTIONS("Crusher Recipe Exceptions", ConfigCategories.OTHER, new String[]{"ingotBrick", "ingotBrickNether"}, "Ingots, Dusts and Ores that will be blacklisted from being auto-registered to be crushed by the Crusher. This list uses OreDictionary Names of the Inputs only."), - CRUSHER_OUTPUT_BLACKLIST("Crusher Output Blacklist", ConfigCategories.OTHER, new String[0], "The items that aren't allowed as outputs from OreDict Crusher recipes. Use this in case a mod, for example, adds a dust variant that can't be smelted into an ingot. Use REGISTRY NAMES, and if metadata is needed, add it like so: somemod:some_item@3"), - MINING_LENS_BLACKLIST("Mining Lens Blacklist", ConfigCategories.OTHER, new String[0], "The items that aren't allowed as being generated by the Lens of the Miner. Use REGISTRY NAMES, and if metadata is needed, add it like so: somemod:some_block@3"), - MINING_LENS_EXTRA_WHITELIST("Mining lens Extra Whitelist", ConfigCategories.OTHER, new String[0], "By default, the mining lens has a set number of ores it can generate. If there is an ore that it should be able to generate, add its OreDictionary name followed by an @ and the weight that it should have (the higher, the more often it will generate), followed by another @ and then an s for it to generate in stone and an n for it to generate in netherrack. For instance: oreCheese@100@s would add cheese ore with a weight of 100 that generates in stone."), - MASHED_FOOD_CRAFTING_EXCEPTIONS("Mashed Food Crafting Exceptions", ConfigCategories.OTHER, new String[]{"actuallyadditions:item_coffee"}, "The ItemFood, IGrowable and IPlantable Items that can not be used to craft Mashed Food. These are the actual registered Item Names, the ones you use, for example, when using the /give Command."), - PAXEL_EXTRA_MINING_WHITELIST("AIOT Extra Whitelist", ConfigCategories.TOOL_VALUES, new String[]{"TConstruct:GravelOre"}, "By default, the AIOT can mine certain blocks. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command."), - DRILL_EXTRA_MINING_WHITELIST("Drill Extra Whitelist", ConfigCategories.TOOL_VALUES, new String[]{"TConstruct:GravelOre"}, "By default, the Drill can mine certain blocks. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command."), - MINER_EXTRA_WHITELIST("Vertical Digger Extra Whitelist", ConfigCategories.MACHINE_VALUES, new String[0], "By default, the Vertical Digger mines everything that starts with 'ore' in the OreDictionary. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command. This Config Option only applies if the miner is in Ores Only Mode."), - MINER_BLACKLIST("Vertical Digger Blacklist", ConfigCategories.MACHINE_VALUES, new String[0], "By default, the Vertical Digger mines everything that starts with 'ore' in the OreDictionary. If there is one that it can mine, but shouldn't be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command. This Config Option will apply in both modes."), - REPAIRER_EXTRA_WHITELIST("Item Repairer Extra Whitelist", ConfigCategories.MACHINE_VALUES, new String[]{"tconstruct:pickaxe", "tconstruct:shovel", "tconstruct:hatchet", "tconstruct:mattock", "tconstruct:broadsword", "tconstruct:longsword", "tconstruct:frypan", "tconstruct:battlesign", "tconstruct:hammer", "tconstruct:excavator", "tconstruct:lumberaxe", "tconstruct:cleaver", "tconstruct:rapier"}, "By default, the Item Repairer only repairs items which are repairable in an anvil. Add an item's REGISTRY NAME here if you want it to be repairable."), - SPAWNER_CHANGER_BLACKLIST("Spawner Changer Blacklist", ConfigCategories.OTHER, new String[]{"minecraft:villager_golem"}, "By default, the Spawner Changer allows every living entity to be put into a spawner. If there is one that shouldn't be able to, put its MAPPING NAME here."), - SACK_BLACKLIST("Sack Blacklist", ConfigCategories.OTHER, new String[0], "The items that aren't allowed to be put in the Traveller's Sack. Use REGISTRY NAMES, and if metadata is needed, add it like so: somemod:some_block@3"); + CONFIGURE_ITEMS( + "Configuration Items", + ConfigCategories.OTHER, + new String[] { "minecraft:redstone_torch", "minecraft:compass" }, + "The non-Actually Additions items that are used to configure blocks from the mod. The first one is the Redstone Torch used to configure the Redstone Mode, and the second one is the Compass used to configure Laser Relays. If another mod overrides usage of either one of these items, you can change the registry name of the used items (using blocks is not possible) here."), + CRUSHER_RECIPE_EXCEPTIONS( + "Crusher Recipe Exceptions", + ConfigCategories.OTHER, + new String[] { "ingotBrick", "ingotBrickNether" }, + "Ingots, Dusts and Ores that will be blacklisted from being auto-registered to be crushed by the Crusher. This list uses OreDictionary Names of the Inputs only."), + CRUSHER_OUTPUT_BLACKLIST( + "Crusher Output Blacklist", + ConfigCategories.OTHER, + new String[0], + "The items that aren't allowed as outputs from OreDict Crusher recipes. Use this in case a mod, for example, adds a dust variant that can't be smelted into an ingot. Use REGISTRY NAMES, and if metadata is needed, add it like so: somemod:some_item@3"), + MINING_LENS_BLACKLIST( + "Mining Lens Blacklist", + ConfigCategories.OTHER, + new String[0], + "The items that aren't allowed as being generated by the Lens of the Miner. Use REGISTRY NAMES, and if metadata is needed, add it like so: somemod:some_block@3"), + MINING_LENS_EXTRA_WHITELIST( + "Mining lens Extra Whitelist", + ConfigCategories.OTHER, + new String[0], + "By default, the mining lens has a set number of ores it can generate. If there is an ore that it should be able to generate, add its OreDictionary name followed by an @ and the weight that it should have (the higher, the more often it will generate), followed by another @ and then an s for it to generate in stone and an n for it to generate in netherrack. For instance: oreCheese@100@s would add cheese ore with a weight of 100 that generates in stone."), + MASHED_FOOD_CRAFTING_EXCEPTIONS( + "Mashed Food Crafting Exceptions", + ConfigCategories.OTHER, + new String[] { "actuallyadditions:item_coffee" }, + "The ItemFood, IGrowable and IPlantable Items that can not be used to craft Mashed Food. These are the actual registered Item Names, the ones you use, for example, when using the /give Command."), + PAXEL_EXTRA_MINING_WHITELIST( + "AIOT Extra Whitelist", + ConfigCategories.TOOL_VALUES, + new String[] { "TConstruct:GravelOre" }, + "By default, the AIOT can mine certain blocks. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command."), + DRILL_EXTRA_MINING_WHITELIST( + "Drill Extra Whitelist", + ConfigCategories.TOOL_VALUES, + new String[] { "TConstruct:GravelOre" }, + "By default, the Drill can mine certain blocks. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command."), + MINER_EXTRA_WHITELIST( + "Vertical Digger Extra Whitelist", + ConfigCategories.MACHINE_VALUES, + new String[0], + "By default, the Vertical Digger mines everything that starts with 'ore' in the OreDictionary. If there is one that it can't mine, but should be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command. This Config Option only applies if the miner is in Ores Only Mode."), + MINER_BLACKLIST( + "Vertical Digger Blacklist", + ConfigCategories.MACHINE_VALUES, + new String[0], + "By default, the Vertical Digger mines everything that starts with 'ore' in the OreDictionary. If there is one that it can mine, but shouldn't be able to, put its REGISTRY NAME here. These are the actual registered Item Names, the ones you use, for example, when using the /give Command. This Config Option will apply in both modes."), + REPAIRER_EXTRA_WHITELIST( + "Item Repairer Extra Whitelist", + ConfigCategories.MACHINE_VALUES, + new String[] { "tconstruct:pickaxe", "tconstruct:shovel", "tconstruct:hatchet", "tconstruct:mattock", "tconstruct:broadsword", "tconstruct:longsword", "tconstruct:frypan", "tconstruct:battlesign", "tconstruct:hammer", "tconstruct:excavator", "tconstruct:lumberaxe", "tconstruct:cleaver", "tconstruct:rapier" }, + "By default, the Item Repairer only repairs items which are repairable in an anvil. Add an item's REGISTRY NAME here if you want it to be repairable."), + SPAWNER_CHANGER_BLACKLIST( + "Spawner Changer Blacklist", + ConfigCategories.OTHER, + new String[] { "minecraft:villager_golem" }, + "By default, the Spawner Changer allows every living entity to be put into a spawner. If there is one that shouldn't be able to, put its MAPPING NAME here."), + SACK_BLACKLIST( + "Sack Blacklist", + ConfigCategories.OTHER, + new String[0], + "The items that aren't allowed to be put in the Traveller's Sack. Use REGISTRY NAMES, and if metadata is needed, add it like so: somemod:some_block@3"); public final String name; public final String category; @@ -35,14 +87,14 @@ public enum ConfigStringListValues{ public String[] currentValue; - ConfigStringListValues(String name, ConfigCategories category, String[] defaultValue, String desc){ + ConfigStringListValues(String name, ConfigCategories category, String[] defaultValue, String desc) { this.name = name; this.category = category.name; this.defaultValue = defaultValue; this.desc = desc; } - public String[] getValue(){ + public String[] getValue() { return this.currentValue; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/BlockCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/BlockCrafting.java index 866cac02a..8b0578191 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/BlockCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/BlockCrafting.java @@ -29,7 +29,7 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; -public final class BlockCrafting{ +public final class BlockCrafting { public static final IRecipe[] RECIPES_LAMPS = new IRecipe[BlockColoredLamp.ALL_LAMP_TYPES.length]; public static IRecipe recipeSmileyCloud; @@ -103,7 +103,7 @@ public final class BlockCrafting{ private static class FireworkIngredient extends Ingredient { ItemStack firework = new ItemStack(Items.FIREWORKS); - ItemStack[] fireworks = new ItemStack[] {this.firework}; + ItemStack[] fireworks = new ItemStack[] { this.firework }; @Override public ItemStack[] getMatchingStacks() { @@ -116,616 +116,307 @@ public final class BlockCrafting{ } } - public static void init(){ + public static void init() { Block[] removeNBTBlocks = new Block[] { InitBlocks.blockOilGenerator, InitBlocks.blockFluidPlacer, InitBlocks.blockFluidCollector, InitBlocks.blockCanolaPress, InitBlocks.blockFermentingBarrel }; - for(Block b : removeNBTBlocks) + for (Block b : removeNBTBlocks) RecipeHandler.addShapelessOreDictRecipe(new ItemStack(b), new ItemStack(b)); //Battery Box - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitBlocks.blockBatteryBox), - new ItemStack(InitBlocks.blockEnergizer), - new ItemStack(InitBlocks.blockEnervator), - new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal())); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitBlocks.blockBatteryBox), new ItemStack(InitBlocks.blockEnergizer), new ItemStack(InitBlocks.blockEnervator), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal())); recipeBatteryBox = RecipeUtil.lastIRecipe(); //Farmer - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFarmer), - "ISI", "SCS", "ISI", - 'I', new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.IRON.ordinal()), - 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), - 'S', new ItemStack(Items.WHEAT_SEEDS)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFarmer), "ISI", "SCS", "ISI", 'I', new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.IRON.ordinal()), 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), 'S', new ItemStack(Items.WHEAT_SEEDS)); recipeFarmer = RecipeUtil.lastIRecipe(); //Empowerer - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockEmpowerer), - " R ", " B ", "CDC", - 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), - 'B', new ItemStack(InitItems.itemBatteryDouble, 1, Util.WILDCARD), - 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), - 'D', new ItemStack(InitBlocks.blockDisplayStand)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockEmpowerer), " R ", " B ", "CDC", 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 'B', new ItemStack(InitItems.itemBatteryDouble, 1, Util.WILDCARD), 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), 'D', new ItemStack(InitBlocks.blockDisplayStand)); recipeEmpowerer = RecipeUtil.lastIRecipe(); //Tiny Torch - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockTinyTorch, 2), - "C", - "W", - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.TINY_COAL.ordinal()), - 'W', "stickWood"); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockTinyTorch, 2), "C", "W", 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.TINY_COAL.ordinal()), 'W', "stickWood"); recipesTinyTorch[0] = RecipeUtil.lastIRecipe(); - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockTinyTorch, 2), - "C", - "W", - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.TINY_CHAR.ordinal()), - 'W', "stickWood"); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockTinyTorch, 2), "C", "W", 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.TINY_CHAR.ordinal()), 'W', "stickWood"); recipesTinyTorch[1] = RecipeUtil.lastIRecipe(); //Firework Box - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFireworkBox), - "GFG", "SAS", "CCC", - 'G', new ItemStack(Items.GUNPOWDER), - 'S', new ItemStack(Items.STICK), - 'A', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), - 'F', new FireworkIngredient(), - 'C', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFireworkBox), "GFG", "SAS", "CCC", 'G', new ItemStack(Items.GUNPOWDER), 'S', new ItemStack(Items.STICK), 'A', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), 'F', new FireworkIngredient(), 'C', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal())); recipeFireworkBox = RecipeUtil.lastIRecipe(); //Shock Suppressor - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockShockSuppressor), - "OAO", "ACA", "OAO", - 'A', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.COAL.ordinal()), - 'O', new ItemStack(Blocks.OBSIDIAN), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockShockSuppressor), "OAO", "ACA", "OAO", 'A', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.COAL.ordinal()), 'O', new ItemStack(Blocks.OBSIDIAN), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); recipeShockSuppressor = RecipeUtil.lastIRecipe(); //Display Stand - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockDisplayStand), - " R ", "EEE", "GGG", - 'R', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), - 'E', new ItemStack(InitBlocks.blockTestifiBucksGreenWall), - 'G', new ItemStack(InitBlocks.blockTestifiBucksWhiteWall)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockDisplayStand), " R ", "EEE", "GGG", 'R', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), 'E', new ItemStack(InitBlocks.blockTestifiBucksGreenWall), 'G', new ItemStack(InitBlocks.blockTestifiBucksWhiteWall)); recipeDisplayStand = RecipeUtil.lastIRecipe(); //Miner - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMiner), - "IRI", "RCR", "IDI", - 'R', "blockRedstone", - 'I', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), - 'C', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.COAL.ordinal()), - 'D', new ItemStack(InitItems.itemDrill, 1, Util.WILDCARD)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMiner), "IRI", "RCR", "IDI", 'R', "blockRedstone", 'I', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), 'C', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.COAL.ordinal()), 'D', new ItemStack(InitItems.itemDrill, 1, Util.WILDCARD)); recipeMiner = RecipeUtil.lastIRecipe(); //Quartz - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockQuartzWall, 6), - "XXX", "XXX", - 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ.ordinal())); - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockQuartzSlab, 6), - "XXX", - 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ.ordinal())); - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockQuartzStair, 6), - "X ", "XX ", "XXX", - 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockQuartzWall, 6), "XXX", "XXX", 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockQuartzSlab, 6), "XXX", 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockQuartzStair, 6), "X ", "XX ", "XXX", 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ.ordinal())); //PillarQuartz - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPillarQuartzWall, 6), - "XXX", "XXX", - 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ_PILLAR.ordinal())); - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPillarQuartzSlab, 6), - "XXX", - 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ_PILLAR.ordinal())); - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPillarQuartzStair, 6), - "X ", "XX ", "XXX", - 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ_PILLAR.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPillarQuartzWall, 6), "XXX", "XXX", 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ_PILLAR.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPillarQuartzSlab, 6), "XXX", 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ_PILLAR.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPillarQuartzStair, 6), "X ", "XX ", "XXX", 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ_PILLAR.ordinal())); //ChiseledQuartz - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockChiseledQuartzWall, 6), - "XXX", "XXX", - 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ_CHISELED.ordinal())); - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockChiseledQuartzSlab, 6), - "XXX", - 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ_CHISELED.ordinal())); - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockChiseledQuartzStair, 6), - "X ", "XX ", "XXX", - 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ_CHISELED.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockChiseledQuartzWall, 6), "XXX", "XXX", 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ_CHISELED.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockChiseledQuartzSlab, 6), "XXX", 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ_CHISELED.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockChiseledQuartzStair, 6), "X ", "XX ", "XXX", 'X', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ_CHISELED.ordinal())); //White Ethetic Blocks - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockTestifiBucksWhiteFence, 6), - "XXX", "XXX", - 'X', new ItemStack(InitBlocks.blockTestifiBucksWhiteWall)); - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockTestifiBucksWhiteSlab, 6), - "XXX", - 'X', new ItemStack(InitBlocks.blockTestifiBucksWhiteWall)); - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockTestifiBucksWhiteStairs, 6), - "X ", "XX ", "XXX", - 'X', new ItemStack(InitBlocks.blockTestifiBucksWhiteWall)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockTestifiBucksWhiteFence, 6), "XXX", "XXX", 'X', new ItemStack(InitBlocks.blockTestifiBucksWhiteWall)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockTestifiBucksWhiteSlab, 6), "XXX", 'X', new ItemStack(InitBlocks.blockTestifiBucksWhiteWall)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockTestifiBucksWhiteStairs, 6), "X ", "XX ", "XXX", 'X', new ItemStack(InitBlocks.blockTestifiBucksWhiteWall)); //Green Ethetic Blocks - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockTestifiBucksGreenFence, 6), - "XXX", "XXX", - 'X', new ItemStack(InitBlocks.blockTestifiBucksGreenWall)); - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockTestifiBucksGreenSlab, 6), - "XXX", - 'X', new ItemStack(InitBlocks.blockTestifiBucksGreenWall)); - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockTestifiBucksGreenStairs, 6), - "X ", "XX ", "XXX", - 'X', new ItemStack(InitBlocks.blockTestifiBucksGreenWall)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockTestifiBucksGreenFence, 6), "XXX", "XXX", 'X', new ItemStack(InitBlocks.blockTestifiBucksGreenWall)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockTestifiBucksGreenSlab, 6), "XXX", 'X', new ItemStack(InitBlocks.blockTestifiBucksGreenWall)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockTestifiBucksGreenStairs, 6), "X ", "XX ", "XXX", 'X', new ItemStack(InitBlocks.blockTestifiBucksGreenWall)); //Atomic Reconstructor - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockAtomicReconstructor), - "IRI", "RCR", "IRI", - 'R', "dustRedstone", - 'I', "ingotIron", - 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockAtomicReconstructor), "IRI", "RCR", "IRI", 'R', "dustRedstone", 'I', "ingotIron", 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal())); recipeAtomicReconstructor = RecipeUtil.lastIRecipe(); //Laser Relay - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockLaserRelay, 4), - "OBO", "RCR", "OBO", - 'B', new ItemStack(Blocks.REDSTONE_BLOCK), - 'O', new ItemStack(Blocks.OBSIDIAN), - 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockLaserRelay, 4), "OBO", "RCR", "OBO", 'B', new ItemStack(Blocks.REDSTONE_BLOCK), 'O', new ItemStack(Blocks.OBSIDIAN), 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); recipeLaserRelay = RecipeUtil.lastIRecipe(); - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockLaserRelayAdvanced), - " I ", "XRX", " I ", - 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), - 'R', new ItemStack(InitBlocks.blockLaserRelay), - 'X', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockLaserRelayAdvanced), " I ", "XRX", " I ", 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), 'R', new ItemStack(InitBlocks.blockLaserRelay), 'X', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal())); recipeLaserRelayAdvanced = RecipeUtil.lastIRecipe(); - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockLaserRelayExtreme), - " I ", "XRX", " I ", - 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), - 'R', new ItemStack(InitBlocks.blockLaserRelayAdvanced), - 'X', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockLaserRelayExtreme), " I ", "XRX", " I ", 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), 'R', new ItemStack(InitBlocks.blockLaserRelayAdvanced), 'X', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal())); recipeLaserRelayExtreme = RecipeUtil.lastIRecipe(); //Whitelist Item Laser Relay - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitBlocks.blockLaserRelayItemWhitelist), - new ItemStack(InitBlocks.blockLaserRelayItem), - new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), - new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), - new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal())); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitBlocks.blockLaserRelayItemWhitelist), new ItemStack(InitBlocks.blockLaserRelayItem), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal())); recipeLaserRelayItemWhitelist = RecipeUtil.lastIRecipe(); //Item Interface - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockItemViewer), - "OBO", "RCR", "OBO", - 'B', new ItemStack(Items.REDSTONE), - 'O', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), - 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), - 'C', "chestWood"); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockItemViewer), "OBO", "RCR", "OBO", 'B', new ItemStack(Items.REDSTONE), 'O', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 'C', "chestWood"); recipeItemInterface = RecipeUtil.lastIRecipe(); //Hopping Item Interface - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitBlocks.blockItemViewerHopping), - new ItemStack(InitBlocks.blockItemViewer), - new ItemStack(Blocks.HOPPER)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitBlocks.blockItemViewerHopping), new ItemStack(InitBlocks.blockItemViewer), new ItemStack(Blocks.HOPPER)); recipeItemInterfaceHopping = RecipeUtil.lastIRecipe(); //Ranged Collector - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockRangedCollector), - " A ", "EHE", " C ", - 'E', new ItemStack(Items.ENDER_PEARL), - 'H', new ItemStack(Blocks.HOPPER), - 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), - 'A', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockRangedCollector), " A ", "EHE", " C ", 'E', new ItemStack(Items.ENDER_PEARL), 'H', new ItemStack(Blocks.HOPPER), 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), 'A', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal())); recipeRangedCollector = RecipeUtil.lastIRecipe(); //Directional Breaker - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockDirectionalBreaker), - "BBB", " C ", - 'C', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), - 'B', new ItemStack(InitBlocks.blockBreaker)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockDirectionalBreaker), "BBB", " C ", 'C', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), 'B', new ItemStack(InitBlocks.blockBreaker)); recipeDirectionalBreaker = RecipeUtil.lastIRecipe(); //Smiley Cloud - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockSmileyCloud), - " W ", "WXW", " W ", - 'W', new ItemStack(Blocks.WOOL, 1, Util.WILDCARD), - 'X', new ItemStack(InitItems.itemSolidifiedExperience)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockSmileyCloud), " W ", "WXW", " W ", 'W', new ItemStack(Blocks.WOOL, 1, Util.WILDCARD), 'X', new ItemStack(InitItems.itemSolidifiedExperience)); recipeSmileyCloud = RecipeUtil.lastIRecipe(); //Compost - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockCompost), - "W W", "W W", "WCW", - 'W', "plankWood", - 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.WOOD_CASING.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockCompost), "W W", "W W", "WCW", 'W', "plankWood", 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.WOOD_CASING.ordinal())); recipeCompost = RecipeUtil.lastIRecipe(); //XP Solidifier - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockXPSolidifier), - "XXX", "DCD", "XXX", - 'X', new ItemStack(InitItems.itemSolidifiedExperience), - 'D', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockXPSolidifier), "XXX", "DCD", "XXX", 'X', new ItemStack(InitItems.itemSolidifiedExperience), 'D', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); recipeSolidifier = RecipeUtil.lastIRecipe(); //Charcoal Block - RecipeHandler.addShapedRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.CHARCOAL_BLOCK.ordinal()), - "CCC", "CCC", "CCC", - 'C', new ItemStack(Items.COAL, 1, 1)); + RecipeHandler.addShapedRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.CHARCOAL_BLOCK.ordinal()), "CCC", "CCC", "CCC", 'C', new ItemStack(Items.COAL, 1, 1)); recipeBlockChar = RecipeUtil.lastIRecipe(); - RecipeHandler.addShapelessRecipe(new ItemStack(Items.COAL, 9, 1), - new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.CHARCOAL_BLOCK.ordinal())); + RecipeHandler.addShapelessRecipe(new ItemStack(Items.COAL, 9, 1), new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.CHARCOAL_BLOCK.ordinal())); //Wood Casing - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.WOOD_CASING.ordinal()), - "WSW", "SRS", "WSW", - 'W', "plankWood", - 'R', "logWood", - 'S', ConfigBoolValues.SUPER_DUPER_HARD_MODE.isEnabled() ? new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDER_CASING.ordinal()) : "stickWood"); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.WOOD_CASING.ordinal()), "WSW", "SRS", "WSW", 'W', "plankWood", 'R', "logWood", 'S', ConfigBoolValues.SUPER_DUPER_HARD_MODE.isEnabled() ? new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDER_CASING.ordinal()) : "stickWood"); recipeCase = RecipeUtil.lastIRecipe(); //Iron Casing - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), - "WSW", "SQS", "WSW", - 'Q', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), - 'W', "ingotIron", - 'S', ConfigBoolValues.SUPER_DUPER_HARD_MODE.isEnabled() ? new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDER_CASING.ordinal()) : "stickWood"); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), "WSW", "SQS", "WSW", 'Q', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), 'W', "ingotIron", 'S', ConfigBoolValues.SUPER_DUPER_HARD_MODE.isEnabled() ? new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDER_CASING.ordinal()) : "stickWood"); recipeIronCase = RecipeUtil.lastIRecipe(); //Ender Casing - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDER_CASING.ordinal()), - "WSW", "SRS", "WSW", - 'W', ConfigBoolValues.SUPER_DUPER_HARD_MODE.isEnabled() ? new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDERPEARL_BLOCK.ordinal()) : new ItemStack(Items.ENDER_PEARL), - 'R', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ.ordinal()), - 'S', ConfigBoolValues.SUPER_DUPER_HARD_MODE.isEnabled() ? new ItemStack(Blocks.DIAMOND_BLOCK) : new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDER_CASING.ordinal()), "WSW", "SRS", "WSW", 'W', ConfigBoolValues.SUPER_DUPER_HARD_MODE.isEnabled() ? new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDERPEARL_BLOCK.ordinal()) : new ItemStack(Items.ENDER_PEARL), 'R', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ.ordinal()), 'S', ConfigBoolValues.SUPER_DUPER_HARD_MODE.isEnabled() ? new ItemStack(Blocks.DIAMOND_BLOCK) : new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal())); recipeEnderCase = RecipeUtil.lastIRecipe(); //Phantom Booster - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPhantomBooster), - "RDR", "DCD", "RDR", - 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), - 'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), - 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDER_CASING.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPhantomBooster), "RDR", "DCD", "RDR", 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDER_CASING.ordinal())); recipePhantomBooster = RecipeUtil.lastIRecipe(); //Coffee Machine - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockCoffeeMachine), - " C ", " S ", "AMA", - 'M', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), - 'C', "cropCoffee", - 'S', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), - 'A', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockCoffeeMachine), " C ", " S ", "AMA", 'M', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), 'C', "cropCoffee", 'S', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), 'A', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal())); recipeCoffeeMachine = RecipeUtil.lastIRecipe(); //Energizer - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockEnergizer), - "I I", "CAC", "I I", - 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), - 'A', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockEnergizer), "I I", "CAC", "I I", 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), 'A', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal())); recipeEnergizer = RecipeUtil.lastIRecipe(); //Enervator - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockEnervator), - " I ", "CAC", " I ", - 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), - 'A', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockEnervator), " I ", "CAC", " I ", 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), 'A', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal())); recipeEnervator = RecipeUtil.lastIRecipe(); //Lava Factory - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockLavaFactoryController), - "SCS", "ISI", "LLL", - 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), - 'S', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), - 'I', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), - 'L', Items.LAVA_BUCKET); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockLavaFactoryController), "SCS", "ISI", "LLL", 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), 'S', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), 'I', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), 'L', Items.LAVA_BUCKET); recipeLavaFactory = RecipeUtil.lastIRecipe(); //Casing - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 32, TheMiscBlocks.LAVA_FACTORY_CASE.ordinal()), - "ICI", - 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), - 'I', new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.IRON.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 32, TheMiscBlocks.LAVA_FACTORY_CASE.ordinal()), "ICI", 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), 'I', new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.IRON.ordinal())); recipeCasing = RecipeUtil.lastIRecipe(); //Canola Press - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockCanolaPress), - "CHC", "CDC", "CRC", - 'C', "cobblestone", - 'H', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), - 'R', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), - 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CANOLA.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockCanolaPress), "CHC", "CDC", "CRC", 'C', "cobblestone", 'H', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 'R', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CANOLA.ordinal())); recipeCanolaPress = RecipeUtil.lastIRecipe(); //Fermenting Barrel - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFermentingBarrel), - "CHC", "CDC", "CRC", - 'C', "logWood", - 'H', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), - 'R', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.WOOD_CASING.ordinal()), - 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CANOLA.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFermentingBarrel), "CHC", "CDC", "CRC", 'C', "logWood", 'H', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 'R', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.WOOD_CASING.ordinal()), 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CANOLA.ordinal())); recipeFermentingBarrel = RecipeUtil.lastIRecipe(); //Phantomface - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPhantomface), - " C ", "EBE", " S ", - 'E', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), - 'C', "chestWood", - 'S', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), - 'B', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDERPEARL_BLOCK.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPhantomface), " C ", "EBE", " S ", 'E', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), 'C', "chestWood", 'S', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), 'B', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDERPEARL_BLOCK.ordinal())); recipePhantomface = RecipeUtil.lastIRecipe(); //Player Interface - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPlayerInterface), - "BCB", "EBE", "BSB", - 'E', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), - 'C', new ItemStack(Items.SKULL, 1, 1), - 'S', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), - 'B', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDER_CASING.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPlayerInterface), "BCB", "EBE", "BSB", 'E', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), 'C', new ItemStack(Items.SKULL, 1, 1), 'S', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), 'B', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDER_CASING.ordinal())); recipePlayerInterface = RecipeUtil.lastIRecipe(); //Phantom Placer - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitBlocks.blockPhantomPlacer), - InitBlocks.blockPlacer, - InitBlocks.blockPhantomface); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitBlocks.blockPhantomPlacer), InitBlocks.blockPlacer, InitBlocks.blockPhantomface); recipePhantomPlacer = RecipeUtil.lastIRecipe(); //Phantom Breaker - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitBlocks.blockPhantomBreaker), - InitBlocks.blockBreaker, - InitBlocks.blockPhantomface); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitBlocks.blockPhantomBreaker), InitBlocks.blockBreaker, InitBlocks.blockPhantomface); recipePhantomBreaker = RecipeUtil.lastIRecipe(); //Phantom Energyface - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPhantomEnergyface), - " R ", "RFR", " R ", - 'R', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.REDSTONE.ordinal()), - 'F', InitBlocks.blockPhantomface); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPhantomEnergyface), " R ", "RFR", " R ", 'R', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.REDSTONE.ordinal()), 'F', InitBlocks.blockPhantomface); recipeEnergyface = RecipeUtil.lastIRecipe(); //Phantom Redstoneface - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPhantomRedstoneface), - "SRS", "RFR", "SRS", - 'R', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.REDSTONE.ordinal()), - 'S', new ItemStack(Items.REDSTONE), - 'F', InitBlocks.blockPhantomface); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPhantomRedstoneface), "SRS", "RFR", "SRS", 'R', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.REDSTONE.ordinal()), 'S', new ItemStack(Items.REDSTONE), 'F', InitBlocks.blockPhantomface); recipePhantomRedstoneface = RecipeUtil.lastIRecipe(); //Phantom Liquiface - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPhantomLiquiface), - "RFR", - 'R', Items.BUCKET, - 'F', InitBlocks.blockPhantomface); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPhantomLiquiface), "RFR", 'R', Items.BUCKET, 'F', InitBlocks.blockPhantomface); recipeLiquiface = RecipeUtil.lastIRecipe(); //Liquid Placer - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFluidPlacer), - "RFR", - 'R', Items.BUCKET, - 'F', InitBlocks.blockPlacer); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFluidPlacer), "RFR", 'R', Items.BUCKET, 'F', InitBlocks.blockPlacer); recipeLiquidPlacer = RecipeUtil.lastIRecipe(); //Liquid Breaker - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFluidCollector), - "RFR", - 'R', Items.BUCKET, - 'F', InitBlocks.blockBreaker); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFluidCollector), "RFR", 'R', Items.BUCKET, 'F', InitBlocks.blockBreaker); recipeLiquidCollector = RecipeUtil.lastIRecipe(); //Oil Generator - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockOilGenerator), - "CRC", "CBC", "CRC", - 'C', "cobblestone", - 'R', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), - 'B', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CANOLA.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockOilGenerator), "CRC", "CBC", "CRC", 'C', "cobblestone", 'R', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), 'B', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CANOLA.ordinal())); recipeOilGen = RecipeUtil.lastIRecipe(); //Bio Reactor - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockBioReactor), - "CRC", "CBC", "CRC", - 'C', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), - 'R', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), - 'B', new ItemStack(Blocks.SAPLING, 1, Util.WILDCARD)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockBioReactor), "CRC", "CBC", "CRC", 'C', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), 'R', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), 'B', new ItemStack(Blocks.SAPLING, 1, Util.WILDCARD)); recipeBioReactor = RecipeUtil.lastIRecipe(); //Coal Generator - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockCoalGenerator), - "CRC", "CBC", "CRC", - 'C', "cobblestone", - 'B', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), - 'R', new ItemStack(Items.COAL, 1, Util.WILDCARD)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockCoalGenerator), "CRC", "CBC", "CRC", 'C', "cobblestone", 'B', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), 'R', new ItemStack(Items.COAL, 1, Util.WILDCARD)); recipeCoalGen = RecipeUtil.lastIRecipe(); //Leaf Generator - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockLeafGenerator), - "IEI", "GLG", "ICI", - 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), - 'G', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.REDSTONE.ordinal()), - 'E', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), - 'L', "treeLeaves", - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockLeafGenerator), "IEI", "GLG", "ICI", 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 'G', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.REDSTONE.ordinal()), 'E', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), 'L', "treeLeaves", 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); recipeLeafGen = RecipeUtil.lastIRecipe(); //Enderpearl Block - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDERPEARL_BLOCK.ordinal()), - "EE", "EE", - 'E', Items.ENDER_PEARL); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDERPEARL_BLOCK.ordinal()), "EE", "EE", 'E', Items.ENDER_PEARL); recipeEnderPearlBlock = RecipeUtil.lastIRecipe(); - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(Items.ENDER_PEARL, 4), - new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDERPEARL_BLOCK.ordinal())); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(Items.ENDER_PEARL, 4), new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDERPEARL_BLOCK.ordinal())); //Quartz Block - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ.ordinal()), - "QQ", "QQ", - 'Q', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ.ordinal()), "QQ", "QQ", 'Q', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())); recipeQuartzBlock = RecipeUtil.lastIRecipe(); //Fishing Net - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFishingNet), - "SSS", "SDS", "SSS", - 'D', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.EMERALD.ordinal()), - 'S', Items.STRING); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFishingNet), "SSS", "SDS", "SSS", 'D', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.EMERALD.ordinal()), 'S', Items.STRING); recipeFisher = RecipeUtil.lastIRecipe(); //Repairer - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockItemRepairer), - "DID", "OCO", "DID", - 'D', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), - 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), - 'O', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), - 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDER_CASING.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockItemRepairer), "DID", "OCO", "DID", 'D', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), 'O', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDER_CASING.ordinal())); recipeRepairer = RecipeUtil.lastIRecipe(); //Solar Panel - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFurnaceSolar), - "IQI", "CDC", "IBI", - 'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), - 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), - 'Q', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), - 'B', new ItemStack(Blocks.IRON_BARS)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFurnaceSolar), "IQI", "CDC", "IBI", 'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), 'Q', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), 'B', new ItemStack(Blocks.IRON_BARS)); recipeSolar = RecipeUtil.lastIRecipe(); //Heat Collector - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockHeatCollector), - "BRB", "CDC", "BQB", - 'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), - 'R', new ItemStack(Items.REPEATER), - 'Q', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), - 'B', new ItemStack(Blocks.IRON_BARS)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockHeatCollector), "BRB", "CDC", "BQB", 'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 'R', new ItemStack(Items.REPEATER), 'Q', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), 'B', new ItemStack(Blocks.IRON_BARS)); recipeHeatCollector = RecipeUtil.lastIRecipe(); //Quartz Pillar - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ_PILLAR.ordinal()), - "Q", "Q", - 'Q', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ_PILLAR.ordinal()), "Q", "Q", 'Q', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())); recipeQuartzPillar = RecipeUtil.lastIRecipe(); //Chiseled Quartz - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 2, TheMiscBlocks.QUARTZ_CHISELED.ordinal()), - "Q", "Q", - 'Q', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 2, TheMiscBlocks.QUARTZ_CHISELED.ordinal()), "Q", "Q", 'Q', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ.ordinal())); recipeQuartzChiseled = RecipeUtil.lastIRecipe(); //Inputter - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockInputter), - "WWW", "CHC", "WWW", - 'W', "plankWood", - 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.WOOD_CASING.ordinal()), - 'H', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockInputter), "WWW", "CHC", "WWW", 'W', "plankWood", 'C', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.WOOD_CASING.ordinal()), 'H', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal())); recipeESD = RecipeUtil.lastIRecipe(); - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitBlocks.blockInputterAdvanced), - InitBlocks.blockInputter, - new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), - new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), - new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal())); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitBlocks.blockInputterAdvanced), InitBlocks.blockInputter, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal())); recipeAdvancedESD = RecipeUtil.lastIRecipe(); //Crusher - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockGrinder), - "MFC", "DQD", "CFM", - 'M', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), - 'C', "cobblestone", - 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), - 'Q', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), - 'F', new ItemStack(Items.FLINT)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockGrinder), "MFC", "DQD", "CFM", 'M', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 'C', "cobblestone", 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), 'Q', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), 'F', new ItemStack(Items.FLINT)); recipeCrusher = RecipeUtil.lastIRecipe(); //Double Crusher - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockGrinderDouble), - "CDC", "RFR", "CDC", - 'C', "cobblestone", - 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), - 'R', InitBlocks.blockGrinder, - 'F', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockGrinderDouble), "CDC", "RFR", "CDC", 'C', "cobblestone", 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), 'R', InitBlocks.blockGrinder, 'F', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal())); recipeDoubleCrusher = RecipeUtil.lastIRecipe(); //Double Furnace - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFurnaceDouble), - "PDC", "RFR", "CDP", - 'C', "cobblestone", - 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), - 'R', new ItemStack(Blocks.FURNACE), - 'F', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), - 'P', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFurnaceDouble), "PDC", "RFR", "CDP", 'C', "cobblestone", 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), 'R', new ItemStack(Blocks.FURNACE), 'F', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), 'P', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal())); recipeFurnace = RecipeUtil.lastIRecipe(); //Feeder - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFeeder), - "WCW", "DHD", "WCW", - 'W', "plankWood", - 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), - 'C', new ItemStack(Items.GOLDEN_CARROT), - 'H', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.WOOD_CASING.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockFeeder), "WCW", "DHD", "WCW", 'W', "plankWood", 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), 'C', new ItemStack(Items.GOLDEN_CARROT), 'H', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.WOOD_CASING.ordinal())); recipeFeeder = RecipeUtil.lastIRecipe(); //Giant Chest - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockGiantChest), - "CWC", "WDW", "CWC", - 'C', "chestWood", - 'D', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.WOOD_CASING.ordinal()), - 'W', "plankWood"); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockGiantChest), "CWC", "WDW", "CWC", 'C', "chestWood", 'D', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.WOOD_CASING.ordinal()), 'W', "plankWood"); recipeCrate = RecipeUtil.lastIRecipe(); - new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "giant_chest_media"), new ItemStack(InitBlocks.blockGiantChestMedium), new ItemStack(InitBlocks.blockGiantChest), - "CWC", "WDW", "CWC", - 'C', new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.COAL.ordinal()), - 'D', new ItemStack(InitBlocks.blockGiantChest), - 'W', "plankWood"); + new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "giant_chest_media"), new ItemStack(InitBlocks.blockGiantChestMedium), new ItemStack(InitBlocks.blockGiantChest), "CWC", "WDW", "CWC", 'C', new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.COAL.ordinal()), 'D', new ItemStack(InitBlocks.blockGiantChest), 'W', "plankWood"); recipeCrateMedium = RecipeUtil.lastIRecipe(); - new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "giant_chest_large"), new ItemStack(InitBlocks.blockGiantChestLarge), new ItemStack(InitBlocks.blockGiantChestMedium), - "CWC", "WDW", "CWC", - 'C', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.COAL.ordinal()), - 'D', new ItemStack(InitBlocks.blockGiantChestMedium), - 'W', "plankWood"); + new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "giant_chest_large"), new ItemStack(InitBlocks.blockGiantChestLarge), new ItemStack(InitBlocks.blockGiantChestMedium), "CWC", "WDW", "CWC", 'C', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.COAL.ordinal()), 'D', new ItemStack(InitBlocks.blockGiantChestMedium), 'W', "plankWood"); recipeCrateLarge = RecipeUtil.lastIRecipe(); //Greenhouse Glass - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockGreenhouseGlass, 2), - "GSG", "SDS", "GSG", - 'G', "blockGlass", - 'D', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.LAPIS.ordinal()), - 'S', "treeSapling"); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockGreenhouseGlass, 2), "GSG", "SDS", "GSG", 'G', "blockGlass", 'D', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.LAPIS.ordinal()), 'S', "treeSapling"); recipeGlass = RecipeUtil.lastIRecipe(); //Placer - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPlacer), - "CCC", "CRP", "CCC", - 'C', "cobblestone", - 'R', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), - 'P', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockPlacer), "CCC", "CRP", "CCC", 'C', "cobblestone", 'R', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), 'P', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal())); recipePlacer = RecipeUtil.lastIRecipe(); //Breaker - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockBreaker), - "CCC", "CRP", "CCC", - 'C', "cobblestone", - 'R', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), - 'P', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockBreaker), "CCC", "CRP", "CCC", 'C', "cobblestone", 'R', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), 'P', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal())); recipeBreaker = RecipeUtil.lastIRecipe(); //Dropper - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockDropper), - "CBC", "CDR", "CBC", - 'B', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), - 'C', "cobblestone", - 'D', Blocks.DROPPER, - 'R', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockDropper), "CBC", "CDR", "CBC", 'B', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), 'C', "cobblestone", 'D', Blocks.DROPPER, 'R', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); recipeDropper = RecipeUtil.lastIRecipe(); - for(int i = 0; i < BlockColoredLamp.ALL_LAMP_TYPES.length; i++){ - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockColoredLamp, 6, i), - "GCG", "DQD", "GCG", - 'C', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), - 'G', "glowstone", - 'D', "dye"+BlockColoredLamp.ALL_LAMP_TYPES[i].oreName, - 'Q', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())); + for (int i = 0; i < BlockColoredLamp.ALL_LAMP_TYPES.length; i++) { + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockColoredLamp, 6, i), "GCG", "DQD", "GCG", 'C', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), 'G', "glowstone", 'D', "dye" + BlockColoredLamp.ALL_LAMP_TYPES[i].oreName, 'Q', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())); RECIPES_LAMPS[i] = RecipeUtil.lastIRecipe(); } - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockLampPowerer, 4), - "XXX", "XLX", "XXX", - 'X', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), - 'L', new ItemStack(InitBlocks.blockColoredLamp, 1, Util.WILDCARD)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockLampPowerer, 4), "XXX", "XLX", "XXX", 'X', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 'L', new ItemStack(InitBlocks.blockColoredLamp, 1, Util.WILDCARD)); recipePowerer = RecipeUtil.lastIRecipe(); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrusherCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrusherCrafting.java index 1af70b8a5..7eadac814 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrusherCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrusherCrafting.java @@ -75,23 +75,15 @@ public final class CrusherCrafting { ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.DOUBLE_PLANT, 1, 5), new ItemStack(Items.DYE, 4, 9), StackUtil.getEmpty(), 0); MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - if(!CrusherRecipeRegistry.hasException("oreRedstone")) - ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreRedstone"), new ItemStack(Items.REDSTONE, 10), StackUtil.getEmpty(), 0); - if(!CrusherRecipeRegistry.hasException("oreLapis")) - ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreLapis"), new ItemStack(Items.DYE, 12, 4), StackUtil.getEmpty(), 0); - if(!CrusherRecipeRegistry.hasException("coal")) - ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("coal"), new ItemStack(InitItems.itemDust, 1, TheDusts.COAL.ordinal()), StackUtil.getEmpty(), 0); - if(!CrusherRecipeRegistry.hasException("oreCoal")) - ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreCoal"), new ItemStack(Items.COAL, 3), StackUtil.getEmpty(), 0); - if(!CrusherRecipeRegistry.hasException("blockCoal")) - ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("blockCoal"), new ItemStack(Items.COAL, 9), StackUtil.getEmpty(), 0); - if(!CrusherRecipeRegistry.hasException("oreQuartz")) - ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreQuartz"), new ItemStack(Items.QUARTZ, 3), StackUtil.getEmpty(), 0); - if(!CrusherRecipeRegistry.hasException("cobblestone")) - ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("cobblestone"), new ItemStack(Blocks.SAND), StackUtil.getEmpty(), 0); + if (!CrusherRecipeRegistry.hasException("oreRedstone")) ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreRedstone"), new ItemStack(Items.REDSTONE, 10), StackUtil.getEmpty(), 0); + if (!CrusherRecipeRegistry.hasException("oreLapis")) ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreLapis"), new ItemStack(Items.DYE, 12, 4), StackUtil.getEmpty(), 0); + if (!CrusherRecipeRegistry.hasException("coal")) ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("coal"), new ItemStack(InitItems.itemDust, 1, TheDusts.COAL.ordinal()), StackUtil.getEmpty(), 0); + if (!CrusherRecipeRegistry.hasException("oreCoal")) ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreCoal"), new ItemStack(Items.COAL, 3), StackUtil.getEmpty(), 0); + if (!CrusherRecipeRegistry.hasException("blockCoal")) ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("blockCoal"), new ItemStack(Items.COAL, 9), StackUtil.getEmpty(), 0); + if (!CrusherRecipeRegistry.hasException("oreQuartz")) ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreQuartz"), new ItemStack(Items.QUARTZ, 3), StackUtil.getEmpty(), 0); + if (!CrusherRecipeRegistry.hasException("cobblestone")) ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("cobblestone"), new ItemStack(Blocks.SAND), StackUtil.getEmpty(), 0); ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.GRAVEL), new ItemStack(Items.FLINT), new ItemStack(Items.FLINT), 50); - if(!CrusherRecipeRegistry.hasException("stone")) - ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("stone", false), OreDictionary.getOres("cobblestone", false), 1, NonNullList.withSize(1, StackUtil.getEmpty()), 0, 0); + if (!CrusherRecipeRegistry.hasException("stone")) ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("stone", false), OreDictionary.getOres("cobblestone", false), 1, NonNullList.withSize(1, StackUtil.getEmpty()), 0, 0); ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal()), new ItemStack(Items.SUGAR, 2), StackUtil.getEmpty(), 0); MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); @@ -99,10 +91,8 @@ public final class CrusherCrafting { ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.GLOWSTONE), new ItemStack(Items.GLOWSTONE_DUST, 4), StackUtil.getEmpty(), 0); MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - if(!CrusherRecipeRegistry.hasException("oreNickel")) - ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreNickel", false), OreDictionary.getOres("dustNickel", false), 2, OreDictionary.getOres("dustPlatinum", false), 1, 15); - if(!CrusherRecipeRegistry.hasException("oreIron")) - ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreIron", false), OreDictionary.getOres("dustIron", false), 2, OreDictionary.getOres("dustGold", false), 1, 20); + if (!CrusherRecipeRegistry.hasException("oreNickel")) ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreNickel", false), OreDictionary.getOres("dustNickel", false), 2, OreDictionary.getOres("dustPlatinum", false), 1, 15); + if (!CrusherRecipeRegistry.hasException("oreIron")) ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreIron", false), OreDictionary.getOres("dustIron", false), 2, OreDictionary.getOres("dustGold", false), 1, 20); ItemStack temp = getStack("dustIron"); if (!temp.isEmpty()) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/FoodCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/FoodCrafting.java index e8233f14d..03fc7168f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/FoodCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/FoodCrafting.java @@ -23,7 +23,7 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.Ingredient; import net.minecraftforge.fml.common.registry.GameRegistry; -public final class FoodCrafting{ +public final class FoodCrafting { public static IRecipe recipePizza; public static IRecipe recipeHamburger; @@ -43,130 +43,78 @@ public final class FoodCrafting{ public static IRecipe recipeChocolateToast; public static IRecipe recipeBacon; - public static void init(){ + public static void init() { Ingredient knife = Ingredient.fromItem(InitItems.itemKnife); //Rice Bread - GameRegistry.addSmelting(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RICE_DOUGH.ordinal()), - new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE_BREAD.ordinal()), 1F); + GameRegistry.addSmelting(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RICE_DOUGH.ordinal()), new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE_BREAD.ordinal()), 1F); //Bacon - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemFoods, 3, TheFoods.BACON.ordinal()), - knife, new ItemStack(Items.COOKED_PORKCHOP)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemFoods, 3, TheFoods.BACON.ordinal()), knife, new ItemStack(Items.COOKED_PORKCHOP)); recipeBacon = RecipeUtil.lastIRecipe(); //Baguette - GameRegistry.addSmelting(new ItemStack(InitItems.itemMisc, 1, - TheMiscItems.DOUGH.ordinal()), new ItemStack(InitItems.itemFoods, 1, TheFoods.BAGUETTE.ordinal()), 1F); + GameRegistry.addSmelting(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.DOUGH.ordinal()), new ItemStack(InitItems.itemFoods, 1, TheFoods.BAGUETTE.ordinal()), 1F); //Pizza - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.PIZZA.ordinal()), - "HKH", "MCF", " D ", - 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.DOUGH.ordinal()), - 'M', new ItemStack(Blocks.BROWN_MUSHROOM), - 'C', "cropCarrot", - 'F', new ItemStack(Items.COOKED_FISH, 1, Util.WILDCARD), - 'K', knife, - 'H', new ItemStack(InitItems.itemFoods, 1, TheFoods.CHEESE.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.PIZZA.ordinal()), "HKH", "MCF", " D ", 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.DOUGH.ordinal()), 'M', new ItemStack(Blocks.BROWN_MUSHROOM), 'C', "cropCarrot", 'F', new ItemStack(Items.COOKED_FISH, 1, Util.WILDCARD), 'K', knife, 'H', new ItemStack(InitItems.itemFoods, 1, TheFoods.CHEESE.ordinal())); recipePizza = RecipeUtil.lastIRecipe(); //Hamburger - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.HAMBURGER.ordinal()), - "KT ", "CB ", " T ", - 'T', new ItemStack(InitItems.itemFoods, 1, TheFoods.TOAST.ordinal()), - 'C', new ItemStack(InitItems.itemFoods, 1, TheFoods.CHEESE.ordinal()), - 'K', knife, - 'B', new ItemStack(Items.COOKED_BEEF)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.HAMBURGER.ordinal()), "KT ", "CB ", " T ", 'T', new ItemStack(InitItems.itemFoods, 1, TheFoods.TOAST.ordinal()), 'C', new ItemStack(InitItems.itemFoods, 1, TheFoods.CHEESE.ordinal()), 'K', knife, 'B', new ItemStack(Items.COOKED_BEEF)); recipeHamburger = RecipeUtil.lastIRecipe(); //Big Cookie - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.BIG_COOKIE.ordinal()), - "DCD", "CDC", "DCD", - 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.DOUGH.ordinal()), - 'C', new ItemStack(Items.DYE, 1, 3)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.BIG_COOKIE.ordinal()), "DCD", "CDC", "DCD", 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.DOUGH.ordinal()), 'C', new ItemStack(Items.DYE, 1, 3)); recipeBigCookie = RecipeUtil.lastIRecipe(); //Sub Sandwich - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.SUBMARINE_SANDWICH.ordinal()), - "KCP", "FB ", "PCP", - 'P', new ItemStack(Items.PAPER), - 'C', new ItemStack(InitItems.itemFoods, 1, TheFoods.CHEESE.ordinal()), - 'F', new ItemStack(Items.COOKED_BEEF, 1, Util.WILDCARD), - 'B', new ItemStack(InitItems.itemFoods, 1, TheFoods.BAGUETTE.ordinal()), - 'K', knife); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.SUBMARINE_SANDWICH.ordinal()), "KCP", "FB ", "PCP", 'P', new ItemStack(Items.PAPER), 'C', new ItemStack(InitItems.itemFoods, 1, TheFoods.CHEESE.ordinal()), 'F', new ItemStack(Items.COOKED_BEEF, 1, Util.WILDCARD), 'B', new ItemStack(InitItems.itemFoods, 1, TheFoods.BAGUETTE.ordinal()), 'K', knife); recipeSubSandwich = RecipeUtil.lastIRecipe(); //French Fry - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemFoods, 2, TheFoods.FRENCH_FRY.ordinal()), - new ItemStack(Items.BAKED_POTATO), - knife); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemFoods, 2, TheFoods.FRENCH_FRY.ordinal()), new ItemStack(Items.BAKED_POTATO), knife); recipeFrenchFry = RecipeUtil.lastIRecipe(); //French Fries - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.FRENCH_FRIES.ordinal()), - "FFF", " P ", - 'P', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.PAPER_CONE.ordinal()), - 'F', new ItemStack(InitItems.itemFoods, 1, TheFoods.FRENCH_FRY.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.FRENCH_FRIES.ordinal()), "FFF", " P ", 'P', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.PAPER_CONE.ordinal()), 'F', new ItemStack(InitItems.itemFoods, 1, TheFoods.FRENCH_FRY.ordinal())); recipeFrenchFries = RecipeUtil.lastIRecipe(); //Fish N Chips - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.FISH_N_CHIPS.ordinal()), - "FIF", " P ", - 'I', new ItemStack(Items.COOKED_FISH, 1, Util.WILDCARD), - 'P', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.PAPER_CONE.ordinal()), - 'F', new ItemStack(InitItems.itemFoods, 1, TheFoods.FRENCH_FRY.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.FISH_N_CHIPS.ordinal()), "FIF", " P ", 'I', new ItemStack(Items.COOKED_FISH, 1, Util.WILDCARD), 'P', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.PAPER_CONE.ordinal()), 'F', new ItemStack(InitItems.itemFoods, 1, TheFoods.FRENCH_FRY.ordinal())); recipeFishNChips = RecipeUtil.lastIRecipe(); //Cheese - RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.CHEESE.ordinal()), - new ItemStack(Items.MILK_BUCKET), new ItemStack(Items.EGG)); //I don't know if this makes any actual sense, but whatever + RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.CHEESE.ordinal()), new ItemStack(Items.MILK_BUCKET), new ItemStack(Items.EGG)); //I don't know if this makes any actual sense, but whatever recipeCheese = RecipeUtil.lastIRecipe(); //Pumpkin Stew - RecipeHandler.addShapedRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.PUMPKIN_STEW.ordinal()), - "P", "B", - 'P', new ItemStack(Blocks.PUMPKIN), - 'B', new ItemStack(Items.BOWL)); + RecipeHandler.addShapedRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.PUMPKIN_STEW.ordinal()), "P", "B", 'P', new ItemStack(Blocks.PUMPKIN), 'B', new ItemStack(Items.BOWL)); recipePumpkinStew = RecipeUtil.lastIRecipe(); //Carrot Juice - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.CARROT_JUICE.ordinal()), - new ItemStack(Items.GLASS_BOTTLE), "cropCarrot", knife); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.CARROT_JUICE.ordinal()), new ItemStack(Items.GLASS_BOTTLE), "cropCarrot", knife); recipeCarrotJuice = RecipeUtil.lastIRecipe(); //Spaghetti - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.SPAGHETTI.ordinal()), - "NNN", " B ", - 'N', new ItemStack(InitItems.itemFoods, 1, TheFoods.NOODLE.ordinal()), - 'B', new ItemStack(Items.BOWL)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.SPAGHETTI.ordinal()), "NNN", " B ", 'N', new ItemStack(InitItems.itemFoods, 1, TheFoods.NOODLE.ordinal()), 'B', new ItemStack(Items.BOWL)); recipeSpaghetti = RecipeUtil.lastIRecipe(); //Noodle - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.NOODLE.ordinal()), - "cropWheat", knife); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.NOODLE.ordinal()), "cropWheat", knife); recipeNoodle = RecipeUtil.lastIRecipe(); //Chocolate - RecipeHandler.addShapedRecipe(new ItemStack(InitItems.itemFoods, 3, TheFoods.CHOCOLATE.ordinal()), - "C C", "CMC", "C C", - 'C', new ItemStack(Items.DYE, 1, 3), - 'M', new ItemStack(Items.MILK_BUCKET)); + RecipeHandler.addShapedRecipe(new ItemStack(InitItems.itemFoods, 3, TheFoods.CHOCOLATE.ordinal()), "C C", "CMC", "C C", 'C', new ItemStack(Items.DYE, 1, 3), 'M', new ItemStack(Items.MILK_BUCKET)); recipeChocolate = RecipeUtil.lastIRecipe(); //Chocolate Cake - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.CHOCOLATE_CAKE.ordinal()), - "MMM", "CCC", "EDS", - 'M', new ItemStack(Items.MILK_BUCKET), - 'E', new ItemStack(Items.EGG), - 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.DOUGH.ordinal()), - 'S', new ItemStack(Items.SUGAR), - 'C', new ItemStack(Items.DYE, 1, 3)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.CHOCOLATE_CAKE.ordinal()), "MMM", "CCC", "EDS", 'M', new ItemStack(Items.MILK_BUCKET), 'E', new ItemStack(Items.EGG), 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.DOUGH.ordinal()), 'S', new ItemStack(Items.SUGAR), 'C', new ItemStack(Items.DYE, 1, 3)); recipeChocolateCake = RecipeUtil.lastIRecipe(); //Toast - RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemFoods, 2, TheFoods.TOAST.ordinal()), - new ItemStack(Items.BREAD)); + RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemFoods, 2, TheFoods.TOAST.ordinal()), new ItemStack(Items.BREAD)); recipeToast = RecipeUtil.lastIRecipe(); //Chocolate Toast diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java index 7148f361e..788057b21 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java @@ -28,9 +28,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; -public final class InitCrafting{ +public final class InitCrafting { - public static void init(){ + public static void init() { ActuallyAdditions.LOGGER.info("Initializing Crafting Recipes..."); ItemCrafting.init(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ItemCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ItemCrafting.java index 0d4b6e10f..b882f86b5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ItemCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ItemCrafting.java @@ -10,13 +10,19 @@ package de.ellpeck.actuallyadditions.mod.crafting; +import java.util.ArrayList; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors; import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.metalists.*; +import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; +import de.ellpeck.actuallyadditions.mod.items.metalists.TheDusts; +import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods; +import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; +import de.ellpeck.actuallyadditions.mod.items.metalists.ThePotionRings; import de.ellpeck.actuallyadditions.mod.util.RecipeUtil; import de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.crafting.RecipeHandler; @@ -33,9 +39,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.oredict.OreDictionary; -import java.util.ArrayList; - -public final class ItemCrafting{ +public final class ItemCrafting { public static final ArrayList RECIPES_POTION_RINGS = new ArrayList<>(); public static final ArrayList RECIPES_DRILL_COLORING = new ArrayList<>(); @@ -97,82 +101,46 @@ public final class ItemCrafting{ public static IRecipe recipeGoggles; public static IRecipe recipeGogglesAdvanced; - public static void init(){ + public static void init() { //Advanced Goggles - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemEngineerGogglesAdvanced), - " R ", "IGI", - 'R', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.REDSTONE.ordinal()), - 'I', new ItemStack(Blocks.IRON_BARS), - 'G', new ItemStack(InitItems.itemEngineerGoggles)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemEngineerGogglesAdvanced), " R ", "IGI", 'R', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.REDSTONE.ordinal()), 'I', new ItemStack(Blocks.IRON_BARS), 'G', new ItemStack(InitItems.itemEngineerGoggles)); recipeGogglesAdvanced = RecipeUtil.lastIRecipe(); //Goggles - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemEngineerGoggles), - " R ", "IGI", - 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), - 'I', new ItemStack(Blocks.IRON_BARS), - 'G', "blockGlass"); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemEngineerGoggles), " R ", "IGI", 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 'I', new ItemStack(Blocks.IRON_BARS), 'G', "blockGlass"); recipeGoggles = RecipeUtil.lastIRecipe(); //Laser Invis Upgrade - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemLaserUpgradeInvisibility, 4), - "GGG", "RCR", "GGG", - 'G', "blockGlassBlack", - 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemLaserUpgradeInvisibility, 4), "GGG", "RCR", "GGG", 'G', "blockGlassBlack", 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); recipeLaserUpgradeInvisibility = RecipeUtil.lastIRecipe(); //Laser Range Upgrade - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemLaserUpgradeRange, 2), - "GGC", "RCR", "CGG", - 'R', new ItemStack(Items.COMPASS), - 'G', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemLaserUpgradeRange, 2), "GGC", "RCR", "CGG", 'R', new ItemStack(Items.COMPASS), 'G', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); recipeLaserUpgradeRange = RecipeUtil.lastIRecipe(); //Filling Wand - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFillingWand), - "IPI", "DCD", " B ", - 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), - 'P', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), - 'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), - 'B', new ItemStack(InitItems.itemBatteryTriple)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFillingWand), "IPI", "DCD", " B ", 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), 'P', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), 'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), 'B', new ItemStack(InitItems.itemBatteryTriple)); recipeFillingWand = RecipeUtil.lastIRecipe(); //Bag - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemBag), - "SLS", "SCS", "LVL", - 'S', new ItemStack(Items.STRING), - 'L', new ItemStack(Items.LEATHER), - 'C', "chestWood", - 'V', new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.COAL.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemBag), "SLS", "SCS", "LVL", 'S', new ItemStack(Items.STRING), 'L', new ItemStack(Items.LEATHER), 'C', "chestWood", 'V', new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.COAL.ordinal())); recipeBag = RecipeUtil.lastIRecipe(); //Void Bag - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemVoidBag), - new ItemStack(InitItems.itemBag), - new ItemStack(Items.ENDER_PEARL), - new ItemStack(Blocks.OBSIDIAN), - new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.COAL.ordinal())); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemVoidBag), new ItemStack(InitItems.itemBag), new ItemStack(Items.ENDER_PEARL), new ItemStack(Blocks.OBSIDIAN), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.COAL.ordinal())); recipeVoidBag = RecipeUtil.lastIRecipe(); //Lens - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), - "GGG", "GBG", "GGG", - 'G', "blockGlass", - 'B', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), "GGG", "GBG", "GGG", 'G', "blockGlass", 'B', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())); recipeLens = RecipeUtil.lastIRecipe(); //Black Dye - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemMisc, 2, TheMiscItems.BLACK_DYE.ordinal()), new ItemStack(InitBlocks.blockBlackLotus)) - ; + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemMisc, 2, TheMiscItems.BLACK_DYE.ordinal()), new ItemStack(InitBlocks.blockBlackLotus)); recipeBlackDye = RecipeUtil.lastIRecipe(); //Booklet - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemBooklet), new ItemStack(InitItems.itemCanolaSeed), new ItemStack(Items.PAPER)) - ; + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemBooklet), new ItemStack(InitItems.itemCanolaSeed), new ItemStack(Items.PAPER)); recipeBook = RecipeUtil.lastIRecipe(); //Clearing NBT Storage @@ -181,411 +149,216 @@ public final class ItemCrafting{ RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemSpawnerChanger), new ItemStack(InitItems.itemSpawnerChanger)); //Chest To Crate Upgrade - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemChestToCrateUpgrade), - " W ", "WCW", " W ", - 'C', new ItemStack(InitBlocks.blockGiantChest), - 'W', "plankWood"); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemChestToCrateUpgrade), " W ", "WCW", " W ", 'C', new ItemStack(InitBlocks.blockGiantChest), 'W', "plankWood"); recipeChestToCrateUpgrade = RecipeUtil.lastIRecipe(); - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemSmallToMediumCrateUpgrade), - " W ", "WCW", " W ", - 'C', new ItemStack(InitBlocks.blockGiantChestMedium), - 'W', "plankWood"); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemSmallToMediumCrateUpgrade), " W ", "WCW", " W ", 'C', new ItemStack(InitBlocks.blockGiantChestMedium), 'W', "plankWood"); recipeSmallToMediumCrateUpgrade = RecipeUtil.lastIRecipe(); - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMediumToLargeCrateUpgrade), - " W ", "WCW", " W ", - 'C', new ItemStack(InitBlocks.blockGiantChestLarge), - 'W', "plankWood"); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMediumToLargeCrateUpgrade), " W ", "WCW", " W ", 'C', new ItemStack(InitBlocks.blockGiantChestLarge), 'W', "plankWood"); recipeMediumToLargeCrateUpgrade = RecipeUtil.lastIRecipe(); //Disenchanting Lens ItemStack crystal = new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()); - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemDisenchantingLens), - new ItemStack(Blocks.ENCHANTING_TABLE), - crystal.copy(), - crystal.copy(), - crystal.copy(), - crystal.copy(), - crystal.copy(), - crystal.copy(), - crystal.copy(), - new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal())); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemDisenchantingLens), new ItemStack(Blocks.ENCHANTING_TABLE), crystal.copy(), crystal.copy(), crystal.copy(), crystal.copy(), crystal.copy(), crystal.copy(), crystal.copy(), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal())); recipeDisenchantingLens = RecipeUtil.lastIRecipe(); //Mining Lens - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMiningLens), - "DGI", "CLB", "QPE", - 'D', "gemDiamond", - 'G', "ingotGold", - 'I', "ingotIron", - 'C', "coal", - 'L', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), - 'B', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), - 'Q', "gemQuartz", - 'P', "gemLapis", - 'E', "gemEmerald"); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMiningLens), "DGI", "CLB", "QPE", 'D', "gemDiamond", 'G', "ingotGold", 'I', "ingotIron", 'C', "coal", 'L', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), 'B', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), 'Q', "gemQuartz", 'P', "gemLapis", 'E', "gemEmerald"); recipeMiningLens = RecipeUtil.lastIRecipe(); //Killer Lens ItemStack enchBook = new ItemStack(Items.ENCHANTED_BOOK); ItemEnchantedBook.addEnchantment(enchBook, new EnchantmentData(Enchantments.SHARPNESS, 5)); - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemMoreDamageLens), - new ItemStack(Items.DIAMOND_SWORD), - new ItemStack(InitItems.itemDamageLens), - enchBook); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemMoreDamageLens), new ItemStack(Items.DIAMOND_SWORD), new ItemStack(InitItems.itemDamageLens), enchBook); recipeLensMoreDeath = RecipeUtil.lastIRecipe(); //Filter - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFilter), - "III", "IQI", "III", - 'I', new ItemStack(Blocks.IRON_BARS), - 'Q', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFilter), "III", "IQI", "III", 'I', new ItemStack(Blocks.IRON_BARS), 'Q', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())); recipeFilter = RecipeUtil.lastIRecipe(); //Crate Keeper - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemCrateKeeper), - "WIW", "IQI", "WIW", - 'I', "ingotIron", - 'W', "plankWood", - 'Q', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemCrateKeeper), "WIW", "IQI", "WIW", 'I', "ingotIron", 'W', "plankWood", 'Q', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())); recipeCrateKeeper = RecipeUtil.lastIRecipe(); //Spawner Changer - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemSpawnerChanger), - "MSM", "SDS", "MSM", - 'M', new ItemStack(Items.MAGMA_CREAM), - 'S', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.SPAWNER_SHARD.ordinal()), - 'D', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemSpawnerChanger), "MSM", "SDS", "MSM", 'M', new ItemStack(Items.MAGMA_CREAM), 'S', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.SPAWNER_SHARD.ordinal()), 'D', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal())); recipeSpawnerChanger = RecipeUtil.lastIRecipe(); //Laser Wrench - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemLaserWrench), - "C ", " S ", " S", - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), - 'S', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemLaserWrench), "C ", " S ", " S", 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), 'S', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal())); recipeLaserWrench = RecipeUtil.lastIRecipe(); //Rice Stuff - RecipeHandler.addOreDictRecipe(new ItemStack(Items.PAPER, 3), - "R ", " R ", " R", - 'R', new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal())); - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 4, TheMiscItems.RICE_SLIME.ordinal()), - " R ", "RBR", " R ", - 'R', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RICE_DOUGH.ordinal()), - 'B', Items.WATER_BUCKET); - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 4, TheMiscItems.RICE_SLIME.ordinal()), - " R ", "RBR", " R ", - 'R', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RICE_DOUGH.ordinal()), - 'B', new ItemStack(Items.POTIONITEM)); + RecipeHandler.addOreDictRecipe(new ItemStack(Items.PAPER, 3), "R ", " R ", " R", 'R', new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 4, TheMiscItems.RICE_SLIME.ordinal()), " R ", "RBR", " R ", 'R', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RICE_DOUGH.ordinal()), 'B', Items.WATER_BUCKET); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 4, TheMiscItems.RICE_SLIME.ordinal()), " R ", "RBR", " R ", 'R', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RICE_DOUGH.ordinal()), 'B', new ItemStack(Items.POTIONITEM)); //Leaf Blower - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemLeafBlower), - " F", "IP", "IC", - 'F', new ItemStack(Items.FLINT), - 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), - 'P', new ItemStack(Blocks.PISTON), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemLeafBlower), " F", "IP", "IC", 'F', new ItemStack(Items.FLINT), 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 'P', new ItemStack(Blocks.PISTON), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); recipeLeafBlower = RecipeUtil.lastIRecipe(); //Drill ItemStack lightBlueDrill = new ItemStack(InitItems.itemDrill, 1, TheColoredLampColors.LIGHT_BLUE.ordinal()); - RecipeHandler.addOreDictRecipe(lightBlueDrill.copy(), - "DDD", "CRC", "III", - 'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), - 'R', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.DRILL_CORE.ordinal()), - 'I', new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.IRON.ordinal())); + RecipeHandler.addOreDictRecipe(lightBlueDrill.copy(), "DDD", "CRC", "III", 'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), 'R', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.DRILL_CORE.ordinal()), 'I', new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.IRON.ordinal())); recipeDrill = RecipeUtil.lastIRecipe(); - for(int i = 0; i < 16; i++){ - if(i != TheColoredLampColors.LIGHT_BLUE.ordinal()){ - new RecipeKeepDataShapeless(new ResourceLocation(ActuallyAdditions.MODID, "dril_color_change"+i), new ItemStack(InitItems.itemDrill, 1, i), new ItemStack(InitItems.itemDrill, 1, Util.WILDCARD), lightBlueDrill.copy(), "dye"+TheColoredLampColors.values()[i].oreName); + for (int i = 0; i < 16; i++) { + if (i != TheColoredLampColors.LIGHT_BLUE.ordinal()) { + new RecipeKeepDataShapeless(new ResourceLocation(ActuallyAdditions.MODID, "dril_color_change" + i), new ItemStack(InitItems.itemDrill, 1, i), new ItemStack(InitItems.itemDrill, 1, Util.WILDCARD), lightBlueDrill.copy(), "dye" + TheColoredLampColors.values()[i].oreName); RECIPES_DRILL_COLORING.add(RecipeUtil.lastIRecipe()); } } //Drill Core - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.DRILL_CORE.ordinal()), - "ICI", "CRC", "ICI", - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), - 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), - 'I', new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.IRON.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.DRILL_CORE.ordinal()), "ICI", "CRC", "ICI", 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 'I', new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.IRON.ordinal())); recipeDrillCore = RecipeUtil.lastIRecipe(); //Tele Staff - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemTeleStaff), - " FE", " S ", "SB ", - 'F', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), - 'E', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDERPEARL_BLOCK.ordinal()), - 'S', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDER_CASING.ordinal()), - 'B', new ItemStack(InitItems.itemBattery, 1, Util.WILDCARD)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemTeleStaff), " FE", " S ", "SB ", 'F', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), 'E', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDERPEARL_BLOCK.ordinal()), 'S', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDER_CASING.ordinal()), 'B', new ItemStack(InitItems.itemBattery, 1, Util.WILDCARD)); recipeStaff = RecipeUtil.lastIRecipe(); //Drill Speed - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeSpeed), - "ISI", "SRS", "ISI", - 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), - 'S', Items.SUGAR, - 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeSpeed), "ISI", "SRS", "ISI", 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 'S', Items.SUGAR, 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal())); recipeDrillSpeedI = RecipeUtil.lastIRecipe(); - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeSpeedII), - "ISI", "SCS", "ISI", - 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), - 'S', Items.SUGAR, - 'C', Items.CAKE); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeSpeedII), "ISI", "SCS", "ISI", 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 'S', Items.SUGAR, 'C', Items.CAKE); recipeDrillSpeedII = RecipeUtil.lastIRecipe(); - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeSpeedIII), - "ISI", "SFS", "ISI", - 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), - 'S', Items.SUGAR, - 'F', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeSpeedIII), "ISI", "SFS", "ISI", 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), 'S', Items.SUGAR, 'F', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal())); recipeDrillSpeedIII = RecipeUtil.lastIRecipe(); //Drill Fortune - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeFortune), - "ISI", "SRS", "ISI", - 'I', Blocks.GLOWSTONE, - 'S', Items.REDSTONE, - 'R', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeFortune), "ISI", "SRS", "ISI", 'I', Blocks.GLOWSTONE, 'S', Items.REDSTONE, 'R', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal())); recipeDrillFortuneI = RecipeUtil.lastIRecipe(); - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeFortuneII), - "ISI", "SRS", "ISI", - 'I', Blocks.GLOWSTONE, - 'S', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.REDSTONE.ordinal()), - 'R', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDER_CASING.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeFortuneII), "ISI", "SRS", "ISI", 'I', Blocks.GLOWSTONE, 'S', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.REDSTONE.ordinal()), 'R', new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDER_CASING.ordinal())); recipeDrillFortuneII = RecipeUtil.lastIRecipe(); //Drill Size - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeThreeByThree), - "DID", "ICI", "DID", - 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), - 'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeThreeByThree), "DID", "ICI", "DID", 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal())); recipeDrillThree = RecipeUtil.lastIRecipe(); - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeFiveByFive), - "DID", "ICI", "DID", - 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), - 'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeFiveByFive), "DID", "ICI", "DID", 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), 'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); recipeDrillFive = RecipeUtil.lastIRecipe(); //Drill Silk Touch - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeSilkTouch), - "DSD", "SCS", "DSD", - 'D', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.EMERALD.ordinal()), - 'S', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeSilkTouch), "DSD", "SCS", "DSD", 'D', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.EMERALD.ordinal()), 'S', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); recipeDrillSilk = RecipeUtil.lastIRecipe(); //Drill Placing - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeBlockPlacing), - "CEC", "RAR", "CEC", - 'C', "cobblestone", - 'E', Items.PAPER, - 'A', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), - 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemDrillUpgradeBlockPlacing), "CEC", "RAR", "CEC", 'C', "cobblestone", 'E', Items.PAPER, 'A', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal())); recipeDrillPlacing = RecipeUtil.lastIRecipe(); //Battery - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemBattery), - " R ", "ICI", "III", - 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), - 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemBattery), " R ", "ICI", "III", 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); recipeBattery = RecipeUtil.lastIRecipe(); //Double Battery - new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "double_battery"), new ItemStack(InitItems.itemBatteryDouble), new ItemStack(InitItems.itemBattery), - " R ", "ICI", "III", - 'R', new ItemStack(InitItems.itemBattery), - 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "double_battery"), new ItemStack(InitItems.itemBatteryDouble), new ItemStack(InitItems.itemBattery), " R ", "ICI", "III", 'R', new ItemStack(InitItems.itemBattery), 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); recipeBatteryDouble = RecipeUtil.lastIRecipe(); //Magnet Ring - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMagnetRing), - "RIB", "IOI", "BIR", - 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), - 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), - 'B', new ItemStack(Items.DYE, 1, 4), - 'O', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RING.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMagnetRing), "RIB", "IOI", "BIR", 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 'I', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 'B', new ItemStack(Items.DYE, 1, 4), 'O', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RING.ordinal())); recipeMagnetRing = RecipeUtil.lastIRecipe(); //Growth Ring - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemGrowthRing), - "SIS", "IOI", "SIS", - 'S', new ItemStack(Items.WHEAT_SEEDS), - 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), - 'O', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RING.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemGrowthRing), "SIS", "IOI", "SIS", 'S', new ItemStack(Items.WHEAT_SEEDS), 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), 'O', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RING.ordinal())); recipeGrowthRing = RecipeUtil.lastIRecipe(); //Water Ring - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemWaterRemovalRing), - "BIB", "IOI", "BIB", - 'B', new ItemStack(Items.WATER_BUCKET), - 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), - 'O', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RING.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemWaterRemovalRing), "BIB", "IOI", "BIB", 'B', new ItemStack(Items.WATER_BUCKET), 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), 'O', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RING.ordinal())); recipeWaterRing = RecipeUtil.lastIRecipe(); //Triple Battery - new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "triple_battery"), new ItemStack(InitItems.itemBatteryTriple), new ItemStack(InitItems.itemBatteryDouble), - " R ", "ICI", "III", - 'R', new ItemStack(InitItems.itemBatteryDouble), - 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "triple_battery"), new ItemStack(InitItems.itemBatteryTriple), new ItemStack(InitItems.itemBatteryDouble), " R ", "ICI", "III", 'R', new ItemStack(InitItems.itemBatteryDouble), 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); recipeBatteryTriple = RecipeUtil.lastIRecipe(); //Quadruple Battery - new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "quadruple_battery"), new ItemStack(InitItems.itemBatteryQuadruple), new ItemStack(InitItems.itemBatteryTriple), - " R ", "ICI", "III", - 'R', new ItemStack(InitItems.itemBatteryTriple), - 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "quadruple_battery"), new ItemStack(InitItems.itemBatteryQuadruple), new ItemStack(InitItems.itemBatteryTriple), " R ", "ICI", "III", 'R', new ItemStack(InitItems.itemBatteryTriple), 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); recipeBatteryQuadruple = RecipeUtil.lastIRecipe(); //Quintuple Battery - new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "quintuple_battery"), new ItemStack(InitItems.itemBatteryQuintuple), new ItemStack(InitItems.itemBatteryQuadruple), - " R ", "ICI", "III", - 'R', new ItemStack(InitItems.itemBatteryQuadruple), - 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + new RecipeKeepDataShaped(new ResourceLocation(ActuallyAdditions.MODID, "quintuple_battery"), new ItemStack(InitItems.itemBatteryQuintuple), new ItemStack(InitItems.itemBatteryQuadruple), " R ", "ICI", "III", 'R', new ItemStack(InitItems.itemBatteryQuadruple), 'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); recipeBatteryQuintuple = RecipeUtil.lastIRecipe(); //Bat Wings - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemWingsOfTheBats), - "WNW", "WDW", "WNW", - 'W', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BAT_WING.ordinal()), - 'N', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), - 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.ENDER_STAR.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemWingsOfTheBats), "WNW", "WDW", "WNW", 'W', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BAT_WING.ordinal()), 'N', new ItemStack(InitBlocks.blockCrystalEmpowered, 1, TheCrystals.DIAMOND.ordinal()), 'D', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.ENDER_STAR.ordinal())); recipeWings = RecipeUtil.lastIRecipe(); //Coil - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), - " R ", "RIR", " R ", - 'I', ConfigBoolValues.SUPER_DUPER_HARD_MODE.isEnabled() ? new ItemStack(InitItems.itemMisc, 1, TheMiscItems.ENDER_STAR.ordinal()) : new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), - 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), " R ", "RIR", " R ", 'I', ConfigBoolValues.SUPER_DUPER_HARD_MODE.isEnabled() ? new ItemStack(InitItems.itemMisc, 1, TheMiscItems.ENDER_STAR.ordinal()) : new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), 'R', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal())); recipeCoil = RecipeUtil.lastIRecipe(); //Cup - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()), - "S S", "SCS", "SSS", - 'S', "stone", - 'C', "cropCoffee"); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()), "S S", "SCS", "SSS", 'S', "stone", 'C', "cropCoffee"); recipeCup = RecipeUtil.lastIRecipe(); //Resonant Rice - if(!OreDictionary.getOres("nuggetEnderium", false).isEmpty()){ - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemResonantRice), - new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal()), "nuggetEnderium", Items.GUNPOWDER); + if (!OreDictionary.getOres("nuggetEnderium", false).isEmpty()) { + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemResonantRice), new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal()), "nuggetEnderium", Items.GUNPOWDER); } //Advanced Coil - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), - "GGG", "GCG", "GGG", - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), - 'G', "nuggetGold"); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), "GGG", "GCG", "GGG", 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), 'G', "nuggetGold"); recipeCoilAdvanced = RecipeUtil.lastIRecipe(); //Advanced Leaf Blower - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemLeafBlowerAdvanced), - " F", "DP", "DC", - 'F', new ItemStack(Items.FLINT), - 'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), - 'P', new ItemStack(Blocks.PISTON), - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemLeafBlowerAdvanced), " F", "DP", "DC", 'F', new ItemStack(Items.FLINT), 'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), 'P', new ItemStack(Blocks.PISTON), 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal())); recipeLeafBlowerAdvanced = RecipeUtil.lastIRecipe(); //Phantom Connector - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemPhantomConnector), - "YE", "EY", "S ", - 'Y', Items.ENDER_EYE, - 'E', Items.ENDER_PEARL, - 'S', "stickWood"); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemPhantomConnector), "YE", "EY", "S ", 'Y', Items.ENDER_EYE, 'E', Items.ENDER_PEARL, 'S', "stickWood"); recipePhantomConnector = RecipeUtil.lastIRecipe(); //Player Probe - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemPlayerProbe), - "A A", "AIA", "RHR", - 'A', new ItemStack(Blocks.IRON_BARS), - 'R', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.REDSTONE.ordinal()), - 'H', new ItemStack(Items.SKULL, 1, 1), - 'I', new ItemStack(Items.IRON_HELMET)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemPlayerProbe), "A A", "AIA", "RHR", 'A', new ItemStack(Blocks.IRON_BARS), 'R', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.REDSTONE.ordinal()), 'H', new ItemStack(Items.SKULL, 1, 1), 'I', new ItemStack(Items.IRON_HELMET)); recipePlayerProbe = RecipeUtil.lastIRecipe(); //Quartz - GameRegistry.addSmelting(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal()), - new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), 1F); + GameRegistry.addSmelting(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal()), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), 1F); //Knife - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemKnife), - new ItemStack(InitItems.itemMisc, 1, TheMiscItems.KNIFE_BLADE.ordinal()), - new ItemStack(InitItems.itemMisc, 1, TheMiscItems.KNIFE_HANDLE.ordinal())); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemKnife), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.KNIFE_BLADE.ordinal()), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.KNIFE_HANDLE.ordinal())); recipeKnife = RecipeUtil.lastIRecipe(); //Crafter on a Stick - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemCrafterOnAStick), - new ItemStack(Blocks.CRAFTING_TABLE), - new ItemStack(Items.SIGN)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemCrafterOnAStick), new ItemStack(Blocks.CRAFTING_TABLE), new ItemStack(Items.SIGN)); //Tiny Coal - if(ConfigBoolValues.TINY_COAL_STUFF.isEnabled()){ - RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemMisc, 8, TheMiscItems.TINY_COAL.ordinal()), - new ItemStack(Items.COAL)); + if (ConfigBoolValues.TINY_COAL_STUFF.isEnabled()) { + RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemMisc, 8, TheMiscItems.TINY_COAL.ordinal()), new ItemStack(Items.COAL)); recipeTinyCoal = RecipeUtil.lastIRecipe(); - RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemMisc, 8, TheMiscItems.TINY_CHAR.ordinal()), - new ItemStack(Items.COAL, 1, 1)); + RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemMisc, 8, TheMiscItems.TINY_CHAR.ordinal()), new ItemStack(Items.COAL, 1, 1)); recipeTinyChar = RecipeUtil.lastIRecipe(); - RecipeHandler.addOreDictRecipe(new ItemStack(Items.COAL), - "CCC", "C C", "CCC", - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.TINY_COAL.ordinal())); - RecipeHandler.addOreDictRecipe(new ItemStack(Items.COAL, 1, 1), - "CCC", "C C", "CCC", - 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.TINY_CHAR.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(Items.COAL), "CCC", "C C", "CCC", 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.TINY_COAL.ordinal())); + RecipeHandler.addOreDictRecipe(new ItemStack(Items.COAL, 1, 1), "CCC", "C C", "CCC", 'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.TINY_CHAR.ordinal())); } //Rice Seeds - RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemRiceSeed), - new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal())); + RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemRiceSeed), new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal())); //Canola Seeds - RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemCanolaSeed), - new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CANOLA.ordinal())); + RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemCanolaSeed), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CANOLA.ordinal())); //Rings initPotionRingRecipes(); //Ingots from Dusts - GameRegistry.addSmelting(new ItemStack(InitItems.itemDust, 1, TheDusts.IRON.ordinal()), - new ItemStack(Items.IRON_INGOT), 1F); - GameRegistry.addSmelting(new ItemStack(InitItems.itemDust, 1, TheDusts.GOLD.ordinal()), - new ItemStack(Items.GOLD_INGOT), 1F); - GameRegistry.addSmelting(new ItemStack(InitItems.itemDust, 1, TheDusts.DIAMOND.ordinal()), - new ItemStack(Items.DIAMOND), 1F); - GameRegistry.addSmelting(new ItemStack(InitItems.itemDust, 1, TheDusts.EMERALD.ordinal()), - new ItemStack(Items.EMERALD), 1F); - GameRegistry.addSmelting(new ItemStack(InitItems.itemDust, 1, TheDusts.LAPIS.ordinal()), - new ItemStack(Items.DYE, 1, 4), 1F); - GameRegistry.addSmelting(new ItemStack(InitItems.itemDust, 1, TheDusts.QUARTZ_BLACK.ordinal()), - new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), 1F); - GameRegistry.addSmelting(new ItemStack(InitItems.itemDust, 1, TheDusts.QUARTZ.ordinal()), - new ItemStack(Items.QUARTZ), 1F); - GameRegistry.addSmelting(new ItemStack(InitItems.itemDust, 1, TheDusts.COAL.ordinal()), - new ItemStack(Items.COAL), 1F); + GameRegistry.addSmelting(new ItemStack(InitItems.itemDust, 1, TheDusts.IRON.ordinal()), new ItemStack(Items.IRON_INGOT), 1F); + GameRegistry.addSmelting(new ItemStack(InitItems.itemDust, 1, TheDusts.GOLD.ordinal()), new ItemStack(Items.GOLD_INGOT), 1F); + GameRegistry.addSmelting(new ItemStack(InitItems.itemDust, 1, TheDusts.DIAMOND.ordinal()), new ItemStack(Items.DIAMOND), 1F); + GameRegistry.addSmelting(new ItemStack(InitItems.itemDust, 1, TheDusts.EMERALD.ordinal()), new ItemStack(Items.EMERALD), 1F); + GameRegistry.addSmelting(new ItemStack(InitItems.itemDust, 1, TheDusts.LAPIS.ordinal()), new ItemStack(Items.DYE, 1, 4), 1F); + GameRegistry.addSmelting(new ItemStack(InitItems.itemDust, 1, TheDusts.QUARTZ_BLACK.ordinal()), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), 1F); + GameRegistry.addSmelting(new ItemStack(InitItems.itemDust, 1, TheDusts.QUARTZ.ordinal()), new ItemStack(Items.QUARTZ), 1F); + GameRegistry.addSmelting(new ItemStack(InitItems.itemDust, 1, TheDusts.COAL.ordinal()), new ItemStack(Items.COAL), 1F); } - public static void initPotionRingRecipes(){ - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RING.ordinal()), - "IGI", "GDG", "IGI", - 'G', "ingotGold", - 'I', "ingotIron", - 'D', "dustGlowstone"); + public static void initPotionRingRecipes() { + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RING.ordinal()), "IGI", "GDG", "IGI", 'G', "ingotGold", 'I', "ingotIron", 'D', "dustGlowstone"); recipeRing = RecipeUtil.lastIRecipe(); addRingRecipeWithStack(ThePotionRings.SPEED.craftingItem, ThePotionRings.SPEED.ordinal()); @@ -600,7 +373,7 @@ public final class ItemCrafting{ addRingRecipeWithStack(ThePotionRings.NIGHT_VISION.craftingItem, ThePotionRings.NIGHT_VISION.ordinal()); } - public static void addRingRecipeWithStack(ItemStack mainStack, int meta){ + public static void addRingRecipeWithStack(ItemStack mainStack, int meta) { ItemStack potion = new ItemStack(Items.POTIONITEM); PotionUtils.addPotionToItemStack(potion, PotionTypes.AWKWARD); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/MiscCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/MiscCrafting.java index d2808d041..d6f0a1036 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/MiscCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/MiscCrafting.java @@ -22,7 +22,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.fml.common.registry.GameRegistry; -public final class MiscCrafting{ +public final class MiscCrafting { public static final IRecipe[] RECIPES_CRYSTAL_SHARDS = new IRecipe[TheCrystals.values().length]; public static final IRecipe[] RECIPES_CRYSTAL_SHARDS_BACK = new IRecipe[TheCrystals.values().length]; @@ -33,70 +33,50 @@ public final class MiscCrafting{ public static final IRecipe[] RECIPES_EMPOWERED_CRYSTALS = new IRecipe[TheCrystals.values().length]; public static final IRecipe[] RECIPES_EMPOWERED_CRYSTAL_BLOCKS = new IRecipe[TheCrystals.values().length]; - public static void init(){ + public static void init() { //Bio Coal - GameRegistry.addSmelting(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BIOMASS.ordinal()), - new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BIOCOAL.ordinal()), 1.0F); + GameRegistry.addSmelting(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BIOMASS.ordinal()), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BIOCOAL.ordinal()), 1.0F); //Crystals - for(int i = 0; i < TheCrystals.values().length; i++){ - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockCrystal, 1, i), - "XXX", "XXX", "XXX", - 'X', new ItemStack(InitItems.itemCrystal, 1, i)); + for (int i = 0; i < TheCrystals.values().length; i++) { + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockCrystal, 1, i), "XXX", "XXX", "XXX", 'X', new ItemStack(InitItems.itemCrystal, 1, i)); RECIPES_CRYSTAL_BLOCKS[i] = RecipeUtil.lastIRecipe(); RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemCrystal, 9, i), new ItemStack(InitBlocks.blockCrystal, 1, i)); RECIPES_CRYSTALS[i] = RecipeUtil.lastIRecipe(); - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockCrystalEmpowered, 1, i), - "XXX", "XXX", "XXX", - 'X', new ItemStack(InitItems.itemCrystalEmpowered, 1, i)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockCrystalEmpowered, 1, i), "XXX", "XXX", "XXX", 'X', new ItemStack(InitItems.itemCrystalEmpowered, 1, i)); RECIPES_EMPOWERED_CRYSTAL_BLOCKS[i] = RecipeUtil.lastIRecipe(); RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemCrystalEmpowered, 9, i), new ItemStack(InitBlocks.blockCrystalEmpowered, 1, i)); RECIPES_EMPOWERED_CRYSTALS[i] = RecipeUtil.lastIRecipe(); - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemCrystal, 1, i), - "XXX", "XXX", "XXX", - 'X', new ItemStack(InitItems.itemCrystalShard, 1, i)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemCrystal, 1, i), "XXX", "XXX", "XXX", 'X', new ItemStack(InitItems.itemCrystalShard, 1, i)); RECIPES_CRYSTAL_SHARDS[i] = RecipeUtil.lastIRecipe(); RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemCrystalShard, 9, i), new ItemStack(InitItems.itemCrystal, 1, i)); RECIPES_CRYSTAL_SHARDS_BACK[i] = RecipeUtil.lastIRecipe(); } //Dough - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemMisc, 2, TheMiscItems.DOUGH.ordinal()), - "cropWheat", "cropWheat"); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemMisc, 2, TheMiscItems.DOUGH.ordinal()), "cropWheat", "cropWheat"); ItemCrafting.recipeDough = RecipeUtil.lastIRecipe(); //Rice Dough - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemMisc, 2, TheMiscItems.RICE_DOUGH.ordinal()), - new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal()), new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal()), new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal())); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemMisc, 2, TheMiscItems.RICE_DOUGH.ordinal()), new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal()), new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal()), new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal())); ItemCrafting.recipeRiceDough = RecipeUtil.lastIRecipe(); //Paper Cone - RecipeHandler.addShapedRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.PAPER_CONE.ordinal()), - "P P", " P ", - 'P', new ItemStack(Items.PAPER)); + RecipeHandler.addShapedRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.PAPER_CONE.ordinal()), "P P", " P ", 'P', new ItemStack(Items.PAPER)); //Knife Handle - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.KNIFE_HANDLE.ordinal()), - "stickWood", - new ItemStack(Items.LEATHER)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.KNIFE_HANDLE.ordinal()), "stickWood", new ItemStack(Items.LEATHER)); ItemCrafting.recipeKnifeHandle = RecipeUtil.lastIRecipe(); //Knife Blade - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.KNIFE_BLADE.ordinal()), - "K", "K", "F", - 'K', "ingotIron", - 'F', new ItemStack(Items.FLINT)); + RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.KNIFE_BLADE.ordinal()), "K", "K", "F", 'K', "ingotIron", 'F', new ItemStack(Items.FLINT)); ItemCrafting.recipeKnifeBlade = RecipeUtil.lastIRecipe(); //Ender Star - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.ENDER_STAR.ordinal()), - new ItemStack(Items.NETHER_STAR), - new ItemStack(Items.DRAGON_BREATH), - new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), - new ItemStack(Items.PRISMARINE_SHARD)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.ENDER_STAR.ordinal()), new ItemStack(Items.NETHER_STAR), new ItemStack(Items.DRAGON_BREATH), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), new ItemStack(Items.PRISMARINE_SHARD)); ItemCrafting.recipeEnderStar = RecipeUtil.lastIRecipe(); //Spawner Shard -> ingot diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeBioMash.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeBioMash.java index 21f2bc8d8..90a5c51ff 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeBioMash.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeBioMash.java @@ -26,32 +26,29 @@ import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.registries.IForgeRegistryEntry; -public class RecipeBioMash extends IForgeRegistryEntry.Impl implements IRecipe{ +public class RecipeBioMash extends IForgeRegistryEntry.Impl implements IRecipe { - public RecipeBioMash(ResourceLocation location){ + public RecipeBioMash(ResourceLocation location) { RecipeHelper.addRecipe(location.getPath(), this); } @Override - public boolean matches(InventoryCrafting inv, World world){ + public boolean matches(InventoryCrafting inv, World world) { boolean foundFood = false; boolean hasKnife = false; - for(int i = 0; i < inv.getSizeInventory(); i++){ + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(StackUtil.isValid(stack)){ - if(stack.getItem() instanceof ItemKnife){ - if(hasKnife){ + if (StackUtil.isValid(stack)) { + if (stack.getItem() instanceof ItemKnife) { + if (hasKnife) { return false; - } - else{ + } else { hasKnife = true; } - } - else if(stack.getItem() instanceof ItemFood){ + } else if (stack.getItem() instanceof ItemFood) { foundFood = true; - } - else{ + } else { return false; } } @@ -61,42 +58,41 @@ public class RecipeBioMash extends IForgeRegistryEntry.Impl implements } @Override - public ItemStack getCraftingResult(InventoryCrafting inv){ + public ItemStack getCraftingResult(InventoryCrafting inv) { int amount = 0; - for(int i = 0; i < inv.getSizeInventory(); i++){ + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(StackUtil.isValid(stack)){ - if(stack.getItem() instanceof ItemFood){ - ItemFood food = (ItemFood)stack.getItem(); + if (StackUtil.isValid(stack)) { + if (stack.getItem() instanceof ItemFood) { + ItemFood food = (ItemFood) stack.getItem(); float heal = food.getHealAmount(stack); float sat = food.getSaturationModifier(stack); - amount += MathHelper.ceil(heal*sat); + amount += MathHelper.ceil(heal * sat); } } } - if(amount > 0 && amount <= 64){ + if (amount > 0 && amount <= 64) { return new ItemStack(InitItems.itemMisc, amount, TheMiscItems.MASHED_FOOD.ordinal()); - } - else{ + } else { return StackUtil.getEmpty(); } } @Override - public boolean canFit(int width, int height){ - return width*height > 5; + public boolean canFit(int width, int height) { + return width * height > 5; } @Override - public ItemStack getRecipeOutput(){ + public ItemStack getRecipeOutput() { return StackUtil.getEmpty(); } @Override - public NonNullList getRemainingItems(InventoryCrafting inv){ + public NonNullList getRemainingItems(InventoryCrafting inv) { return ForgeHooks.defaultRecipeGetRemainingItems(inv); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShaped.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShaped.java index 7924a598c..58300bf8e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShaped.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShaped.java @@ -18,11 +18,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.oredict.ShapedOreRecipe; -public class RecipeKeepDataShaped extends ShapedOreRecipe{ +public class RecipeKeepDataShaped extends ShapedOreRecipe { private final ItemStack nbtCopyStack; - public RecipeKeepDataShaped(ResourceLocation group, ItemStack result, ItemStack nbtCopyStack, Object... recipe){ + public RecipeKeepDataShaped(ResourceLocation group, ItemStack result, ItemStack nbtCopyStack, Object... recipe) { super(group, result, recipe); this.nbtCopyStack = nbtCopyStack; @@ -30,12 +30,12 @@ public class RecipeKeepDataShaped extends ShapedOreRecipe{ } @Override - public ItemStack getCraftingResult(InventoryCrafting inventory){ + public ItemStack getCraftingResult(InventoryCrafting inventory) { ItemStack stack = super.getCraftingResult(inventory); - if(StackUtil.isValid(stack)){ - for(int i = 0; i < inventory.getSizeInventory(); i++){ + if (StackUtil.isValid(stack)) { + for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack input = inventory.getStackInSlot(i); - if(ItemUtil.areItemsEqual(this.nbtCopyStack, input, true)){ + if (ItemUtil.areItemsEqual(this.nbtCopyStack, input, true)) { stack.setTagCompound(input.getTagCompound()); break; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShapeless.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShapeless.java index dc0265938..fd85a8b56 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShapeless.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShapeless.java @@ -18,11 +18,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.oredict.ShapelessOreRecipe; -public class RecipeKeepDataShapeless extends ShapelessOreRecipe{ +public class RecipeKeepDataShapeless extends ShapelessOreRecipe { private final ItemStack nbtCopyStack; - public RecipeKeepDataShapeless(ResourceLocation group, ItemStack result, ItemStack nbtCopyStack, Object... recipe){ + public RecipeKeepDataShapeless(ResourceLocation group, ItemStack result, ItemStack nbtCopyStack, Object... recipe) { super(group, result, recipe); this.nbtCopyStack = nbtCopyStack; @@ -30,12 +30,12 @@ public class RecipeKeepDataShapeless extends ShapelessOreRecipe{ } @Override - public ItemStack getCraftingResult(InventoryCrafting inventory){ + public ItemStack getCraftingResult(InventoryCrafting inventory) { ItemStack stack = super.getCraftingResult(inventory); - if(StackUtil.isValid(stack)){ - for(int i = 0; i < inventory.getSizeInventory(); i++){ + if (StackUtil.isValid(stack)) { + for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack input = inventory.getStackInSlot(i); - if(ItemUtil.areItemsEqual(this.nbtCopyStack, input, true)){ + if (ItemUtil.areItemsEqual(this.nbtCopyStack, input, true)) { stack.setTagCompound(input.getTagCompound()); break; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipePotionRingCharging.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipePotionRingCharging.java index 633991466..856eaba76 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipePotionRingCharging.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipePotionRingCharging.java @@ -23,30 +23,26 @@ import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.registries.IForgeRegistryEntry; -public class RecipePotionRingCharging extends IForgeRegistryEntry.Impl implements IRecipe{ +public class RecipePotionRingCharging extends IForgeRegistryEntry.Impl implements IRecipe { - public RecipePotionRingCharging(ResourceLocation location){ + public RecipePotionRingCharging(ResourceLocation location) { RecipeHelper.addRecipe(location.getPath(), this); } @Override - public boolean matches(InventoryCrafting inv, World worldIn){ + public boolean matches(InventoryCrafting inv, World worldIn) { boolean hasRing = false; - for(int i = 0; i < inv.getSizeInventory(); i++){ + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(StackUtil.isValid(stack)){ - if(stack.getItem() instanceof ItemPotionRing){ - if(!hasRing){ + if (StackUtil.isValid(stack)) { + if (stack.getItem() instanceof ItemPotionRing) { + if (!hasRing) { hasRing = true; - } - else{ + } else { return false; } - } - else if(stack.getItem() != Items.BLAZE_POWDER){ - return false; - } + } else if (stack.getItem() != Items.BLAZE_POWDER) { return false; } } } @@ -54,27 +50,26 @@ public class RecipePotionRingCharging extends IForgeRegistryEntry.Impl } @Override - public ItemStack getCraftingResult(InventoryCrafting inv){ + public ItemStack getCraftingResult(InventoryCrafting inv) { ItemStack inputRing = StackUtil.getEmpty(); int totalBlaze = 0; - for(int i = 0; i < inv.getSizeInventory(); i++){ + for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); - if(StackUtil.isValid(stack)){ - if(stack.getItem() instanceof ItemPotionRing){ + if (StackUtil.isValid(stack)) { + if (stack.getItem() instanceof ItemPotionRing) { inputRing = stack; - } - else if(stack.getItem() == Items.BLAZE_POWDER){ + } else if (stack.getItem() == Items.BLAZE_POWDER) { totalBlaze += 20; } } } - if(StackUtil.isValid(inputRing) && totalBlaze > 0){ + if (StackUtil.isValid(inputRing) && totalBlaze > 0) { ItemStack copy = inputRing.copy(); - int total = ItemPotionRing.getStoredBlaze(copy)+totalBlaze; - if(total <= ItemPotionRing.MAX_BLAZE){ + int total = ItemPotionRing.getStoredBlaze(copy) + totalBlaze; + if (total <= ItemPotionRing.MAX_BLAZE) { ItemPotionRing.setStoredBlaze(copy, total); return copy; } @@ -84,17 +79,17 @@ public class RecipePotionRingCharging extends IForgeRegistryEntry.Impl } @Override - public boolean canFit(int width, int height){ - return width*height > 3; + public boolean canFit(int width, int height) { + return width * height > 3; } @Override - public ItemStack getRecipeOutput(){ + public ItemStack getRecipeOutput() { return StackUtil.getEmpty(); } @Override - public NonNullList getRemainingItems(InventoryCrafting inv){ + public NonNullList getRemainingItems(InventoryCrafting inv) { return ForgeHooks.defaultRecipeGetRemainingItems(inv); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ToolCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ToolCrafting.java index 2a2c035fc..ca081d1c1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ToolCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ToolCrafting.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.crafting; +import java.util.ArrayList; + import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; @@ -21,13 +23,11 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; -import java.util.ArrayList; - -public final class ToolCrafting{ +public final class ToolCrafting { public static final ArrayList RECIPES_PAXELS = new ArrayList<>(); - public static void init(){ + public static void init() { addToolAndArmorRecipes(new ItemStack(Items.EMERALD), InitItems.itemPickaxeEmerald, InitItems.itemSwordEmerald, InitItems.itemAxeEmerald, InitItems.itemShovelEmerald, InitItems.itemHoeEmerald, InitItems.itemHelmEmerald, InitItems.itemChestEmerald, InitItems.itemPantsEmerald, InitItems.itemBootsEmerald); addToolAndArmorRecipes(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), InitItems.itemPickaxeQuartz, InitItems.itemSwordQuartz, InitItems.itemAxeQuartz, InitItems.itemShovelQuartz, InitItems.itemHoeQuartz, InitItems.itemHelmQuartz, InitItems.itemChestQuartz, InitItems.itemPantsQuartz, InitItems.itemBootsQuartz); @@ -41,156 +41,63 @@ public final class ToolCrafting{ addToolAndArmorRecipes(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), InitItems.itemPickaxeCrystalBlack, InitItems.itemSwordCrystalBlack, InitItems.itemAxeCrystalBlack, InitItems.itemShovelCrystalBlack, InitItems.itemHoeCrystalBlack, InitItems.itemHelmCrystalBlack, InitItems.itemChestCrystalBlack, InitItems.itemPantsCrystalBlack, InitItems.itemBootsCrystalBlack); //Paxels - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.woodenPaxel), - new ItemStack(Items.WOODEN_AXE), - new ItemStack(Items.WOODEN_PICKAXE), - new ItemStack(Items.WOODEN_SHOVEL), - new ItemStack(Items.WOODEN_SWORD), - new ItemStack(Items.WOODEN_HOE)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.woodenPaxel), new ItemStack(Items.WOODEN_AXE), new ItemStack(Items.WOODEN_PICKAXE), new ItemStack(Items.WOODEN_SHOVEL), new ItemStack(Items.WOODEN_SWORD), new ItemStack(Items.WOODEN_HOE)); RECIPES_PAXELS.add(RecipeUtil.lastIRecipe()); - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.stonePaxel), - new ItemStack(Items.STONE_AXE), - new ItemStack(Items.STONE_PICKAXE), - new ItemStack(Items.STONE_SHOVEL), - new ItemStack(Items.STONE_SWORD), - new ItemStack(Items.STONE_HOE)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.stonePaxel), new ItemStack(Items.STONE_AXE), new ItemStack(Items.STONE_PICKAXE), new ItemStack(Items.STONE_SHOVEL), new ItemStack(Items.STONE_SWORD), new ItemStack(Items.STONE_HOE)); RECIPES_PAXELS.add(RecipeUtil.lastIRecipe()); - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.ironPaxel), - new ItemStack(Items.IRON_AXE), - new ItemStack(Items.IRON_PICKAXE), - new ItemStack(Items.IRON_SHOVEL), - new ItemStack(Items.IRON_SWORD), - new ItemStack(Items.IRON_HOE)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.ironPaxel), new ItemStack(Items.IRON_AXE), new ItemStack(Items.IRON_PICKAXE), new ItemStack(Items.IRON_SHOVEL), new ItemStack(Items.IRON_SWORD), new ItemStack(Items.IRON_HOE)); RECIPES_PAXELS.add(RecipeUtil.lastIRecipe()); - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.goldPaxel), - new ItemStack(Items.GOLDEN_AXE), - new ItemStack(Items.GOLDEN_PICKAXE), - new ItemStack(Items.GOLDEN_SHOVEL), - new ItemStack(Items.GOLDEN_SWORD), - new ItemStack(Items.GOLDEN_HOE)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.goldPaxel), new ItemStack(Items.GOLDEN_AXE), new ItemStack(Items.GOLDEN_PICKAXE), new ItemStack(Items.GOLDEN_SHOVEL), new ItemStack(Items.GOLDEN_SWORD), new ItemStack(Items.GOLDEN_HOE)); RECIPES_PAXELS.add(RecipeUtil.lastIRecipe()); - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.diamondPaxel), - new ItemStack(Items.DIAMOND_AXE), - new ItemStack(Items.DIAMOND_PICKAXE), - new ItemStack(Items.DIAMOND_SHOVEL), - new ItemStack(Items.DIAMOND_SWORD), - new ItemStack(Items.DIAMOND_HOE)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.diamondPaxel), new ItemStack(Items.DIAMOND_AXE), new ItemStack(Items.DIAMOND_PICKAXE), new ItemStack(Items.DIAMOND_SHOVEL), new ItemStack(Items.DIAMOND_SWORD), new ItemStack(Items.DIAMOND_HOE)); RECIPES_PAXELS.add(RecipeUtil.lastIRecipe()); - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.emeraldPaxel), - new ItemStack(InitItems.itemAxeEmerald), - new ItemStack(InitItems.itemPickaxeEmerald), - new ItemStack(InitItems.itemSwordEmerald), - new ItemStack(InitItems.itemShovelEmerald), - new ItemStack(InitItems.itemHoeEmerald)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.emeraldPaxel), new ItemStack(InitItems.itemAxeEmerald), new ItemStack(InitItems.itemPickaxeEmerald), new ItemStack(InitItems.itemSwordEmerald), new ItemStack(InitItems.itemShovelEmerald), new ItemStack(InitItems.itemHoeEmerald)); RECIPES_PAXELS.add(RecipeUtil.lastIRecipe()); - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.obsidianPaxel), - new ItemStack(InitItems.itemAxeObsidian), - new ItemStack(InitItems.itemPickaxeObsidian), - new ItemStack(InitItems.itemSwordObsidian), - new ItemStack(InitItems.itemShovelObsidian), - new ItemStack(InitItems.itemHoeObsidian)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.obsidianPaxel), new ItemStack(InitItems.itemAxeObsidian), new ItemStack(InitItems.itemPickaxeObsidian), new ItemStack(InitItems.itemSwordObsidian), new ItemStack(InitItems.itemShovelObsidian), new ItemStack(InitItems.itemHoeObsidian)); RECIPES_PAXELS.add(RecipeUtil.lastIRecipe()); - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.quartzPaxel), - new ItemStack(InitItems.itemAxeQuartz), - new ItemStack(InitItems.itemPickaxeQuartz), - new ItemStack(InitItems.itemSwordQuartz), - new ItemStack(InitItems.itemShovelQuartz), - new ItemStack(InitItems.itemHoeQuartz)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.quartzPaxel), new ItemStack(InitItems.itemAxeQuartz), new ItemStack(InitItems.itemPickaxeQuartz), new ItemStack(InitItems.itemSwordQuartz), new ItemStack(InitItems.itemShovelQuartz), new ItemStack(InitItems.itemHoeQuartz)); RECIPES_PAXELS.add(RecipeUtil.lastIRecipe()); - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalRed), - new ItemStack(InitItems.itemAxeCrystalRed), - new ItemStack(InitItems.itemPickaxeCrystalRed), - new ItemStack(InitItems.itemSwordCrystalRed), - new ItemStack(InitItems.itemShovelCrystalRed), - new ItemStack(InitItems.itemHoeCrystalRed)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalRed), new ItemStack(InitItems.itemAxeCrystalRed), new ItemStack(InitItems.itemPickaxeCrystalRed), new ItemStack(InitItems.itemSwordCrystalRed), new ItemStack(InitItems.itemShovelCrystalRed), new ItemStack(InitItems.itemHoeCrystalRed)); RECIPES_PAXELS.add(RecipeUtil.lastIRecipe()); - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalGreen), - new ItemStack(InitItems.itemAxeCrystalGreen), - new ItemStack(InitItems.itemPickaxeCrystalGreen), - new ItemStack(InitItems.itemSwordCrystalGreen), - new ItemStack(InitItems.itemShovelCrystalGreen), - new ItemStack(InitItems.itemHoeCrystalGreen)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalGreen), new ItemStack(InitItems.itemAxeCrystalGreen), new ItemStack(InitItems.itemPickaxeCrystalGreen), new ItemStack(InitItems.itemSwordCrystalGreen), new ItemStack(InitItems.itemShovelCrystalGreen), new ItemStack(InitItems.itemHoeCrystalGreen)); RECIPES_PAXELS.add(RecipeUtil.lastIRecipe()); - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalBlue), - new ItemStack(InitItems.itemAxeCrystalBlue), - new ItemStack(InitItems.itemPickaxeCrystalBlue), - new ItemStack(InitItems.itemSwordCrystalBlue), - new ItemStack(InitItems.itemShovelCrystalBlue), - new ItemStack(InitItems.itemHoeCrystalBlue)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalBlue), new ItemStack(InitItems.itemAxeCrystalBlue), new ItemStack(InitItems.itemPickaxeCrystalBlue), new ItemStack(InitItems.itemSwordCrystalBlue), new ItemStack(InitItems.itemShovelCrystalBlue), new ItemStack(InitItems.itemHoeCrystalBlue)); RECIPES_PAXELS.add(RecipeUtil.lastIRecipe()); - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalLightBlue), - new ItemStack(InitItems.itemAxeCrystalLightBlue), - new ItemStack(InitItems.itemPickaxeCrystalLightBlue), - new ItemStack(InitItems.itemSwordCrystalLightBlue), - new ItemStack(InitItems.itemShovelCrystalLightBlue), - new ItemStack(InitItems.itemHoeCrystalLightBlue)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalLightBlue), new ItemStack(InitItems.itemAxeCrystalLightBlue), new ItemStack(InitItems.itemPickaxeCrystalLightBlue), new ItemStack(InitItems.itemSwordCrystalLightBlue), new ItemStack(InitItems.itemShovelCrystalLightBlue), new ItemStack(InitItems.itemHoeCrystalLightBlue)); RECIPES_PAXELS.add(RecipeUtil.lastIRecipe()); - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalBlack), - new ItemStack(InitItems.itemAxeCrystalBlack), - new ItemStack(InitItems.itemPickaxeCrystalBlack), - new ItemStack(InitItems.itemSwordCrystalBlack), - new ItemStack(InitItems.itemShovelCrystalBlack), - new ItemStack(InitItems.itemHoeCrystalBlack)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalBlack), new ItemStack(InitItems.itemAxeCrystalBlack), new ItemStack(InitItems.itemPickaxeCrystalBlack), new ItemStack(InitItems.itemSwordCrystalBlack), new ItemStack(InitItems.itemShovelCrystalBlack), new ItemStack(InitItems.itemHoeCrystalBlack)); RECIPES_PAXELS.add(RecipeUtil.lastIRecipe()); - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalWhite), - new ItemStack(InitItems.itemAxeCrystalWhite), - new ItemStack(InitItems.itemPickaxeCrystalWhite), - new ItemStack(InitItems.itemSwordCrystalWhite), - new ItemStack(InitItems.itemShovelCrystalWhite), - new ItemStack(InitItems.itemHoeCrystalWhite)); + RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitItems.itemPaxelCrystalWhite), new ItemStack(InitItems.itemAxeCrystalWhite), new ItemStack(InitItems.itemPickaxeCrystalWhite), new ItemStack(InitItems.itemSwordCrystalWhite), new ItemStack(InitItems.itemShovelCrystalWhite), new ItemStack(InitItems.itemHoeCrystalWhite)); RECIPES_PAXELS.add(RecipeUtil.lastIRecipe()); } - public static void addToolAndArmorRecipes(ItemStack base, Item pickaxe, Item sword, Item axe, Item shovel, Item hoe, Item helm, Item chest, Item pants, Item boots){ + public static void addToolAndArmorRecipes(ItemStack base, Item pickaxe, Item sword, Item axe, Item shovel, Item hoe, Item helm, Item chest, Item pants, Item boots) { //Pickaxe - RecipeHandler.addOreDictRecipe(new ItemStack(pickaxe), - "EEE", " S ", " S ", - 'E', base, - 'S', new ItemStack(Items.STICK)); + RecipeHandler.addOreDictRecipe(new ItemStack(pickaxe), "EEE", " S ", " S ", 'E', base, 'S', new ItemStack(Items.STICK)); //Sword - RecipeHandler.addOreDictRecipe(new ItemStack(sword), - "E", "E", "S", - 'E', base, - 'S', new ItemStack(Items.STICK)); + RecipeHandler.addOreDictRecipe(new ItemStack(sword), "E", "E", "S", 'E', base, 'S', new ItemStack(Items.STICK)); //Axe - RecipeHandler.addOreDictRecipe(new ItemStack(axe), - "EE", "ES", " S", - 'E', base, - 'S', new ItemStack(Items.STICK)); + RecipeHandler.addOreDictRecipe(new ItemStack(axe), "EE", "ES", " S", 'E', base, 'S', new ItemStack(Items.STICK)); //Shovel - RecipeHandler.addOreDictRecipe(new ItemStack(shovel), - "E", "S", "S", - 'E', base, - 'S', new ItemStack(Items.STICK)); + RecipeHandler.addOreDictRecipe(new ItemStack(shovel), "E", "S", "S", 'E', base, 'S', new ItemStack(Items.STICK)); //Hoe - RecipeHandler.addOreDictRecipe(new ItemStack(hoe), - "EE", " S", " S", - 'E', base, - 'S', new ItemStack(Items.STICK)); + RecipeHandler.addOreDictRecipe(new ItemStack(hoe), "EE", " S", " S", 'E', base, 'S', new ItemStack(Items.STICK)); //Helm - RecipeHandler.addShapedRecipe(new ItemStack(helm), - "OOO", "O O", - 'O', base); + RecipeHandler.addShapedRecipe(new ItemStack(helm), "OOO", "O O", 'O', base); //Chest - RecipeHandler.addShapedRecipe(new ItemStack(chest), - "O O", "OOO", "OOO", - 'O', base); + RecipeHandler.addShapedRecipe(new ItemStack(chest), "O O", "OOO", "OOO", 'O', base); //Legs - RecipeHandler.addShapedRecipe(new ItemStack(pants), - "OOO", "O O", "O O", - 'O', base); + RecipeHandler.addShapedRecipe(new ItemStack(pants), "OOO", "O O", "O O", 'O', base); //Boots - RecipeHandler.addShapedRecipe(new ItemStack(boots), - "O O", "O O", - 'O', base); + RecipeHandler.addShapedRecipe(new ItemStack(boots), "O O", "O O", 'O', base); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/creative/CreativeTab.java b/src/main/java/de/ellpeck/actuallyadditions/mod/creative/CreativeTab.java index a2fe2f02c..324dcec70 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/creative/CreativeTab.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/creative/CreativeTab.java @@ -26,34 +26,34 @@ import net.minecraftforge.fluids.FluidUtil; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class CreativeTab extends CreativeTabs{ +public class CreativeTab extends CreativeTabs { public static final CreativeTab INSTANCE = new CreativeTab(); private NonNullList list; - public CreativeTab(){ + public CreativeTab() { super(ActuallyAdditions.MODID); - this.setBackgroundImageName(ActuallyAdditions.MODID+".png"); + this.setBackgroundImageName(ActuallyAdditions.MODID + ".png"); } @Override - public boolean hasSearchBar(){ + public boolean hasSearchBar() { return true; } @Override - public int getSearchbarWidth(){ + public int getSearchbarWidth() { return 70; } @Override - public ItemStack createIcon(){ + public ItemStack createIcon() { return new ItemStack(InitItems.itemBooklet); } @Override @SideOnly(Side.CLIENT) - public void displayAllRelevantItems(NonNullList list){ + public void displayAllRelevantItems(NonNullList list) { this.list = list; this.add(InitItems.itemBooklet); @@ -349,14 +349,14 @@ public class CreativeTab extends CreativeTabs{ this.add(InitItems.itemBootsCrystalWhite); } - public void add(Item item){ - if(item != null && (!(item instanceof IDisableableItem) || item instanceof IDisableableItem && !((IDisableableItem) item).isDisabled())){ + public void add(Item item) { + if (item != null && (!(item instanceof IDisableableItem) || item instanceof IDisableableItem && !((IDisableableItem) item).isDisabled())) { item.getSubItems(INSTANCE, this.list); } } - public void add(Block block){ - if(block != null){ + public void add(Block block) { + if (block != null) { block.getSubBlocks(INSTANCE, this.list); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/data/PlayerData.java b/src/main/java/de/ellpeck/actuallyadditions/mod/data/PlayerData.java index 776ad5b43..9163566a8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/data/PlayerData.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/data/PlayerData.java @@ -10,6 +10,11 @@ package de.ellpeck.actuallyadditions.mod.data; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet; import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; @@ -20,23 +25,16 @@ import net.minecraft.nbt.NBTTagString; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; +public final class PlayerData { -public final class PlayerData{ - - public static PlayerSave getDataFromPlayer(EntityPlayer player){ + public static PlayerSave getDataFromPlayer(EntityPlayer player) { WorldData worldData = WorldData.get(player.getEntityWorld()); ConcurrentHashMap data = worldData.playerSaveData; UUID id = player.getUniqueID(); - if(data.containsKey(id)){ + if (data.containsKey(id)) { PlayerSave save = data.get(id); - if(save != null && save.id != null && save.id.equals(id)){ - return save; - } + if (save != null && save.id != null && save.id.equals(id)) { return save; } } //Add Data if none is existant @@ -46,7 +44,7 @@ public final class PlayerData{ return save; } - public static class PlayerSave{ + public static class PlayerSave { public UUID id; @@ -62,11 +60,11 @@ public final class PlayerData{ @SideOnly(Side.CLIENT) public GuiBooklet lastOpenBooklet; - public PlayerSave(UUID id){ + public PlayerSave(UUID id) { this.id = id; } - public void readFromNBT(NBTTagCompound compound, boolean savingToFile){ + public void readFromNBT(NBTTagCompound compound, boolean savingToFile) { this.bookGottenAlready = compound.getBoolean("BookGotten"); this.didBookTutorial = compound.getBoolean("DidTutorial"); @@ -79,12 +77,12 @@ public final class PlayerData{ NBTTagList trials = compound.getTagList("Trials", 8); this.loadTrials(trials); - if(!savingToFile){ + if (!savingToFile) { this.shouldDisableBatWings = compound.getBoolean("ShouldDisableWings"); } } - public void writeToNBT(NBTTagCompound compound, boolean savingToFile){ + public void writeToNBT(NBTTagCompound compound, boolean savingToFile) { compound.setBoolean("BookGotten", this.bookGottenAlready); compound.setBoolean("DidTutorial", this.didBookTutorial); @@ -94,51 +92,49 @@ public final class PlayerData{ compound.setTag("Bookmarks", this.saveBookmarks()); compound.setTag("Trials", this.saveTrials()); - if(!savingToFile){ + if (!savingToFile) { compound.setBoolean("ShouldDisableWings", this.shouldDisableBatWings); } } - public NBTTagList saveBookmarks(){ + public NBTTagList saveBookmarks() { NBTTagList bookmarks = new NBTTagList(); - for(IBookletPage bookmark : this.bookmarks){ + for (IBookletPage bookmark : this.bookmarks) { bookmarks.appendTag(new NBTTagString(bookmark == null ? "" : bookmark.getIdentifier())); } return bookmarks; } - public void loadBookmarks(NBTTagList bookmarks){ - for(int i = 0; i < bookmarks.tagCount(); i++){ + public void loadBookmarks(NBTTagList bookmarks) { + for (int i = 0; i < bookmarks.tagCount(); i++) { String strg = bookmarks.getStringTagAt(i); - if(strg != null && !strg.isEmpty()){ + if (strg != null && !strg.isEmpty()) { IBookletPage page = BookletUtils.getBookletPageById(strg); this.bookmarks[i] = page; - } - else{ + } else { this.bookmarks[i] = null; } } } - public NBTTagList saveTrials(){ + public NBTTagList saveTrials() { NBTTagList trials = new NBTTagList(); - for(String trial : this.completedTrials){ + for (String trial : this.completedTrials) { trials.appendTag(new NBTTagString(trial)); } return trials; } - public void loadTrials(NBTTagList trials){ + public void loadTrials(NBTTagList trials) { this.completedTrials.clear(); - for(int i = 0; i < trials.tagCount(); i++){ + for (int i = 0; i < trials.tagCount(); i++) { String strg = trials.getStringTagAt(i); - if(strg != null && !strg.isEmpty()){ + if (strg != null && !strg.isEmpty()) { this.completedTrials.add(strg); } } } } - } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java index 46f63abae..6e6e80e54 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java @@ -25,94 +25,92 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.IPlantable; -public class EntityWorm extends Entity{ +public class EntityWorm extends Entity { public int timer; - public EntityWorm(World world){ + public EntityWorm(World world) { super(world); this.setEntityBoundingBox(null); } - public static boolean canWormify(World world, BlockPos pos, IBlockState state){ + public static boolean canWormify(World world, BlockPos pos, IBlockState state) { Block block = state.getBlock(); boolean rightBlock = block instanceof BlockFarmland || block instanceof BlockDirt || block instanceof BlockGrass; - if(rightBlock){ + if (rightBlock) { BlockPos posUp = pos.up(); IBlockState stateUp = world.getBlockState(posUp); Block blockUp = stateUp.getBlock(); return blockUp instanceof IPlantable || blockUp instanceof BlockBush || blockUp.isReplaceable(world, posUp); - } - else{ + } else { return false; } } @Override - protected void entityInit(){ + protected void entityInit() { } @Override - protected void readEntityFromNBT(NBTTagCompound compound){ + protected void readEntityFromNBT(NBTTagCompound compound) { this.timer = compound.getInteger("Timer"); } @Override - protected void writeEntityToNBT(NBTTagCompound compound){ + protected void writeEntityToNBT(NBTTagCompound compound) { compound.setInteger("Timer", this.timer); } @Override - public void onUpdate(){ + public void onUpdate() { this.onEntityUpdate(); } @Override - public void onEntityUpdate(){ - if(!this.world.isRemote){ + public void onEntityUpdate() { + if (!this.world.isRemote) { this.timer++; - if(this.timer%50 == 0){ - for(int x = -1; x <= 1; x++){ - for(int z = -1; z <= 1; z++){ - BlockPos pos = new BlockPos(this.posX+x, this.posY, this.posZ+z); + if (this.timer % 50 == 0) { + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + BlockPos pos = new BlockPos(this.posX + x, this.posY, this.posZ + z); IBlockState state = this.world.getBlockState(pos); Block block = state.getBlock(); boolean isMiddlePose = x == 0 && z == 0; - if(canWormify(this.world, pos, state)){ + if (canWormify(this.world, pos, state)) { boolean isFarmland = block instanceof BlockFarmland; - if(!isFarmland || state.getValue(BlockFarmland.MOISTURE) < 7){ - if(isMiddlePose || this.world.rand.nextFloat() >= 0.45F){ + if (!isFarmland || state.getValue(BlockFarmland.MOISTURE) < 7) { + if (isMiddlePose || this.world.rand.nextFloat() >= 0.45F) { - if(!isFarmland) DefaultFarmerBehavior.useHoeAt(this.world, pos); + if (!isFarmland) DefaultFarmerBehavior.useHoeAt(this.world, pos); state = this.world.getBlockState(pos); isFarmland = state.getBlock() instanceof BlockFarmland; - if(isFarmland) this.world.setBlockState(pos, state.withProperty(BlockFarmland.MOISTURE, 7), 2); + if (isFarmland) this.world.setBlockState(pos, state.withProperty(BlockFarmland.MOISTURE, 7), 2); } } - if(isFarmland && this.world.rand.nextFloat() >= 0.95F){ + if (isFarmland && this.world.rand.nextFloat() >= 0.95F) { BlockPos plant = pos.up(); - if(!this.world.isAirBlock(plant)){ + if (!this.world.isAirBlock(plant)) { IBlockState plantState = this.world.getBlockState(plant); Block plantBlock = plantState.getBlock(); - if((plantBlock instanceof IGrowable || plantBlock instanceof IPlantable) && !(plantBlock instanceof BlockGrass)){ + if ((plantBlock instanceof IGrowable || plantBlock instanceof IPlantable) && !(plantBlock instanceof BlockGrass)) { plantBlock.updateTick(this.world, plant, plantState, this.world.rand); IBlockState newState = this.world.getBlockState(plant); - if(newState != plantState){ + if (newState != plantState) { this.world.playEvent(2005, plant, 0); } } } } - } - else if(isMiddlePose){ + } else if (isMiddlePose) { this.setDead(); } } @@ -120,7 +118,7 @@ public class EntityWorm extends Entity{ } int dieTime = ConfigIntValues.WORMS_DIE_TIME.getValue(); - if(dieTime > 0 && this.timer >= dieTime){ + if (dieTime > 0 && this.timer >= dieTime) { this.setDead(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/InitEntities.java b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/InitEntities.java index 6cc065a6e..643cf3402 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/InitEntities.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/InitEntities.java @@ -17,16 +17,16 @@ import net.minecraftforge.fml.common.registry.EntityRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public final class InitEntities{ +public final class InitEntities { - public static void init(){ + public static void init() { ActuallyAdditions.LOGGER.info("Initializing Entities..."); - EntityRegistry.registerModEntity(new ResourceLocation(ActuallyAdditions.MODID, "worm"), EntityWorm.class, ActuallyAdditions.MODID+".worm", 0, ActuallyAdditions.INSTANCE, 64, 1, false); + EntityRegistry.registerModEntity(new ResourceLocation(ActuallyAdditions.MODID, "worm"), EntityWorm.class, ActuallyAdditions.MODID + ".worm", 0, ActuallyAdditions.INSTANCE, 64, 1, false); } @SideOnly(Side.CLIENT) - public static void initClient(){ + public static void initClient() { RenderingRegistry.registerEntityRenderingHandler(EntityWorm.class, RenderWorm::new); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/RenderWorm.java b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/RenderWorm.java index c510f1940..761e11775 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/RenderWorm.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/RenderWorm.java @@ -23,30 +23,30 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class RenderWorm extends Render{ +public class RenderWorm extends Render { private static ItemStack stack = ItemStack.EMPTY; - public static void fixItemStack(){ + public static void fixItemStack() { stack = new ItemStack(InitItems.itemWorm); } - protected RenderWorm(RenderManager renderManager){ + protected RenderWorm(RenderManager renderManager) { super(renderManager); } @Override - protected ResourceLocation getEntityTexture(EntityWorm entity){ + protected ResourceLocation getEntityTexture(EntityWorm entity) { return TextureMap.LOCATION_BLOCKS_TEXTURE; } @Override - public void doRender(EntityWorm entity, double x, double y, double z, float entityYaw, float partialTicks){ + public void doRender(EntityWorm entity, double x, double y, double z, float entityYaw, float partialTicks) { GlStateManager.pushMatrix(); this.bindEntityTexture(entity); - GlStateManager.translate(x, y+0.7F, z); - double boop = Minecraft.getSystemTime()/70D; - GlStateManager.rotate(-(float)(boop%360), 0, 1, 0); + GlStateManager.translate(x, y + 0.7F, z); + double boop = Minecraft.getSystemTime() / 70D; + GlStateManager.rotate(-(float) (boop % 360), 0, 1, 0); GlStateManager.translate(0, 0, 0.4); stack.setStackDisplayName(entity.getName()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java b/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java index d82ed0069..50c8864ab 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java @@ -49,122 +49,118 @@ import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.oredict.OreDictionary; @SideOnly(Side.CLIENT) -public class ClientEvents{ +public class ClientEvents { - private static final String ADVANCED_INFO_TEXT_PRE = TextFormatting.DARK_GRAY+" "; - private static final String ADVANCED_INFO_HEADER_PRE = TextFormatting.GRAY+" -"; + private static final String ADVANCED_INFO_TEXT_PRE = TextFormatting.DARK_GRAY + " "; + private static final String ADVANCED_INFO_HEADER_PRE = TextFormatting.GRAY + " -"; private static EnergyDisplay energyDisplay; - public ClientEvents(){ + public ClientEvents() { MinecraftForge.EVENT_BUS.register(this); } @SubscribeEvent - public void onClientTick(ClientTickEvent event){ - if(event.phase == Phase.END){ + public void onClientTick(ClientTickEvent event) { + if (event.phase == Phase.END) { Minecraft mc = Minecraft.getMinecraft(); - if(mc.world == null){ + if (mc.world == null) { WorldData.clear(); } } } @SubscribeEvent - public void onTooltipEvent(ItemTooltipEvent event){ + public void onTooltipEvent(ItemTooltipEvent event) { ItemStack stack = event.getItemStack(); - if(StackUtil.isValid(stack)){ + if (StackUtil.isValid(stack)) { //Be da bland - if(ConfigBoolValues.MOST_BLAND_PERSON_EVER.isEnabled()){ + if (ConfigBoolValues.MOST_BLAND_PERSON_EVER.isEnabled()) { ResourceLocation regName = stack.getItem().getRegistryName(); - if(regName != null){ - if(regName.toString().toLowerCase(Locale.ROOT).contains(ActuallyAdditions.MODID)){ - if(event.getToolTip().size() > 0){ - event.getToolTip().set(0, TextFormatting.RESET+TextFormatting.WHITE.toString()+event.getToolTip().get(0)); + if (regName != null) { + if (regName.toString().toLowerCase(Locale.ROOT).contains(ActuallyAdditions.MODID)) { + if (event.getToolTip().size() > 0) { + event.getToolTip().set(0, TextFormatting.RESET + TextFormatting.WHITE.toString() + event.getToolTip().get(0)); } } } } - if(ItemWingsOfTheBats.THE_BAT_BAT.equalsIgnoreCase(stack.getDisplayName()) && stack.getItem() instanceof ItemSword){ - event.getToolTip().set(0, TextFormatting.GOLD+event.getToolTip().get(0)); - event.getToolTip().add(1, TextFormatting.RED.toString()+TextFormatting.ITALIC+"That's a really bat pun"); + if (ItemWingsOfTheBats.THE_BAT_BAT.equalsIgnoreCase(stack.getDisplayName()) && stack.getItem() instanceof ItemSword) { + event.getToolTip().set(0, TextFormatting.GOLD + event.getToolTip().get(0)); + event.getToolTip().add(1, TextFormatting.RED.toString() + TextFormatting.ITALIC + "That's a really bat pun"); } } //Advanced Item Info - if(event.getFlags().isAdvanced() && StackUtil.isValid(event.getItemStack())){ - if(ConfigBoolValues.CTRL_EXTRA_INFO.isEnabled()){ - if(GuiScreen.isCtrlKeyDown()){ - event.getToolTip().add(TextFormatting.DARK_GRAY+""+TextFormatting.ITALIC+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".extraInfo.desc")+":"); + if (event.getFlags().isAdvanced() && StackUtil.isValid(event.getItemStack())) { + if (ConfigBoolValues.CTRL_EXTRA_INFO.isEnabled()) { + if (GuiScreen.isCtrlKeyDown()) { + event.getToolTip().add(TextFormatting.DARK_GRAY + "" + TextFormatting.ITALIC + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".extraInfo.desc") + ":"); //OreDict Names int[] oreIDs = OreDictionary.getOreIDs(event.getItemStack()); - event.getToolTip().add(ADVANCED_INFO_HEADER_PRE+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".oredictName.desc")+":"); - if(oreIDs.length > 0){ - for(int oreID : oreIDs){ - event.getToolTip().add(ADVANCED_INFO_TEXT_PRE+OreDictionary.getOreName(oreID)); + event.getToolTip().add(ADVANCED_INFO_HEADER_PRE + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".oredictName.desc") + ":"); + if (oreIDs.length > 0) { + for (int oreID : oreIDs) { + event.getToolTip().add(ADVANCED_INFO_TEXT_PRE + OreDictionary.getOreName(oreID)); } - } - else{ - event.getToolTip().add(ADVANCED_INFO_TEXT_PRE+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".noOredictNameAvail.desc")); + } else { + event.getToolTip().add(ADVANCED_INFO_TEXT_PRE + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".noOredictNameAvail.desc")); } //Code Name - event.getToolTip().add(ADVANCED_INFO_HEADER_PRE+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".codeName.desc")+":"); - event.getToolTip().add(ADVANCED_INFO_TEXT_PRE+Item.REGISTRY.getNameForObject(event.getItemStack().getItem())); + event.getToolTip().add(ADVANCED_INFO_HEADER_PRE + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".codeName.desc") + ":"); + event.getToolTip().add(ADVANCED_INFO_TEXT_PRE + Item.REGISTRY.getNameForObject(event.getItemStack().getItem())); //Base Item's Unlocalized Name String baseName = event.getItemStack().getItem().getTranslationKey(); - if(baseName != null){ - event.getToolTip().add(ADVANCED_INFO_HEADER_PRE+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".baseUnlocName.desc")+":"); - event.getToolTip().add(ADVANCED_INFO_TEXT_PRE+baseName); + if (baseName != null) { + event.getToolTip().add(ADVANCED_INFO_HEADER_PRE + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".baseUnlocName.desc") + ":"); + event.getToolTip().add(ADVANCED_INFO_TEXT_PRE + baseName); } //Metadata int meta = event.getItemStack().getItemDamage(); int max = event.getItemStack().getMaxDamage(); - event.getToolTip().add(ADVANCED_INFO_HEADER_PRE+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".meta.desc")+":"); - event.getToolTip().add(ADVANCED_INFO_TEXT_PRE+meta+(max > 0 ? "/"+max : "")); + event.getToolTip().add(ADVANCED_INFO_HEADER_PRE + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".meta.desc") + ":"); + event.getToolTip().add(ADVANCED_INFO_TEXT_PRE + meta + (max > 0 ? "/" + max : "")); //Unlocalized Name String metaName = event.getItemStack().getItem().getTranslationKey(event.getItemStack()); - if(metaName != null && baseName != null && !metaName.equals(baseName)){ - event.getToolTip().add(ADVANCED_INFO_HEADER_PRE+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".unlocName.desc")+":"); - event.getToolTip().add(ADVANCED_INFO_TEXT_PRE+metaName); + if (metaName != null && baseName != null && !metaName.equals(baseName)) { + event.getToolTip().add(ADVANCED_INFO_HEADER_PRE + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".unlocName.desc") + ":"); + event.getToolTip().add(ADVANCED_INFO_TEXT_PRE + metaName); } //NBT NBTTagCompound compound = event.getItemStack().getTagCompound(); - if(compound != null && !compound.isEmpty()){ - event.getToolTip().add(ADVANCED_INFO_HEADER_PRE+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".nbt.desc")+":"); - if(GuiScreen.isShiftKeyDown()){ + if (compound != null && !compound.isEmpty()) { + event.getToolTip().add(ADVANCED_INFO_HEADER_PRE + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".nbt.desc") + ":"); + if (GuiScreen.isShiftKeyDown()) { int limit = ConfigIntValues.CTRL_INFO_NBT_CHAR_LIMIT.getValue(); String compoundStrg = compound.toString(); int compoundStrgLength = compoundStrg.length(); String compoundDisplay; - if(limit > 0 && compoundStrgLength > limit){ - compoundDisplay = compoundStrg.substring(0, limit)+TextFormatting.GRAY+" ("+(compoundStrgLength-limit)+" more characters...)"; - } - else{ + if (limit > 0 && compoundStrgLength > limit) { + compoundDisplay = compoundStrg.substring(0, limit) + TextFormatting.GRAY + " (" + (compoundStrgLength - limit) + " more characters...)"; + } else { compoundDisplay = compoundStrg; } - event.getToolTip().add(ADVANCED_INFO_TEXT_PRE+compoundDisplay); - } - else{ - event.getToolTip().add(ADVANCED_INFO_TEXT_PRE+TextFormatting.ITALIC+"["+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".pressShift.desc")+"]"); + event.getToolTip().add(ADVANCED_INFO_TEXT_PRE + compoundDisplay); + } else { + event.getToolTip().add(ADVANCED_INFO_TEXT_PRE + TextFormatting.ITALIC + "[" + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".pressShift.desc") + "]"); } } //Disabling Info - event.getToolTip().add(TextFormatting.ITALIC+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".disablingInfo.desc")); + event.getToolTip().add(TextFormatting.ITALIC + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".disablingInfo.desc")); - } - else{ - if(ConfigBoolValues.CTRL_INFO_FOR_EXTRA_INFO.isEnabled()){ - event.getToolTip().add(TextFormatting.DARK_GRAY+""+TextFormatting.ITALIC+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".ctrlForMoreInfo.desc")); + } else { + if (ConfigBoolValues.CTRL_INFO_FOR_EXTRA_INFO.isEnabled()) { + event.getToolTip().add(TextFormatting.DARK_GRAY + "" + TextFormatting.ITALIC + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".ctrlForMoreInfo.desc")); } } } @@ -172,52 +168,51 @@ public class ClientEvents{ } @SubscribeEvent - public void onGameOverlay(RenderGameOverlayEvent.Post event){ - if(event.getType() == RenderGameOverlayEvent.ElementType.ALL && Minecraft.getMinecraft().currentScreen == null){ + public void onGameOverlay(RenderGameOverlayEvent.Post event) { + if (event.getType() == RenderGameOverlayEvent.ElementType.ALL && Minecraft.getMinecraft().currentScreen == null) { Minecraft minecraft = Minecraft.getMinecraft(); EntityPlayer player = minecraft.player; RayTraceResult posHit = minecraft.objectMouseOver; FontRenderer font = minecraft.fontRenderer; ItemStack stack = player.getHeldItemMainhand(); - if(StackUtil.isValid(stack)){ - if(stack.getItem() instanceof IHudDisplay){ - ((IHudDisplay)stack.getItem()).displayHud(minecraft, player, stack, posHit, event.getResolution()); + if (StackUtil.isValid(stack)) { + if (stack.getItem() instanceof IHudDisplay) { + ((IHudDisplay) stack.getItem()).displayHud(minecraft, player, stack, posHit, event.getResolution()); } } - if(posHit != null && posHit.getBlockPos() != null){ + if (posHit != null && posHit.getBlockPos() != null) { Block blockHit = minecraft.world.getBlockState(posHit.getBlockPos()).getBlock(); TileEntity tileHit = minecraft.world.getTileEntity(posHit.getBlockPos()); - if(blockHit instanceof IHudDisplay){ - ((IHudDisplay)blockHit).displayHud(minecraft, player, stack, posHit, event.getResolution()); + if (blockHit instanceof IHudDisplay) { + ((IHudDisplay) blockHit).displayHud(minecraft, player, stack, posHit, event.getResolution()); } - if(tileHit instanceof TileEntityBase){ - TileEntityBase base = (TileEntityBase)tileHit; - if(base.isRedstoneToggle()){ - String strg = String.format("%s: %s", StringUtil.localize("info."+ActuallyAdditions.MODID+".redstoneMode.name"), TextFormatting.DARK_RED+StringUtil.localize("info."+ActuallyAdditions.MODID+".redstoneMode."+(base.isPulseMode ? "pulse" : "deactivation"))+TextFormatting.RESET); - font.drawStringWithShadow(strg, event.getResolution().getScaledWidth()/2+5, event.getResolution().getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE); + if (tileHit instanceof TileEntityBase) { + TileEntityBase base = (TileEntityBase) tileHit; + if (base.isRedstoneToggle()) { + String strg = String.format("%s: %s", StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode.name"), TextFormatting.DARK_RED + StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode." + (base.isPulseMode ? "pulse" : "deactivation")) + TextFormatting.RESET); + font.drawStringWithShadow(strg, event.getResolution().getScaledWidth() / 2 + 5, event.getResolution().getScaledHeight() / 2 + 5, StringUtil.DECIMAL_COLOR_WHITE); String expl; - if(StackUtil.isValid(stack) && stack.getItem() == ConfigValues.itemRedstoneTorchConfigurator){ - expl = TextFormatting.GREEN+StringUtil.localize("info."+ActuallyAdditions.MODID+".redstoneMode.validItem"); + if (StackUtil.isValid(stack) && stack.getItem() == ConfigValues.itemRedstoneTorchConfigurator) { + expl = TextFormatting.GREEN + StringUtil.localize("info." + ActuallyAdditions.MODID + ".redstoneMode.validItem"); + } else { + expl = TextFormatting.GRAY.toString() + TextFormatting.ITALIC + StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".redstoneMode.invalidItem", StringUtil.localize(ConfigValues.itemRedstoneTorchConfigurator.getTranslationKey() + ".name")); } - else{ - expl = TextFormatting.GRAY.toString()+TextFormatting.ITALIC+StringUtil.localizeFormatted("info."+ActuallyAdditions.MODID+".redstoneMode.invalidItem", StringUtil.localize(ConfigValues.itemRedstoneTorchConfigurator.getTranslationKey()+".name")); - } - font.drawStringWithShadow(expl, event.getResolution().getScaledWidth()/2+5, event.getResolution().getScaledHeight()/2+15, StringUtil.DECIMAL_COLOR_WHITE); + font.drawStringWithShadow(expl, event.getResolution().getScaledWidth() / 2 + 5, event.getResolution().getScaledHeight() / 2 + 15, StringUtil.DECIMAL_COLOR_WHITE); } } - if(tileHit instanceof IEnergyDisplay){ - IEnergyDisplay display = (IEnergyDisplay)tileHit; - if(!display.needsHoldShift() || player.isSneaking()){ - if(energyDisplay == null){ + if (tileHit instanceof IEnergyDisplay) { + IEnergyDisplay display = (IEnergyDisplay) tileHit; + if (!display.needsHoldShift() || player.isSneaking()) { + if (energyDisplay == null) { energyDisplay = new EnergyDisplay(0, 0, null); } - energyDisplay.setData(2, event.getResolution().getScaledHeight()-96, display.getEnergyStorage(), true, true); + energyDisplay.setData(2, event.getResolution().getScaledHeight() - 96, display.getEnergyStorage(), true, true); GlStateManager.pushMatrix(); GlStateManager.color(1F, 1F, 1F, 1F); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java b/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java index 45980b572..04fec3e6b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java @@ -40,74 +40,70 @@ import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent; -public class CommonEvents{ +public class CommonEvents { @SubscribeEvent - public void onBlockBreakEvent(BlockEvent.HarvestDropsEvent event){ + public void onBlockBreakEvent(BlockEvent.HarvestDropsEvent event) { IBlockState state = event.getState(); - if(state != null && state.getBlock() == Blocks.MOB_SPAWNER){ + if (state != null && state.getBlock() == Blocks.MOB_SPAWNER) { event.getDrops().add(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.SPAWNER_SHARD.ordinal())); } } @SubscribeEvent - public void onItemPickup(EntityItemPickupEvent event){ - if(event.isCanceled() || event.getResult() == Event.Result.ALLOW){ - return; - } + public void onItemPickup(EntityItemPickupEvent event) { + if (event.isCanceled() || event.getResult() == Event.Result.ALLOW) { return; } EntityPlayer player = event.getEntityPlayer(); EntityItem item = event.getItem(); - if(item != null && !item.isDead){ + if (item != null && !item.isDead) { ItemStack stack = item.getItem(); - if(StackUtil.isValid(stack)){ - for(int i = 0; i < player.inventory.getSizeInventory(); i++){ - if(i != player.inventory.currentItem){ + if (StackUtil.isValid(stack)) { + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { + if (i != player.inventory.currentItem) { ItemStack invStack = player.inventory.getStackInSlot(i); - if(StackUtil.isValid(invStack) && invStack.getItem() instanceof ItemBag && invStack.hasTagCompound()){ - if(invStack.getTagCompound().getBoolean("AutoInsert")){ + if (StackUtil.isValid(invStack) && invStack.getItem() instanceof ItemBag && invStack.hasTagCompound()) { + if (invStack.getTagCompound().getBoolean("AutoInsert")) { boolean changed = false; - boolean isVoid = ((ItemBag)invStack.getItem()).isVoid; + boolean isVoid = ((ItemBag) invStack.getItem()).isVoid; ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerBag.getSlotAmount(isVoid)); ItemDrill.loadSlotsFromNBT(inv, invStack); FilterSettings filter = new FilterSettings(4, false, false, false, false, 0, 0); filter.readFromNBT(invStack.getTagCompound(), "Filter"); - if(filter.check(stack)){ - if(isVoid){ + if (filter.check(stack)) { + if (isVoid) { stack.setCount(0); changed = true; - } - else{ - for(int j = 0; j < inv.getSlots(); j++){ + } else { + for (int j = 0; j < inv.getSlots(); j++) { ItemStack bagStack = inv.getStackInSlot(j); - if(StackUtil.isValid(bagStack)){ - if(ItemUtil.canBeStacked(bagStack, stack)){ - int maxTransfer = Math.min(stack.getCount(), stack.getMaxStackSize()-bagStack.getCount()); - if(maxTransfer > 0){ + if (StackUtil.isValid(bagStack)) { + if (ItemUtil.canBeStacked(bagStack, stack)) { + int maxTransfer = Math.min(stack.getCount(), stack.getMaxStackSize() - bagStack.getCount()); + if (maxTransfer > 0) { inv.setStackInSlot(j, StackUtil.grow(bagStack, maxTransfer)); stack.shrink(maxTransfer); changed = true; } } - } - else{ + } else { inv.setStackInSlot(j, stack.copy()); stack.setCount(0); changed = true; } - if(!StackUtil.isValid(stack)){ + if (!StackUtil.isValid(stack)) { break; } } } } - if(changed){ - if(!isVoid){ + if (changed) { + if (!isVoid) { ItemDrill.writeSlotsToNBT(inv, invStack); } event.setResult(Event.Result.ALLOW); @@ -116,7 +112,7 @@ public class CommonEvents{ } } - if(!StackUtil.isValid(stack)){ + if (!StackUtil.isValid(stack)) { break; } } @@ -140,37 +136,37 @@ public class CommonEvents{ }*/ @SubscribeEvent - public void onEntityDropEvent(LivingDropsEvent event){ - if(event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote && event.getSource().getTrueSource() instanceof EntityPlayer){ + public void onEntityDropEvent(LivingDropsEvent event) { + if (event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote && event.getSource().getTrueSource() instanceof EntityPlayer) { //Drop Cobwebs from Spiders - if(ConfigBoolValues.DO_SPIDER_DROPS.isEnabled() && event.getEntityLiving() instanceof EntitySpider){ - if(event.getEntityLiving().world.rand.nextInt(20) <= event.getLootingLevel()*2){ - event.getDrops().add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, new ItemStack(Blocks.WEB, event.getEntityLiving().world.rand.nextInt(2+event.getLootingLevel())+1))); + if (ConfigBoolValues.DO_SPIDER_DROPS.isEnabled() && event.getEntityLiving() instanceof EntitySpider) { + if (event.getEntityLiving().world.rand.nextInt(20) <= event.getLootingLevel() * 2) { + event.getDrops().add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, new ItemStack(Blocks.WEB, event.getEntityLiving().world.rand.nextInt(2 + event.getLootingLevel()) + 1))); } } } } @SubscribeEvent - public void onLogInEvent(PlayerEvent.PlayerLoggedInEvent event){ - if(!event.player.world.isRemote && event.player instanceof EntityPlayerMP){ - EntityPlayerMP player = (EntityPlayerMP)event.player; + public void onLogInEvent(PlayerEvent.PlayerLoggedInEvent event) { + if (!event.player.world.isRemote && event.player instanceof EntityPlayerMP) { + EntityPlayerMP player = (EntityPlayerMP) event.player; PacketHandlerHelper.syncPlayerData(player, true); - ActuallyAdditions.LOGGER.info("Sending Player Data to player "+player.getName()+" with UUID "+player.getUniqueID()+"."); + ActuallyAdditions.LOGGER.info("Sending Player Data to player " + player.getName() + " with UUID " + player.getUniqueID() + "."); } } @SubscribeEvent - public void onCraftedEvent(PlayerEvent.ItemCraftedEvent event){ + public void onCraftedEvent(PlayerEvent.ItemCraftedEvent event) { //checkAchievements(event.crafting, event.player, InitAchievements.Type.CRAFTING); - if(ConfigBoolValues.GIVE_BOOKLET_ON_FIRST_CRAFT.isEnabled()){ - if(!event.player.world.isRemote && StackUtil.isValid(event.crafting) && event.crafting.getItem() != InitItems.itemBooklet){ + if (ConfigBoolValues.GIVE_BOOKLET_ON_FIRST_CRAFT.isEnabled()) { + if (!event.player.world.isRemote && StackUtil.isValid(event.crafting) && event.crafting.getItem() != InitItems.itemBooklet) { String name = event.crafting.getItem().getRegistryName().toString(); - if(name != null && name.toLowerCase(Locale.ROOT).contains(ActuallyAdditions.MODID)){ + if (name != null && name.toLowerCase(Locale.ROOT).contains(ActuallyAdditions.MODID)) { PlayerData.PlayerSave save = PlayerData.getDataFromPlayer(event.player); - if(save != null && !save.bookGottenAlready){ + if (save != null && !save.bookGottenAlready) { save.bookGottenAlready = true; WorldData.get(event.player.getEntityWorld()).markDirty(); @@ -184,12 +180,12 @@ public class CommonEvents{ } @SubscribeEvent - public void onSmeltedEvent(PlayerEvent.ItemSmeltedEvent event){ + public void onSmeltedEvent(PlayerEvent.ItemSmeltedEvent event) { //checkAchievements(event.smelting, event.player, InitAchievements.Type.SMELTING); } @SubscribeEvent - public void onPickupEvent(EntityItemPickupEvent event){ + public void onPickupEvent(EntityItemPickupEvent event) { //checkAchievements(event.getItem().getItem(), event.getEntityPlayer(), InitAchievements.Type.PICK_UP); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/FluidAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/FluidAA.java index 60d9f777e..46d56d317 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/FluidAA.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/FluidAA.java @@ -14,14 +14,14 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.Fluid; -public class FluidAA extends Fluid{ +public class FluidAA extends Fluid { - public FluidAA(String fluidName, String textureName){ - super(fluidName, new ResourceLocation(ActuallyAdditions.MODID, "blocks/"+textureName+"_still"), new ResourceLocation(ActuallyAdditions.MODID, "blocks/"+textureName+"_flowing")); + public FluidAA(String fluidName, String textureName) { + super(fluidName, new ResourceLocation(ActuallyAdditions.MODID, "blocks/" + textureName + "_still"), new ResourceLocation(ActuallyAdditions.MODID, "blocks/" + textureName + "_flowing")); } @Override - public String getUnlocalizedName(){ - return "fluid."+ActuallyAdditions.MODID+"."+this.unlocalizedName; + public String getUnlocalizedName() { + return "fluid." + ActuallyAdditions.MODID + "." + this.unlocalizedName; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/InitFluids.java b/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/InitFluids.java index 2465e4176..b672c5748 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/InitFluids.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/InitFluids.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.fluids; +import java.util.Locale; + import de.ellpeck.actuallyadditions.mod.blocks.base.BlockFluidFlowing; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -17,9 +19,7 @@ import net.minecraft.item.EnumRarity; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; -import java.util.Locale; - -public final class InitFluids{ +public final class InitFluids { public static Fluid fluidCanolaOil; public static Fluid fluidRefinedCanolaOil; @@ -31,7 +31,7 @@ public final class InitFluids{ public static Block blockCrystalOil; public static Block blockEmpoweredOil; - public static void init(){ + public static void init() { fluidCanolaOil = registerFluid("canolaoil", "block_canola_oil", EnumRarity.UNCOMMON); fluidRefinedCanolaOil = registerFluid("refinedcanolaoil", "block_refined_canola_oil", EnumRarity.UNCOMMON); fluidCrystalOil = registerFluid("crystaloil", "block_crystal_oil", EnumRarity.RARE); @@ -43,7 +43,7 @@ public final class InitFluids{ blockEmpoweredOil = registerFluidBlock(fluidEmpoweredOil, Material.WATER, "block_empowered_oil"); } - private static Fluid registerFluid(String fluidName, String fluidTextureName, EnumRarity rarity){ + private static Fluid registerFluid(String fluidName, String fluidTextureName, EnumRarity rarity) { Fluid fluid = new FluidAA(fluidName.toLowerCase(Locale.ROOT), fluidTextureName).setRarity(rarity); FluidRegistry.registerFluid(fluid); FluidRegistry.addBucketForFluid(fluid); @@ -51,7 +51,7 @@ public final class InitFluids{ return FluidRegistry.getFluid(fluid.getName()); } - private static Block registerFluidBlock(Fluid fluid, Material material, String name){ + private static Block registerFluidBlock(Fluid fluid, Material material, String name) { return new BlockFluidFlowing(fluid, material, name); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/WorldGenLushCaves.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/WorldGenLushCaves.java index 61e9f63e8..0304811cf 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/WorldGenLushCaves.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/WorldGenLushCaves.java @@ -10,6 +10,11 @@ package de.ellpeck.actuallyadditions.mod.gen; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Random; + import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot; @@ -30,66 +35,53 @@ import net.minecraft.world.gen.feature.WorldGenTrees; import net.minecraft.world.gen.structure.StructureBoundingBox; import net.minecraft.world.storage.loot.ILootContainer; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Random; +public class WorldGenLushCaves { -public class WorldGenLushCaves{ + public static final Block[] CRYSTAL_CLUSTERS = new Block[] { InitBlocks.blockCrystalClusterRedstone, InitBlocks.blockCrystalClusterLapis, InitBlocks.blockCrystalClusterDiamond, InitBlocks.blockCrystalClusterCoal, InitBlocks.blockCrystalClusterEmerald, InitBlocks.blockCrystalClusterIron }; - public static final Block[] CRYSTAL_CLUSTERS = new Block[]{ - InitBlocks.blockCrystalClusterRedstone, - InitBlocks.blockCrystalClusterLapis, - InitBlocks.blockCrystalClusterDiamond, - InitBlocks.blockCrystalClusterCoal, - InitBlocks.blockCrystalClusterEmerald, - InitBlocks.blockCrystalClusterIron - }; - - public boolean generate(World world, Random rand, BlockPos position, StructureBoundingBox blockRegion){ + public boolean generate(World world, Random rand, BlockPos position, StructureBoundingBox blockRegion) { this.generateCave(world, position, rand, blockRegion); return true; } - private void generateCave(World world, BlockPos center, Random rand, StructureBoundingBox chunkRegion){ - int spheres = rand.nextInt(5)+3; + private void generateCave(World world, BlockPos center, Random rand, StructureBoundingBox chunkRegion) { + int spheres = rand.nextInt(5) + 3; StructureBoundingBox spheresBox = new StructureBoundingBox(chunkRegion); //the region for spheres is larger so that trees can generate in the smaller one spheresBox.minX -= 7; spheresBox.minZ -= 7; spheresBox.maxX += 7; spheresBox.maxZ += 7; - for(int i = 0; i <= spheres; i++){ + for (int i = 0; i <= spheres; i++) { //center already is random value within population area - this.makeSphereWithGrassFloor(world, center.add(rand.nextInt(11)-5, rand.nextInt(7)-3, rand.nextInt(11)-5), rand.nextInt(3)+5, spheresBox, rand); + this.makeSphereWithGrassFloor(world, center.add(rand.nextInt(11) - 5, rand.nextInt(7) - 3, rand.nextInt(11) - 5), rand.nextInt(3) + 5, spheresBox, rand); } - this.genTreesAndTallGrass(world, center, 11, spheres*2, rand, chunkRegion); + this.genTreesAndTallGrass(world, center, 11, spheres * 2, rand, chunkRegion); } - private void genTreesAndTallGrass(World world, BlockPos center, int radius, int amount, Random rand, StructureBoundingBox box){ + private void genTreesAndTallGrass(World world, BlockPos center, int radius, int amount, Random rand, StructureBoundingBox box) { List possiblePoses = new ArrayList<>(); - for(double x = -radius; x < radius; x++){ - for(double y = -radius; y < radius; y++){ - for(double z = -radius; z < radius; z++){ + for (double x = -radius; x < radius; x++) { + for (double y = -radius; y < radius; y++) { + for (double z = -radius; z < radius; z++) { BlockPos pos = center.add(x, y, z); - if(box.isVecInside(pos)){ - if(rand.nextDouble() >= 0.5D){ - if(world.getBlockState(pos).getBlock() == Blocks.GRASS){ + if (box.isVecInside(pos)) { + if (rand.nextDouble() >= 0.5D) { + if (world.getBlockState(pos).getBlock() == Blocks.GRASS) { possiblePoses.add(pos); } - } - else{ - if(ConfigBoolValues.DO_CRYSTAL_CLUSTERS.isEnabled() && rand.nextInt(20) == 0){ + } else { + if (ConfigBoolValues.DO_CRYSTAL_CLUSTERS.isEnabled() && rand.nextInt(20) == 0) { EnumFacing[] values = EnumFacing.values(); EnumFacing side = values[rand.nextInt(values.length)]; BlockPos posSide = pos.offset(side); - if(!this.checkIndestructable(world, posSide)){ + if (!this.checkIndestructable(world, posSide)) { IBlockState state = world.getBlockState(pos); IBlockState stateSide = world.getBlockState(posSide); - if(state.getBlock().isAir(state, world, pos) && stateSide.isSideSolid(world, posSide, side.getOpposite())){ + if (state.getBlock().isAir(state, world, pos) && stateSide.isSideSolid(world, posSide, side.getOpposite())) { Block block = CRYSTAL_CLUSTERS[rand.nextInt(CRYSTAL_CLUSTERS.length)]; world.setBlockState(pos, block.getDefaultState().withProperty(BlockDirectional.FACING, side.getOpposite()), 2); } @@ -101,61 +93,58 @@ public class WorldGenLushCaves{ } } - if(!possiblePoses.isEmpty()){ + if (!possiblePoses.isEmpty()) { boolean crateGenDone = false; - for(int i = 0; i <= amount; i++){ + for (int i = 0; i <= amount; i++) { Collections.shuffle(possiblePoses); BlockPos pos = possiblePoses.get(0); - if(rand.nextBoolean()){ + if (rand.nextBoolean()) { boolean genCrate = false; WorldGenAbstractTree trees; - if(rand.nextBoolean()){ - if(rand.nextBoolean()){ + if (rand.nextBoolean()) { + if (rand.nextBoolean()) { trees = new WorldGenBigTree(false); - } - else{ + } else { trees = new WorldGenShrub(Blocks.LOG.getDefaultState(), Blocks.LEAVES.getDefaultState()); genCrate = true; } - } - else{ + } else { trees = new WorldGenTrees(false); } trees.generate(world, rand, pos.up()); - if(ConfigBoolValues.DUNGEON_LOOT.isEnabled() && !crateGenDone && genCrate){ + if (ConfigBoolValues.DUNGEON_LOOT.isEnabled() && !crateGenDone && genCrate) { BlockPos cratePos = pos.add(MathHelper.getInt(rand, -2, 2), MathHelper.getInt(rand, 3, 8), MathHelper.getInt(rand, -2, 2)); IBlockState state = world.getBlockState(cratePos); - if(state != null && state.getBlock().isLeaves(state, world, cratePos)){ + if (state != null && state.getBlock().isLeaves(state, world, cratePos)) { world.setBlockState(cratePos, InitBlocks.blockGiantChest.getDefaultState(), 2); TileEntity tile = world.getTileEntity(cratePos); - if(tile instanceof TileEntityGiantChest){ - ((TileEntityGiantChest)tile).lootTable = DungeonLoot.LUSH_CAVES; + if (tile instanceof TileEntityGiantChest) { + ((TileEntityGiantChest) tile).lootTable = DungeonLoot.LUSH_CAVES; } } crateGenDone = true; } - } - else{ + } else { Blocks.GRASS.grow(world, rand, pos, world.getBlockState(pos)); } } } } - private void makeSphereWithGrassFloor(World world, BlockPos center, int radius, StructureBoundingBox boundingBox, Random rand){ - for(double x = -radius; x < radius; x++){ - for(double y = -radius; y < radius; y++){ - for(double z = -radius; z < radius; z++){ - if(Math.sqrt(x*x+y*y+z*z) < radius){ + private void makeSphereWithGrassFloor(World world, BlockPos center, int radius, StructureBoundingBox boundingBox, Random rand) { + for (double x = -radius; x < radius; x++) { + for (double y = -radius; y < radius; y++) { + for (double z = -radius; z < radius; z++) { + if (Math.sqrt(x * x + y * y + z * z) < radius) { BlockPos pos = center.add(x, y, z); //Note: order matters, checkIndestructable will generate chunks if order is reversed - if(boundingBox.isVecInside(pos) && !this.checkIndestructable(world, pos)){ + if (boundingBox.isVecInside(pos) && !this.checkIndestructable(world, pos)) { world.setBlockToAir(pos); } } @@ -163,17 +152,17 @@ public class WorldGenLushCaves{ } } - for(double x = -radius; x < radius; x++){ - for(double z = -radius; z < radius; z++){ - for(double y = -radius; y <= -3; y++){ + for (double x = -radius; x < radius; x++) { + for (double z = -radius; z < radius; z++) { + for (double y = -radius; y <= -3; y++) { BlockPos pos = center.add(x, y, z); - if(boundingBox.isVecInside(pos) && !this.checkIndestructable(world, pos)){ + if (boundingBox.isVecInside(pos) && !this.checkIndestructable(world, pos)) { IBlockState state = world.getBlockState(pos); BlockPos posUp = pos.up(); - if(!this.checkIndestructable(world, posUp)){ + if (!this.checkIndestructable(world, posUp)) { IBlockState stateUp = world.getBlockState(posUp); - if(!state.getBlock().isAir(state, world, pos) && stateUp.getBlock().isAir(stateUp, world, posUp)){ + if (!state.getBlock().isAir(state, world, pos) && stateUp.getBlock().isAir(stateUp, world, posUp)) { world.setBlockState(pos, Blocks.GRASS.getDefaultState(), 2); } } @@ -183,23 +172,17 @@ public class WorldGenLushCaves{ } } - private boolean checkIndestructable(World world, BlockPos pos){ + private boolean checkIndestructable(World world, BlockPos pos) { //If this isn't checked, the game crashes because it tries to destroy a chest that doesn't have any loot yet :v TileEntity tile = world.getTileEntity(pos); - if(tile instanceof ILootContainer){ - return true; - } + if (tile instanceof ILootContainer) { return true; } IBlockState state = world.getBlockState(pos); - if(state != null){ + if (state != null) { Block block = state.getBlock(); //check if it's tree or grass that is generated here - if(block == Blocks.LOG || block == Blocks.LEAVES || block == Blocks.TALLGRASS){ - return true; - } - if(block != null && (block.isAir(state, world, pos) || block.getHarvestLevel(state) >= 0F)){ - return false; - } + if (block == Blocks.LOG || block == Blocks.LEAVES || block == Blocks.TALLGRASS) { return true; } + if (block != null && (block.isAir(state, world, pos) || block.getHarvestLevel(state) >= 0F)) { return false; } } return true; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/BasicTradeList.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/BasicTradeList.java index 51c8c6835..391b16f4d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/BasicTradeList.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/BasicTradeList.java @@ -20,30 +20,30 @@ import net.minecraft.item.ItemStack; import net.minecraft.village.MerchantRecipe; import net.minecraft.village.MerchantRecipeList; -public class BasicTradeList implements ITradeList{ +public class BasicTradeList implements ITradeList { private final ItemStack input; private final PriceInfo inputAmount; private final ItemStack output; private final PriceInfo outputAmount; - public BasicTradeList(ItemStack input, PriceInfo inputAmount, ItemStack output, PriceInfo outputAmount){ + public BasicTradeList(ItemStack input, PriceInfo inputAmount, ItemStack output, PriceInfo outputAmount) { this.input = input; this.inputAmount = inputAmount; this.output = output; this.outputAmount = outputAmount; } - public BasicTradeList(PriceInfo emeraldInput, ItemStack output, PriceInfo outputAmount){ + public BasicTradeList(PriceInfo emeraldInput, ItemStack output, PriceInfo outputAmount) { this(new ItemStack(Items.EMERALD), emeraldInput, output, outputAmount); } - public BasicTradeList(ItemStack input, PriceInfo inputAmount, PriceInfo emeraldOutput){ + public BasicTradeList(ItemStack input, PriceInfo inputAmount, PriceInfo emeraldOutput) { this(input, inputAmount, new ItemStack(Items.EMERALD), emeraldOutput); } @Override - public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random){ + public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random) { ItemStack in = this.input.copy(); in.setCount(this.inputAmount.getPrice(random)); ItemStack out = this.output.copy(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/InitVillager.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/InitVillager.java index 8e7d979db..d971d04c5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/InitVillager.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/InitVillager.java @@ -31,88 +31,58 @@ import net.minecraftforge.fml.common.registry.VillagerRegistry; import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer; import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession; -public final class InitVillager{ +public final class InitVillager { public static VillagerProfession jamProfession; public static VillagerProfession engineerProfession; - public static void init(){ + public static void init() { ActuallyAdditions.LOGGER.info("Initializing Village Addons..."); - if(ConfigBoolValues.JAM_VILLAGER_EXISTS.isEnabled()){ + if (ConfigBoolValues.JAM_VILLAGER_EXISTS.isEnabled()) { initJamVillagePart(); } - if(ConfigBoolValues.CROP_FIELD_EXISTS.isEnabled()){ + if (ConfigBoolValues.CROP_FIELD_EXISTS.isEnabled()) { initCustomCropFieldPart(); } - if(ConfigBoolValues.ENGINEER_VILLAGER_EXISTS.isEnabled()){ + if (ConfigBoolValues.ENGINEER_VILLAGER_EXISTS.isEnabled()) { initEngineerVillagePart(); } } - private static void initEngineerVillagePart(){ + private static void initEngineerVillagePart() { VillagerRegistry.instance().registerVillageCreationHandler(new VillageEngineerHouseHandler()); - MapGenStructureIO.registerStructureComponent(VillageComponentEngineerHouse.class, ActuallyAdditions.MODID+":engineerHouseStructure"); + MapGenStructureIO.registerStructureComponent(VillageComponentEngineerHouse.class, ActuallyAdditions.MODID + ":engineerHouseStructure"); - engineerProfession = new VillagerProfession(ActuallyAdditions.MODID+":engineer", ActuallyAdditions.MODID+":textures/entity/villager/engineer_villager.png", ActuallyAdditions.MODID+":textures/entity/villager/engineer_villager_zombie.png"); + engineerProfession = new VillagerProfession(ActuallyAdditions.MODID + ":engineer", ActuallyAdditions.MODID + ":textures/entity/villager/engineer_villager.png", ActuallyAdditions.MODID + ":textures/entity/villager/engineer_villager_zombie.png"); - VillagerCareer crystallizer = new VillagerCareer(engineerProfession, ActuallyAdditions.MODID+".crystallizer"); - crystallizer.addTrade(1, - new BasicTradeList(new PriceInfo(1, 2), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), new PriceInfo(2, 8)), - new BasicTradeList(new PriceInfo(1, 3), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), new PriceInfo(2, 6)), - new BasicTradeList(new PriceInfo(1, 3), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), new PriceInfo(1, 4)), - new BasicTradeList(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), new PriceInfo(10, 16), new PriceInfo(1, 1))); - crystallizer.addTrade(2, - new BasicTradeList(new PriceInfo(2, 3), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), new PriceInfo(2, 4)), - new BasicTradeList(new PriceInfo(1, 3), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), new PriceInfo(2, 6)), - new BasicTradeList(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), new PriceInfo(8, 12), new PriceInfo(1, 1)), - new BasicTradeList(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), new PriceInfo(8, 16), new PriceInfo(1, 2))); - crystallizer.addTrade(3, - new BasicTradeList(new PriceInfo(2, 4), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), new PriceInfo(2, 3)), - new BasicTradeList(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), new PriceInfo(6, 10), new PriceInfo(1, 1)), - new BasicTradeList(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), new PriceInfo(4, 6), new PriceInfo(1, 1)), - new BasicTradeList(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), new PriceInfo(6, 12), new PriceInfo(1, 2))); + VillagerCareer crystallizer = new VillagerCareer(engineerProfession, ActuallyAdditions.MODID + ".crystallizer"); + crystallizer.addTrade(1, new BasicTradeList(new PriceInfo(1, 2), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), new PriceInfo(2, 8)), new BasicTradeList(new PriceInfo(1, 3), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), new PriceInfo(2, 6)), new BasicTradeList(new PriceInfo(1, 3), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), new PriceInfo(1, 4)), new BasicTradeList(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), new PriceInfo(10, 16), new PriceInfo(1, 1))); + crystallizer.addTrade(2, new BasicTradeList(new PriceInfo(2, 3), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), new PriceInfo(2, 4)), new BasicTradeList(new PriceInfo(1, 3), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), new PriceInfo(2, 6)), new BasicTradeList(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), new PriceInfo(8, 12), new PriceInfo(1, 1)), new BasicTradeList(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), new PriceInfo(8, 16), new PriceInfo(1, 2))); + crystallizer.addTrade(3, new BasicTradeList(new PriceInfo(2, 4), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), new PriceInfo(2, 3)), new BasicTradeList(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), new PriceInfo(6, 10), new PriceInfo(1, 1)), new BasicTradeList(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), new PriceInfo(4, 6), new PriceInfo(1, 1)), new BasicTradeList(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), new PriceInfo(6, 12), new PriceInfo(1, 2))); - VillagerCareer engineer = new VillagerCareer(engineerProfession, ActuallyAdditions.MODID+".engineer"); - engineer.addTrade(1, - new BasicTradeList(new PriceInfo(1, 2), new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal()), new PriceInfo(2, 3)), - new BasicTradeList(new PriceInfo(1, 2), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), new PriceInfo(6, 8)), - new BasicTradeList(new PriceInfo(1, 3), new ItemStack(InitItems.itemLaserWrench), new PriceInfo(1, 1))); - engineer.addTrade(2, - new BasicTradeList(new ItemStack(InitItems.itemCoffeeBean), new PriceInfo(20, 30), new PriceInfo(1, 2)), - new BasicTradeList(new PriceInfo(3, 5), new ItemStack(InitItems.itemPhantomConnector), new PriceInfo(1, 1)), - new BasicTradeList(new PriceInfo(10, 20), new ItemStack(InitBlocks.blockLaserRelay), new PriceInfo(1, 2))); - engineer.addTrade(3, - new BasicTradeList(new ItemStack(InitBlocks.blockTinyTorch), new PriceInfo(30, 40), new PriceInfo(1, 2)), - new BasicTradeList(new PriceInfo(1, 2), new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.WOOD_CASING.ordinal()), new PriceInfo(1, 2))); - engineer.addTrade(4, - new BasicTradeList(new PriceInfo(3, 5), new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), new PriceInfo(1, 2)), - new BasicTradeList(new ItemStack(InitBlocks.blockEmpowerer), new PriceInfo(1, 1), new PriceInfo(15, 20)), - new BasicTradeList(new PriceInfo(30, 40), new ItemStack(InitBlocks.blockLaserRelayExtreme), new PriceInfo(1, 1))); + VillagerCareer engineer = new VillagerCareer(engineerProfession, ActuallyAdditions.MODID + ".engineer"); + engineer.addTrade(1, new BasicTradeList(new PriceInfo(1, 2), new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal()), new PriceInfo(2, 3)), new BasicTradeList(new PriceInfo(1, 2), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), new PriceInfo(6, 8)), new BasicTradeList(new PriceInfo(1, 3), new ItemStack(InitItems.itemLaserWrench), new PriceInfo(1, 1))); + engineer.addTrade(2, new BasicTradeList(new ItemStack(InitItems.itemCoffeeBean), new PriceInfo(20, 30), new PriceInfo(1, 2)), new BasicTradeList(new PriceInfo(3, 5), new ItemStack(InitItems.itemPhantomConnector), new PriceInfo(1, 1)), new BasicTradeList(new PriceInfo(10, 20), new ItemStack(InitBlocks.blockLaserRelay), new PriceInfo(1, 2))); + engineer.addTrade(3, new BasicTradeList(new ItemStack(InitBlocks.blockTinyTorch), new PriceInfo(30, 40), new PriceInfo(1, 2)), new BasicTradeList(new PriceInfo(1, 2), new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.WOOD_CASING.ordinal()), new PriceInfo(1, 2))); + engineer.addTrade(4, new BasicTradeList(new PriceInfo(3, 5), new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), new PriceInfo(1, 2)), new BasicTradeList(new ItemStack(InitBlocks.blockEmpowerer), new PriceInfo(1, 1), new PriceInfo(15, 20)), new BasicTradeList(new PriceInfo(30, 40), new ItemStack(InitBlocks.blockLaserRelayExtreme), new PriceInfo(1, 1))); } - private static void initJamVillagePart(){ - jamProfession = new VillagerProfession(ActuallyAdditions.MODID+":jamGuy", ActuallyAdditions.MODID+":textures/entity/villager/jam_villager.png", ActuallyAdditions.MODID+":textures/entity/villager/jam_villager_zombie.png"); + private static void initJamVillagePart() { + jamProfession = new VillagerProfession(ActuallyAdditions.MODID + ":jamGuy", ActuallyAdditions.MODID + ":textures/entity/villager/jam_villager.png", ActuallyAdditions.MODID + ":textures/entity/villager/jam_villager_zombie.png"); - VillagerCareer career = new VillagerCareer(jamProfession, ActuallyAdditions.MODID+".jammer"); - career.addTrade(1, - new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.CU_BA_RA.ordinal()), new PriceInfo(1, 3)), - new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.GRA_KI_BA.ordinal()), new PriceInfo(1, 3))); - career.addTrade(2, - new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.PL_AP_LE.ordinal()), new PriceInfo(1, 3)), - new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.CH_AP_CI.ordinal()), new PriceInfo(1, 3)), - new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.HO_ME_KI.ordinal()), new PriceInfo(1, 3))); - career.addTrade(3, - new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.HO_ME_CO.ordinal()), new PriceInfo(1, 3)), - new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.PI_CO.ordinal()), new PriceInfo(1, 3))); + VillagerCareer career = new VillagerCareer(jamProfession, ActuallyAdditions.MODID + ".jammer"); + career.addTrade(1, new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.CU_BA_RA.ordinal()), new PriceInfo(1, 3)), new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.GRA_KI_BA.ordinal()), new PriceInfo(1, 3))); + career.addTrade(2, new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.PL_AP_LE.ordinal()), new PriceInfo(1, 3)), new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.CH_AP_CI.ordinal()), new PriceInfo(1, 3)), new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.HO_ME_KI.ordinal()), new PriceInfo(1, 3))); + career.addTrade(3, new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.HO_ME_CO.ordinal()), new PriceInfo(1, 3)), new BasicTradeList(new PriceInfo(1, 4), new ItemStack(InitItems.itemJams, 1, TheJams.PI_CO.ordinal()), new PriceInfo(1, 3))); VillagerRegistry.instance().registerVillageCreationHandler(new VillageJamHouseHandler()); - MapGenStructureIO.registerStructureComponent(VillageComponentJamHouse.class, ActuallyAdditions.MODID+":jamHouseStructure"); + MapGenStructureIO.registerStructureComponent(VillageComponentJamHouse.class, ActuallyAdditions.MODID + ":jamHouseStructure"); } - private static void initCustomCropFieldPart(){ + private static void initCustomCropFieldPart() { VillagerRegistry.instance().registerVillageCreationHandler(new VillageCustomCropFieldHandler()); - MapGenStructureIO.registerStructureComponent(VillageComponentCustomCropField.class, ActuallyAdditions.MODID+":customCropFieldStructure"); + MapGenStructureIO.registerStructureComponent(VillageComponentCustomCropField.class, ActuallyAdditions.MODID + ":customCropFieldStructure"); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentCustomCropField.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentCustomCropField.java index accb53a1b..7b5d38de2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentCustomCropField.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentCustomCropField.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.gen.village.component; +import java.util.List; +import java.util.Random; + import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import net.minecraft.block.Block; import net.minecraft.block.BlockCrops; @@ -22,10 +25,7 @@ import net.minecraft.world.gen.structure.StructureBoundingBox; import net.minecraft.world.gen.structure.StructureComponent; import net.minecraft.world.gen.structure.StructureVillagePieces; -import java.util.List; -import java.util.Random; - -public class VillageComponentCustomCropField extends StructureVillagePieces.House1{ +public class VillageComponentCustomCropField extends StructureVillagePieces.House1 { private static final int X_SIZE = 13; private static final int Y_SIZE = 4; @@ -33,35 +33,33 @@ public class VillageComponentCustomCropField extends StructureVillagePieces.Hous private int averageGroundLevel = -1; - public VillageComponentCustomCropField(){ + public VillageComponentCustomCropField() { } - public VillageComponentCustomCropField(StructureBoundingBox boundingBox, EnumFacing par5){ + public VillageComponentCustomCropField(StructureBoundingBox boundingBox, EnumFacing par5) { this.setCoordBaseMode(par5); this.boundingBox = boundingBox; } - public static VillageComponentCustomCropField buildComponent(List pieces, int p1, int p2, int p3, EnumFacing p4){ + public static VillageComponentCustomCropField buildComponent(List pieces, int p1, int p2, int p3, EnumFacing p4) { StructureBoundingBox boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, X_SIZE, Y_SIZE, Z_SIZE, p4); return canVillageGoDeeper(boundingBox) && StructureComponent.findIntersecting(pieces, boundingBox) == null ? new VillageComponentCustomCropField(boundingBox, p4) : null; } @Override - public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb){ - if(this.averageGroundLevel < 0){ + public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb) { + if (this.averageGroundLevel < 0) { this.averageGroundLevel = this.getAverageGroundLevel(world, sbb); - if(this.averageGroundLevel < 0){ - return true; - } - this.boundingBox.offset(0, this.averageGroundLevel-this.boundingBox.maxY+Y_SIZE-1, 0); + if (this.averageGroundLevel < 0) { return true; } + this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + Y_SIZE - 1, 0); } - this.fillWithBlocks(world, sbb, 0, 0, 0, X_SIZE-1, Y_SIZE-1, Z_SIZE-1, Blocks.AIR); + this.fillWithBlocks(world, sbb, 0, 0, 0, X_SIZE - 1, Y_SIZE - 1, Z_SIZE - 1, Blocks.AIR); this.spawnActualHouse(world, rand, sbb); - for(int i = 0; i < X_SIZE; i++){ - for(int j = 0; j < Z_SIZE; j++){ + for (int i = 0; i < X_SIZE; i++) { + for (int j = 0; j < Z_SIZE; j++) { this.clearCurrentPositionBlocksUpwards(world, i, Y_SIZE, j, sbb); this.replaceAirAndLiquidDownwards(world, Blocks.DIRT.getDefaultState(), i, -1, j, sbb); } @@ -70,11 +68,11 @@ public class VillageComponentCustomCropField extends StructureVillagePieces.Hous return true; } - public void fillWithBlocks(World world, StructureBoundingBox sbb, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Block block){ + public void fillWithBlocks(World world, StructureBoundingBox sbb, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Block block) { this.fillWithBlocks(world, sbb, minX, minY, minZ, maxX, maxY, maxZ, block.getDefaultState(), block.getDefaultState(), false); } - public void spawnActualHouse(World world, Random rand, StructureBoundingBox sbb){ + public void spawnActualHouse(World world, Random rand, StructureBoundingBox sbb) { this.fillWithBlocks(world, sbb, 1, 0, 1, 2, 0, 7, Blocks.FARMLAND); this.fillWithBlocks(world, sbb, 4, 0, 1, 5, 0, 7, Blocks.FARMLAND); this.fillWithBlocks(world, sbb, 7, 0, 1, 8, 0, 7, Blocks.FARMLAND); @@ -87,7 +85,7 @@ public class VillageComponentCustomCropField extends StructureVillagePieces.Hous this.fillWithBlocks(world, sbb, 3, 0, 1, 3, 0, 7, Blocks.WATER); this.fillWithBlocks(world, sbb, 9, 0, 1, 9, 0, 7, Blocks.WATER); - for(int i = 1; i <= 7; ++i){ + for (int i = 1; i <= 7; ++i) { this.setBlockState(world, this.getRandomCropType(rand), 1, 1, i, sbb); this.setBlockState(world, this.getRandomCropType(rand), 2, 1, i, sbb); this.setBlockState(world, this.getRandomCropType(rand), 4, 1, i, sbb); @@ -99,9 +97,9 @@ public class VillageComponentCustomCropField extends StructureVillagePieces.Hous } } - private IBlockState getRandomCropType(Random rand){ + private IBlockState getRandomCropType(Random rand) { int randomMeta = MathHelper.getInt(rand, 1, 7); - switch(rand.nextInt(4)){ + switch (rand.nextInt(4)) { case 0: return InitBlocks.blockFlax.getDefaultState().withProperty(BlockCrops.AGE, randomMeta); case 1: diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentEngineerHouse.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentEngineerHouse.java index ac1c3f5c7..3dd219af9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentEngineerHouse.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentEngineerHouse.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.gen.village.component; +import java.util.List; +import java.util.Random; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.laser.LaserType; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; @@ -23,7 +26,14 @@ import de.ellpeck.actuallyadditions.mod.gen.village.InitVillager; import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot; -import de.ellpeck.actuallyadditions.mod.tile.*; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityFermentingBarrel; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinder; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergy; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -46,10 +56,7 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession; -import java.util.List; -import java.util.Random; - -public class VillageComponentEngineerHouse extends StructureVillagePieces.House1{ +public class VillageComponentEngineerHouse extends StructureVillagePieces.House1 { private static final ResourceLocation STRUCTURE_RES_LOC = new ResourceLocation(ActuallyAdditions.MODID, "andrew_period_house"); @@ -59,36 +66,34 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1 private int averageGroundLevel = -1; - public VillageComponentEngineerHouse(){ + public VillageComponentEngineerHouse() { } - public VillageComponentEngineerHouse(StructureBoundingBox boundingBox, EnumFacing par5){ + public VillageComponentEngineerHouse(StructureBoundingBox boundingBox, EnumFacing par5) { this.setCoordBaseMode(par5); this.boundingBox = boundingBox; } - public static VillageComponentEngineerHouse buildComponent(List pieces, int p1, int p2, int p3, EnumFacing p4){ + public static VillageComponentEngineerHouse buildComponent(List pieces, int p1, int p2, int p3, EnumFacing p4) { StructureBoundingBox boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, X_SIZE, Y_SIZE, Z_SIZE, p4); return canVillageGoDeeper(boundingBox) && StructureComponent.findIntersecting(pieces, boundingBox) == null ? new VillageComponentEngineerHouse(boundingBox, p4) : null; } @Override - public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb){ - if(this.averageGroundLevel < 0){ + public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb) { + if (this.averageGroundLevel < 0) { this.averageGroundLevel = this.getAverageGroundLevel(world, sbb); - if(this.averageGroundLevel < 0){ - return true; - } - this.boundingBox.offset(0, this.averageGroundLevel-this.boundingBox.maxY+Y_SIZE-2, 0); + if (this.averageGroundLevel < 0) { return true; } + this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + Y_SIZE - 2, 0); } - this.fillWithBlocks(world, sbb, 0, 0, 0, X_SIZE-1, Y_SIZE-1, Z_SIZE-1, Blocks.AIR); + this.fillWithBlocks(world, sbb, 0, 0, 0, X_SIZE - 1, Y_SIZE - 1, Z_SIZE - 1, Blocks.AIR); this.spawnActualHouse(world, sbb); this.fillHouse(world, sbb); - for(int i = 0; i < X_SIZE; i++){ - for(int j = 0; j < Z_SIZE; j++){ + for (int i = 0; i < X_SIZE; i++) { + for (int j = 0; j < Z_SIZE; j++) { this.clearCurrentPositionBlocksUpwards(world, i, Y_SIZE, j, sbb); this.replaceAirAndLiquidDownwards(world, Blocks.DIRT.getDefaultState(), i, -1, j, sbb); } @@ -99,65 +104,65 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1 return true; } - private void fillWithBlocks(World world, StructureBoundingBox sbb, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Block block){ + private void fillWithBlocks(World world, StructureBoundingBox sbb, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Block block) { this.fillWithBlocks(world, sbb, minX, minY, minZ, maxX, maxY, maxZ, block.getDefaultState(), block.getDefaultState(), false); } - private void fillHouse(World world, StructureBoundingBox sbb){ - if(ConfigBoolValues.DUNGEON_LOOT.isEnabled()){ - if(world.rand.nextBoolean()){ + private void fillHouse(World world, StructureBoundingBox sbb) { + if (ConfigBoolValues.DUNGEON_LOOT.isEnabled()) { + if (world.rand.nextBoolean()) { TileEntity compost = this.getTileAtPos(world, 6, 1, 2, sbb); - if(compost instanceof TileEntityCompost){ - TileEntityCompost tile = (TileEntityCompost)compost; + if (compost instanceof TileEntityCompost) { + TileEntityCompost tile = (TileEntityCompost) compost; tile.stopFromDropping = true; tile.inv.setStackInSlot(0, new ItemStack(InitItems.itemFertilizer, 10)); } } TileEntity ferment = this.getTileAtPos(world, 11, 1, 0, sbb); - if(ferment instanceof TileEntityFermentingBarrel){ - TileEntityFermentingBarrel tile = (TileEntityFermentingBarrel)ferment; + if (ferment instanceof TileEntityFermentingBarrel) { + TileEntityFermentingBarrel tile = (TileEntityFermentingBarrel) ferment; tile.stopFromDropping = true; - tile.canolaTank.setFluid(new FluidStack(InitFluids.fluidCanolaOil, world.rand.nextInt(1500)+200)); + tile.canolaTank.setFluid(new FluidStack(InitFluids.fluidCanolaOil, world.rand.nextInt(1500) + 200)); } TileEntity coffee = this.getTileAtPos(world, 4, 2, 6, sbb); - if(coffee instanceof TileEntityCoffeeMachine){ - TileEntityCoffeeMachine tile = (TileEntityCoffeeMachine)coffee; + if (coffee instanceof TileEntityCoffeeMachine) { + TileEntityCoffeeMachine tile = (TileEntityCoffeeMachine) coffee; tile.stopFromDropping = true; - tile.tank.setFluid(new FluidStack(FluidRegistry.WATER, world.rand.nextInt(3000)+500)); + tile.tank.setFluid(new FluidStack(FluidRegistry.WATER, world.rand.nextInt(3000) + 500)); tile.coffeeCacheAmount = world.rand.nextInt(150); - tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored()/2)); + tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored() / 2)); } TileEntity press = this.getTileAtPos(world, 2, 1, 5, sbb); - if(press instanceof TileEntityCanolaPress){ - TileEntityCanolaPress tile = (TileEntityCanolaPress)press; + if (press instanceof TileEntityCanolaPress) { + TileEntityCanolaPress tile = (TileEntityCanolaPress) press; tile.stopFromDropping = true; - tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored()/3)); - tile.inv.setStackInSlot(0, new ItemStack(InitItems.itemMisc, world.rand.nextInt(60)+1, TheMiscItems.CANOLA.ordinal())); + tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored() / 3)); + tile.inv.setStackInSlot(0, new ItemStack(InitItems.itemMisc, world.rand.nextInt(60) + 1, TheMiscItems.CANOLA.ordinal())); } TileEntity crusher = this.getTileAtPos(world, 2, 1, 6, sbb); - if(crusher instanceof TileEntityGrinder){ - TileEntityGrinder tile = (TileEntityGrinder)crusher; + if (crusher instanceof TileEntityGrinder) { + TileEntityGrinder tile = (TileEntityGrinder) crusher; tile.stopFromDropping = true; - tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored()/2)); - if(world.rand.nextFloat() >= 0.25F){ - tile.inv.setStackInSlot(TileEntityGrinder.SLOT_INPUT_1, new ItemStack(InitBlocks.blockMisc, world.rand.nextInt(10)+1, TheMiscBlocks.ORE_QUARTZ.ordinal())); + tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored() / 2)); + if (world.rand.nextFloat() >= 0.25F) { + tile.inv.setStackInSlot(TileEntityGrinder.SLOT_INPUT_1, new ItemStack(InitBlocks.blockMisc, world.rand.nextInt(10) + 1, TheMiscBlocks.ORE_QUARTZ.ordinal())); } } TileEntity coal = this.getTileAtPos(world, 5, 5, 6, sbb); - if(coal instanceof TileEntityCoalGenerator){ - TileEntityCoalGenerator tile = (TileEntityCoalGenerator)coal; + if (coal instanceof TileEntityCoalGenerator) { + TileEntityCoalGenerator tile = (TileEntityCoalGenerator) coal; tile.stopFromDropping = true; - tile.inv.setStackInSlot(0, new ItemStack(Items.COAL, world.rand.nextInt(25)+3, 1)); + tile.inv.setStackInSlot(0, new ItemStack(Items.COAL, world.rand.nextInt(25) + 3, 1)); } TileEntity reconstructor = this.getTileAtPos(world, 8, 4, 3, sbb); - if(reconstructor instanceof TileEntityAtomicReconstructor){ - ((TileEntityAtomicReconstructor)reconstructor).stopFromDropping = true; + if (reconstructor instanceof TileEntityAtomicReconstructor) { + ((TileEntityAtomicReconstructor) reconstructor).stopFromDropping = true; } VillageComponentJamHouse.generateCrate(world, sbb, this.getXWithOffset(6, 4), this.getYWithOffset(4), this.getZWithOffset(6, 4), DungeonLoot.ENGINEER_HOUSE); @@ -165,9 +170,9 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1 TileEntity firstRelay = this.getTileAtPos(world, 6, 5, 6, sbb); TileEntity secondRelay = this.getTileAtPos(world, 8, 5, 3, sbb); - if(firstRelay instanceof TileEntityLaserRelayEnergy && secondRelay instanceof TileEntityLaserRelayEnergy){ - ((TileEntityLaserRelayEnergy)firstRelay).stopFromDropping = true; - ((TileEntityLaserRelayEnergy)secondRelay).stopFromDropping = true; + if (firstRelay instanceof TileEntityLaserRelayEnergy && secondRelay instanceof TileEntityLaserRelayEnergy) { + ((TileEntityLaserRelayEnergy) firstRelay).stopFromDropping = true; + ((TileEntityLaserRelayEnergy) secondRelay).stopFromDropping = true; ActuallyAdditionsAPI.connectionHandler.addConnection(firstRelay.getPos(), secondRelay.getPos(), LaserType.ENERGY, world); } @@ -175,28 +180,25 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1 this.setBlockState(world, InitBlocks.blockColoredLampOn.getDefaultState().withProperty(BlockColoredLamp.TYPE, BlockColoredLamp.ALL_LAMP_TYPES[meta]), 8, 1, 6, sbb); } - private void spawnActualHouse(World world, StructureBoundingBox sbb){ + private void spawnActualHouse(World world, StructureBoundingBox sbb) { TemplateManager manager = world.getSaveHandler().getStructureTemplateManager(); MinecraftServer server = world.getMinecraftServer(); - if(manager != null && server != null){ + if (manager != null && server != null) { EnumFacing facing = this.getCoordBaseMode(); Mirror mirror; Rotation rotation; - if(facing == EnumFacing.SOUTH){ + if (facing == EnumFacing.SOUTH) { mirror = Mirror.NONE; rotation = Rotation.NONE; - } - else if(facing == EnumFacing.WEST){ + } else if (facing == EnumFacing.WEST) { mirror = Mirror.NONE; rotation = Rotation.CLOCKWISE_90; - } - else if(facing == EnumFacing.EAST){ + } else if (facing == EnumFacing.EAST) { mirror = Mirror.LEFT_RIGHT; rotation = Rotation.CLOCKWISE_90; - } - else{ + } else { mirror = Mirror.LEFT_RIGHT; rotation = Rotation.NONE; } @@ -204,24 +206,23 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1 PlacementSettings placement = new PlacementSettings().setRotation(rotation).setMirror(mirror).setBoundingBox(sbb); Template template = manager.getTemplate(server, STRUCTURE_RES_LOC); - if(template != null){ + if (template != null) { template.addBlocksToWorld(world, new BlockPos(this.getXWithOffset(0, 0), this.getYWithOffset(0), this.getZWithOffset(0, 0)), placement); } } } - private TileEntity getTileAtPos(World world, int x, int y, int z, StructureBoundingBox sbb){ + private TileEntity getTileAtPos(World world, int x, int y, int z, StructureBoundingBox sbb) { BlockPos pos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z)); - if(sbb.isVecInside(pos)){ + if (sbb.isVecInside(pos)) { return world.getTileEntity(pos); - } - else{ + } else { return null; } } @Override - protected VillagerProfession chooseForgeProfession(int count, VillagerProfession prof){ + protected VillagerProfession chooseForgeProfession(int count, VillagerProfession prof) { return InitVillager.engineerProfession; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentJamHouse.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentJamHouse.java index a06c88b63..d9be48266 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentJamHouse.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentJamHouse.java @@ -10,12 +10,19 @@ package de.ellpeck.actuallyadditions.mod.gen.village.component; +import java.util.List; +import java.util.Random; + import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.gen.village.InitVillager; import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot; import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest; -import net.minecraft.block.*; +import net.minecraft.block.Block; +import net.minecraft.block.BlockDoor; +import net.minecraft.block.BlockLeaves; +import net.minecraft.block.BlockStairs; +import net.minecraft.block.BlockTorch; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; @@ -28,10 +35,7 @@ import net.minecraft.world.gen.structure.StructureComponent; import net.minecraft.world.gen.structure.StructureVillagePieces; import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession; -import java.util.List; -import java.util.Random; - -public class VillageComponentJamHouse extends StructureVillagePieces.House1{ +public class VillageComponentJamHouse extends StructureVillagePieces.House1 { private static final int X_SIZE = 11; private static final int Y_SIZE = 8; @@ -39,53 +43,50 @@ public class VillageComponentJamHouse extends StructureVillagePieces.House1{ private int averageGroundLevel = -1; - public VillageComponentJamHouse(){ + public VillageComponentJamHouse() { } - public VillageComponentJamHouse(StructureBoundingBox boundingBox, EnumFacing par5){ + public VillageComponentJamHouse(StructureBoundingBox boundingBox, EnumFacing par5) { this.setCoordBaseMode(par5); this.boundingBox = boundingBox; } - public static VillageComponentJamHouse buildComponent(List pieces, int p1, int p2, int p3, EnumFacing p4){ + public static VillageComponentJamHouse buildComponent(List pieces, int p1, int p2, int p3, EnumFacing p4) { StructureBoundingBox boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, X_SIZE, Y_SIZE, Z_SIZE, p4); return canVillageGoDeeper(boundingBox) && StructureComponent.findIntersecting(pieces, boundingBox) == null ? new VillageComponentJamHouse(boundingBox, p4) : null; } - public static boolean generateCrate(World world, StructureBoundingBox box, int x, int y, int z, ResourceLocation loot){ + public static boolean generateCrate(World world, StructureBoundingBox box, int x, int y, int z, ResourceLocation loot) { BlockPos pos = new BlockPos(x, y, z); - if(box.isVecInside(pos)){ + if (box.isVecInside(pos)) { world.setBlockState(pos, InitBlocks.blockGiantChest.getDefaultState(), 2); TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityGiantChest){ - ((TileEntityGiantChest)tile).lootTable = loot; + if (tile instanceof TileEntityGiantChest) { + ((TileEntityGiantChest) tile).lootTable = loot; } return true; - } - else{ + } else { return false; } } @Override - public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb){ - if(this.averageGroundLevel < 0){ + public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb) { + if (this.averageGroundLevel < 0) { this.averageGroundLevel = this.getAverageGroundLevel(world, sbb); - if(this.averageGroundLevel < 0){ - return true; - } - this.boundingBox.offset(0, this.averageGroundLevel-this.boundingBox.maxY+Y_SIZE-1, 0); + if (this.averageGroundLevel < 0) { return true; } + this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + Y_SIZE - 1, 0); } - this.fillWithBlocks(world, sbb, 0, 0, 0, X_SIZE-1, Y_SIZE-1, Z_SIZE-1, Blocks.AIR); + this.fillWithBlocks(world, sbb, 0, 0, 0, X_SIZE - 1, Y_SIZE - 1, Z_SIZE - 1, Blocks.AIR); this.spawnActualHouse(world, rand, sbb); - for(int i = 0; i < X_SIZE; i++){ - for(int j = 0; j < Z_SIZE; j++){ + for (int i = 0; i < X_SIZE; i++) { + for (int j = 0; j < Z_SIZE; j++) { this.clearCurrentPositionBlocksUpwards(world, i, Y_SIZE, j, sbb); this.replaceAirAndLiquidDownwards(world, Blocks.COBBLESTONE.getDefaultState(), i, -1, j, sbb); } @@ -96,12 +97,12 @@ public class VillageComponentJamHouse extends StructureVillagePieces.House1{ return true; } - public void fillWithBlocks(World world, StructureBoundingBox sbb, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Block block){ + public void fillWithBlocks(World world, StructureBoundingBox sbb, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Block block) { this.fillWithBlocks(world, sbb, minX, minY, minZ, maxX, maxY, maxZ, block.getDefaultState(), block.getDefaultState(), false); } @SuppressWarnings("deprecation") - public void spawnActualHouse(World world, Random rand, StructureBoundingBox sbb){ + public void spawnActualHouse(World world, Random rand, StructureBoundingBox sbb) { //Base this.fillWithBlocks(world, sbb, 1, 0, 8, 9, 0, 10, Blocks.GRASS); this.fillWithBlocks(world, sbb, 0, 0, 0, 1, 0, 7, Blocks.COBBLESTONE); @@ -124,15 +125,15 @@ public class VillageComponentJamHouse extends StructureVillagePieces.House1{ this.fillWithBlocks(world, sbb, 1, 1, 11, 9, 1, 11, Blocks.OAK_FENCE); //Side Walls - for(int i = 0; i < 2; i++){ - this.fillWithBlocks(world, sbb, 1+i*8, 1, 1, 1+i*8, 1, 7, Blocks.COBBLESTONE); - this.fillWithBlocks(world, sbb, 1+i*8, 1, 1, 1+i*8, 4, 1, Blocks.COBBLESTONE); - this.fillWithBlocks(world, sbb, 1+i*8, 1, 7, 1+i*8, 4, 7, Blocks.COBBLESTONE); - this.fillWithBlocks(world, sbb, 1+i*8, 4, 2, 1+i*8, 5, 6, Blocks.COBBLESTONE); - this.fillWithBlocks(world, sbb, 1+i*8, 3, 2, 1+i*8, 3, 6, Blocks.PLANKS); - this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(0), 1+i*8, 2, 2, sbb); - this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(0), 1+i*8, 2, 6, sbb); - this.fillWithBlocks(world, sbb, 1+i*8, 2, 3, 1+i*8, 2, 5, Blocks.GLASS_PANE); + for (int i = 0; i < 2; i++) { + this.fillWithBlocks(world, sbb, 1 + i * 8, 1, 1, 1 + i * 8, 1, 7, Blocks.COBBLESTONE); + this.fillWithBlocks(world, sbb, 1 + i * 8, 1, 1, 1 + i * 8, 4, 1, Blocks.COBBLESTONE); + this.fillWithBlocks(world, sbb, 1 + i * 8, 1, 7, 1 + i * 8, 4, 7, Blocks.COBBLESTONE); + this.fillWithBlocks(world, sbb, 1 + i * 8, 4, 2, 1 + i * 8, 5, 6, Blocks.COBBLESTONE); + this.fillWithBlocks(world, sbb, 1 + i * 8, 3, 2, 1 + i * 8, 3, 6, Blocks.PLANKS); + this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(0), 1 + i * 8, 2, 2, sbb); + this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(0), 1 + i * 8, 2, 6, sbb); + this.fillWithBlocks(world, sbb, 1 + i * 8, 2, 3, 1 + i * 8, 2, 5, Blocks.GLASS_PANE); } //Front Wall @@ -145,7 +146,6 @@ public class VillageComponentJamHouse extends StructureVillagePieces.House1{ this.setBlockState(world, Blocks.SPRUCE_DOOR.getDefaultState(), 5, 1, 1, sbb); this.setBlockState(world, Blocks.SPRUCE_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 5, 2, 1, sbb); - //Back Wall this.fillWithBlocks(world, sbb, 2, 1, 7, 2, 4, 7, Blocks.COBBLESTONE); this.fillWithBlocks(world, sbb, 3, 1, 7, 3, 3, 7, Blocks.PLANKS); @@ -210,7 +210,7 @@ public class VillageComponentJamHouse extends StructureVillagePieces.House1{ this.fillWithBlocks(world, sbb, 3, 1, 4, 4, 1, 6, Blocks.CARPET.getStateFromMeta(10), Blocks.CARPET.getStateFromMeta(10), false); //Loot Chest - if(ConfigBoolValues.DUNGEON_LOOT.isEnabled()){ + if (ConfigBoolValues.DUNGEON_LOOT.isEnabled()) { generateCrate(world, this.boundingBox, this.getXWithOffset(8, 6), this.getYWithOffset(1), this.getZWithOffset(8, 6), DungeonLoot.JAM_HOUSE); } @@ -226,7 +226,7 @@ public class VillageComponentJamHouse extends StructureVillagePieces.House1{ } @Override - protected VillagerProfession chooseForgeProfession(int count, VillagerProfession prof){ + protected VillagerProfession chooseForgeProfession(int count, VillagerProfession prof) { return InitVillager.jamProfession; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/handler/VillageCustomCropFieldHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/handler/VillageCustomCropFieldHandler.java index e5f3c45d1..491ac68eb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/handler/VillageCustomCropFieldHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/handler/VillageCustomCropFieldHandler.java @@ -10,29 +10,29 @@ package de.ellpeck.actuallyadditions.mod.gen.village.component.handler; +import java.util.List; +import java.util.Random; + import de.ellpeck.actuallyadditions.mod.gen.village.component.VillageComponentCustomCropField; import net.minecraft.util.EnumFacing; import net.minecraft.world.gen.structure.StructureComponent; import net.minecraft.world.gen.structure.StructureVillagePieces; import net.minecraftforge.fml.common.registry.VillagerRegistry; -import java.util.List; -import java.util.Random; - -public class VillageCustomCropFieldHandler implements VillagerRegistry.IVillageCreationHandler{ +public class VillageCustomCropFieldHandler implements VillagerRegistry.IVillageCreationHandler { @Override - public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i){ + public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i) { return new StructureVillagePieces.PieceWeight(VillageComponentCustomCropField.class, 5, 1); } @Override - public Class getComponentClass(){ + public Class getComponentClass() { return VillageComponentCustomCropField.class; } @Override - public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5){ + public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5) { return VillageComponentCustomCropField.buildComponent(pieces, p1, p2, p3, facing); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/handler/VillageEngineerHouseHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/handler/VillageEngineerHouseHandler.java index 80cfc49a5..0b1144c82 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/handler/VillageEngineerHouseHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/handler/VillageEngineerHouseHandler.java @@ -10,29 +10,29 @@ package de.ellpeck.actuallyadditions.mod.gen.village.component.handler; +import java.util.List; +import java.util.Random; + import de.ellpeck.actuallyadditions.mod.gen.village.component.VillageComponentEngineerHouse; import net.minecraft.util.EnumFacing; import net.minecraft.world.gen.structure.StructureComponent; import net.minecraft.world.gen.structure.StructureVillagePieces; import net.minecraftforge.fml.common.registry.VillagerRegistry; -import java.util.List; -import java.util.Random; - -public class VillageEngineerHouseHandler implements VillagerRegistry.IVillageCreationHandler{ +public class VillageEngineerHouseHandler implements VillagerRegistry.IVillageCreationHandler { @Override - public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i){ + public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i) { return new StructureVillagePieces.PieceWeight(VillageComponentEngineerHouse.class, 10, 1); } @Override - public Class getComponentClass(){ + public Class getComponentClass() { return VillageComponentEngineerHouse.class; } @Override - public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5){ + public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5) { return VillageComponentEngineerHouse.buildComponent(pieces, p1, p2, p3, facing); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/handler/VillageJamHouseHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/handler/VillageJamHouseHandler.java index ddb0de416..c9a4a50e7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/handler/VillageJamHouseHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/handler/VillageJamHouseHandler.java @@ -10,29 +10,29 @@ package de.ellpeck.actuallyadditions.mod.gen.village.component.handler; +import java.util.List; +import java.util.Random; + import de.ellpeck.actuallyadditions.mod.gen.village.component.VillageComponentJamHouse; import net.minecraft.util.EnumFacing; import net.minecraft.world.gen.structure.StructureComponent; import net.minecraft.world.gen.structure.StructureVillagePieces; import net.minecraftforge.fml.common.registry.VillagerRegistry; -import java.util.List; -import java.util.Random; - -public class VillageJamHouseHandler implements VillagerRegistry.IVillageCreationHandler{ +public class VillageJamHouseHandler implements VillagerRegistry.IVillageCreationHandler { @Override - public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i){ + public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i) { return new StructureVillagePieces.PieceWeight(VillageComponentJamHouse.class, 3, 1); } @Override - public Class getComponentClass(){ + public Class getComponentClass() { return VillageComponentJamHouse.class; } @Override - public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5){ + public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5) { return VillageComponentJamHouse.buildComponent(pieces, p1, p2, p3, facing); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBioReactor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBioReactor.java index a7102916a..172ee7928 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBioReactor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBioReactor.java @@ -20,75 +20,62 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerBioReactor extends Container{ +public class ContainerBioReactor extends Container { private final TileEntityBioReactor tile; - public ContainerBioReactor(InventoryPlayer inventory, TileEntityBase tile){ - this.tile = (TileEntityBioReactor)tile; + public ContainerBioReactor(InventoryPlayer inventory, TileEntityBase tile) { + this.tile = (TileEntityBioReactor) tile; - for(int i = 0; i < 4; i++){ - for(int j = 0; j < 2; j++){ - this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tile.inv, j+i*2, 50+j*18, 13+i*18)); + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 2; j++) { + this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tile.inv, j + i * 2, 50 + j * 18, 13 + i * 18)); } } - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 8; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ + if (slot >= inventoryStart) { //Shift from Inventory - if(TileEntityBioReactor.isValidItem(newStack)){ - if(!this.mergeItemStack(newStack, 0, 8, false)){ - return StackUtil.getEmpty(); - } + if (TileEntityBioReactor.isValidItem(newStack)) { + if (!this.mergeItemStack(newStack, 0, 8, false)) { return StackUtil.getEmpty(); } } // - else if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + else if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -97,7 +84,7 @@ public class ContainerBioReactor extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.tile.canPlayerUse(player); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBreaker.java index fb8853405..45be35e3e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBreaker.java @@ -20,72 +20,60 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerBreaker extends Container{ +public class ContainerBreaker extends Container { private final TileEntityBreaker breaker; - public ContainerBreaker(InventoryPlayer inventory, TileEntityBase tile){ - this.breaker = (TileEntityBreaker)tile; + public ContainerBreaker(InventoryPlayer inventory, TileEntityBase tile) { + this.breaker = (TileEntityBreaker) tile; - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 3; j++){ - this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.breaker.inv, j+i*3, 62+j*18, 21+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.breaker.inv, j + i * 3, 62 + j * 18, 21 + i * 18)); } } - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 9; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ + if (slot >= inventoryStart) { //Shift from Inventory - if(!this.mergeItemStack(newStack, 0, 9, false)){ + if (!this.mergeItemStack(newStack, 0, 9, false)) { // - if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } + if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -94,7 +82,7 @@ public class ContainerBreaker extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.breaker.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCanolaPress.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCanolaPress.java index 3efd28468..712f513fe 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCanolaPress.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCanolaPress.java @@ -22,72 +22,58 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerCanolaPress extends Container{ +public class ContainerCanolaPress extends Container { private final TileEntityCanolaPress press; - public ContainerCanolaPress(InventoryPlayer inventory, TileEntityBase tile){ - this.press = (TileEntityCanolaPress)tile; + public ContainerCanolaPress(InventoryPlayer inventory, TileEntityBase tile) { + this.press = (TileEntityCanolaPress) tile; this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.press.inv, 0, 81, 10)); - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 1; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ + if (slot >= inventoryStart) { //Shift from Inventory - if(newStack.getItem() == InitItems.itemMisc && newStack.getItemDamage() == TheMiscItems.CANOLA.ordinal()){ - if(!this.mergeItemStack(newStack, 0, 1, false)){ - return StackUtil.getEmpty(); - } + if (newStack.getItem() == InitItems.itemMisc && newStack.getItemDamage() == TheMiscItems.CANOLA.ordinal()) { + if (!this.mergeItemStack(newStack, 0, 1, false)) { return StackUtil.getEmpty(); } } // - else if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + else if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -96,7 +82,7 @@ public class ContainerCanolaPress extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.press.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoalGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoalGenerator.java index c6a18dd9e..01e1422d3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoalGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoalGenerator.java @@ -21,72 +21,58 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntityFurnace; - -public class ContainerCoalGenerator extends Container{ +public class ContainerCoalGenerator extends Container { private final TileEntityCoalGenerator generator; - public ContainerCoalGenerator(InventoryPlayer inventory, TileEntityBase tile){ - this.generator = (TileEntityCoalGenerator)tile; + public ContainerCoalGenerator(InventoryPlayer inventory, TileEntityBase tile) { + this.generator = (TileEntityCoalGenerator) tile; this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.generator.inv, 0, 87, 43)); - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 1; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ + if (slot >= inventoryStart) { //Shift from Inventory - if(TileEntityFurnace.getItemBurnTime(newStack) > 0){ - if(!this.mergeItemStack(newStack, 0, 1, false)){ - return StackUtil.getEmpty(); - } + if (TileEntityFurnace.getItemBurnTime(newStack) > 0) { + if (!this.mergeItemStack(newStack, 0, 1, false)) { return StackUtil.getEmpty(); } } // - else if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + else if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -95,7 +81,7 @@ public class ContainerCoalGenerator extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.generator.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoffeeMachine.java index f6dc2b46a..5c210df53 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoffeeMachine.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoffeeMachine.java @@ -24,97 +24,75 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerCoffeeMachine extends Container{ +public class ContainerCoffeeMachine extends Container { private final TileEntityCoffeeMachine machine; - public ContainerCoffeeMachine(InventoryPlayer inventory, TileEntityBase tile){ - this.machine = (TileEntityCoffeeMachine)tile; + public ContainerCoffeeMachine(InventoryPlayer inventory, TileEntityBase tile) { + this.machine = (TileEntityCoffeeMachine) tile; this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.machine.inv, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS, 37, 6)); this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.machine.inv, TileEntityCoffeeMachine.SLOT_INPUT, 80, 42)); this.addSlotToContainer(new SlotOutput(this.machine.inv, TileEntityCoffeeMachine.SLOT_OUTPUT, 80, 73)); - for(int i = 0; i < 4; i++){ - for(int j = 0; j < 2; j++){ - this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.machine.inv, j+i*2+3, 125+j*18, 6+i*18)); + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 2; j++) { + this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.machine.inv, j + i * 2 + 3, 125 + j * 18, 6 + i * 18)); } } - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 11; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Slots in Inventory to shift from - if(slot == TileEntityCoffeeMachine.SLOT_OUTPUT){ - if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, true)){ - return StackUtil.getEmpty(); - } + if (slot == TileEntityCoffeeMachine.SLOT_OUTPUT) { + if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, true)) { return StackUtil.getEmpty(); } theSlot.onSlotChange(newStack, currentStack); } //Other Slots in Inventory excluded - else if(slot >= inventoryStart){ + else if (slot >= inventoryStart) { //Shift from Inventory - if(newStack.getItem() == InitItems.itemMisc && newStack.getItemDamage() == TheMiscItems.CUP.ordinal()){ - if(!this.mergeItemStack(newStack, TileEntityCoffeeMachine.SLOT_INPUT, TileEntityCoffeeMachine.SLOT_INPUT+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(ItemCoffee.getIngredientFromStack(newStack) != null){ - if(!this.mergeItemStack(newStack, 3, 11, false)){ - return StackUtil.getEmpty(); - } - } - else if(TileEntityCoffeeMachine.COFFEE.apply(newStack)){ - if(!this.mergeItemStack(newStack, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS+1, false)){ - return StackUtil.getEmpty(); - } + if (newStack.getItem() == InitItems.itemMisc && newStack.getItemDamage() == TheMiscItems.CUP.ordinal()) { + if (!this.mergeItemStack(newStack, TileEntityCoffeeMachine.SLOT_INPUT, TileEntityCoffeeMachine.SLOT_INPUT + 1, false)) { return StackUtil.getEmpty(); } + } else if (ItemCoffee.getIngredientFromStack(newStack) != null) { + if (!this.mergeItemStack(newStack, 3, 11, false)) { return StackUtil.getEmpty(); } + } else if (TileEntityCoffeeMachine.COFFEE.apply(newStack)) { + if (!this.mergeItemStack(newStack, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS + 1, false)) { return StackUtil.getEmpty(); } } // - else if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + else if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -123,7 +101,7 @@ public class ContainerCoffeeMachine extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.machine.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDirectionalBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDirectionalBreaker.java index 49a1a2466..4a0c6ce72 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDirectionalBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDirectionalBreaker.java @@ -20,72 +20,60 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerDirectionalBreaker extends Container{ +public class ContainerDirectionalBreaker extends Container { private final TileEntityDirectionalBreaker breaker; - public ContainerDirectionalBreaker(InventoryPlayer inventory, TileEntityBase tile){ - this.breaker = (TileEntityDirectionalBreaker)tile; + public ContainerDirectionalBreaker(InventoryPlayer inventory, TileEntityBase tile) { + this.breaker = (TileEntityDirectionalBreaker) tile; - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 3; j++){ - this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.breaker.inv, j+i*3, 74+j*18, 21+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.breaker.inv, j + i * 3, 74 + j * 18, 21 + i * 18)); } } - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 9; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ + if (slot >= inventoryStart) { //Shift from Inventory - if(!this.mergeItemStack(newStack, 0, 9, false)){ + if (!this.mergeItemStack(newStack, 0, 9, false)) { // - if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } + if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -94,7 +82,7 @@ public class ContainerDirectionalBreaker extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.breaker.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDrill.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDrill.java index 8db8a06de..4313404ec 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDrill.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDrill.java @@ -23,92 +23,77 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerDrill extends Container{ +public class ContainerDrill extends Container { public static final int SLOT_AMOUNT = 5; private final ItemStackHandlerAA drillInventory = new ItemStackHandlerAA(SLOT_AMOUNT); private final InventoryPlayer inventory; - public ContainerDrill(InventoryPlayer inventory){ + public ContainerDrill(InventoryPlayer inventory) { this.inventory = inventory; - for(int i = 0; i < SLOT_AMOUNT; i++){ - this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.drillInventory, i, 44+i*18, 19){ + for (int i = 0; i < SLOT_AMOUNT; i++) { + this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.drillInventory, i, 44 + i * 18, 19) { @Override - public boolean isItemValid(ItemStack stack){ + public boolean isItemValid(ItemStack stack) { return stack.getItem() instanceof ItemDrillUpgrade; } }); } - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 58+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 58 + i * 18)); } } - for(int i = 0; i < 9; i++){ - if(i == inventory.currentItem){ - this.addSlotToContainer(new SlotImmovable(inventory, i, 8+i*18, 116)); - } - else{ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 116)); + for (int i = 0; i < 9; i++) { + if (i == inventory.currentItem) { + this.addSlotToContainer(new SlotImmovable(inventory, i, 8 + i * 18, 116)); + } else { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 116)); } } ItemStack stack = inventory.getCurrentItem(); - if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemDrill){ + if (StackUtil.isValid(stack) && stack.getItem() instanceof ItemDrill) { ItemDrill.loadSlotsFromNBT(this.drillInventory, inventory.getCurrentItem()); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 5; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ + if (slot >= inventoryStart) { //Shift from Inventory - if(newStack.getItem() instanceof ItemDrillUpgrade){ - if(!this.mergeItemStack(newStack, 0, 5, false)){ - return StackUtil.getEmpty(); - } + if (newStack.getItem() instanceof ItemDrillUpgrade) { + if (!this.mergeItemStack(newStack, 0, 5, false)) { return StackUtil.getEmpty(); } } // - else if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + else if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -117,26 +102,25 @@ public class ContainerDrill extends Container{ } @Override - public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player){ - if(clickTypeIn == ClickType.SWAP && dragType == this.inventory.currentItem){ + public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) { + if (clickTypeIn == ClickType.SWAP && dragType == this.inventory.currentItem) { return ItemStack.EMPTY; - } - else{ + } else { return super.slotClick(slotId, dragType, clickTypeIn, player); } } @Override - public void onContainerClosed(EntityPlayer player){ + public void onContainerClosed(EntityPlayer player) { ItemStack stack = this.inventory.getCurrentItem(); - if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemDrill){ + if (StackUtil.isValid(stack) && stack.getItem() instanceof ItemDrill) { ItemDrill.writeSlotsToNBT(this.drillInventory, this.inventory.getCurrentItem()); } super.onContainerClosed(player); } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return true; } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDropper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDropper.java index a362af326..a839ba4c7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDropper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDropper.java @@ -21,74 +21,62 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerDropper extends Container{ +public class ContainerDropper extends Container { private final TileEntityDropper dropper; EntityPlayer player; - public ContainerDropper(EntityPlayer player, TileEntityBase tile){ - this.dropper = (TileEntityDropper)tile; + public ContainerDropper(EntityPlayer player, TileEntityBase tile) { + this.dropper = (TileEntityDropper) tile; this.player = player; InventoryPlayer inventory = player.inventory; - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 3; j++){ - this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.dropper.inv, j+i*3, 62+j*18, 21+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.dropper.inv, j + i * 3, 62 + j * 18, 21 + i * 18)); } } - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 9; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ + if (slot >= inventoryStart) { //Shift from Inventory - if(!this.mergeItemStack(newStack, 0, 9, false)){ + if (!this.mergeItemStack(newStack, 0, 9, false)) { // - if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } + if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -97,7 +85,7 @@ public class ContainerDropper extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.dropper.canPlayerUse(player); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnervator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnervator.java index f2046e8f8..e607122bb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnervator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnervator.java @@ -26,43 +26,42 @@ import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - -public class ContainerEnervator extends Container{ +public class ContainerEnervator extends Container { private final TileEntityEnervator enervator; - public ContainerEnervator(final EntityPlayer player, TileEntityBase tile){ - this.enervator = (TileEntityEnervator)tile; + public ContainerEnervator(final EntityPlayer player, TileEntityBase tile) { + this.enervator = (TileEntityEnervator) tile; InventoryPlayer inventory = player.inventory; this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.enervator.inv, 0, 76, 73)); this.addSlotToContainer(new SlotOutput(this.enervator.inv, 1, 76, 42)); - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } - for(int k = 0; k < 4; ++k){ + for (int k = 0; k < 4; ++k) { final EntityEquipmentSlot slot = ContainerEnergizer.VALID_EQUIPMENT_SLOTS[k]; - this.addSlotToContainer(new Slot(player.inventory, 36+3-k, 102, 19+k*18){ + this.addSlotToContainer(new Slot(player.inventory, 36 + 3 - k, 102, 19 + k * 18) { @Override - public int getSlotStackLimit(){ + public int getSlotStackLimit() { return 1; } @Override - public boolean isItemValid(ItemStack stack){ + public boolean isItemValid(ItemStack stack) { return StackUtil.isValid(stack) && stack.getItem().isValidArmor(stack, slot, player); } @Override @SideOnly(Side.CLIENT) - public String getSlotTexture(){ + public String getSlotTexture() { return ItemArmor.EMPTY_SLOT_NAMES[slot.getIndex()]; } }); @@ -70,58 +69,43 @@ public class ContainerEnervator extends Container{ } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 2; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Slots in Inventory to shift from - if(slot == 1){ - if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, true)){ - return StackUtil.getEmpty(); - } + if (slot == 1) { + if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, true)) { return StackUtil.getEmpty(); } theSlot.onSlotChange(newStack, currentStack); } //Other Slots in Inventory excluded - else if(slot >= inventoryStart){ + else if (slot >= inventoryStart) { //Shift from Inventory - if(newStack.hasCapability(CapabilityEnergy.ENERGY, null)){ - if(!this.mergeItemStack(newStack, 0, 1, false)){ - return StackUtil.getEmpty(); - } + if (newStack.hasCapability(CapabilityEnergy.ENERGY, null)) { + if (!this.mergeItemStack(newStack, 0, 1, false)) { return StackUtil.getEmpty(); } } // - else if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + else if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -130,7 +114,7 @@ public class ContainerEnervator extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.enervator.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFarmer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFarmer.java index 726fc5e14..a680ad5d8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFarmer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFarmer.java @@ -20,77 +20,65 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerFarmer extends Container{ +public class ContainerFarmer extends Container { private final TileEntityFarmer farmer; - public ContainerFarmer(InventoryPlayer inventory, TileEntityBase tile){ - this.farmer = (TileEntityFarmer)tile; + public ContainerFarmer(InventoryPlayer inventory, TileEntityBase tile) { + this.farmer = (TileEntityFarmer) tile; - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 2; j++){ - this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.farmer.inv, j+i*2, 67+j*18, 21+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 2; j++) { + this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.farmer.inv, j + i * 2, 67 + j * 18, 21 + i * 18)); } } - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 2; j++){ - this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.farmer.inv, 6+j+i*2, 105+j*18, 21+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 2; j++) { + this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.farmer.inv, 6 + j + i * 2, 105 + j * 18, 21 + i * 18)); } } - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 12; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ + if (slot >= inventoryStart) { //Shift from Inventory - if(!this.mergeItemStack(newStack, 0, 6, false)){ + if (!this.mergeItemStack(newStack, 0, 6, false)) { // - if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } + if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -99,7 +87,7 @@ public class ContainerFarmer extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.farmer.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFeeder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFeeder.java index 45e3c0e04..909a68e92 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFeeder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFeeder.java @@ -20,67 +20,55 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerFeeder extends Container{ +public class ContainerFeeder extends Container { private final TileEntityFeeder tileFeeder; - public ContainerFeeder(InventoryPlayer inventory, TileEntityBase tile){ - this.tileFeeder = (TileEntityFeeder)tile; + public ContainerFeeder(InventoryPlayer inventory, TileEntityBase tile) { + this.tileFeeder = (TileEntityFeeder) tile; this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileFeeder.inv, 0, 80, 45)); - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 74+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 74 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 132)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 132)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 1; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ + if (slot >= inventoryStart) { //Shift from Inventory - if(!this.mergeItemStack(newStack, 0, 1, false)){ + if (!this.mergeItemStack(newStack, 0, 1, false)) { // - if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } + if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -89,7 +77,7 @@ public class ContainerFeeder extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.tileFeeder.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFermentingBarrel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFermentingBarrel.java index 99133544f..bd9f51091 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFermentingBarrel.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFermentingBarrel.java @@ -19,62 +19,50 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerFermentingBarrel extends Container{ +public class ContainerFermentingBarrel extends Container { private final TileEntityFermentingBarrel barrel; - public ContainerFermentingBarrel(InventoryPlayer inventory, TileEntityBase tile){ - this.barrel = (TileEntityFermentingBarrel)tile; + public ContainerFermentingBarrel(InventoryPlayer inventory, TileEntityBase tile) { + this.barrel = (TileEntityFermentingBarrel) tile; - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 0; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ - if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + if (slot >= inventoryStart) { + if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -83,7 +71,7 @@ public class ContainerFermentingBarrel extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.barrel.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFilter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFilter.java index e6f2d0fb6..afa306218 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFilter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFilter.java @@ -22,83 +22,70 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerFilter extends Container{ +public class ContainerFilter extends Container { public static final int SLOT_AMOUNT = 24; private final ItemStackHandlerAA filterInventory = new ItemStackHandlerAA(SLOT_AMOUNT); private final InventoryPlayer inventory; - public ContainerFilter(InventoryPlayer inventory){ + public ContainerFilter(InventoryPlayer inventory) { this.inventory = inventory; - for(int i = 0; i < 4; i++){ - for(int j = 0; j < 6; j++){ - this.addSlotToContainer(new SlotFilter(this.filterInventory, j+i*6, 35+j*18, 10+i*18)); + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 6; j++) { + this.addSlotToContainer(new SlotFilter(this.filterInventory, j + i * 6, 35 + j * 18, 10 + i * 18)); } } - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 94+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 94 + i * 18)); } } - for(int i = 0; i < 9; i++){ - if(i == inventory.currentItem){ - this.addSlotToContainer(new SlotImmovable(inventory, i, 8+i*18, 152)); - } - else{ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 152)); + for (int i = 0; i < 9; i++) { + if (i == inventory.currentItem) { + this.addSlotToContainer(new SlotImmovable(inventory, i, 8 + i * 18, 152)); + } else { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 152)); } } ItemStack stack = inventory.getCurrentItem(); - if(SlotFilter.isFilter(stack)){ + if (SlotFilter.isFilter(stack)) { ItemDrill.loadSlotsFromNBT(this.filterInventory, inventory.getCurrentItem()); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = SLOT_AMOUNT; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ + if (slot >= inventoryStart) { //Shift from Inventory // - if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -107,29 +94,27 @@ public class ContainerFilter extends Container{ } @Override - public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player){ - if(SlotFilter.checkFilter(this, slotId, player)){ + public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) { + if (SlotFilter.checkFilter(this, slotId, player)) { return StackUtil.getEmpty(); - } - else if(clickTypeIn == ClickType.SWAP && dragType == this.inventory.currentItem){ + } else if (clickTypeIn == ClickType.SWAP && dragType == this.inventory.currentItem) { return ItemStack.EMPTY; - } - else{ + } else { return super.slotClick(slotId, dragType, clickTypeIn, player); } } @Override - public void onContainerClosed(EntityPlayer player){ + public void onContainerClosed(EntityPlayer player) { ItemStack stack = this.inventory.getCurrentItem(); - if(SlotFilter.isFilter(stack)){ + if (SlotFilter.isFilter(stack)) { ItemDrill.writeSlotsToNBT(this.filterInventory, this.inventory.getCurrentItem()); } super.onContainerClosed(player); } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return true; } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFireworkBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFireworkBox.java index cbd3b0827..319210ce0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFireworkBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFireworkBox.java @@ -14,15 +14,15 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; -public class ContainerFireworkBox extends Container{ +public class ContainerFireworkBox extends Container { @Override - public ItemStack transferStackInSlot(EntityPlayer playerIn, int index){ + public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { return ItemStack.EMPTY; } @Override - public boolean canInteractWith(EntityPlayer playerIn){ + public boolean canInteractWith(EntityPlayer playerIn) { return true; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFluidCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFluidCollector.java index 39b316a91..1fbf30a60 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFluidCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFluidCollector.java @@ -19,69 +19,55 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerFluidCollector extends Container{ +public class ContainerFluidCollector extends Container { private final TileEntityFluidCollector collector; - public ContainerFluidCollector(InventoryPlayer inventory, TileEntityBase tile){ - this.collector = (TileEntityFluidCollector)tile; + public ContainerFluidCollector(InventoryPlayer inventory, TileEntityBase tile) { + this.collector = (TileEntityFluidCollector) tile; - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 0; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Slots in Inventory to shift from - if(slot == 1){ - if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, true)){ - return StackUtil.getEmpty(); - } + if (slot == 1) { + if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, true)) { return StackUtil.getEmpty(); } theSlot.onSlotChange(newStack, currentStack); } //Other Slots in Inventory excluded - else if(slot >= inventoryStart){ - if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + else if (slot >= inventoryStart) { + if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -90,7 +76,7 @@ public class ContainerFluidCollector extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.collector.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFurnaceDouble.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFurnaceDouble.java index bef7cb0d4..c11205223 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFurnaceDouble.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFurnaceDouble.java @@ -22,84 +22,68 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; - -public class ContainerFurnaceDouble extends Container{ +public class ContainerFurnaceDouble extends Container { private final TileEntityFurnaceDouble tileFurnace; - public ContainerFurnaceDouble(InventoryPlayer inventory, TileEntityBase tile){ - this.tileFurnace = (TileEntityFurnaceDouble)tile; + public ContainerFurnaceDouble(InventoryPlayer inventory, TileEntityBase tile) { + this.tileFurnace = (TileEntityFurnaceDouble) tile; this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileFurnace.inv, TileEntityFurnaceDouble.SLOT_INPUT_1, 51, 21)); this.addSlotToContainer(new SlotOutput(this.tileFurnace.inv, TileEntityFurnaceDouble.SLOT_OUTPUT_1, 51, 69)); this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileFurnace.inv, TileEntityFurnaceDouble.SLOT_INPUT_2, 109, 21)); this.addSlotToContainer(new SlotOutput(this.tileFurnace.inv, TileEntityFurnaceDouble.SLOT_OUTPUT_2, 108, 69)); - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 4; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Slots in Inventory to shift from - if(slot == TileEntityFurnaceDouble.SLOT_OUTPUT_1 || slot == TileEntityFurnaceDouble.SLOT_OUTPUT_2){ - if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, true)){ - return StackUtil.getEmpty(); - } + if (slot == TileEntityFurnaceDouble.SLOT_OUTPUT_1 || slot == TileEntityFurnaceDouble.SLOT_OUTPUT_2) { + if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, true)) { return StackUtil.getEmpty(); } theSlot.onSlotChange(newStack, currentStack); } //Other Slots in Inventory excluded - else if(slot >= inventoryStart){ + else if (slot >= inventoryStart) { //Shift from Inventory - if(StackUtil.isValid(FurnaceRecipes.instance().getSmeltingResult(newStack))){ - if(!this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_1, TileEntityFurnaceDouble.SLOT_INPUT_1+1, false)){ - if(!this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_2, TileEntityFurnaceDouble.SLOT_INPUT_2+1, false)){ - return StackUtil.getEmpty(); - } + if (StackUtil.isValid(FurnaceRecipes.instance().getSmeltingResult(newStack))) { + if (!this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_1, TileEntityFurnaceDouble.SLOT_INPUT_1 + 1, false)) { + if (!this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_2, TileEntityFurnaceDouble.SLOT_INPUT_2 + 1, false)) { return StackUtil.getEmpty(); } } } // - else if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + else if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -108,7 +92,7 @@ public class ContainerFurnaceDouble extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.tileFurnace.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerGiantChest.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerGiantChest.java index 31e901478..4ea41feeb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerGiantChest.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerGiantChest.java @@ -22,71 +22,60 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; @ChestContainer(rowSize = 13, isLargeChest = true) -public class ContainerGiantChest extends Container{ +public class ContainerGiantChest extends Container { public final TileEntityGiantChest tileChest; - public ContainerGiantChest(InventoryPlayer inventory, TileEntityBase tile, int page){ - this.tileChest = (TileEntityGiantChest)tile; + public ContainerGiantChest(InventoryPlayer inventory, TileEntityBase tile, int page) { + this.tileChest = (TileEntityGiantChest) tile; - for(int i = 0; i < 9; i++){ - for(int j = 0; j < 13; j++){ - this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileChest.inv, 9*13*page+j+i*13, 5+j*18, 5+i*18)); + for (int i = 0; i < 9; i++) { + for (int j = 0; j < 13; j++) { + this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileChest.inv, 9 * 13 * page + j + i * 13, 5 + j * 18, 5 + i * 18)); } } - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 33+8+j*18, 172+4+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 33 + 8 + j * 18, 172 + 4 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 33+8+i*18, 172+62)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 33 + 8 + i * 18, 172 + 62)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 117; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ + if (slot >= inventoryStart) { //Shift from Inventory - if(!this.mergeItemStack(newStack, 0, 117, false)){ + if (!this.mergeItemStack(newStack, 0, 117, false)) { // - if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } + if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, true)){ - return StackUtil.getEmpty(); - } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, true)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -95,7 +84,7 @@ public class ContainerGiantChest extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.tileChest.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerGrinder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerGrinder.java index 88b4cfe86..2edaab084 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerGrinder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerGrinder.java @@ -22,95 +22,78 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerGrinder extends Container{ +public class ContainerGrinder extends Container { public final TileEntityGrinder tileGrinder; private final boolean isDouble; - public ContainerGrinder(InventoryPlayer inventory, TileEntityBase tile, boolean isDouble){ - this.tileGrinder = (TileEntityGrinder)tile; + public ContainerGrinder(InventoryPlayer inventory, TileEntityBase tile, boolean isDouble) { + this.tileGrinder = (TileEntityGrinder) tile; this.isDouble = isDouble; this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileGrinder.inv, TileEntityGrinder.SLOT_INPUT_1, this.isDouble ? 51 : 80, 21)); this.addSlotToContainer(new SlotOutput(this.tileGrinder.inv, TileEntityGrinder.SLOT_OUTPUT_1_1, this.isDouble ? 37 : 66, 69)); this.addSlotToContainer(new SlotOutput(this.tileGrinder.inv, TileEntityGrinder.SLOT_OUTPUT_1_2, this.isDouble ? 64 : 92, 69)); - if(this.isDouble){ + if (this.isDouble) { this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileGrinder.inv, TileEntityGrinder.SLOT_INPUT_2, 109, 21)); this.addSlotToContainer(new SlotOutput(this.tileGrinder.inv, TileEntityGrinder.SLOT_OUTPUT_2_1, 96, 69)); this.addSlotToContainer(new SlotOutput(this.tileGrinder.inv, TileEntityGrinder.SLOT_OUTPUT_2_2, 121, 69)); } - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = this.isDouble ? 6 : 3; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Slots in Inventory to shift from - if(slot == TileEntityGrinder.SLOT_OUTPUT_1_1 || slot == TileEntityGrinder.SLOT_OUTPUT_1_2 || this.isDouble && (slot == TileEntityGrinder.SLOT_OUTPUT_2_1 || slot == TileEntityGrinder.SLOT_OUTPUT_2_2)){ - if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, true)){ - return StackUtil.getEmpty(); - } + if (slot == TileEntityGrinder.SLOT_OUTPUT_1_1 || slot == TileEntityGrinder.SLOT_OUTPUT_1_2 || this.isDouble && (slot == TileEntityGrinder.SLOT_OUTPUT_2_1 || slot == TileEntityGrinder.SLOT_OUTPUT_2_2)) { + if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, true)) { return StackUtil.getEmpty(); } theSlot.onSlotChange(newStack, currentStack); } //Other Slots in Inventory excluded - else if(slot >= inventoryStart){ + else if (slot >= inventoryStart) { //Shift from Inventory - if(CrusherRecipeRegistry.getRecipeFromInput(newStack) != null){ - if(!this.mergeItemStack(newStack, TileEntityGrinder.SLOT_INPUT_1, TileEntityGrinder.SLOT_INPUT_1+1, false)){ - if(this.isDouble){ - if(!this.mergeItemStack(newStack, TileEntityGrinder.SLOT_INPUT_2, TileEntityGrinder.SLOT_INPUT_2+1, false)){ - return StackUtil.getEmpty(); - } - } - else{ + if (CrusherRecipeRegistry.getRecipeFromInput(newStack) != null) { + if (!this.mergeItemStack(newStack, TileEntityGrinder.SLOT_INPUT_1, TileEntityGrinder.SLOT_INPUT_1 + 1, false)) { + if (this.isDouble) { + if (!this.mergeItemStack(newStack, TileEntityGrinder.SLOT_INPUT_2, TileEntityGrinder.SLOT_INPUT_2 + 1, false)) { return StackUtil.getEmpty(); } + } else { return StackUtil.getEmpty(); } } } // - else if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + else if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -119,7 +102,7 @@ public class ContainerGrinder extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.tileGrinder.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerInputter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerInputter.java index 00c8b4e54..dc5e6116c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerInputter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerInputter.java @@ -23,81 +23,69 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerInputter extends Container{ +public class ContainerInputter extends Container { private final TileEntityInputter tileInputter; private final boolean isAdvanced; - public ContainerInputter(InventoryPlayer inventory, TileEntityBase tile, boolean isAdvanced){ - this.tileInputter = (TileEntityInputter)tile; + public ContainerInputter(InventoryPlayer inventory, TileEntityBase tile, boolean isAdvanced) { + this.tileInputter = (TileEntityInputter) tile; this.isAdvanced = isAdvanced; - this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileInputter.inv, 0, 80, 21+(isAdvanced ? 12 : 0))); + this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileInputter.inv, 0, 80, 21 + (isAdvanced ? 12 : 0))); - if(isAdvanced){ - for(int i = 0; i < 2; i++){ - for(int x = 0; x < 3; x++){ - for(int y = 0; y < 4; y++){ - this.addSlotToContainer(new SlotFilter(i == 0 ? this.tileInputter.leftFilter : this.tileInputter.rightFilter, y+x*4, 20+i*84+x*18, 6+y*18)); + if (isAdvanced) { + for (int i = 0; i < 2; i++) { + for (int x = 0; x < 3; x++) { + for (int y = 0; y < 4; y++) { + this.addSlotToContainer(new SlotFilter(i == 0 ? this.tileInputter.leftFilter : this.tileInputter.rightFilter, y + x * 4, 20 + i * 84 + x * 18, 6 + y * 18)); } } } } - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 101+i*18+(isAdvanced ? GuiInputter.OFFSET_ADVANCED : 0))); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 101 + i * 18 + (isAdvanced ? GuiInputter.OFFSET_ADVANCED : 0))); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 159+(isAdvanced ? GuiInputter.OFFSET_ADVANCED : 0))); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 159 + (isAdvanced ? GuiInputter.OFFSET_ADVANCED : 0))); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = this.isAdvanced ? 25 : 1; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ + if (slot >= inventoryStart) { //Shift from Inventory - if(!this.mergeItemStack(newStack, 0, 1, false)){ + if (!this.mergeItemStack(newStack, 0, 1, false)) { // - if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } + if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -106,17 +94,16 @@ public class ContainerInputter extends Container{ } @Override - public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player){ - if(SlotFilter.checkFilter(this, slotId, player)){ + public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) { + if (SlotFilter.checkFilter(this, slotId, player)) { return StackUtil.getEmpty(); - } - else{ + } else { return super.slotClick(slotId, dragType, clickTypeIn, player); } } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.tileInputter.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerLaserRelayItemWhitelist.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerLaserRelayItemWhitelist.java index db546dd31..178b98bf4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerLaserRelayItemWhitelist.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerLaserRelayItemWhitelist.java @@ -21,70 +21,58 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerLaserRelayItemWhitelist extends Container{ +public class ContainerLaserRelayItemWhitelist extends Container { private final TileEntityLaserRelayItemWhitelist tile; - public ContainerLaserRelayItemWhitelist(InventoryPlayer inventory, TileEntityBase tile){ - this.tile = (TileEntityLaserRelayItemWhitelist)tile; + public ContainerLaserRelayItemWhitelist(InventoryPlayer inventory, TileEntityBase tile) { + this.tile = (TileEntityLaserRelayItemWhitelist) tile; - for(int i = 0; i < 2; i++){ - for(int x = 0; x < 3; x++){ - for(int y = 0; y < 4; y++){ - this.addSlotToContainer(new SlotFilter(i == 0 ? this.tile.leftFilter : this.tile.rightFilter, y+x*4, 20+i*84+x*18, 6+y*18)); + for (int i = 0; i < 2; i++) { + for (int x = 0; x < 3; x++) { + for (int y = 0; y < 4; y++) { + this.addSlotToContainer(new SlotFilter(i == 0 ? this.tile.leftFilter : this.tile.rightFilter, y + x * 4, 20 + i * 84 + x * 18, 6 + y * 18)); } } } - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 24; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ - if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + if (slot >= inventoryStart) { + if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -93,17 +81,16 @@ public class ContainerLaserRelayItemWhitelist extends Container{ } @Override - public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player){ - if(SlotFilter.checkFilter(this, slotId, player)){ + public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) { + if (SlotFilter.checkFilter(this, slotId, player)) { return StackUtil.getEmpty(); - } - else{ + } else { return super.slotClick(slotId, dragType, clickTypeIn, player); } } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.tile.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerMiner.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerMiner.java index 77e1189ef..b85faa13f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerMiner.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerMiner.java @@ -20,72 +20,60 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerMiner extends Container{ +public class ContainerMiner extends Container { private final TileEntityMiner miner; - public ContainerMiner(InventoryPlayer inventory, TileEntityBase tile){ - this.miner = (TileEntityMiner)tile; + public ContainerMiner(InventoryPlayer inventory, TileEntityBase tile) { + this.miner = (TileEntityMiner) tile; - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 3; j++){ - this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.miner.inv, j+i*3, 62+j*18, 21+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.miner.inv, j + i * 3, 62 + j * 18, 21 + i * 18)); } } - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 9; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ + if (slot >= inventoryStart) { //Shift from Inventory - if(!this.mergeItemStack(newStack, 0, 9, false)){ + if (!this.mergeItemStack(newStack, 0, 9, false)) { // - if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } + if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -94,7 +82,7 @@ public class ContainerMiner extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.miner.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerOilGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerOilGenerator.java index e067df46d..3c96a3230 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerOilGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerOilGenerator.java @@ -19,61 +19,50 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerOilGenerator extends Container{ +public class ContainerOilGenerator extends Container { private final TileEntityOilGenerator generator; - public ContainerOilGenerator(InventoryPlayer inventory, TileEntityBase tile){ - this.generator = (TileEntityOilGenerator)tile; + public ContainerOilGenerator(InventoryPlayer inventory, TileEntityBase tile) { + this.generator = (TileEntityOilGenerator) tile; - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 0; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ - if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + if (slot >= inventoryStart) { + if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -82,7 +71,7 @@ public class ContainerOilGenerator extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.generator.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerPhantomPlacer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerPhantomPlacer.java index 0a236223a..69ad4b61c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerPhantomPlacer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerPhantomPlacer.java @@ -20,72 +20,60 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerPhantomPlacer extends Container{ +public class ContainerPhantomPlacer extends Container { private final TileEntityPhantomPlacer placer; - public ContainerPhantomPlacer(InventoryPlayer inventory, TileEntityBase tile){ - this.placer = (TileEntityPhantomPlacer)tile; + public ContainerPhantomPlacer(InventoryPlayer inventory, TileEntityBase tile) { + this.placer = (TileEntityPhantomPlacer) tile; - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 3; j++){ - this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.placer.inv, j+i*3, 62+j*18, 21+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.placer.inv, j + i * 3, 62 + j * 18, 21 + i * 18)); } } - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 9; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ + if (slot >= inventoryStart) { //Shift from Inventory - if(!this.mergeItemStack(newStack, 0, 9, false)){ + if (!this.mergeItemStack(newStack, 0, 9, false)) { // - if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } + if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -94,7 +82,7 @@ public class ContainerPhantomPlacer extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.placer.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerRangedCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerRangedCollector.java index a11c15ae0..b5e360a40 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerRangedCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerRangedCollector.java @@ -22,77 +22,65 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerRangedCollector extends Container{ +public class ContainerRangedCollector extends Container { private final TileEntityRangedCollector collector; - public ContainerRangedCollector(InventoryPlayer inventory, TileEntityBase tile){ - this.collector = (TileEntityRangedCollector)tile; + public ContainerRangedCollector(InventoryPlayer inventory, TileEntityBase tile) { + this.collector = (TileEntityRangedCollector) tile; - for(int i = 0; i < 2; i++){ - for(int j = 0; j < 3; j++){ - this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.collector.inv, j+i*3, 96+j*18, 24+i*18)); + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 3; j++) { + this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.collector.inv, j + i * 3, 96 + j * 18, 24 + i * 18)); } } - for(int i = 0; i < 4; i++){ - for(int j = 0; j < 3; j++){ - this.addSlotToContainer(new SlotFilter(this.collector.filter, j+i*3, 20+j*18, 6+i*18)); + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 3; j++) { + this.addSlotToContainer(new SlotFilter(this.collector.filter, j + i * 3, 20 + j * 18, 6 + i * 18)); } } - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 90+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 90 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 148)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 148)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 18; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ + if (slot >= inventoryStart) { //Shift from Inventory - if(!this.mergeItemStack(newStack, 0, 6, false)){ + if (!this.mergeItemStack(newStack, 0, 6, false)) { // - if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } + if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -101,17 +89,16 @@ public class ContainerRangedCollector extends Container{ } @Override - public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player){ - if(SlotFilter.checkFilter(this, slotId, player)){ + public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) { + if (SlotFilter.checkFilter(this, slotId, player)) { return StackUtil.getEmpty(); - } - else{ + } else { return super.slotClick(slotId, dragType, clickTypeIn, player); } } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.collector.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerRepairer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerRepairer.java index 12756aeb5..6ca69a116 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerRepairer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerRepairer.java @@ -21,73 +21,59 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerRepairer extends Container{ +public class ContainerRepairer extends Container { private final TileEntityItemRepairer tileRepairer; - public ContainerRepairer(InventoryPlayer inventory, TileEntityBase tile){ - this.tileRepairer = (TileEntityItemRepairer)tile; + public ContainerRepairer(InventoryPlayer inventory, TileEntityBase tile) { + this.tileRepairer = (TileEntityItemRepairer) tile; this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileRepairer.inv, TileEntityItemRepairer.SLOT_INPUT, 47, 53)); this.addSlotToContainer(new SlotOutput(this.tileRepairer.inv, TileEntityItemRepairer.SLOT_OUTPUT, 109, 53)); - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 2; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ + if (slot >= inventoryStart) { //Shift from Inventory - if(TileEntityItemRepairer.canBeRepaired(newStack)){ - if(!this.mergeItemStack(newStack, TileEntityItemRepairer.SLOT_INPUT, TileEntityItemRepairer.SLOT_INPUT+1, false)){ - return StackUtil.getEmpty(); - } + if (TileEntityItemRepairer.canBeRepaired(newStack)) { + if (!this.mergeItemStack(newStack, TileEntityItemRepairer.SLOT_INPUT, TileEntityItemRepairer.SLOT_INPUT + 1, false)) { return StackUtil.getEmpty(); } } // - else if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + else if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -96,7 +82,7 @@ public class ContainerRepairer extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.tileRepairer.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerSmileyCloud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerSmileyCloud.java index 4f70f0a4e..6cfd89925 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerSmileyCloud.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerSmileyCloud.java @@ -14,15 +14,15 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; -public class ContainerSmileyCloud extends Container{ +public class ContainerSmileyCloud extends Container { @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { return ItemStack.EMPTY; } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return true; } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerXPSolidifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerXPSolidifier.java index ab8fe986b..c2fb8ceee 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerXPSolidifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerXPSolidifier.java @@ -22,70 +22,55 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - -public class ContainerXPSolidifier extends Container{ +public class ContainerXPSolidifier extends Container { private final TileEntityXPSolidifier solidifier; - public ContainerXPSolidifier(InventoryPlayer inventory, TileEntityBase tile){ - this.solidifier = (TileEntityXPSolidifier)tile; + public ContainerXPSolidifier(InventoryPlayer inventory, TileEntityBase tile) { + this.solidifier = (TileEntityXPSolidifier) tile; this.addSlotToContainer(new SlotOutput(this.solidifier.inv, 0, 95, 8)); this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.solidifier.inv, 1, 65, 8)); - for(int i = 0; i < 3; i++){ - for(int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18)); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); } } - for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155)); + for (int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } } @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + public ItemStack transferStackInSlot(EntityPlayer player, int slot) { int inventoryStart = 2; - int inventoryEnd = inventoryStart+26; - int hotbarStart = inventoryEnd+1; - int hotbarEnd = hotbarStart+8; + int inventoryEnd = inventoryStart + 26; + int hotbarStart = inventoryEnd + 1; + int hotbarEnd = hotbarStart + 8; Slot theSlot = this.inventorySlots.get(slot); - if(theSlot != null && theSlot.getHasStack()){ + if (theSlot != null && theSlot.getHasStack()) { ItemStack newStack = theSlot.getStack(); ItemStack currentStack = newStack.copy(); //Other Slots in Inventory excluded - if(slot >= inventoryStart){ - if(newStack.getItem() instanceof ItemSolidifiedExperience){ - if(!this.mergeItemStack(newStack, 1, 2, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryStart && slot <= inventoryEnd){ - if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){ - return StackUtil.getEmpty(); - } - } - else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){ - return StackUtil.getEmpty(); - } + if (slot >= inventoryStart) { + if (newStack.getItem() instanceof ItemSolidifiedExperience) { + if (!this.mergeItemStack(newStack, 1, 2, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryStart && slot <= inventoryEnd) { + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - if(!StackUtil.isValid(newStack)){ + if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); - } - else{ + } else { theSlot.onSlotChanged(); } - if(newStack.getCount() == currentStack.getCount()){ - return StackUtil.getEmpty(); - } + if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } theSlot.onTake(player, newStack); return currentStack; @@ -94,7 +79,7 @@ public class ContainerXPSolidifier extends Container{ } @Override - public boolean canInteractWith(EntityPlayer player){ + public boolean canInteractWith(EntityPlayer player) { return this.solidifier.canPlayerUse(player); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/GuiFireworkBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/GuiFireworkBox.java index ad3914393..98c518c36 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/GuiFireworkBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/GuiFireworkBox.java @@ -22,91 +22,91 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiFireworkBox extends GuiContainer implements GuiResponder{ +public class GuiFireworkBox extends GuiContainer implements GuiResponder { private final TileEntityFireworkBox tile; - public GuiFireworkBox(TileEntity tile){ + public GuiFireworkBox(TileEntity tile) { super(new ContainerFireworkBox()); - this.tile = (TileEntityFireworkBox)tile; + this.tile = (TileEntityFireworkBox) tile; this.xSize = 300; this.ySize = 120; } @Override - public void initGui(){ + public void initGui() { super.initGui(); this.buttonList.add(new CustomSlider(this, 0, this.guiLeft, this.guiTop, "Value Play", 0F, 5F, this.tile.intValuePlay, IntFormatter.INSTANCE)); - this.buttonList.add(new CustomSlider(this, 1, this.guiLeft, this.guiTop+20, "Average Charge Amount", 1F, 4F, this.tile.chargeAmount, IntFormatter.INSTANCE)); - this.buttonList.add(new CustomSlider(this, 2, this.guiLeft, this.guiTop+40, "Average Flight Time", 1F, 3F, this.tile.flightTime, IntFormatter.INSTANCE)); - this.buttonList.add(new CustomSlider(this, 3, this.guiLeft, this.guiTop+60, "Effect Chance", 0F, 1F, this.tile.trailOrFlickerChance, null)); - this.buttonList.add(new CustomSlider(this, 4, this.guiLeft, this.guiTop+80, "Flicker/Trail Ratio", 0F, 1F, this.tile.flickerChance, null)); - this.buttonList.add(new CustomSlider(this, 5, this.guiLeft, this.guiTop+100, "Color Amount", 1, 6, this.tile.colorAmount, IntFormatter.INSTANCE)); + this.buttonList.add(new CustomSlider(this, 1, this.guiLeft, this.guiTop + 20, "Average Charge Amount", 1F, 4F, this.tile.chargeAmount, IntFormatter.INSTANCE)); + this.buttonList.add(new CustomSlider(this, 2, this.guiLeft, this.guiTop + 40, "Average Flight Time", 1F, 3F, this.tile.flightTime, IntFormatter.INSTANCE)); + this.buttonList.add(new CustomSlider(this, 3, this.guiLeft, this.guiTop + 60, "Effect Chance", 0F, 1F, this.tile.trailOrFlickerChance, null)); + this.buttonList.add(new CustomSlider(this, 4, this.guiLeft, this.guiTop + 80, "Flicker/Trail Ratio", 0F, 1F, this.tile.flickerChance, null)); + this.buttonList.add(new CustomSlider(this, 5, this.guiLeft, this.guiTop + 100, "Color Amount", 1, 6, this.tile.colorAmount, IntFormatter.INSTANCE)); - this.buttonList.add(new CustomSlider(this, 6, this.guiLeft+150, this.guiTop, "Small Ball", 0F, 1F, this.tile.typeChance0, null)); - this.buttonList.add(new CustomSlider(this, 7, this.guiLeft+150, this.guiTop+20, "Large Ball", 0F, 1F, this.tile.typeChance1, null)); - this.buttonList.add(new CustomSlider(this, 8, this.guiLeft+150, this.guiTop+40, "Star Shape", 0F, 1F, this.tile.typeChance2, null)); - this.buttonList.add(new CustomSlider(this, 9, this.guiLeft+150, this.guiTop+60, "Creeper Shape", 0F, 1F, this.tile.typeChance3, null)); - this.buttonList.add(new CustomSlider(this, 10, this.guiLeft+150, this.guiTop+80, "Burst", 0F, 1F, this.tile.typeChance4, null)); + this.buttonList.add(new CustomSlider(this, 6, this.guiLeft + 150, this.guiTop, "Small Ball", 0F, 1F, this.tile.typeChance0, null)); + this.buttonList.add(new CustomSlider(this, 7, this.guiLeft + 150, this.guiTop + 20, "Large Ball", 0F, 1F, this.tile.typeChance1, null)); + this.buttonList.add(new CustomSlider(this, 8, this.guiLeft + 150, this.guiTop + 40, "Star Shape", 0F, 1F, this.tile.typeChance2, null)); + this.buttonList.add(new CustomSlider(this, 9, this.guiLeft + 150, this.guiTop + 60, "Creeper Shape", 0F, 1F, this.tile.typeChance3, null)); + this.buttonList.add(new CustomSlider(this, 10, this.guiLeft + 150, this.guiTop + 80, "Burst", 0F, 1F, this.tile.typeChance4, null)); - this.buttonList.add(new CustomSlider(this, 11, this.guiLeft+150, this.guiTop+100, "Area of Effect", 0, 4, this.tile.areaOfEffect, IntFormatter.INSTANCE)); + this.buttonList.add(new CustomSlider(this, 11, this.guiLeft + 150, this.guiTop + 100, "Area of Effect", 0, 4, this.tile.areaOfEffect, IntFormatter.INSTANCE)); } @Override - public void setEntryValue(int id, float value){ + public void setEntryValue(int id, float value) { GuiButton button = this.buttonList.get(id); - if(button instanceof GuiSlider){ - if(!((GuiSlider)button).isMouseDown){ - System.out.println("SETTING VALUE FOR "+id+"!!"); + if (button instanceof GuiSlider) { + if (!((GuiSlider) button).isMouseDown) { + System.out.println("SETTING VALUE FOR " + id + "!!"); PacketHandlerHelper.sendNumberPacket(this.tile, value, id); } } } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY){ + protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.tile); } @Override - public void setEntryValue(int id, boolean value){ + public void setEntryValue(int id, boolean value) { } @Override - public void setEntryValue(int id, String value){ + public void setEntryValue(int id, String value) { } - private static class CustomSlider extends GuiSlider{ + private static class CustomSlider extends GuiSlider { private final GuiResponder responder; - public CustomSlider(GuiResponder guiResponder, int idIn, int x, int y, String name, float min, float max, float defaultValue, FormatHelper formatter){ + public CustomSlider(GuiResponder guiResponder, int idIn, int x, int y, String name, float min, float max, float defaultValue, FormatHelper formatter) { super(guiResponder, idIn, x, y, name, min, max, defaultValue, formatter); this.responder = guiResponder; } @Override - public void mouseReleased(int mouseX, int mouseY){ + public void mouseReleased(int mouseX, int mouseY) { super.mouseReleased(mouseX, mouseY); this.responder.setEntryValue(this.id, this.getSliderValue()); } } - private static class IntFormatter implements GuiSlider.FormatHelper{ + private static class IntFormatter implements GuiSlider.FormatHelper { public static final IntFormatter INSTANCE = new IntFormatter(); @Override - public String getText(int id, String name, float value){ - return name+": "+(int)value; + public String getText(int id, String name, float value) { + return name + ": " + (int) value; } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/GuiHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/GuiHandler.java index 4b95dec0d..18c7f7879 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/GuiHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/GuiHandler.java @@ -52,20 +52,20 @@ import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; import net.minecraftforge.fml.common.network.NetworkRegistry; -public class GuiHandler implements IGuiHandler{ +public class GuiHandler implements IGuiHandler { - public static void init(){ + public static void init() { ActuallyAdditions.LOGGER.info("Initializing GuiHandler..."); NetworkRegistry.INSTANCE.registerGuiHandler(ActuallyAdditions.INSTANCE, new GuiHandler()); } @Override - public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z){ + public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { TileEntityBase tile = null; - if(GuiTypes.values()[id].checkTileEntity){ - tile = (TileEntityBase)world.getTileEntity(new BlockPos(x, y, z)); + if (GuiTypes.values()[id].checkTileEntity) { + tile = (TileEntityBase) world.getTileEntity(new BlockPos(x, y, z)); } - switch(GuiTypes.values()[id]){ + switch (GuiTypes.values()[id]) { case FEEDER: return new ContainerFeeder(player.inventory, tile); case GIANT_CHEST: @@ -142,12 +142,12 @@ public class GuiHandler implements IGuiHandler{ } @Override - public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z){ + public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { TileEntityBase tile = null; - if(GuiTypes.values()[id].checkTileEntity){ - tile = (TileEntityBase)world.getTileEntity(new BlockPos(x, y, z)); + if (GuiTypes.values()[id].checkTileEntity) { + tile = (TileEntityBase) world.getTileEntity(new BlockPos(x, y, z)); } - switch(GuiTypes.values()[id]){ + switch (GuiTypes.values()[id]) { case FEEDER: return new GuiFeeder(player.inventory, tile); case GIANT_CHEST: @@ -201,17 +201,15 @@ public class GuiHandler implements IGuiHandler{ case CLOUD: return new GuiSmileyCloud(tile, x, y, z, world); case BOOK: - if(ItemBooklet.forcedPage != null){ + if (ItemBooklet.forcedPage != null) { GuiBooklet gui = BookletUtils.createBookletGuiFromPage(null, ItemBooklet.forcedPage); ItemBooklet.forcedPage = null; return gui; - } - else{ + } else { PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player); - if(data.lastOpenBooklet != null){ + if (data.lastOpenBooklet != null) { return data.lastOpenBooklet; - } - else{ + } else { return new GuiMainPage(null); } } @@ -238,7 +236,7 @@ public class GuiHandler implements IGuiHandler{ } } - public enum GuiTypes{ + public enum GuiTypes { FEEDER, GIANT_CHEST, GIANT_CHEST_PAGE_2, @@ -278,11 +276,11 @@ public class GuiHandler implements IGuiHandler{ public final boolean checkTileEntity; - GuiTypes(){ + GuiTypes() { this(true); } - GuiTypes(boolean checkTileEntity){ + GuiTypes(boolean checkTileEntity) { this.checkTileEntity = checkTileEntity; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/EnergyDisplay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/EnergyDisplay.java index 991f10fe4..97e00004d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/EnergyDisplay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/EnergyDisplay.java @@ -10,6 +10,10 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.List; + import de.ellpeck.actuallyadditions.mod.tile.CustomEnergyStorage; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil; @@ -20,12 +24,8 @@ import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.List; - @SideOnly(Side.CLIENT) -public class EnergyDisplay extends Gui{ +public class EnergyDisplay extends Gui { private CustomEnergyStorage rfReference; private int x; @@ -33,15 +33,15 @@ public class EnergyDisplay extends Gui{ private boolean outline; private boolean drawTextNextTo; - public EnergyDisplay(int x, int y, CustomEnergyStorage rfReference, boolean outline, boolean drawTextNextTo){ + public EnergyDisplay(int x, int y, CustomEnergyStorage rfReference, boolean outline, boolean drawTextNextTo) { this.setData(x, y, rfReference, outline, drawTextNextTo); } - public EnergyDisplay(int x, int y, CustomEnergyStorage rfReference){ + public EnergyDisplay(int x, int y, CustomEnergyStorage rfReference) { this(x, y, rfReference, false, false); } - public void setData(int x, int y, CustomEnergyStorage rfReference, boolean outline, boolean drawTextNextTo){ + public void setData(int x, int y, CustomEnergyStorage rfReference, boolean outline, boolean drawTextNextTo) { this.x = x; this.y = y; this.rfReference = rfReference; @@ -49,14 +49,14 @@ public class EnergyDisplay extends Gui{ this.drawTextNextTo = drawTextNextTo; } - public void draw(){ + public void draw() { Minecraft mc = Minecraft.getMinecraft(); mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); int barX = this.x; int barY = this.y; - if(this.outline){ + if (this.outline) { this.drawTexturedModalRect(this.x, this.y, 52, 163, 26, 93); barX += 4; @@ -64,22 +64,22 @@ public class EnergyDisplay extends Gui{ } this.drawTexturedModalRect(barX, barY, 18, 171, 18, 85); - if(this.rfReference.getEnergyStored() > 0){ - int i = this.rfReference.getEnergyStored()*83/this.rfReference.getMaxEnergyStored(); + if (this.rfReference.getEnergyStored() > 0) { + int i = this.rfReference.getEnergyStored() * 83 / this.rfReference.getMaxEnergyStored(); - float[] color = AssetUtil.getWheelColor(mc.world.getTotalWorldTime()%256); - GlStateManager.color(color[0]/255F, color[1]/255F, color[2]/255F); - this.drawTexturedModalRect(barX+1, barY+84-i, 36, 172, 16, i); + float[] color = AssetUtil.getWheelColor(mc.world.getTotalWorldTime() % 256); + GlStateManager.color(color[0] / 255F, color[1] / 255F, color[2] / 255F); + this.drawTexturedModalRect(barX + 1, barY + 84 - i, 36, 172, 16, i); GlStateManager.color(1F, 1F, 1F); } - if(this.drawTextNextTo){ - this.drawString(mc.fontRenderer, this.getOverlayText(), barX+25, barY+78, StringUtil.DECIMAL_COLOR_WHITE); + if (this.drawTextNextTo) { + this.drawString(mc.fontRenderer, this.getOverlayText(), barX + 25, barY + 78, StringUtil.DECIMAL_COLOR_WHITE); } } - public void drawOverlay(int mouseX, int mouseY){ - if(this.isMouseOver(mouseX, mouseY)){ + public void drawOverlay(int mouseX, int mouseY) { + if (this.isMouseOver(mouseX, mouseY)) { Minecraft mc = Minecraft.getMinecraft(); List text = new ArrayList<>(); @@ -88,11 +88,11 @@ public class EnergyDisplay extends Gui{ } } - private boolean isMouseOver(int mouseX, int mouseY){ - return mouseX >= this.x && mouseY >= this.y && mouseX < this.x+(this.outline ? 26 : 18) && mouseY < this.y+(this.outline ? 93 : 85); + private boolean isMouseOver(int mouseX, int mouseY) { + return mouseX >= this.x && mouseY >= this.y && mouseX < this.x + (this.outline ? 26 : 18) && mouseY < this.y + (this.outline ? 93 : 85); } - private String getOverlayText(){ + private String getOverlayText() { NumberFormat format = NumberFormat.getInstance(); return String.format("%s/%s Crystal Flux", format.format(this.rfReference.getEnergyStored()), format.format(this.rfReference.getMaxEnergyStored())); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FilterSettingsGui.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FilterSettingsGui.java index 123e0df3d..16022195f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FilterSettingsGui.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FilterSettingsGui.java @@ -10,6 +10,10 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiInputter.SmallerButton; import de.ellpeck.actuallyadditions.mod.tile.FilterSettings; @@ -22,12 +26,8 @@ import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - @SideOnly(Side.CLIENT) -public class FilterSettingsGui extends Gui{ +public class FilterSettingsGui extends Gui { private final FilterSettings theSettings; @@ -37,7 +37,7 @@ public class FilterSettingsGui extends Gui{ public SmallerButton modButton; public SmallerButton oredictButton; - public FilterSettingsGui(FilterSettings settings, int x, int y, List buttonList){ + public FilterSettingsGui(FilterSettings settings, int x, int y, List buttonList) { this.theSettings = settings; this.whitelistButton = new SmallerButton(this.theSettings.whitelistButtonId, x, y, "", true); @@ -58,51 +58,46 @@ public class FilterSettingsGui extends Gui{ this.update(); } - public void update(){ - this.whitelistButton.displayString = (this.theSettings.isWhitelist ? TextFormatting.DARK_GREEN : TextFormatting.RED)+"WH"; - this.metaButton.displayString = (this.theSettings.respectMeta ? TextFormatting.DARK_GREEN : TextFormatting.RED)+"ME"; - this.nbtButton.displayString = (this.theSettings.respectNBT ? TextFormatting.DARK_GREEN : TextFormatting.RED)+"NB"; - this.modButton.displayString = (this.theSettings.respectMod ? TextFormatting.DARK_GREEN : TextFormatting.RED)+"MO"; - this.oredictButton.displayString = (this.theSettings.respectOredict == 0 ? TextFormatting.RED : this.theSettings.respectOredict == 1 ? TextFormatting.GREEN : TextFormatting.DARK_GREEN)+"OR"; + public void update() { + this.whitelistButton.displayString = (this.theSettings.isWhitelist ? TextFormatting.DARK_GREEN : TextFormatting.RED) + "WH"; + this.metaButton.displayString = (this.theSettings.respectMeta ? TextFormatting.DARK_GREEN : TextFormatting.RED) + "ME"; + this.nbtButton.displayString = (this.theSettings.respectNBT ? TextFormatting.DARK_GREEN : TextFormatting.RED) + "NB"; + this.modButton.displayString = (this.theSettings.respectMod ? TextFormatting.DARK_GREEN : TextFormatting.RED) + "MO"; + this.oredictButton.displayString = (this.theSettings.respectOredict == 0 ? TextFormatting.RED : this.theSettings.respectOredict == 1 ? TextFormatting.GREEN : TextFormatting.DARK_GREEN) + "OR"; } - public void drawHover(int mouseX, int mouseY){ + public void drawHover(int mouseX, int mouseY) { Minecraft mc = Minecraft.getMinecraft(); - if(this.whitelistButton.isMouseOver()){ + if (this.whitelistButton.isMouseOver()) { List list = new ArrayList<>(); - list.add(TextFormatting.BOLD+(this.theSettings.isWhitelist ? StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.whitelist") : StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.blacklist"))); - list.addAll(mc.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("info."+ActuallyAdditions.MODID+".gui.whitelistInfo"), 200)); + list.add(TextFormatting.BOLD + (this.theSettings.isWhitelist ? StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.whitelist") : StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.blacklist"))); + list.addAll(mc.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".gui.whitelistInfo"), 200)); GuiUtils.drawHoveringText(list, mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRenderer); - } - else if(this.metaButton.isMouseOver()){ - GuiUtils.drawHoveringText(Collections.singletonList(TextFormatting.BOLD+(this.theSettings.respectMeta ? StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.respectMeta") : StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.ignoreMeta"))), mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRenderer); - } - else if(this.nbtButton.isMouseOver()){ - GuiUtils.drawHoveringText(Collections.singletonList(TextFormatting.BOLD+(this.theSettings.respectNBT ? StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.respectNBT") : StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.ignoreNBT"))), mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRenderer); - } - else if(this.modButton.isMouseOver()){ + } else if (this.metaButton.isMouseOver()) { + GuiUtils.drawHoveringText(Collections.singletonList(TextFormatting.BOLD + (this.theSettings.respectMeta ? StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.respectMeta") : StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.ignoreMeta"))), mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRenderer); + } else if (this.nbtButton.isMouseOver()) { + GuiUtils.drawHoveringText(Collections.singletonList(TextFormatting.BOLD + (this.theSettings.respectNBT ? StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.respectNBT") : StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.ignoreNBT"))), mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRenderer); + } else if (this.modButton.isMouseOver()) { List list = new ArrayList<>(); - list.add(TextFormatting.BOLD+(this.theSettings.respectMod ? StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.respectMod") : StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.ignoreMod"))); + list.add(TextFormatting.BOLD + (this.theSettings.respectMod ? StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.respectMod") : StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.ignoreMod"))); - list.addAll(mc.fontRenderer.listFormattedStringToWidth(StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.respectModInfo"), 200)); + list.addAll(mc.fontRenderer.listFormattedStringToWidth(StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.respectModInfo"), 200)); GuiUtils.drawHoveringText(list, mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRenderer); - } - else if(this.oredictButton.isMouseOver()){ + } else if (this.oredictButton.isMouseOver()) { List list = new ArrayList<>(); - list.add(TextFormatting.BOLD+(this.theSettings.respectOredict == 0 ? StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.ignoreOredict") : this.theSettings.respectOredict == 1 ? StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.respectOredictSoft") : StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.respectOredictHard"))); + list.add(TextFormatting.BOLD + (this.theSettings.respectOredict == 0 ? StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.ignoreOredict") : this.theSettings.respectOredict == 1 ? StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.respectOredictSoft") : StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.respectOredictHard"))); String type = null; - if(this.theSettings.respectOredict == 1){ + if (this.theSettings.respectOredict == 1) { type = "one"; - } - else if(this.theSettings.respectOredict == 2){ + } else if (this.theSettings.respectOredict == 2) { type = "all"; } - if(type != null){ - list.addAll(mc.fontRenderer.listFormattedStringToWidth(StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.respectOredictInfo."+type), 200)); + if (type != null) { + list.addAll(mc.fontRenderer.listFormattedStringToWidth(StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.respectOredictInfo." + type), 200)); } GuiUtils.drawHoveringText(list, mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRenderer); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FluidDisplay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FluidDisplay.java index 55a8b7b42..31f615196 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FluidDisplay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FluidDisplay.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; +import java.text.NumberFormat; +import java.util.Collections; + import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil; import net.minecraft.client.Minecraft; @@ -23,11 +26,8 @@ import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.text.NumberFormat; -import java.util.Collections; - @SideOnly(Side.CLIENT) -public class FluidDisplay extends Gui{ +public class FluidDisplay extends Gui { private FluidTank fluidReference; private Fluid oldFluid; @@ -40,15 +40,15 @@ public class FluidDisplay extends Gui{ private boolean drawTextNextTo; - public FluidDisplay(int x, int y, FluidTank fluidReference, boolean outline, boolean drawTextNextTo){ + public FluidDisplay(int x, int y, FluidTank fluidReference, boolean outline, boolean drawTextNextTo) { this.setData(x, y, fluidReference, outline, drawTextNextTo); } - public FluidDisplay(int x, int y, FluidTank fluidReference){ + public FluidDisplay(int x, int y, FluidTank fluidReference) { this(x, y, fluidReference, false, false); } - public void setData(int x, int y, FluidTank fluidReference, boolean outline, boolean drawTextNextTo){ + public void setData(int x, int y, FluidTank fluidReference, boolean outline, boolean drawTextNextTo) { this.x = x; this.y = y; this.fluidReference = fluidReference; @@ -56,14 +56,14 @@ public class FluidDisplay extends Gui{ this.drawTextNextTo = drawTextNextTo; } - public void draw(){ + public void draw() { Minecraft mc = Minecraft.getMinecraft(); mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); int barX = this.x; int barY = this.y; - if(this.outline){ + if (this.outline) { this.drawTexturedModalRect(this.x, this.y, 52, 163, 26, 93); barX += 4; @@ -74,44 +74,44 @@ public class FluidDisplay extends Gui{ FluidStack stack = this.fluidReference.getFluid(); Fluid fluid = stack == null ? null : stack.getFluid(); - if(this.resLoc == null || this.oldFluid != fluid){ + if (this.resLoc == null || this.oldFluid != fluid) { this.oldFluid = fluid; - if(fluid != null && fluid.getStill() != null){ - this.resLoc = new ResourceLocation(fluid.getStill().getNamespace(), "textures/"+fluid.getStill().getPath()+".png"); + if (fluid != null && fluid.getStill() != null) { + this.resLoc = new ResourceLocation(fluid.getStill().getNamespace(), "textures/" + fluid.getStill().getPath() + ".png"); } } - if(stack != null && fluid != null && this.resLoc != null){ + if (stack != null && fluid != null && this.resLoc != null) { mc.getTextureManager().bindTexture(this.resLoc); GlStateManager.pushMatrix(); GlStateManager.enableBlend(); GlStateManager.disableAlpha(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - int i = this.fluidReference.getFluidAmount()*83/this.fluidReference.getCapacity(); - Gui.drawModalRectWithCustomSizedTexture(barX+1, barY+84-i, 36, 172, 16, i, 16, 512); + int i = this.fluidReference.getFluidAmount() * 83 / this.fluidReference.getCapacity(); + Gui.drawModalRectWithCustomSizedTexture(barX + 1, barY + 84 - i, 36, 172, 16, i, 16, 512); GlStateManager.disableBlend(); GlStateManager.enableAlpha(); GlStateManager.popMatrix(); } - if(this.drawTextNextTo){ - this.drawString(mc.fontRenderer, this.getOverlayText(), barX+25, barY+78, StringUtil.DECIMAL_COLOR_WHITE); + if (this.drawTextNextTo) { + this.drawString(mc.fontRenderer, this.getOverlayText(), barX + 25, barY + 78, StringUtil.DECIMAL_COLOR_WHITE); } } - public void drawOverlay(int mouseX, int mouseY){ - if(mouseX >= this.x && mouseY >= this.y && mouseX < this.x+(this.outline ? 26 : 18) && mouseY < this.y+(this.outline ? 93 : 85)){ + public void drawOverlay(int mouseX, int mouseY) { + if (mouseX >= this.x && mouseY >= this.y && mouseX < this.x + (this.outline ? 26 : 18) && mouseY < this.y + (this.outline ? 93 : 85)) { Minecraft mc = Minecraft.getMinecraft(); GuiUtils.drawHoveringText(Collections.singletonList(this.getOverlayText()), mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRenderer); } } - private String getOverlayText(){ + private String getOverlayText() { NumberFormat format = NumberFormat.getInstance(); FluidStack stack = this.fluidReference.getFluid(); String cap = format.format(this.fluidReference.getCapacity()); - return stack == null || stack.getFluid() == null ? "0/"+cap+" mB" : format.format(this.fluidReference.getFluidAmount())+"/"+cap+" mB "+stack.getLocalizedName(); + return stack == null || stack.getFluid() == null ? "0/" + cap + " mB" : format.format(this.fluidReference.getFluidAmount()) + "/" + cap + " mB " + stack.getLocalizedName(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBag.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBag.java index fe4157d49..e230d5be5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBag.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBag.java @@ -10,6 +10,10 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.inventory.ContainerBag; import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer; @@ -27,12 +31,8 @@ import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - @SideOnly(Side.CLIENT) -public class GuiBag extends GuiWtfMojang{ +public class GuiBag extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_bag"); private static final ResourceLocation RES_LOC_VOID = AssetUtil.getGuiLocation("gui_void_bag"); @@ -42,30 +42,30 @@ public class GuiBag extends GuiWtfMojang{ private FilterSettingsGui filter; private GuiButton buttonAutoInsert; - public GuiBag(ItemStack sack, InventoryPlayer inventory, boolean isVoid){ + public GuiBag(ItemStack sack, InventoryPlayer inventory, boolean isVoid) { this(isVoid, new ContainerBag(sack, inventory, isVoid)); } - private GuiBag(boolean isVoid, ContainerBag container){ + private GuiBag(boolean isVoid, ContainerBag container) { super(container); this.xSize = 176; - this.ySize = 90+86; + this.ySize = 90 + 86; this.isVoid = isVoid; this.container = container; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.filter = new FilterSettingsGui(this.container.filter, this.guiLeft+138, this.guiTop+10, this.buttonList); + this.filter = new FilterSettingsGui(this.container.filter, this.guiLeft + 138, this.guiTop + 10, this.buttonList); - this.buttonAutoInsert = new GuiButton(0, this.guiLeft-21, this.guiTop+8, 20, 20, (this.container.autoInsert ? TextFormatting.DARK_GREEN : TextFormatting.RED)+"I"); + this.buttonAutoInsert = new GuiButton(0, this.guiLeft - 21, this.guiTop + 8, 20, 20, (this.container.autoInsert ? TextFormatting.DARK_GREEN : TextFormatting.RED) + "I"); this.buttonList.add(this.buttonAutoInsert); } @Override - protected void actionPerformed(GuiButton button) throws IOException{ + protected void actionPerformed(GuiButton button) throws IOException { NBTTagCompound data = new NBTTagCompound(); data.setInteger("ButtonID", button.id); data.setInteger("PlayerID", Minecraft.getMinecraft().player.getEntityId()); @@ -74,39 +74,39 @@ public class GuiBag extends GuiWtfMojang{ } @Override - public void updateScreen(){ + public void updateScreen() { super.updateScreen(); this.filter.update(); - this.buttonAutoInsert.displayString = (this.container.autoInsert ? TextFormatting.DARK_GREEN : TextFormatting.RED)+"I"; + this.buttonAutoInsert.displayString = (this.container.autoInsert ? TextFormatting.DARK_GREEN : TextFormatting.RED) + "I"; } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ - AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, StringUtil.localize("container."+ActuallyAdditions.MODID+"."+(this.isVoid ? "voidBag" : "bag")+".name")); + public void drawGuiContainerForegroundLayer(int x, int y) { + AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, StringUtil.localize("container." + ActuallyAdditions.MODID + "." + (this.isVoid ? "voidBag" : "bag") + ".name")); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+90, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 90, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(this.isVoid ? RES_LOC_VOID : RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 90); } @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks){ + public void drawScreen(int mouseX, int mouseY, float partialTicks) { super.drawScreen(mouseX, mouseY, partialTicks); this.filter.drawHover(mouseX, mouseY); - if(this.buttonAutoInsert.isMouseOver()){ + if (this.buttonAutoInsert.isMouseOver()) { List text = new ArrayList<>(); - text.add(TextFormatting.BOLD+"Auto-Insert "+(this.container.autoInsert ? "On" : "Off")); + text.add(TextFormatting.BOLD + "Auto-Insert " + (this.container.autoInsert ? "On" : "Off")); text.addAll(this.mc.fontRenderer.listFormattedStringToWidth("Turn this on to make items that get picked up automatically go into the bag.", 200)); - text.addAll(this.mc.fontRenderer.listFormattedStringToWidth(TextFormatting.GRAY+""+TextFormatting.ITALIC+"Note that this WON'T work when you are holding the bag in your hand.", 200)); + text.addAll(this.mc.fontRenderer.listFormattedStringToWidth(TextFormatting.GRAY + "" + TextFormatting.ITALIC + "Note that this WON'T work when you are holding the bag in your hand.", 200)); this.drawHoveringText(text, mouseX, mouseY); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBioReactor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBioReactor.java index 57c009d22..2f39e853b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBioReactor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBioReactor.java @@ -19,53 +19,53 @@ import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; -public class GuiBioReactor extends GuiWtfMojang{ +public class GuiBioReactor extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_bio_reactor"); private final TileEntityBioReactor tile; private EnergyDisplay energy; - public GuiBioReactor(InventoryPlayer inventory, TileEntityBase tile){ + public GuiBioReactor(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerBioReactor(inventory, tile)); - this.tile = (TileEntityBioReactor)tile; + this.tile = (TileEntityBioReactor) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.energy = new EnergyDisplay(this.guiLeft+116, this.guiTop+5, this.tile.storage); + this.energy = new EnergyDisplay(this.guiLeft + 116, this.guiTop + 5, this.tile.storage); } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); this.energy.drawOverlay(x, y); } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.tile); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - if(this.tile.burnTime > 0){ - int i = this.tile.burnTime*13/this.tile.maxBurnTime; - this.drawTexturedModalRect(this.guiLeft+87, this.guiTop+51+12-i, 176, 96-i, 14, i); + if (this.tile.burnTime > 0) { + int i = this.tile.burnTime * 13 / this.tile.maxBurnTime; + this.drawTexturedModalRect(this.guiLeft + 87, this.guiTop + 51 + 12 - i, 176, 96 - i, 14, i); } - if(this.tile.producePerTick > 0){ - this.drawCenteredString(this.fontRenderer, this.tile.producePerTick+" "+I18n.format("actuallyadditions.cft"), this.guiLeft+87, this.guiTop+86, 0xFFFFFF); + if (this.tile.producePerTick > 0) { + this.drawCenteredString(this.fontRenderer, this.tile.producePerTick + " " + I18n.format("actuallyadditions.cft"), this.guiLeft + 87, this.guiTop + 86, 0xFFFFFF); } this.energy.draw(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBreaker.java index 71c3d2840..98649cdf5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBreaker.java @@ -21,29 +21,29 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiBreaker extends GuiWtfMojang{ +public class GuiBreaker extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_breaker"); private final TileEntityBreaker breaker; - public GuiBreaker(InventoryPlayer inventory, TileEntityBase tile){ + public GuiBreaker(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerBreaker(inventory, tile)); - this.breaker = (TileEntityBreaker)tile; + this.breaker = (TileEntityBreaker) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.breaker); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCanolaPress.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCanolaPress.java index eb487da91..d06c1d20b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCanolaPress.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCanolaPress.java @@ -21,29 +21,29 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiCanolaPress extends GuiWtfMojang{ +public class GuiCanolaPress extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_canola_press"); private final TileEntityCanolaPress press; private EnergyDisplay energy; private FluidDisplay fluid; - public GuiCanolaPress(InventoryPlayer inventory, TileEntityBase tile){ + public GuiCanolaPress(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerCanolaPress(inventory, tile)); - this.press = (TileEntityCanolaPress)tile; + this.press = (TileEntityCanolaPress) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.energy = new EnergyDisplay(this.guiLeft+42, this.guiTop+5, this.press.storage); - this.fluid = new FluidDisplay(this.guiLeft+116, this.guiTop+5, this.press.tank); + this.energy = new EnergyDisplay(this.guiLeft + 42, this.guiTop + 5, this.press.storage); + this.fluid = new FluidDisplay(this.guiLeft + 116, this.guiTop + 5, this.press.tank); } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); this.energy.drawOverlay(x, y); @@ -51,23 +51,23 @@ public class GuiCanolaPress extends GuiWtfMojang{ } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.press); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - if(this.press.currentProcessTime > 0){ + if (this.press.currentProcessTime > 0) { int i = this.press.getProcessScaled(29); - this.drawTexturedModalRect(this.guiLeft+83, this.guiTop+32, 176, 0, 12, i); + this.drawTexturedModalRect(this.guiLeft + 83, this.guiTop + 32, 176, 0, 12, i); } this.energy.draw(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoalGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoalGenerator.java index 5eebd3ce3..8ab878610 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoalGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoalGenerator.java @@ -21,49 +21,49 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiCoalGenerator extends GuiWtfMojang{ +public class GuiCoalGenerator extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_coal_generator"); private final TileEntityCoalGenerator generator; private EnergyDisplay energy; - public GuiCoalGenerator(InventoryPlayer inventory, TileEntityBase tile){ + public GuiCoalGenerator(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerCoalGenerator(inventory, tile)); - this.generator = (TileEntityCoalGenerator)tile; + this.generator = (TileEntityCoalGenerator) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.energy = new EnergyDisplay(this.guiLeft+42, this.guiTop+5, this.generator.storage); + this.energy = new EnergyDisplay(this.guiLeft + 42, this.guiTop + 5, this.generator.storage); } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); this.energy.drawOverlay(x, y); } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.generator); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - if(this.generator.currentBurnTime > 0){ + if (this.generator.currentBurnTime > 0) { int i = this.generator.getBurningScaled(13); - this.drawTexturedModalRect(this.guiLeft+87, this.guiTop+27+12-i, 176, 96-i, 14, i); + this.drawTexturedModalRect(this.guiLeft + 87, this.guiTop + 27 + 12 - i, 176, 96 - i, 14, i); } this.energy.draw(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoffeeMachine.java index a8d1371c0..fcc879603 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoffeeMachine.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoffeeMachine.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; +import java.util.Collections; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.inventory.ContainerCoffeeMachine; import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; @@ -24,10 +26,8 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.Collections; - @SideOnly(Side.CLIENT) -public class GuiCoffeeMachine extends GuiWtfMojang{ +public class GuiCoffeeMachine extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_coffee_machine"); private final TileEntityCoffeeMachine machine; @@ -35,30 +35,30 @@ public class GuiCoffeeMachine extends GuiWtfMojang{ private EnergyDisplay energy; private FluidDisplay fluid; - public GuiCoffeeMachine(InventoryPlayer inventory, TileEntityBase tile){ + public GuiCoffeeMachine(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerCoffeeMachine(inventory, tile)); - this.machine = (TileEntityCoffeeMachine)tile; + this.machine = (TileEntityCoffeeMachine) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - GuiButton buttonOkay = new GuiButton(0, this.guiLeft+60, this.guiTop+11, 58, 20, StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.ok")); + GuiButton buttonOkay = new GuiButton(0, this.guiLeft + 60, this.guiTop + 11, 58, 20, StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.ok")); this.buttonList.add(buttonOkay); - this.energy = new EnergyDisplay(this.guiLeft+16, this.guiTop+5, this.machine.storage); - this.fluid = new FluidDisplay(this.guiLeft-30, this.guiTop+1, this.machine.tank, true, false); + this.energy = new EnergyDisplay(this.guiLeft + 16, this.guiTop + 5, this.machine.storage); + this.fluid = new FluidDisplay(this.guiLeft - 30, this.guiTop + 1, this.machine.tank, true, false); } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); - String text2 = this.machine.coffeeCacheAmount+"/"+TileEntityCoffeeMachine.COFFEE_CACHE_MAX_AMOUNT+" "+StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.coffee"); - if(x >= this.guiLeft+40 && y >= this.guiTop+25 && x <= this.guiLeft+49 && y <= this.guiTop+56){ + String text2 = this.machine.coffeeCacheAmount + "/" + TileEntityCoffeeMachine.COFFEE_CACHE_MAX_AMOUNT + " " + StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.coffee"); + if (x >= this.guiLeft + 40 && y >= this.guiTop + 25 && x <= this.guiLeft + 49 && y <= this.guiTop + 56) { this.drawHoveringText(Collections.singletonList(text2), x, y); } @@ -67,31 +67,31 @@ public class GuiCoffeeMachine extends GuiWtfMojang{ } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.machine); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - if(this.machine.coffeeCacheAmount > 0){ + if (this.machine.coffeeCacheAmount > 0) { int i = this.machine.getCoffeeScaled(30); - this.drawTexturedModalRect(this.guiLeft+41, this.guiTop+56-i, 192, 0, 8, i); + this.drawTexturedModalRect(this.guiLeft + 41, this.guiTop + 56 - i, 192, 0, 8, i); } - if(this.machine.brewTime > 0){ + if (this.machine.brewTime > 0) { int i = this.machine.getBrewScaled(23); - this.drawTexturedModalRect(this.guiLeft+53, this.guiTop+42, 192, 30, i, 16); + this.drawTexturedModalRect(this.guiLeft + 53, this.guiTop + 42, 192, 30, i, 16); int j = this.machine.getBrewScaled(26); - this.drawTexturedModalRect(this.guiLeft+99+25-j, this.guiTop+44, 192+25-j, 46, j, 12); + this.drawTexturedModalRect(this.guiLeft + 99 + 25 - j, this.guiTop + 44, 192 + 25 - j, 46, j, 12); } this.energy.draw(); @@ -99,7 +99,7 @@ public class GuiCoffeeMachine extends GuiWtfMojang{ } @Override - public void actionPerformed(GuiButton button){ + public void actionPerformed(GuiButton button) { PacketHandlerHelper.sendButtonPacket(this.machine, button.id); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDirectionalBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDirectionalBreaker.java index 6c8790688..50a4fffef 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDirectionalBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDirectionalBreaker.java @@ -21,43 +21,43 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiDirectionalBreaker extends GuiWtfMojang{ +public class GuiDirectionalBreaker extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_directional_breaker"); private final TileEntityDirectionalBreaker breaker; private EnergyDisplay energy; - public GuiDirectionalBreaker(InventoryPlayer inventory, TileEntityBase tile){ + public GuiDirectionalBreaker(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerDirectionalBreaker(inventory, tile)); - this.breaker = (TileEntityDirectionalBreaker)tile; + this.breaker = (TileEntityDirectionalBreaker) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.energy = new EnergyDisplay(this.guiLeft+42, this.guiTop+5, this.breaker.storage); + this.energy = new EnergyDisplay(this.guiLeft + 42, this.guiTop + 5, this.breaker.storage); } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); this.energy.drawOverlay(x, y); } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.breaker); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDrill.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDrill.java index 70a9d3585..7ed16f66d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDrill.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDrill.java @@ -21,27 +21,27 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiDrill extends GuiWtfMojang{ +public class GuiDrill extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_drill"); - public GuiDrill(InventoryPlayer inventory){ + public GuiDrill(InventoryPlayer inventory) { super(new ContainerDrill(inventory)); this.xSize = 176; - this.ySize = 54+86; + this.ySize = 54 + 86; } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ - AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, StringUtil.localize("container."+ActuallyAdditions.MODID+".drill.name")); + public void drawGuiContainerForegroundLayer(int x, int y) { + AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, StringUtil.localize("container." + ActuallyAdditions.MODID + ".drill.name")); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+54, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 54, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 54); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDropper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDropper.java index 34d213fbf..7175054a3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDropper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDropper.java @@ -21,29 +21,29 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiDropper extends GuiWtfMojang{ +public class GuiDropper extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_breaker"); private final TileEntityDropper dropper; - public GuiDropper(EntityPlayer player, TileEntityBase tile){ + public GuiDropper(EntityPlayer player, TileEntityBase tile) { super(new ContainerDropper(player, tile)); - this.dropper = (TileEntityDropper)tile; + this.dropper = (TileEntityDropper) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.dropper); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnergizer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnergizer.java index 7eeb21dc6..d29b30f3b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnergizer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnergizer.java @@ -21,42 +21,42 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiEnergizer extends GuiWtfMojang{ +public class GuiEnergizer extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_energizer"); private final TileEntityEnergizer energizer; private EnergyDisplay energy; - public GuiEnergizer(EntityPlayer inventory, TileEntityBase tile){ + public GuiEnergizer(EntityPlayer inventory, TileEntityBase tile) { super(new ContainerEnergizer(inventory, tile)); - this.energizer = (TileEntityEnergizer)tile; + this.energizer = (TileEntityEnergizer) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.energy = new EnergyDisplay(this.guiLeft+56, this.guiTop+5, this.energizer.storage); + this.energy = new EnergyDisplay(this.guiLeft + 56, this.guiTop + 5, this.energizer.storage); } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); this.energy.drawOverlay(x, y); } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.energizer); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnervator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnervator.java index c5759cbbf..0fd6a5df3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnervator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnervator.java @@ -21,42 +21,42 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiEnervator extends GuiWtfMojang{ +public class GuiEnervator extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_energizer"); private final TileEntityEnervator enervator; private EnergyDisplay energy; - public GuiEnervator(EntityPlayer inventory, TileEntityBase tile){ + public GuiEnervator(EntityPlayer inventory, TileEntityBase tile) { super(new ContainerEnervator(inventory, tile)); - this.enervator = (TileEntityEnervator)tile; + this.enervator = (TileEntityEnervator) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.energy = new EnergyDisplay(this.guiLeft+56, this.guiTop+5, this.enervator.storage); + this.energy = new EnergyDisplay(this.guiLeft + 56, this.guiTop + 5, this.enervator.storage); } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); this.energy.drawOverlay(x, y); } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.enervator); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFarmer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFarmer.java index 2980b2593..44c5ae42b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFarmer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFarmer.java @@ -21,38 +21,38 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiFarmer extends GuiWtfMojang{ +public class GuiFarmer extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_farmer"); private final TileEntityFarmer farmer; private EnergyDisplay energy; - public GuiFarmer(InventoryPlayer inventory, TileEntityBase tile){ + public GuiFarmer(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerFarmer(inventory, tile)); - this.farmer = (TileEntityFarmer)tile; + this.farmer = (TileEntityFarmer) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.energy = new EnergyDisplay(this.guiLeft+33, this.guiTop+6, this.farmer.storage); + this.energy = new EnergyDisplay(this.guiLeft + 33, this.guiTop + 6, this.farmer.storage); } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.farmer); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); @@ -61,7 +61,7 @@ public class GuiFarmer extends GuiWtfMojang{ } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); this.energy.drawOverlay(x, y); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFeeder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFeeder.java index e2d19cef5..45bfe2da5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFeeder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFeeder.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; +import java.util.Arrays; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.inventory.ContainerFeeder; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; @@ -22,54 +24,52 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.Arrays; - @SideOnly(Side.CLIENT) -public class GuiFeeder extends GuiWtfMojang{ +public class GuiFeeder extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_feeder"); public final TileEntityFeeder tileFeeder; - public GuiFeeder(InventoryPlayer inventory, TileEntityBase tile){ + public GuiFeeder(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerFeeder(inventory, tile)); - this.tileFeeder = (TileEntityFeeder)tile; + this.tileFeeder = (TileEntityFeeder) tile; this.xSize = 176; - this.ySize = 70+86; + this.ySize = 70 + 86; } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); - if(x >= this.guiLeft+69 && y >= this.guiTop+30 && x <= this.guiLeft+69+10 && y <= this.guiTop+30+10){ - String[] array = new String[]{this.tileFeeder.currentAnimalAmount+" "+StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.animals"), this.tileFeeder.currentAnimalAmount >= 2 && this.tileFeeder.currentAnimalAmount < TileEntityFeeder.THRESHOLD ? StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.enoughToBreed") : this.tileFeeder.currentAnimalAmount >= TileEntityFeeder.THRESHOLD ? StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.tooMany") : StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.notEnough")}; + if (x >= this.guiLeft + 69 && y >= this.guiTop + 30 && x <= this.guiLeft + 69 + 10 && y <= this.guiTop + 30 + 10) { + String[] array = new String[] { this.tileFeeder.currentAnimalAmount + " " + StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.animals"), this.tileFeeder.currentAnimalAmount >= 2 && this.tileFeeder.currentAnimalAmount < TileEntityFeeder.THRESHOLD ? StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.enoughToBreed") : this.tileFeeder.currentAnimalAmount >= TileEntityFeeder.THRESHOLD ? StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.tooMany") : StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.notEnough") }; this.drawHoveringText(Arrays.asList(array), x, y); } } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.tileFeeder); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+70, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 70, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 70); - if(this.tileFeeder.currentTimer > 0){ + if (this.tileFeeder.currentTimer > 0) { int i = this.tileFeeder.getCurrentTimerToScale(20); - this.drawTexturedModalRect(this.guiLeft+85, this.guiTop+42-i, 181, 19+19-i, 6, 20); + this.drawTexturedModalRect(this.guiLeft + 85, this.guiTop + 42 - i, 181, 19 + 19 - i, 6, 20); } - if(this.tileFeeder.currentAnimalAmount >= 2 && this.tileFeeder.currentAnimalAmount < TileEntityFeeder.THRESHOLD){ - this.drawTexturedModalRect(this.guiLeft+70, this.guiTop+31, 192, 16, 8, 8); + if (this.tileFeeder.currentAnimalAmount >= 2 && this.tileFeeder.currentAnimalAmount < TileEntityFeeder.THRESHOLD) { + this.drawTexturedModalRect(this.guiLeft + 70, this.guiTop + 31, 192, 16, 8, 8); } - if(this.tileFeeder.currentAnimalAmount >= TileEntityFeeder.THRESHOLD){ - this.drawTexturedModalRect(this.guiLeft+70, this.guiTop+31, 192, 24, 8, 8); + if (this.tileFeeder.currentAnimalAmount >= TileEntityFeeder.THRESHOLD) { + this.drawTexturedModalRect(this.guiLeft + 70, this.guiTop + 31, 192, 24, 8, 8); } } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFermentingBarrel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFermentingBarrel.java index 9b1372f98..818940186 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFermentingBarrel.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFermentingBarrel.java @@ -21,52 +21,52 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiFermentingBarrel extends GuiWtfMojang{ +public class GuiFermentingBarrel extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_fermenting_barrel"); private final TileEntityFermentingBarrel press; private FluidDisplay input; private FluidDisplay output; - public GuiFermentingBarrel(InventoryPlayer inventory, TileEntityBase tile){ + public GuiFermentingBarrel(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerFermentingBarrel(inventory, tile)); - this.press = (TileEntityFermentingBarrel)tile; + this.press = (TileEntityFermentingBarrel) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); this.input.drawOverlay(x, y); this.output.drawOverlay(x, y); } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.input = new FluidDisplay(this.guiLeft+60, this.guiTop+5, this.press.canolaTank); - this.output = new FluidDisplay(this.guiLeft+98, this.guiTop+5, this.press.oilTank); + this.input = new FluidDisplay(this.guiLeft + 60, this.guiTop + 5, this.press.canolaTank); + this.output = new FluidDisplay(this.guiLeft + 98, this.guiTop + 5, this.press.oilTank); } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.press); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - if(this.press.currentProcessTime > 0){ + if (this.press.currentProcessTime > 0) { int i = this.press.getProcessScaled(29); - this.drawTexturedModalRect(this.guiLeft+82, this.guiTop+34, 176, 0, 12, i); + this.drawTexturedModalRect(this.guiLeft + 82, this.guiTop + 34, 176, 0, 12, i); } this.input.draw(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFilter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFilter.java index 00baea86c..48e27d4ee 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFilter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFilter.java @@ -21,27 +21,27 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiFilter extends GuiWtfMojang{ +public class GuiFilter extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_filter"); - public GuiFilter(InventoryPlayer inventory){ + public GuiFilter(InventoryPlayer inventory) { super(new ContainerFilter(inventory)); this.xSize = 176; - this.ySize = 90+86; + this.ySize = 90 + 86; } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ - AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, StringUtil.localize("container."+ActuallyAdditions.MODID+".filter.name")); + public void drawGuiContainerForegroundLayer(int x, int y) { + AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, StringUtil.localize("container." + ActuallyAdditions.MODID + ".filter.name")); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+90, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 90, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 90); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFluidCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFluidCollector.java index 4e70d5fc7..b50c2aa24 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFluidCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFluidCollector.java @@ -21,43 +21,43 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiFluidCollector extends GuiWtfMojang{ +public class GuiFluidCollector extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_fluid_collector"); private final TileEntityFluidCollector collector; private FluidDisplay fluid; - public GuiFluidCollector(InventoryPlayer inventory, TileEntityBase tile){ + public GuiFluidCollector(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerFluidCollector(inventory, tile)); - this.collector = (TileEntityFluidCollector)tile; + this.collector = (TileEntityFluidCollector) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); this.fluid.drawOverlay(x, y); } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.fluid = new FluidDisplay(this.guiLeft+67, this.guiTop+5, this.collector.tank); + this.fluid = new FluidDisplay(this.guiLeft + 67, this.guiTop + 5, this.collector.tank); } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.collector); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFurnaceDouble.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFurnaceDouble.java index cc0fe0d8b..84d7ef70a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFurnaceDouble.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFurnaceDouble.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; +import java.io.IOException; +import java.util.Collections; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.inventory.ContainerFurnaceDouble; import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; @@ -25,11 +28,8 @@ import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.io.IOException; -import java.util.Collections; - @SideOnly(Side.CLIENT) -public class GuiFurnaceDouble extends GuiWtfMojang{ +public class GuiFurnaceDouble extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_furnace_double"); private final TileEntityFurnaceDouble tileFurnace; @@ -37,68 +37,68 @@ public class GuiFurnaceDouble extends GuiWtfMojang{ private GuiButton buttonAutoSplit; - public GuiFurnaceDouble(InventoryPlayer inventory, TileEntityBase tile){ + public GuiFurnaceDouble(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerFurnaceDouble(inventory, tile)); - this.tileFurnace = (TileEntityFurnaceDouble)tile; + this.tileFurnace = (TileEntityFurnaceDouble) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); this.energy.drawOverlay(x, y); - if(this.buttonAutoSplit.isMouseOver()){ - this.drawHoveringText(Collections.singletonList(TextFormatting.BOLD+(this.tileFurnace.isAutoSplit ? StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.autoSplitItems.on") : StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.autoSplitItems.off"))), x, y); + if (this.buttonAutoSplit.isMouseOver()) { + this.drawHoveringText(Collections.singletonList(TextFormatting.BOLD + (this.tileFurnace.isAutoSplit ? StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.autoSplitItems.on") : StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.autoSplitItems.off"))), x, y); } } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.energy = new EnergyDisplay(this.guiLeft+27, this.guiTop+5, this.tileFurnace.storage); + this.energy = new EnergyDisplay(this.guiLeft + 27, this.guiTop + 5, this.tileFurnace.storage); this.buttonAutoSplit = new GuiInputter.SmallerButton(0, this.guiLeft, this.guiTop, "S"); this.buttonList.add(this.buttonAutoSplit); } @Override - public void updateScreen(){ + public void updateScreen() { super.updateScreen(); - this.buttonAutoSplit.displayString = (this.tileFurnace.isAutoSplit ? TextFormatting.DARK_GREEN : TextFormatting.RED)+"S"; + this.buttonAutoSplit.displayString = (this.tileFurnace.isAutoSplit ? TextFormatting.DARK_GREEN : TextFormatting.RED) + "S"; } @Override - protected void actionPerformed(GuiButton button) throws IOException{ - if(button.id == 0){ + protected void actionPerformed(GuiButton button) throws IOException { + if (button.id == 0) { PacketHandlerHelper.sendButtonPacket(this.tileFurnace, button.id); } } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.tileFurnace); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - if(this.tileFurnace.firstSmeltTime > 0){ + if (this.tileFurnace.firstSmeltTime > 0) { int i = this.tileFurnace.getFirstTimeToScale(23); - this.drawTexturedModalRect(this.guiLeft+51, this.guiTop+40, 176, 0, 24, i); + this.drawTexturedModalRect(this.guiLeft + 51, this.guiTop + 40, 176, 0, 24, i); } - if(this.tileFurnace.secondSmeltTime > 0){ + if (this.tileFurnace.secondSmeltTime > 0) { int i = this.tileFurnace.getSecondTimeToScale(23); - this.drawTexturedModalRect(this.guiLeft+101, this.guiTop+40, 176, 22, 24, i); + this.drawTexturedModalRect(this.guiLeft + 101, this.guiTop + 40, 176, 22, 24, i); } this.energy.draw(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGiantChest.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGiantChest.java index b8f9f3c38..981eff115 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGiantChest.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGiantChest.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; +import java.io.IOException; + import de.ellpeck.actuallyadditions.mod.inventory.ContainerGiantChest; import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; @@ -24,56 +26,54 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.io.IOException; - @SideOnly(Side.CLIENT) -public class GuiGiantChest extends GuiWtfMojang{ +public class GuiGiantChest extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_giant_chest"); private final TileEntityGiantChest chest; private final int page; - public GuiGiantChest(InventoryPlayer inventory, TileEntityBase tile, int page){ + public GuiGiantChest(InventoryPlayer inventory, TileEntityBase tile, int page) { super(new ContainerGiantChest(inventory, tile, page)); - this.chest = (TileEntityGiantChest)tile; + this.chest = (TileEntityGiantChest) tile; this.page = page; this.xSize = 242; - this.ySize = 172+86; + this.ySize = 172 + 86; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - if(this.page > 0){ - this.buttonList.add(new GuiButton(this.page-1, this.guiLeft+13, this.guiTop+172, 20, 20, "<")); + if (this.page > 0) { + this.buttonList.add(new GuiButton(this.page - 1, this.guiLeft + 13, this.guiTop + 172, 20, 20, "<")); } - if(this.page == 0 && this.chest instanceof TileEntityGiantChestMedium || this.page <= 1 && this.chest instanceof TileEntityGiantChestLarge){ - this.buttonList.add(new GuiButton(this.page+1, this.guiLeft+209, this.guiTop+172, 20, 20, ">")); + if (this.page == 0 && this.chest instanceof TileEntityGiantChestMedium || this.page <= 1 && this.chest instanceof TileEntityGiantChestLarge) { + this.buttonList.add(new GuiButton(this.page + 1, this.guiLeft + 209, this.guiTop + 172, 20, 20, ">")); } } @Override - protected void actionPerformed(GuiButton button) throws IOException{ - if(button.id >= 0 && button.id < 3){ + protected void actionPerformed(GuiButton button) throws IOException { + if (button.id >= 0 && button.id < 3) { PacketHandlerHelper.sendButtonPacket(this.chest, button.id); } } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.chest); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 242, 190); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft+33, this.guiTop+172, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft + 33, this.guiTop + 172, 0, 0, 176, 86); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGrinder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGrinder.java index 8ac1e9fc1..fe4c13473 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGrinder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGrinder.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; +import java.io.IOException; +import java.util.Collections; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.inventory.ContainerGrinder; import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; @@ -25,11 +28,8 @@ import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.io.IOException; -import java.util.Collections; - @SideOnly(Side.CLIENT) -public class GuiGrinder extends GuiWtfMojang{ +public class GuiGrinder extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_grinder"); private static final ResourceLocation RES_LOC_DOUBLE = AssetUtil.getGuiLocation("gui_grinder_double"); @@ -39,88 +39,88 @@ public class GuiGrinder extends GuiWtfMojang{ private GuiButton buttonAutoSplit; - public GuiGrinder(InventoryPlayer inventoryPlayer, TileEntityBase tile){ + public GuiGrinder(InventoryPlayer inventoryPlayer, TileEntityBase tile) { this(inventoryPlayer, tile, false); } - private GuiGrinder(InventoryPlayer inventory, TileEntityBase tile, boolean isDouble){ + private GuiGrinder(InventoryPlayer inventory, TileEntityBase tile, boolean isDouble) { super(new ContainerGrinder(inventory, tile, isDouble)); - this.tileGrinder = (TileEntityGrinder)tile; + this.tileGrinder = (TileEntityGrinder) tile; this.isDouble = isDouble; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.energy = new EnergyDisplay(this.guiLeft+(this.isDouble ? 13 : 42), this.guiTop+5, this.tileGrinder.storage); + this.energy = new EnergyDisplay(this.guiLeft + (this.isDouble ? 13 : 42), this.guiTop + 5, this.tileGrinder.storage); - if(this.isDouble){ - this.buttonAutoSplit = new GuiInputter.SmallerButton(0, this.guiLeft-10, this.guiTop, "S"); + if (this.isDouble) { + this.buttonAutoSplit = new GuiInputter.SmallerButton(0, this.guiLeft - 10, this.guiTop, "S"); this.buttonList.add(this.buttonAutoSplit); } } @Override - protected void actionPerformed(GuiButton button) throws IOException{ - if(this.isDouble && button.id == 0){ + protected void actionPerformed(GuiButton button) throws IOException { + if (this.isDouble && button.id == 0) { PacketHandlerHelper.sendButtonPacket(this.tileGrinder, button.id); } } @Override - public void updateScreen(){ + public void updateScreen() { super.updateScreen(); - if(this.isDouble){ - this.buttonAutoSplit.displayString = (this.tileGrinder.isAutoSplit ? TextFormatting.DARK_GREEN : TextFormatting.RED)+"S"; + if (this.isDouble) { + this.buttonAutoSplit.displayString = (this.tileGrinder.isAutoSplit ? TextFormatting.DARK_GREEN : TextFormatting.RED) + "S"; } } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); this.energy.drawOverlay(x, y); - if(this.isDouble && this.buttonAutoSplit.isMouseOver()){ + if (this.isDouble && this.buttonAutoSplit.isMouseOver()) { - this.drawHoveringText(Collections.singletonList(TextFormatting.BOLD+(this.tileGrinder.isAutoSplit ? StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.autoSplitItems.on") : StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.autoSplitItems.off"))), x, y); + this.drawHoveringText(Collections.singletonList(TextFormatting.BOLD + (this.tileGrinder.isAutoSplit ? StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.autoSplitItems.on") : StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.autoSplitItems.off"))), x, y); } } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.tileGrinder); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(this.isDouble ? RES_LOC_DOUBLE : RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - if(this.tileGrinder.firstCrushTime > 0){ + if (this.tileGrinder.firstCrushTime > 0) { int i = this.tileGrinder.getFirstTimeToScale(23); - this.drawTexturedModalRect(this.guiLeft+(this.isDouble ? 51 : 80), this.guiTop+40, 176, 0, 24, i); + this.drawTexturedModalRect(this.guiLeft + (this.isDouble ? 51 : 80), this.guiTop + 40, 176, 0, 24, i); } - if(this.isDouble){ - if(this.tileGrinder.secondCrushTime > 0){ + if (this.isDouble) { + if (this.tileGrinder.secondCrushTime > 0) { int i = this.tileGrinder.getSecondTimeToScale(23); - this.drawTexturedModalRect(this.guiLeft+101, this.guiTop+40, 176, 22, 24, i); + this.drawTexturedModalRect(this.guiLeft + 101, this.guiTop + 40, 176, 22, 24, i); } } this.energy.draw(); } - public static class GuiGrinderDouble extends GuiGrinder{ + public static class GuiGrinderDouble extends GuiGrinder { - public GuiGrinderDouble(InventoryPlayer inventory, TileEntityBase tile){ + public GuiGrinderDouble(InventoryPlayer inventory, TileEntityBase tile) { super(inventory, tile, true); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiInputter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiInputter.java index f476dea04..880a376d7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiInputter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiInputter.java @@ -31,17 +31,10 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiInputter extends GuiWtfMojang{ +public class GuiInputter extends GuiWtfMojang { - public static final int OFFSET_ADVANCED = 12+36; - public static final String[] SIDES = new String[]{ - StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.disabled"), - StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.up"), - StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.down"), - StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.north"), - StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.east"), - StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.south"), - StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.west")}; + public static final int OFFSET_ADVANCED = 12 + 36; + public static final String[] SIDES = new String[] { StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.disabled"), StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.up"), StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.down"), StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.north"), StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.east"), StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.south"), StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.west") }; private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_inputter"); private static final ResourceLocation RES_LOC_ADVANCED = AssetUtil.getGuiLocation("gui_inputter_advanced"); public final TileEntityInputter tileInputter; @@ -54,101 +47,101 @@ public class GuiInputter extends GuiWtfMojang{ private FilterSettingsGui leftFilter; private FilterSettingsGui rightFilter; - public GuiInputter(InventoryPlayer inventory, TileEntityBase tile, boolean isAdvanced){ + public GuiInputter(InventoryPlayer inventory, TileEntityBase tile, boolean isAdvanced) { super(new ContainerInputter(inventory, tile, isAdvanced)); - this.tileInputter = (TileEntityInputter)tile; + this.tileInputter = (TileEntityInputter) tile; this.xSize = 176; - this.ySize = 97+86+(isAdvanced ? OFFSET_ADVANCED : 0); + this.ySize = 97 + 86 + (isAdvanced ? OFFSET_ADVANCED : 0); this.isAdvanced = isAdvanced; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - if(this.isAdvanced){ - this.leftFilter = new FilterSettingsGui(this.tileInputter.leftFilter, this.guiLeft+3, this.guiTop+6, this.buttonList); - this.rightFilter = new FilterSettingsGui(this.tileInputter.rightFilter, this.guiLeft+157, this.guiTop+6, this.buttonList); + if (this.isAdvanced) { + this.leftFilter = new FilterSettingsGui(this.tileInputter.leftFilter, this.guiLeft + 3, this.guiTop + 6, this.buttonList); + this.rightFilter = new FilterSettingsGui(this.tileInputter.rightFilter, this.guiLeft + 157, this.guiTop + 6, this.buttonList); } - this.fieldPullStart = new GuiTextField(3000, this.fontRenderer, this.guiLeft+6, this.guiTop+80+(this.isAdvanced ? OFFSET_ADVANCED : 0), 34, 8); + this.fieldPullStart = new GuiTextField(3000, this.fontRenderer, this.guiLeft + 6, this.guiTop + 80 + (this.isAdvanced ? OFFSET_ADVANCED : 0), 34, 8); this.fieldPullStart.setMaxStringLength(5); this.fieldPullStart.setEnableBackgroundDrawing(false); - this.fieldPullEnd = new GuiTextField(3001, this.fontRenderer, this.guiLeft+50, this.guiTop+80+(this.isAdvanced ? OFFSET_ADVANCED : 0), 34, 8); + this.fieldPullEnd = new GuiTextField(3001, this.fontRenderer, this.guiLeft + 50, this.guiTop + 80 + (this.isAdvanced ? OFFSET_ADVANCED : 0), 34, 8); this.fieldPullEnd.setMaxStringLength(5); this.fieldPullEnd.setEnableBackgroundDrawing(false); - this.fieldPutStart = new GuiTextField(3002, this.fontRenderer, this.guiLeft+91, this.guiTop+80+(this.isAdvanced ? OFFSET_ADVANCED : 0), 34, 8); + this.fieldPutStart = new GuiTextField(3002, this.fontRenderer, this.guiLeft + 91, this.guiTop + 80 + (this.isAdvanced ? OFFSET_ADVANCED : 0), 34, 8); this.fieldPutStart.setMaxStringLength(5); this.fieldPutStart.setEnableBackgroundDrawing(false); - this.fieldPutEnd = new GuiTextField(3004, this.fontRenderer, this.guiLeft+135, this.guiTop+80+(this.isAdvanced ? OFFSET_ADVANCED : 0), 34, 8); + this.fieldPutEnd = new GuiTextField(3004, this.fontRenderer, this.guiLeft + 135, this.guiTop + 80 + (this.isAdvanced ? OFFSET_ADVANCED : 0), 34, 8); this.fieldPutEnd.setMaxStringLength(5); this.fieldPutEnd.setEnableBackgroundDrawing(false); - SmallerButton buttonSidePutP = new SmallerButton(0, this.guiLeft+155, this.guiTop+43+(this.isAdvanced ? OFFSET_ADVANCED : 0), ">"); - SmallerButton buttonSidePutM = new SmallerButton(1, this.guiLeft+90, this.guiTop+43+(this.isAdvanced ? OFFSET_ADVANCED : 0), "<"); + SmallerButton buttonSidePutP = new SmallerButton(0, this.guiLeft + 155, this.guiTop + 43 + (this.isAdvanced ? OFFSET_ADVANCED : 0), ">"); + SmallerButton buttonSidePutM = new SmallerButton(1, this.guiLeft + 90, this.guiTop + 43 + (this.isAdvanced ? OFFSET_ADVANCED : 0), "<"); - SmallerButton buttonSidePullP = new SmallerButton(2, this.guiLeft+70, this.guiTop+43+(this.isAdvanced ? OFFSET_ADVANCED : 0), ">"); - SmallerButton buttonSidePullM = new SmallerButton(3, this.guiLeft+5, this.guiTop+43+(this.isAdvanced ? OFFSET_ADVANCED : 0), "<"); + SmallerButton buttonSidePullP = new SmallerButton(2, this.guiLeft + 70, this.guiTop + 43 + (this.isAdvanced ? OFFSET_ADVANCED : 0), ">"); + SmallerButton buttonSidePullM = new SmallerButton(3, this.guiLeft + 5, this.guiTop + 43 + (this.isAdvanced ? OFFSET_ADVANCED : 0), "<"); this.buttonList.add(buttonSidePutP); this.buttonList.add(buttonSidePullP); this.buttonList.add(buttonSidePutM); this.buttonList.add(buttonSidePullM); - this.buttonList.add(new TinyButton(TileEntityInputter.OKAY_BUTTON_ID, this.guiLeft+84, this.guiTop+91+(this.isAdvanced ? OFFSET_ADVANCED : 0))); + this.buttonList.add(new TinyButton(TileEntityInputter.OKAY_BUTTON_ID, this.guiLeft + 84, this.guiTop + 91 + (this.isAdvanced ? OFFSET_ADVANCED : 0))); } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); - int newTopOffset = this.guiTop+(this.isAdvanced ? OFFSET_ADVANCED : 0); + int newTopOffset = this.guiTop + (this.isAdvanced ? OFFSET_ADVANCED : 0); //Info Mode on! - if(x >= this.guiLeft+4 && y >= newTopOffset+65 && x <= this.guiLeft+4+38 && y <= newTopOffset+65+12){ - this.drawHoveringText(this.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("info."+ActuallyAdditions.MODID+".inputter.info.1").replace("

", StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.pull")), 200), x, y); + if (x >= this.guiLeft + 4 && y >= newTopOffset + 65 && x <= this.guiLeft + 4 + 38 && y <= newTopOffset + 65 + 12) { + this.drawHoveringText(this.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".inputter.info.1").replace("

", StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.pull")), 200), x, y); } - if(x >= this.guiLeft+89 && y >= newTopOffset+65 && x <= this.guiLeft+89+38 && y <= newTopOffset+65+12){ - this.drawHoveringText(this.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("info."+ActuallyAdditions.MODID+".inputter.info.1").replace("

", StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.put")), 200), x, y); + if (x >= this.guiLeft + 89 && y >= newTopOffset + 65 && x <= this.guiLeft + 89 + 38 && y <= newTopOffset + 65 + 12) { + this.drawHoveringText(this.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".inputter.info.1").replace("

", StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.put")), 200), x, y); } - if(x >= this.guiLeft+48 && y >= newTopOffset+65 && x <= this.guiLeft+48+38 && y <= newTopOffset+65+12){ - this.drawHoveringText(this.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("info."+ActuallyAdditions.MODID+".inputter.info.2").replace("

", StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.pull")), 200), x, y); + if (x >= this.guiLeft + 48 && y >= newTopOffset + 65 && x <= this.guiLeft + 48 + 38 && y <= newTopOffset + 65 + 12) { + this.drawHoveringText(this.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".inputter.info.2").replace("

", StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.pull")), 200), x, y); } - if(x >= this.guiLeft+133 && y >= newTopOffset+65 && x <= this.guiLeft+133+38 && y <= newTopOffset+65+12){ - this.drawHoveringText(this.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("info."+ActuallyAdditions.MODID+".inputter.info.2").replace("

", StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.put")), 200), x, y); + if (x >= this.guiLeft + 133 && y >= newTopOffset + 65 && x <= this.guiLeft + 133 + 38 && y <= newTopOffset + 65 + 12) { + this.drawHoveringText(this.fontRenderer.listFormattedStringToWidth(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".inputter.info.2").replace("

", StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.put")), 200), x, y); } - if(this.isAdvanced){ + if (this.isAdvanced) { this.leftFilter.drawHover(x, y); this.rightFilter.drawHover(x, y); } } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.tileInputter); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+97+(this.isAdvanced ? OFFSET_ADVANCED : 0), 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 97 + (this.isAdvanced ? OFFSET_ADVANCED : 0), 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(this.isAdvanced ? RES_LOC_ADVANCED : RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 97+(this.isAdvanced ? OFFSET_ADVANCED : 0)); + this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 97 + (this.isAdvanced ? OFFSET_ADVANCED : 0)); - this.fontRenderer.drawString(StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.inbound"), this.guiLeft+23+3, this.guiTop+32+(this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT); - this.fontRenderer.drawString(StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.outbound"), this.guiLeft+104+3, this.guiTop+32+(this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT); + this.fontRenderer.drawString(StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.inbound"), this.guiLeft + 23 + 3, this.guiTop + 32 + (this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT); + this.fontRenderer.drawString(StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.outbound"), this.guiLeft + 104 + 3, this.guiTop + 32 + (this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT); - this.fontRenderer.drawString(SIDES[this.tileInputter.sideToPull+1], this.guiLeft+24+1, this.guiTop+45+3+(this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT); - this.fontRenderer.drawString(SIDES[this.tileInputter.sideToPut+1], this.guiLeft+109+1, this.guiTop+45+3+(this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT); + this.fontRenderer.drawString(SIDES[this.tileInputter.sideToPull + 1], this.guiLeft + 24 + 1, this.guiTop + 45 + 3 + (this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT); + this.fontRenderer.drawString(SIDES[this.tileInputter.sideToPut + 1], this.guiLeft + 109 + 1, this.guiTop + 45 + 3 + (this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT); - this.fontRenderer.drawString(Integer.toString(this.tileInputter.slotToPutStart), this.guiLeft+92, this.guiTop+67+(this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_WHITE); - this.fontRenderer.drawString(Integer.toString(this.tileInputter.slotToPutEnd), this.guiLeft+136, this.guiTop+67+(this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_WHITE); - this.fontRenderer.drawString(Integer.toString(this.tileInputter.slotToPullStart), this.guiLeft+7, this.guiTop+67+(this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_WHITE); - this.fontRenderer.drawString(Integer.toString(this.tileInputter.slotToPullEnd), this.guiLeft+51, this.guiTop+67+(this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_WHITE); + this.fontRenderer.drawString(Integer.toString(this.tileInputter.slotToPutStart), this.guiLeft + 92, this.guiTop + 67 + (this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_WHITE); + this.fontRenderer.drawString(Integer.toString(this.tileInputter.slotToPutEnd), this.guiLeft + 136, this.guiTop + 67 + (this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_WHITE); + this.fontRenderer.drawString(Integer.toString(this.tileInputter.slotToPullStart), this.guiLeft + 7, this.guiTop + 67 + (this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_WHITE); + this.fontRenderer.drawString(Integer.toString(this.tileInputter.slotToPullEnd), this.guiLeft + 51, this.guiTop + 67 + (this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_WHITE); this.fieldPutStart.drawTextBox(); this.fieldPutEnd.drawTextBox(); @@ -157,7 +150,7 @@ public class GuiInputter extends GuiWtfMojang{ } @Override - protected void mouseClicked(int par1, int par2, int par3) throws IOException{ + protected void mouseClicked(int par1, int par2, int par3) throws IOException { this.fieldPutStart.mouseClicked(par1, par2, par3); this.fieldPutEnd.mouseClicked(par1, par2, par3); this.fieldPullStart.mouseClicked(par1, par2, par3); @@ -167,34 +160,32 @@ public class GuiInputter extends GuiWtfMojang{ } @Override - public void keyTyped(char theChar, int key) throws IOException{ - if(key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER){ - if(this.fieldPutStart.isFocused()){ + public void keyTyped(char theChar, int key) throws IOException { + if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) { + if (this.fieldPutStart.isFocused()) { this.setVariable(this.fieldPutStart, 0); } - if(this.fieldPutEnd.isFocused()){ + if (this.fieldPutEnd.isFocused()) { this.setVariable(this.fieldPutEnd, 1); } - if(this.fieldPullStart.isFocused()){ + if (this.fieldPullStart.isFocused()) { this.setVariable(this.fieldPullStart, 2); } - if(this.fieldPullEnd.isFocused()){ + if (this.fieldPullEnd.isFocused()) { this.setVariable(this.fieldPullEnd, 3); } - } - else if(Character.isDigit(theChar) || key == Keyboard.KEY_BACK || key == Keyboard.KEY_DELETE || key == Keyboard.KEY_LEFT || key == Keyboard.KEY_RIGHT){ + } else if (Character.isDigit(theChar) || key == Keyboard.KEY_BACK || key == Keyboard.KEY_DELETE || key == Keyboard.KEY_LEFT || key == Keyboard.KEY_RIGHT) { this.fieldPutStart.textboxKeyTyped(theChar, key); this.fieldPutEnd.textboxKeyTyped(theChar, key); this.fieldPullStart.textboxKeyTyped(theChar, key); this.fieldPullEnd.textboxKeyTyped(theChar, key); - } - else{ + } else { super.keyTyped(theChar, key); } } @Override - public void updateScreen(){ + public void updateScreen() { super.updateScreen(); this.fieldPutStart.updateCursorCounter(); @@ -202,109 +193,105 @@ public class GuiInputter extends GuiWtfMojang{ this.fieldPullStart.updateCursorCounter(); this.fieldPullEnd.updateCursorCounter(); - if(this.isAdvanced){ + if (this.isAdvanced) { this.leftFilter.update(); this.rightFilter.update(); } } - public void setVariable(GuiTextField field, int sendInt){ - if(!field.getText().isEmpty()){ + public void setVariable(GuiTextField field, int sendInt) { + if (!field.getText().isEmpty()) { this.sendPacket(this.parse(field.getText()), sendInt); field.setText(""); } } - private void sendPacket(int text, int textID){ + private void sendPacket(int text, int textID) { PacketHandlerHelper.sendNumberPacket(this.tileInputter, text, textID); } - private int parse(String theInt){ - try{ + private int parse(String theInt) { + try { return Integer.parseInt(theInt); - } - catch(Exception e){ + } catch (Exception e) { return -1; } } @Override - public void actionPerformed(GuiButton button){ - if(button.id == TileEntityInputter.OKAY_BUTTON_ID){ + public void actionPerformed(GuiButton button) { + if (button.id == TileEntityInputter.OKAY_BUTTON_ID) { this.setVariable(this.fieldPutStart, 0); this.setVariable(this.fieldPutEnd, 1); this.setVariable(this.fieldPullStart, 2); this.setVariable(this.fieldPullEnd, 3); - } - else{ + } else { PacketHandlerHelper.sendButtonPacket(this.tileInputter, button.id); } } @SideOnly(Side.CLIENT) - public static class SmallerButton extends GuiButton{ + public static class SmallerButton extends GuiButton { public final ResourceLocation resLoc = AssetUtil.getGuiLocation("gui_inputter"); private final boolean smaller; - public SmallerButton(int id, int x, int y, String display){ + public SmallerButton(int id, int x, int y, String display) { this(id, x, y, display, false); } - public SmallerButton(int id, int x, int y, String display, boolean smaller){ + public SmallerButton(int id, int x, int y, String display, boolean smaller) { super(id, x, y, 16, smaller ? 12 : 16, display); this.smaller = smaller; } @Override - public void drawButton(Minecraft mc, int x, int y, float f){ - if(this.visible){ + public void drawButton(Minecraft mc, int x, int y, float f) { + if (this.visible) { mc.getTextureManager().bindTexture(this.resLoc); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - this.hovered = x >= this.x && y >= this.y && x < this.x+this.width && y < this.y+this.height; + this.hovered = x >= this.x && y >= this.y && x < this.x + this.width && y < this.y + this.height; int k = this.getHoverState(this.hovered); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.blendFunc(770, 771); - this.drawTexturedModalRect(this.x, this.y, this.smaller ? 200 : 176, k*this.height, this.width, this.height); + this.drawTexturedModalRect(this.x, this.y, this.smaller ? 200 : 176, k * this.height, this.width, this.height); this.mouseDragged(mc, x, y); int color = 14737632; - if(this.packedFGColour != 0){ + if (this.packedFGColour != 0) { color = this.packedFGColour; - } - else if(!this.enabled){ + } else if (!this.enabled) { color = 10526880; - } - else if(this.hovered){ + } else if (this.hovered) { color = 16777120; } - this.drawCenteredString(mc.fontRenderer, this.displayString, this.x+this.width/2, this.y+(this.height-8)/2, color); + this.drawCenteredString(mc.fontRenderer, this.displayString, this.x + this.width / 2, this.y + (this.height - 8) / 2, color); } } } @SideOnly(Side.CLIENT) - public static class TinyButton extends GuiButton{ + public static class TinyButton extends GuiButton { public final ResourceLocation resLoc = AssetUtil.getGuiLocation("gui_inputter"); - public TinyButton(int id, int x, int y){ + public TinyButton(int id, int x, int y) { super(id, x, y, 8, 8, ""); } @Override - public void drawButton(Minecraft mc, int x, int y, float f){ - if(this.visible){ + public void drawButton(Minecraft mc, int x, int y, float f) { + if (this.visible) { mc.getTextureManager().bindTexture(this.resLoc); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - this.hovered = x >= this.x && y >= this.y && x < this.x+this.width && y < this.y+this.height; + this.hovered = x >= this.x && y >= this.y && x < this.x + this.width && y < this.y + this.height; int k = this.getHoverState(this.hovered); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.blendFunc(770, 771); - this.drawTexturedModalRect(this.x, this.y, 192, k*8, 8, 8); + this.drawTexturedModalRect(this.x, this.y, 192, k * 8, 8, 8); this.mouseDragged(mc, x, y); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiLaserRelayItemWhitelist.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiLaserRelayItemWhitelist.java index ff80f1028..22d653987 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiLaserRelayItemWhitelist.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiLaserRelayItemWhitelist.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; +import java.util.ArrayList; +import java.util.List; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.inventory.ContainerLaserRelayItemWhitelist; import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiInputter.SmallerButton; @@ -26,11 +29,8 @@ import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.ArrayList; -import java.util.List; - @SideOnly(Side.CLIENT) -public class GuiLaserRelayItemWhitelist extends GuiWtfMojang{ +public class GuiLaserRelayItemWhitelist extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_laser_relay_item_whitelist"); private final TileEntityLaserRelayItemWhitelist tile; @@ -41,15 +41,15 @@ public class GuiLaserRelayItemWhitelist extends GuiWtfMojang{ private GuiButton buttonSmartWhitelistLeft; private GuiButton buttonSmartWhitelistRight; - public GuiLaserRelayItemWhitelist(InventoryPlayer inventory, TileEntityBase tile){ + public GuiLaserRelayItemWhitelist(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerLaserRelayItemWhitelist(inventory, tile)); - this.tile = (TileEntityLaserRelayItemWhitelist)tile; + this.tile = (TileEntityLaserRelayItemWhitelist) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void updateScreen(){ + public void updateScreen() { super.updateScreen(); this.leftFilter.update(); @@ -57,31 +57,31 @@ public class GuiLaserRelayItemWhitelist extends GuiWtfMojang{ } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.leftFilter = new FilterSettingsGui(this.tile.leftFilter, this.guiLeft+3, this.guiTop+6, this.buttonList); - this.rightFilter = new FilterSettingsGui(this.tile.rightFilter, this.guiLeft+157, this.guiTop+6, this.buttonList); + this.leftFilter = new FilterSettingsGui(this.tile.leftFilter, this.guiLeft + 3, this.guiTop + 6, this.buttonList); + this.rightFilter = new FilterSettingsGui(this.tile.rightFilter, this.guiLeft + 157, this.guiTop + 6, this.buttonList); - this.buttonSmartWhitelistLeft = new SmallerButton(2, this.guiLeft+3, this.guiTop+79, "S"); - this.buttonSmartWhitelistRight = new SmallerButton(3, this.guiLeft+157, this.guiTop+79, "S"); + this.buttonSmartWhitelistLeft = new SmallerButton(2, this.guiLeft + 3, this.guiTop + 79, "S"); + this.buttonSmartWhitelistRight = new SmallerButton(3, this.guiLeft + 157, this.guiTop + 79, "S"); this.buttonList.add(this.buttonSmartWhitelistLeft); this.buttonList.add(this.buttonSmartWhitelistRight); } @Override - public void actionPerformed(GuiButton button){ + public void actionPerformed(GuiButton button) { PacketHandlerHelper.sendButtonPacket(this.tile, button.id); } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); - if(this.buttonSmartWhitelistLeft.isMouseOver() || this.buttonSmartWhitelistRight.isMouseOver()){ + if (this.buttonSmartWhitelistLeft.isMouseOver() || this.buttonSmartWhitelistRight.isMouseOver()) { List list = new ArrayList<>(); - list.add(TextFormatting.BOLD+StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.smart")); - list.addAll(this.fontRenderer.listFormattedStringToWidth(StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.smartInfo"), 200)); + list.add(TextFormatting.BOLD + StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.smart")); + list.addAll(this.fontRenderer.listFormattedStringToWidth(StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.smartInfo"), 200)); this.drawHoveringText(list, x, y); } @@ -90,21 +90,21 @@ public class GuiLaserRelayItemWhitelist extends GuiWtfMojang{ } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.tile); - String s1 = StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.inbound"); - String s2 = StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.outbound"); - this.fontRenderer.drawString(s1, 46-this.fontRenderer.getStringWidth(s1)/2, 80, StringUtil.DECIMAL_COLOR_GRAY_TEXT); - this.fontRenderer.drawString(s2, 131-this.fontRenderer.getStringWidth(s2)/2, 80, StringUtil.DECIMAL_COLOR_GRAY_TEXT); + String s1 = StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.inbound"); + String s2 = StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.outbound"); + this.fontRenderer.drawString(s1, 46 - this.fontRenderer.getStringWidth(s1) / 2, 80, StringUtil.DECIMAL_COLOR_GRAY_TEXT); + this.fontRenderer.drawString(s2, 131 - this.fontRenderer.getStringWidth(s2) / 2, 80, StringUtil.DECIMAL_COLOR_GRAY_TEXT); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiMiner.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiMiner.java index a0a55046e..a225dfec2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiMiner.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiMiner.java @@ -24,50 +24,50 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiMiner extends GuiWtfMojang{ +public class GuiMiner extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_breaker"); private final TileEntityMiner miner; - public GuiMiner(InventoryPlayer inventory, TileEntityBase tile){ + public GuiMiner(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerMiner(inventory, tile)); - this.miner = (TileEntityMiner)tile; + this.miner = (TileEntityMiner) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - GuiButton buttonMode = new GuiButton(0, this.guiLeft+this.xSize/2-51, this.guiTop+75, 50, 20, "Mode"); + GuiButton buttonMode = new GuiButton(0, this.guiLeft + this.xSize / 2 - 51, this.guiTop + 75, 50, 20, "Mode"); this.buttonList.add(buttonMode); - GuiButton buttonReset = new GuiButton(1, this.guiLeft+this.xSize/2+1, this.guiTop+75, 50, 20, "Reset"); + GuiButton buttonReset = new GuiButton(1, this.guiLeft + this.xSize / 2 + 1, this.guiTop + 75, 50, 20, "Reset"); this.buttonList.add(buttonReset); } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.miner); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); String mining = this.miner.onlyMineOres ? "Only Mining Ores" : "Mining Everything"; - this.fontRenderer.drawString(mining, this.guiLeft+this.xSize/2-this.fontRenderer.getStringWidth(mining)/2, this.guiTop+8, StringUtil.DECIMAL_COLOR_GRAY_TEXT); + this.fontRenderer.drawString(mining, this.guiLeft + this.xSize / 2 - this.fontRenderer.getStringWidth(mining) / 2, this.guiTop + 8, StringUtil.DECIMAL_COLOR_GRAY_TEXT); } @Override - public void actionPerformed(GuiButton button){ + public void actionPerformed(GuiButton button) { PacketHandlerHelper.sendButtonPacket(this.miner, button.id); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiOilGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiOilGenerator.java index 33358e78a..2b76070a2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiOilGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiOilGenerator.java @@ -23,7 +23,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiOilGenerator extends GuiWtfMojang{ +public class GuiOilGenerator extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_oil_generator"); private final TileEntityOilGenerator generator; @@ -31,50 +31,50 @@ public class GuiOilGenerator extends GuiWtfMojang{ private EnergyDisplay energy; private FluidDisplay fluid; - public GuiOilGenerator(InventoryPlayer inventory, TileEntityBase tile){ + public GuiOilGenerator(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerOilGenerator(inventory, tile)); - this.generator = (TileEntityOilGenerator)tile; + this.generator = (TileEntityOilGenerator) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.energy = new EnergyDisplay(this.guiLeft+42, this.guiTop+5, this.generator.storage); - this.fluid = new FluidDisplay(this.guiLeft+116, this.guiTop+5, this.generator.tank); + this.energy = new EnergyDisplay(this.guiLeft + 42, this.guiTop + 5, this.generator.storage); + this.fluid = new FluidDisplay(this.guiLeft + 116, this.guiTop + 5, this.generator.tank); } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); this.energy.drawOverlay(x, y); this.fluid.drawOverlay(x, y); } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.generator); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - if(this.generator.currentBurnTime > 0 && this.generator.maxBurnTime > 0){ + if (this.generator.currentBurnTime > 0 && this.generator.maxBurnTime > 0) { int i = this.generator.getBurningScaled(13); - this.drawTexturedModalRect(this.guiLeft+72, this.guiTop+44+12-i, 176, 96-i, 14, i); + this.drawTexturedModalRect(this.guiLeft + 72, this.guiTop + 44 + 12 - i, 176, 96 - i, 14, i); } - if(this.generator.maxBurnTime > 0 && this.generator.currentEnergyProduce > 0){ - this.drawCenteredString(this.fontRenderer, this.generator.currentEnergyProduce + " "+I18n.format("actuallyadditions.cft"), this.guiLeft + 87, this.guiTop + 65, 0xFFFFFF); - this.drawCenteredString(this.fontRenderer, "for "+ this.generator.maxBurnTime + " t", this.guiLeft + 87, this.guiTop + 75, 0xFFFFFF); + if (this.generator.maxBurnTime > 0 && this.generator.currentEnergyProduce > 0) { + this.drawCenteredString(this.fontRenderer, this.generator.currentEnergyProduce + " " + I18n.format("actuallyadditions.cft"), this.guiLeft + 87, this.guiTop + 65, 0xFFFFFF); + this.drawCenteredString(this.fontRenderer, "for " + this.generator.maxBurnTime + " t", this.guiLeft + 87, this.guiTop + 75, 0xFFFFFF); GlStateManager.pushMatrix(); GlStateManager.scale(0.75, 0.75, 1); float xS = (this.guiLeft + 87) * 1.365F - this.fontRenderer.getStringWidth("(per 50 mB)") / 2F; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiPhantomPlacer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiPhantomPlacer.java index 2bfa699b6..32aa3ad8d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiPhantomPlacer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiPhantomPlacer.java @@ -10,6 +10,10 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.inventory.ContainerPhantomPlacer; import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; @@ -25,77 +29,73 @@ import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - @SideOnly(Side.CLIENT) -public class GuiPhantomPlacer extends GuiWtfMojang{ +public class GuiPhantomPlacer extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_breaker"); private final TileEntityPhantomPlacer placer; - public GuiPhantomPlacer(InventoryPlayer inventory, TileEntityBase tile){ + public GuiPhantomPlacer(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerPhantomPlacer(inventory, tile)); - this.placer = (TileEntityPhantomPlacer)tile; + this.placer = (TileEntityPhantomPlacer) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - if(!this.placer.isBreaker){ - this.buttonList.add(new GuiButton(0, this.guiLeft+63, this.guiTop+75, 50, 20, this.getSide())); + if (!this.placer.isBreaker) { + this.buttonList.add(new GuiButton(0, this.guiLeft + 63, this.guiTop + 75, 50, 20, this.getSide())); } } @Override - public void updateScreen(){ + public void updateScreen() { super.updateScreen(); - if(!this.placer.isBreaker){ + if (!this.placer.isBreaker) { this.buttonList.get(0).displayString = this.getSide(); } } @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks){ + public void drawScreen(int mouseX, int mouseY, float partialTicks) { super.drawScreen(mouseX, mouseY, partialTicks); - if(!this.placer.isBreaker && this.buttonList.get(0).isMouseOver()){ - String loc = "info."+ActuallyAdditions.MODID+".placer.sides"; + if (!this.placer.isBreaker && this.buttonList.get(0).isMouseOver()) { + String loc = "info." + ActuallyAdditions.MODID + ".placer.sides"; List textList = new ArrayList<>(); - textList.add(TextFormatting.GOLD+StringUtil.localize(loc+".1")); - textList.addAll(this.fontRenderer.listFormattedStringToWidth(StringUtil.localize(loc+".2"), 200)); + textList.add(TextFormatting.GOLD + StringUtil.localize(loc + ".1")); + textList.addAll(this.fontRenderer.listFormattedStringToWidth(StringUtil.localize(loc + ".2"), 200)); this.drawHoveringText(textList, mouseX, mouseY); } } @Override - protected void actionPerformed(GuiButton button) throws IOException{ - if(!this.placer.isBreaker){ + protected void actionPerformed(GuiButton button) throws IOException { + if (!this.placer.isBreaker) { PacketHandlerHelper.sendButtonPacket(this.placer, button.id); } } - private String getSide(){ - return GuiInputter.SIDES[this.placer.side+1]; + private String getSide() { + return GuiInputter.SIDES[this.placer.side + 1]; } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.placer); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRangedCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRangedCollector.java index cc4793340..014844b8e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRangedCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRangedCollector.java @@ -23,59 +23,59 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiRangedCollector extends GuiWtfMojang{ +public class GuiRangedCollector extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_ranged_collector"); private final TileEntityRangedCollector collector; private FilterSettingsGui filter; - public GuiRangedCollector(InventoryPlayer inventory, TileEntityBase tile){ + public GuiRangedCollector(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerRangedCollector(inventory, tile)); - this.collector = (TileEntityRangedCollector)tile; + this.collector = (TileEntityRangedCollector) tile; this.xSize = 176; - this.ySize = 86+86; + this.ySize = 86 + 86; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.filter = new FilterSettingsGui(this.collector.filter, this.guiLeft+3, this.guiTop+6, this.buttonList); + this.filter = new FilterSettingsGui(this.collector.filter, this.guiLeft + 3, this.guiTop + 6, this.buttonList); } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); this.filter.drawHover(x, y); } @Override - public void updateScreen(){ + public void updateScreen() { super.updateScreen(); this.filter.update(); } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.collector); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+86, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 86, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 86); } @Override - public void actionPerformed(GuiButton button){ + public void actionPerformed(GuiButton button) { PacketHandlerHelper.sendButtonPacket(this.collector, button.id); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRepairer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRepairer.java index 682d2e131..2568f9dd2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRepairer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRepairer.java @@ -21,49 +21,49 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiRepairer extends GuiWtfMojang{ +public class GuiRepairer extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_repairer"); private final TileEntityItemRepairer tileRepairer; private EnergyDisplay energy; - public GuiRepairer(InventoryPlayer inventory, TileEntityBase tile){ + public GuiRepairer(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerRepairer(inventory, tile)); - this.tileRepairer = (TileEntityItemRepairer)tile; + this.tileRepairer = (TileEntityItemRepairer) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.energy = new EnergyDisplay(this.guiLeft+27, this.guiTop+5, this.tileRepairer.storage); + this.energy = new EnergyDisplay(this.guiLeft + 27, this.guiTop + 5, this.tileRepairer.storage); } @Override - public void drawScreen(int x, int y, float f){ + public void drawScreen(int x, int y, float f) { super.drawScreen(x, y, f); this.energy.drawOverlay(x, y); } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.tileRepairer); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - if(TileEntityItemRepairer.canBeRepaired(this.tileRepairer.inv.getStackInSlot(TileEntityItemRepairer.SLOT_INPUT))){ + if (TileEntityItemRepairer.canBeRepaired(this.tileRepairer.inv.getStackInSlot(TileEntityItemRepairer.SLOT_INPUT))) { int i = this.tileRepairer.getItemDamageToScale(22); - this.drawTexturedModalRect(this.guiLeft+73, this.guiTop+52, 176, 28, i, 16); + this.drawTexturedModalRect(this.guiLeft + 73, this.guiTop + 52, 176, 28, i, 16); } this.energy.draw(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiSmileyCloud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiSmileyCloud.java index 58e8145f2..653e103a8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiSmileyCloud.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiSmileyCloud.java @@ -10,6 +10,10 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; +import java.io.IOException; + +import org.lwjgl.input.Keyboard; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.inventory.ContainerSmileyCloud; import de.ellpeck.actuallyadditions.mod.network.PacketClientToServer; @@ -27,12 +31,9 @@ import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import org.lwjgl.input.Keyboard; - -import java.io.IOException; @SideOnly(Side.CLIENT) -public class GuiSmileyCloud extends GuiWtfMojang{ +public class GuiSmileyCloud extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_smiley_cloud"); @@ -43,9 +44,9 @@ public class GuiSmileyCloud extends GuiWtfMojang{ private final TileEntitySmileyCloud cloud; private GuiTextField nameField; - public GuiSmileyCloud(TileEntityBase tile, int x, int y, int z, World world){ + public GuiSmileyCloud(TileEntityBase tile, int x, int y, int z, World world) { super(new ContainerSmileyCloud()); - this.cloud = (TileEntitySmileyCloud)tile; + this.cloud = (TileEntitySmileyCloud) tile; this.x = x; this.y = y; this.z = z; @@ -55,24 +56,24 @@ public class GuiSmileyCloud extends GuiWtfMojang{ } @Override - public void initGui(){ + public void initGui() { super.initGui(); - this.nameField = new GuiTextField(4000, this.fontRenderer, this.guiLeft+5, this.guiTop+6, 114, 8); + this.nameField = new GuiTextField(4000, this.fontRenderer, this.guiLeft + 5, this.guiTop + 6, 114, 8); this.nameField.setMaxStringLength(20); this.nameField.setEnableBackgroundDrawing(false); this.nameField.setFocused(true); } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ - String name = this.cloud.name == null || this.cloud.name.isEmpty() ? "" : TextFormatting.GOLD+this.cloud.name+TextFormatting.RESET+" "+StringUtil.localize("info."+ActuallyAdditions.MODID+".gui.the")+" "; - String localizedName = name+StringUtil.localize("container."+ActuallyAdditions.MODID+".cloud.name"); - this.fontRenderer.drawString(localizedName, this.xSize/2-this.fontRenderer.getStringWidth(localizedName)/2, -10, StringUtil.DECIMAL_COLOR_WHITE); + public void drawGuiContainerForegroundLayer(int x, int y) { + String name = this.cloud.name == null || this.cloud.name.isEmpty() ? "" : TextFormatting.GOLD + this.cloud.name + TextFormatting.RESET + " " + StringUtil.localize("info." + ActuallyAdditions.MODID + ".gui.the") + " "; + String localizedName = name + StringUtil.localize("container." + ActuallyAdditions.MODID + ".cloud.name"); + this.fontRenderer.drawString(localizedName, this.xSize / 2 - this.fontRenderer.getStringWidth(localizedName) / 2, -10, StringUtil.DECIMAL_COLOR_WHITE); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(RES_LOC); @@ -82,38 +83,36 @@ public class GuiSmileyCloud extends GuiWtfMojang{ } @Override - protected void mouseClicked(int par1, int par2, int par3) throws IOException{ + protected void mouseClicked(int par1, int par2, int par3) throws IOException { this.nameField.mouseClicked(par1, par2, par3); super.mouseClicked(par1, par2, par3); } @Override - public void keyTyped(char theChar, int key) throws IOException{ - if(key != 1 && this.nameField.isFocused()){ - if(key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER){ + public void keyTyped(char theChar, int key) throws IOException { + if (key != 1 && this.nameField.isFocused()) { + if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) { this.setVariable(this.nameField); - } - else{ + } else { this.nameField.textboxKeyTyped(theChar, key); } - } - else{ + } else { super.keyTyped(theChar, key); } } @Override - public void updateScreen(){ + public void updateScreen() { super.updateScreen(); this.nameField.updateCursorCounter(); } - public void setVariable(GuiTextField field){ + public void setVariable(GuiTextField field) { this.sendPacket(field.getText(), 0); field.setText(""); } - private void sendPacket(String text, int textID){ + private void sendPacket(String text, int textID) { NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("X", this.x); compound.setInteger("Y", this.y); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiWtfMojang.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiWtfMojang.java index 77f4e7db9..4304dbd44 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiWtfMojang.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiWtfMojang.java @@ -13,14 +13,14 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.inventory.Container; -public abstract class GuiWtfMojang extends GuiContainer{ +public abstract class GuiWtfMojang extends GuiContainer { - public GuiWtfMojang(Container inventorySlotsIn){ + public GuiWtfMojang(Container inventorySlotsIn) { super(inventorySlotsIn); } @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks){ + public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); super.drawScreen(mouseX, mouseY, partialTicks); this.renderHoveredToolTip(mouseX, mouseY); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiXPSolidifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiXPSolidifier.java index 742e6c329..23438b279 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiXPSolidifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiXPSolidifier.java @@ -25,31 +25,31 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiXPSolidifier extends GuiWtfMojang{ +public class GuiXPSolidifier extends GuiWtfMojang { private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_xp_solidifier"); private final TileEntityXPSolidifier solidifier; - public GuiXPSolidifier(InventoryPlayer inventory, TileEntityBase tile){ + public GuiXPSolidifier(InventoryPlayer inventory, TileEntityBase tile) { super(new ContainerXPSolidifier(inventory, tile)); - this.solidifier = (TileEntityXPSolidifier)tile; + this.solidifier = (TileEntityXPSolidifier) tile; this.xSize = 176; - this.ySize = 93+86; + this.ySize = 93 + 86; } @Override - public void initGui(){ + public void initGui() { super.initGui(); - GuiButton buttonOne = new GuiInputter.SmallerButton(0, this.guiLeft+62, this.guiTop+44, "1"); - GuiButton buttonFive = new GuiInputter.SmallerButton(1, this.guiLeft+80, this.guiTop+44, "5"); - GuiButton buttonTen = new GuiInputter.SmallerButton(2, this.guiLeft+99, this.guiTop+44, "10"); - GuiButton buttonTwenty = new GuiInputter.SmallerButton(3, this.guiLeft+62, this.guiTop+61, "20"); - GuiButton buttonThirty = new GuiInputter.SmallerButton(4, this.guiLeft+80, this.guiTop+61, "30"); - GuiButton buttonForty = new GuiInputter.SmallerButton(5, this.guiLeft+99, this.guiTop+61, "40"); - GuiButton buttonFifty = new GuiInputter.SmallerButton(6, this.guiLeft+62, this.guiTop+78, "50"); - GuiButton buttonSixtyFour = new GuiInputter.SmallerButton(7, this.guiLeft+80, this.guiTop+78, "64"); - GuiButton buttonAll = new GuiInputter.SmallerButton(8, this.guiLeft+99, this.guiTop+78, "All"); + GuiButton buttonOne = new GuiInputter.SmallerButton(0, this.guiLeft + 62, this.guiTop + 44, "1"); + GuiButton buttonFive = new GuiInputter.SmallerButton(1, this.guiLeft + 80, this.guiTop + 44, "5"); + GuiButton buttonTen = new GuiInputter.SmallerButton(2, this.guiLeft + 99, this.guiTop + 44, "10"); + GuiButton buttonTwenty = new GuiInputter.SmallerButton(3, this.guiLeft + 62, this.guiTop + 61, "20"); + GuiButton buttonThirty = new GuiInputter.SmallerButton(4, this.guiLeft + 80, this.guiTop + 61, "30"); + GuiButton buttonForty = new GuiInputter.SmallerButton(5, this.guiLeft + 99, this.guiTop + 61, "40"); + GuiButton buttonFifty = new GuiInputter.SmallerButton(6, this.guiLeft + 62, this.guiTop + 78, "50"); + GuiButton buttonSixtyFour = new GuiInputter.SmallerButton(7, this.guiLeft + 80, this.guiTop + 78, "64"); + GuiButton buttonAll = new GuiInputter.SmallerButton(8, this.guiLeft + 99, this.guiTop + 78, "All"); this.buttonList.add(buttonOne); this.buttonList.add(buttonFive); @@ -63,25 +63,25 @@ public class GuiXPSolidifier extends GuiWtfMojang{ } @Override - public void drawGuiContainerForegroundLayer(int x, int y){ + public void drawGuiContainerForegroundLayer(int x, int y) { AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.solidifier); } @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + public void drawGuiContainerBackgroundLayer(float f, int x, int y) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + this.drawTexturedModalRect(this.guiLeft, this.guiTop + 93, 0, 0, 176, 86); this.mc.getTextureManager().bindTexture(RES_LOC); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - this.drawCenteredString(this.fontRenderer, Integer.toString(this.solidifier.amount), this.guiLeft+88, this.guiTop+30, StringUtil.DECIMAL_COLOR_WHITE); + this.drawCenteredString(this.fontRenderer, Integer.toString(this.solidifier.amount), this.guiLeft + 88, this.guiTop + 30, StringUtil.DECIMAL_COLOR_WHITE); } @Override - public void actionPerformed(GuiButton button){ + public void actionPerformed(GuiButton button) { PacketHandlerHelper.sendButtonPacket(this.solidifier, button.id); this.solidifier.onButtonPressed(button.id, Minecraft.getMinecraft().player); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/TexturedButton.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/TexturedButton.java index 070d666fb..e3401f027 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/TexturedButton.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/TexturedButton.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.renderer.GlStateManager; @@ -18,22 +21,19 @@ import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.ArrayList; -import java.util.List; - @SideOnly(Side.CLIENT) -public class TexturedButton extends GuiButton{ +public class TexturedButton extends GuiButton { public final List textList = new ArrayList<>(); private final ResourceLocation resLoc; public int texturePosX; public int texturePosY; - public TexturedButton(ResourceLocation resLoc, int id, int x, int y, int texturePosX, int texturePosY, int width, int height){ + public TexturedButton(ResourceLocation resLoc, int id, int x, int y, int texturePosX, int texturePosY, int width, int height) { this(resLoc, id, x, y, texturePosX, texturePosY, width, height, new ArrayList()); } - public TexturedButton(ResourceLocation resLoc, int id, int x, int y, int texturePosX, int texturePosY, int width, int height, List hoverTextList){ + public TexturedButton(ResourceLocation resLoc, int id, int x, int y, int texturePosX, int texturePosY, int width, int height, List hoverTextList) { super(id, x, y, width, height, ""); this.texturePosX = texturePosX; this.texturePosY = texturePosY; @@ -42,26 +42,26 @@ public class TexturedButton extends GuiButton{ } @Override - public void drawButton(Minecraft minecraft, int x, int y, float f){ - if(this.visible){ + public void drawButton(Minecraft minecraft, int x, int y, float f) { + if (this.visible) { minecraft.getTextureManager().bindTexture(this.resLoc); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - this.hovered = x >= this.x && y >= this.y && x < this.x+this.width && y < this.y+this.height; + this.hovered = x >= this.x && y >= this.y && x < this.x + this.width && y < this.y + this.height; int k = this.getHoverState(this.hovered); - if(k == 0){ + if (k == 0) { k = 1; } GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.blendFunc(770, 771); - this.drawTexturedModalRect(this.x, this.y, this.texturePosX, this.texturePosY-this.height+k*this.height, this.width, this.height); + this.drawTexturedModalRect(this.x, this.y, this.texturePosX, this.texturePosY - this.height + k * this.height, this.width, this.height); this.mouseDragged(minecraft, x, y); } } - public void drawHover(int x, int y){ - if(this.isMouseOver()){ + public void drawHover(int x, int y) { + if (this.isMouseOver()) { Minecraft mc = Minecraft.getMinecraft(); GuiUtils.drawHoveringText(this.textList, x, y, mc.displayWidth, mc.displayHeight, -1, mc.fontRenderer); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotDeletion.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotDeletion.java index a002a2719..eaa9b6a5a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotDeletion.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotDeletion.java @@ -13,14 +13,14 @@ package de.ellpeck.actuallyadditions.mod.inventory.slot; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; import net.minecraft.item.ItemStack; -public class SlotDeletion extends SlotItemHandlerUnconditioned{ +public class SlotDeletion extends SlotItemHandlerUnconditioned { - public SlotDeletion(ItemStackHandlerAA inv, int slot, int x, int y){ + public SlotDeletion(ItemStackHandlerAA inv, int slot, int x, int y) { super(inv, slot, x, y); } @Override - public void putStack(ItemStack stack){ + public void putStack(ItemStack stack) { this.onSlotChanged(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotFilter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotFilter.java index 34ae02195..a2ce69533 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotFilter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotFilter.java @@ -19,49 +19,48 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class SlotFilter extends SlotItemHandlerUnconditioned{ +public class SlotFilter extends SlotItemHandlerUnconditioned { - public SlotFilter(ItemStackHandlerAA inv, int slot, int x, int y){ + public SlotFilter(ItemStackHandlerAA inv, int slot, int x, int y) { super(inv, slot, x, y); } - public SlotFilter(FilterSettings inv, int slot, int x, int y){ + public SlotFilter(FilterSettings inv, int slot, int x, int y) { this(inv.filterInventory, slot, x, y); } - public static boolean checkFilter(Container container, int slotId, EntityPlayer player){ - if(slotId >= 0 && slotId < container.inventorySlots.size()){ + public static boolean checkFilter(Container container, int slotId, EntityPlayer player) { + if (slotId >= 0 && slotId < container.inventorySlots.size()) { Slot slot = container.getSlot(slotId); - if(slot instanceof SlotFilter){ - ((SlotFilter)slot).slotClick(player); + if (slot instanceof SlotFilter) { + ((SlotFilter) slot).slotClick(player); return true; } } return false; } - public static boolean isFilter(ItemStack stack){ + public static boolean isFilter(ItemStack stack) { return StackUtil.isValid(stack) && stack.getItem() instanceof ItemFilter; } - private void slotClick(EntityPlayer player){ + private void slotClick(EntityPlayer player) { ItemStack heldStack = player.inventory.getItemStack(); ItemStack stackInSlot = this.getStack(); - if(StackUtil.isValid(stackInSlot) && !StackUtil.isValid(heldStack)){ - if(isFilter(stackInSlot)){ + if (StackUtil.isValid(stackInSlot) && !StackUtil.isValid(heldStack)) { + if (isFilter(stackInSlot)) { player.inventory.setItemStack(stackInSlot); } this.putStack(StackUtil.getEmpty()); - } - else if(StackUtil.isValid(heldStack)){ - if(!isFilter(stackInSlot)){ + } else if (StackUtil.isValid(heldStack)) { + if (!isFilter(stackInSlot)) { ItemStack s = heldStack.copy(); s.setCount(1); this.putStack(s); - if(isFilter(heldStack)){ + if (isFilter(heldStack)) { heldStack.shrink(1); } } @@ -69,17 +68,17 @@ public class SlotFilter extends SlotItemHandlerUnconditioned{ } @Override - public boolean isItemValid(ItemStack stack){ + public boolean isItemValid(ItemStack stack) { return false; } @Override - public void putStack(ItemStack stack){ + public void putStack(ItemStack stack) { super.putStack(stack.copy()); } @Override - public boolean canTakeStack(EntityPlayer player){ + public boolean canTakeStack(EntityPlayer player) { return false; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotImmovable.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotImmovable.java index b704db14d..cec0555ce 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotImmovable.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotImmovable.java @@ -15,30 +15,29 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class SlotImmovable extends Slot{ +public class SlotImmovable extends Slot { - public SlotImmovable(IInventory inventory, int id, int x, int y){ + public SlotImmovable(IInventory inventory, int id, int x, int y) { super(inventory, id, x, y); } @Override - public boolean isItemValid(ItemStack stack){ + public boolean isItemValid(ItemStack stack) { return false; } @Override - public void putStack(ItemStack stack){ + public void putStack(ItemStack stack) { } - @Override - public ItemStack decrStackSize(int i){ + public ItemStack decrStackSize(int i) { return ItemStack.EMPTY; } @Override - public boolean canTakeStack(EntityPlayer player){ + public boolean canTakeStack(EntityPlayer player) { return false; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotOutput.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotOutput.java index aa816b9be..564b8a3ae 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotOutput.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotOutput.java @@ -13,14 +13,14 @@ package de.ellpeck.actuallyadditions.mod.inventory.slot; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; import net.minecraft.item.ItemStack; -public class SlotOutput extends SlotItemHandlerUnconditioned{ +public class SlotOutput extends SlotItemHandlerUnconditioned { - public SlotOutput(ItemStackHandlerAA inventory, int id, int x, int y){ + public SlotOutput(ItemStackHandlerAA inventory, int id, int x, int y) { super(inventory, id, x, y); } @Override - public boolean isItemValid(ItemStack stack){ + public boolean isItemValid(ItemStack stack) { return false; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitItems.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitItems.java index d2e9bbf75..b763a4eb7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitItems.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitItems.java @@ -36,7 +36,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.tileentity.TileEntityChest; -public final class InitItems{ +public final class InitItems { public static Item itemBooklet; public static Item itemFertilizer; @@ -202,7 +202,7 @@ public final class InitItems{ public static Item itemEngineerGogglesAdvanced; public static Item itemCrystalShard; - public static void init(){ + public static void init() { ActuallyAdditions.LOGGER.info("Initializing Items..."); itemCrystalShard = new ItemCrystalShard("item_crystal_shard"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java index 1569bf2f9..040d7bd44 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java @@ -24,28 +24,28 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.IRarity; -public class ItemAxeAA extends ItemToolAA{ +public class ItemAxeAA extends ItemToolAA { private static final Set EFFECTIVE_ON = Sets.newHashSet(Blocks.PLANKS, Blocks.BOOKSHELF, Blocks.LOG, Blocks.LOG2, Blocks.CHEST, Blocks.PUMPKIN, Blocks.LIT_PUMPKIN, Blocks.MELON_BLOCK, Blocks.LADDER, Blocks.WOODEN_BUTTON, Blocks.WOODEN_PRESSURE_PLATE); - public ItemAxeAA(Item.ToolMaterial material, String repairItem, String unlocalizedName, IRarity rarity){ + public ItemAxeAA(Item.ToolMaterial material, String repairItem, String unlocalizedName, IRarity rarity) { super(6.0F, -3.0F, material, repairItem, unlocalizedName, rarity, EFFECTIVE_ON); this.setHarvestLevel("axe", material.getHarvestLevel()); } - public ItemAxeAA(Item.ToolMaterial material, ItemStack repairItem, String unlocalizedName, IRarity rarity){ + public ItemAxeAA(Item.ToolMaterial material, ItemStack repairItem, String unlocalizedName, IRarity rarity) { super(6.0F, -3.0F, material, repairItem, unlocalizedName, rarity, EFFECTIVE_ON); this.setHarvestLevel("axe", material.getHarvestLevel()); } @Override - public float getDestroySpeed(ItemStack stack, IBlockState state){ + public float getDestroySpeed(ItemStack stack, IBlockState state) { Material material = state.getMaterial(); return material != Material.WOOD && material != Material.PLANTS && material != Material.VINE ? super.getDestroySpeed(stack, state) : this.efficiency; } @Override - public Set getToolClasses(ItemStack stack){ + public Set getToolClasses(ItemStack stack) { return Collections.singleton("axe"); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBattery.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBattery.java index 77a5eb855..bd0a4b90f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBattery.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBattery.java @@ -29,41 +29,41 @@ import net.minecraft.world.World; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; -public class ItemBattery extends ItemEnergy{ +public class ItemBattery extends ItemEnergy { - public ItemBattery(String name, int capacity, int transfer){ + public ItemBattery(String name, int capacity, int transfer) { super(capacity, transfer, name); this.setMaxStackSize(1); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override - public boolean hasEffect(ItemStack stack){ + public boolean hasEffect(ItemStack stack) { return ItemUtil.isEnabled(stack); } @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected){ - if(!world.isRemote && entity instanceof EntityPlayer && ItemUtil.isEnabled(stack) && !isSelected){ - EntityPlayer player = (EntityPlayer)entity; - for(int i = 0; i < player.inventory.getSizeInventory(); i++){ + public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) { + if (!world.isRemote && entity instanceof EntityPlayer && ItemUtil.isEnabled(stack) && !isSelected) { + EntityPlayer player = (EntityPlayer) entity; + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack slot = player.inventory.getStackInSlot(i); - if(StackUtil.isValid(slot) && slot.getCount() == 1){ + if (StackUtil.isValid(slot) && slot.getCount() == 1) { int extractable = this.extractEnergy(stack, Integer.MAX_VALUE, true); int received = 0; - if(slot.hasCapability(CapabilityEnergy.ENERGY, null)){ + if (slot.hasCapability(CapabilityEnergy.ENERGY, null)) { IEnergyStorage cap = slot.getCapability(CapabilityEnergy.ENERGY, null); - if(cap != null){ + if (cap != null) { received = cap.receiveEnergy(extractable, false); } } - if(received > 0){ + if (received > 0) { this.extractEnergy(stack, received, false); } } @@ -72,8 +72,8 @@ public class ItemBattery extends ItemEnergy{ } @Override - public ActionResult onItemRightClick(World worldIn, EntityPlayer player, EnumHand hand){ - if(!worldIn.isRemote && player.isSneaking()){ + public ActionResult onItemRightClick(World worldIn, EntityPlayer player, EnumHand hand) { + if (!worldIn.isRemote && player.isSneaking()) { ItemUtil.changeEnabled(player, hand); return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand)); } @@ -81,9 +81,9 @@ public class ItemBattery extends ItemEnergy{ } @Override - public void addInformation(ItemStack stack, World playerIn, List list, ITooltipFlag advanced){ + public void addInformation(ItemStack stack, World playerIn, List list, ITooltipFlag advanced) { super.addInformation(stack, playerIn, list, advanced); - list.add(StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".battery."+(ItemUtil.isEnabled(stack) ? "discharge" : "noDischarge"))); - list.add(StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".battery.changeMode")); + list.add(StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".battery." + (ItemUtil.isEnabled(stack) ? "discharge" : "noDischarge"))); + list.add(StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".battery.changeMode")); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java index ba09142c2..f92450c62 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java @@ -10,6 +10,10 @@ package de.ellpeck.actuallyadditions.mod.items; +import java.util.List; + +import javax.annotation.Nullable; + import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay; @@ -38,30 +42,26 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import javax.annotation.Nullable; -import java.util.List; - -public class ItemBooklet extends ItemBase implements IHudDisplay{ +public class ItemBooklet extends ItemBase implements IHudDisplay { @SideOnly(Side.CLIENT) public static IBookletPage forcedPage; - public ItemBooklet(String name){ + public ItemBooklet(String name) { super(name); this.setMaxStackSize(1); this.setMaxDamage(0); } - @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing face, float hitX, float hitY, float hitZ){ - if(player.isSneaking()){ + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing face, float hitX, float hitY, float hitZ) { + if (player.isSneaking()) { IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); ItemStack blockStack = new ItemStack(block, 1, block.damageDropped(state)); IBookletPage page = BookletUtils.findFirstPageForStack(blockStack); - if(page != null){ - if(world.isRemote){ + if (page != null) { + if (world.isRemote) { forcedPage = page; } this.onItemRightClick(world, player, hand); @@ -71,12 +71,11 @@ public class ItemBooklet extends ItemBase implements IHudDisplay{ return EnumActionResult.FAIL; } - @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.BOOK.ordinal(), world, (int)player.posX, (int)player.posY, (int)player.posZ); + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.BOOK.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ); - if(!world.isRemote){ + if (!world.isRemote) { //TheAchievements.OPEN_BOOKLET.get(player); //TheAchievements.OPEN_BOOKLET_MILESTONE.get(player); } @@ -84,49 +83,48 @@ public class ItemBooklet extends ItemBase implements IHudDisplay{ } @Override - public void addInformation(ItemStack stack, @Nullable World playerIn, List tooltip, ITooltipFlag advanced){ - tooltip.add(StringUtil.localize("tooltip."+ActuallyAdditions.MODID+"."+this.getBaseName()+".desc")); + public void addInformation(ItemStack stack, @Nullable World playerIn, List tooltip, ITooltipFlag advanced) { + tooltip.add(StringUtil.localize("tooltip." + ActuallyAdditions.MODID + "." + this.getBaseName() + ".desc")); - for(int i = 1; i <= 4; i++){ - String format = i == 4 ? TextFormatting.GOLD.toString()+TextFormatting.ITALIC : TextFormatting.RESET.toString(); - tooltip.add(format+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+"."+this.getBaseName()+".sub."+i)); + for (int i = 1; i <= 4; i++) { + String format = i == 4 ? TextFormatting.GOLD.toString() + TextFormatting.ITALIC : TextFormatting.RESET.toString(); + tooltip.add(format + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + "." + this.getBaseName() + ".sub." + i)); } } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } @Override @SideOnly(Side.CLIENT) - public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){ - if(posHit != null && posHit.getBlockPos() != null){ + public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution) { + if (posHit != null && posHit.getBlockPos() != null) { IBlockState state = minecraft.world.getBlockState(posHit.getBlockPos()); Block block = state.getBlock(); - if(block != null && !block.isAir(minecraft.world.getBlockState(posHit.getBlockPos()), minecraft.world, posHit.getBlockPos())){ + if (block != null && !block.isAir(minecraft.world.getBlockState(posHit.getBlockPos()), minecraft.world, posHit.getBlockPos())) { ItemStack blockStack = new ItemStack(block, 1, block.getMetaFromState(state)); - int height = resolution.getScaledHeight()/5*3; - if(player.isSneaking()){ + int height = resolution.getScaledHeight() / 5 * 3; + if (player.isSneaking()) { IBookletPage page = BookletUtils.findFirstPageForStack(blockStack); - if(page != null){ + if (page != null) { String strg1 = page.getChapter().getLocalizedName(); - String strg2 = StringUtil.localize("info."+ActuallyAdditions.MODID+".booklet.hudDisplay.page")+" "+(page.getChapter().getPageIndex(page)+1); - String strg3 = StringUtil.localize("info."+ActuallyAdditions.MODID+".booklet.hudDisplay.open"); + String strg2 = StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.page") + " " + (page.getChapter().getPageIndex(page) + 1); + String strg3 = StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.open"); - AssetUtil.renderStackToGui(StackUtil.isValid(page.getChapter().getDisplayItemStack()) ? page.getChapter().getDisplayItemStack() : new ItemStack(InitItems.itemBooklet), resolution.getScaledWidth()/2-10, height+41, 1F); - minecraft.fontRenderer.drawStringWithShadow(TextFormatting.YELLOW+""+TextFormatting.ITALIC+strg1, resolution.getScaledWidth()/2-minecraft.fontRenderer.getStringWidth(strg1)/2, height+20, StringUtil.DECIMAL_COLOR_WHITE); - minecraft.fontRenderer.drawStringWithShadow(TextFormatting.YELLOW+""+TextFormatting.ITALIC+strg2, resolution.getScaledWidth()/2-minecraft.fontRenderer.getStringWidth(strg2)/2, height+30, StringUtil.DECIMAL_COLOR_WHITE); - minecraft.fontRenderer.drawStringWithShadow(TextFormatting.GOLD+strg3, resolution.getScaledWidth()/2-minecraft.fontRenderer.getStringWidth(strg3)/2, height+60, StringUtil.DECIMAL_COLOR_WHITE); - } - else{ - String strg1 = TextFormatting.DARK_RED+StringUtil.localize("info."+ActuallyAdditions.MODID+".booklet.hudDisplay.noInfo"); - String strg2 = TextFormatting.DARK_GREEN+""+TextFormatting.ITALIC+StringUtil.localize("info."+ActuallyAdditions.MODID+".booklet.hudDisplay.noInfo.desc.1"); - String strg3 = TextFormatting.DARK_GREEN+""+TextFormatting.ITALIC+StringUtil.localize("info."+ActuallyAdditions.MODID+".booklet.hudDisplay.noInfo.desc.2"); + AssetUtil.renderStackToGui(StackUtil.isValid(page.getChapter().getDisplayItemStack()) ? page.getChapter().getDisplayItemStack() : new ItemStack(InitItems.itemBooklet), resolution.getScaledWidth() / 2 - 10, height + 41, 1F); + minecraft.fontRenderer.drawStringWithShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + strg1, resolution.getScaledWidth() / 2 - minecraft.fontRenderer.getStringWidth(strg1) / 2, height + 20, StringUtil.DECIMAL_COLOR_WHITE); + minecraft.fontRenderer.drawStringWithShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + strg2, resolution.getScaledWidth() / 2 - minecraft.fontRenderer.getStringWidth(strg2) / 2, height + 30, StringUtil.DECIMAL_COLOR_WHITE); + minecraft.fontRenderer.drawStringWithShadow(TextFormatting.GOLD + strg3, resolution.getScaledWidth() / 2 - minecraft.fontRenderer.getStringWidth(strg3) / 2, height + 60, StringUtil.DECIMAL_COLOR_WHITE); + } else { + String strg1 = TextFormatting.DARK_RED + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.noInfo"); + String strg2 = TextFormatting.DARK_GREEN + "" + TextFormatting.ITALIC + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.noInfo.desc.1"); + String strg3 = TextFormatting.DARK_GREEN + "" + TextFormatting.ITALIC + StringUtil.localize("info." + ActuallyAdditions.MODID + ".booklet.hudDisplay.noInfo.desc.2"); - minecraft.fontRenderer.drawStringWithShadow(strg1, resolution.getScaledWidth()/2-minecraft.fontRenderer.getStringWidth(strg1)/2, height+30, StringUtil.DECIMAL_COLOR_WHITE); - minecraft.fontRenderer.drawStringWithShadow(strg2, resolution.getScaledWidth()/2-minecraft.fontRenderer.getStringWidth(strg2)/2, height+50, StringUtil.DECIMAL_COLOR_WHITE); - minecraft.fontRenderer.drawStringWithShadow(strg3, resolution.getScaledWidth()/2-minecraft.fontRenderer.getStringWidth(strg3)/2, height+60, StringUtil.DECIMAL_COLOR_WHITE); + minecraft.fontRenderer.drawStringWithShadow(strg1, resolution.getScaledWidth() / 2 - minecraft.fontRenderer.getStringWidth(strg1) / 2, height + 30, StringUtil.DECIMAL_COLOR_WHITE); + minecraft.fontRenderer.drawStringWithShadow(strg2, resolution.getScaledWidth() / 2 - minecraft.fontRenderer.getStringWidth(strg2) / 2, height + 50, StringUtil.DECIMAL_COLOR_WHITE); + minecraft.fontRenderer.drawStringWithShadow(strg3, resolution.getScaledWidth() / 2 - minecraft.fontRenderer.getStringWidth(strg3) / 2, height + 60, StringUtil.DECIMAL_COLOR_WHITE); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemChestToCrateUpgrade.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemChestToCrateUpgrade.java index 7744ac0e8..6aa66069d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemChestToCrateUpgrade.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemChestToCrateUpgrade.java @@ -28,37 +28,36 @@ import net.minecraft.world.World; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.wrapper.InvWrapper; -public class ItemChestToCrateUpgrade extends ItemBase{ +public class ItemChestToCrateUpgrade extends ItemBase { private final Class start; private final IBlockState end; - public ItemChestToCrateUpgrade(String name, Class start, IBlockState end){ + public ItemChestToCrateUpgrade(String name, Class start, IBlockState end) { super(name); this.start = start; this.end = end; } @Override - public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand){ + public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { ItemStack heldStack = player.getHeldItem(hand); - if(player.isSneaking()){ + if (player.isSneaking()) { TileEntity tileHit = world.getTileEntity(pos); - if(tileHit != null && this.start.isInstance(tileHit)){ - if(!world.isRemote){ + if (tileHit != null && this.start.isInstance(tileHit)) { + if (!world.isRemote) { //Copy Slots IItemHandlerModifiable chest = null; - if(tileHit instanceof IInventory){ - chest = new InvWrapper((IInventory)tileHit); - } - else if(tileHit instanceof TileEntityInventoryBase){ - chest = ((TileEntityInventoryBase)tileHit).inv; + if (tileHit instanceof IInventory) { + chest = new InvWrapper((IInventory) tileHit); + } else if (tileHit instanceof TileEntityInventoryBase) { + chest = ((TileEntityInventoryBase) tileHit).inv; } - if(chest != null){ + if (chest != null) { ItemStack[] stacks = new ItemStack[chest.getSlots()]; - for(int i = 0; i < stacks.length; i++){ + for (int i = 0; i < stacks.length; i++) { ItemStack aStack = chest.getStackInSlot(i); stacks[i] = aStack.copy(); } @@ -68,17 +67,16 @@ public class ItemChestToCrateUpgrade extends ItemBase{ world.removeTileEntity(pos); world.setBlockState(pos, this.end, 2); - if(!player.capabilities.isCreativeMode) - heldStack.shrink(1); + if (!player.capabilities.isCreativeMode) heldStack.shrink(1); //Copy Items into new Chest TileEntity newTileHit = world.getTileEntity(pos); - if(newTileHit instanceof TileEntityInventoryBase){ - IItemHandlerModifiable newChest = ((TileEntityInventoryBase)newTileHit).inv; + if (newTileHit instanceof TileEntityInventoryBase) { + IItemHandlerModifiable newChest = ((TileEntityInventoryBase) newTileHit).inv; - for(int i = 0; i < stacks.length; i++){ - if(StackUtil.isValid(stacks[i])){ - if(newChest.getSlots() > i){ + for (int i = 0; i < stacks.length; i++) { + if (StackUtil.isValid(stacks[i])) { + if (newChest.getSlots() > i) { newChest.setStackInSlot(i, stacks[i].copy()); } } @@ -94,7 +92,7 @@ public class ItemChestToCrateUpgrade extends ItemBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffee.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffee.java index 34f1d39a0..153371d76 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffee.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffee.java @@ -37,9 +37,9 @@ import net.minecraft.util.StringUtils; import net.minecraft.world.World; import net.minecraftforge.fml.common.Loader; -public class ItemCoffee extends ItemFoodBase{ +public class ItemCoffee extends ItemFoodBase { - public ItemCoffee(String name){ + public ItemCoffee(String name) { super(8, 5.0F, false, name); this.setMaxDamage(3); this.setAlwaysEdible(); @@ -47,12 +47,12 @@ public class ItemCoffee extends ItemFoodBase{ this.setNoRepair(); } - public static void initIngredients(){ + public static void initIngredients() { ActuallyAdditionsAPI.addCoffeeMachineIngredient(new MilkIngredient(Ingredient.fromItem(Items.MILK_BUCKET))); //Pam's Soy Milk (For Jemx because he's lactose intolerant. YER HAPPY NAO!?) - if(Loader.isModLoaded("harvestcraft")){ + if (Loader.isModLoaded("harvestcraft")) { Item item = ItemUtil.getItemFromName("harvestcraft:soymilkitem"); - if(item != null){ + if (item != null) { ActuallyAdditionsAPI.addCoffeeMachineIngredient(new MilkIngredient(Ingredient.fromItem(item))); } } @@ -67,88 +67,85 @@ public class ItemCoffee extends ItemFoodBase{ } @Nullable - public static CoffeeIngredient getIngredientFromStack(ItemStack stack){ - for(CoffeeIngredient ingredient : ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS){ - if(ingredient.getInput().apply(stack)) return ingredient; + public static CoffeeIngredient getIngredientFromStack(ItemStack stack) { + for (CoffeeIngredient ingredient : ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS) { + if (ingredient.getInput().apply(stack)) return ingredient; } return null; } - public static void applyPotionEffectsFromStack(ItemStack stack, EntityLivingBase player){ + public static void applyPotionEffectsFromStack(ItemStack stack, EntityLivingBase player) { PotionEffect[] effects = ActuallyAdditionsAPI.methodHandler.getEffectsFromStack(stack); - if(effects != null && effects.length > 0){ - for(PotionEffect effect : effects){ - player.addPotionEffect(new PotionEffect(effect.getPotion(), effect.getDuration()*20, effect.getAmplifier())); + if (effects != null && effects.length > 0) { + for (PotionEffect effect : effects) { + player.addPotionEffect(new PotionEffect(effect.getPotion(), effect.getDuration() * 20, effect.getAmplifier())); } } } @Override - public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase player){ + public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase player) { ItemStack theStack = stack.copy(); super.onItemUseFinish(stack, world, player); applyPotionEffectsFromStack(stack, player); - theStack.setItemDamage(theStack.getItemDamage()+1); - if(theStack.getMaxDamage()-theStack.getItemDamage() < 0){ + theStack.setItemDamage(theStack.getItemDamage() + 1); + if (theStack.getMaxDamage() - theStack.getItemDamage() < 0) { return new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()); - } - else{ + } else { return theStack; } } - @Override - public EnumAction getItemUseAction(ItemStack stack){ + public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.DRINK; } @Override - public int getMetadata(int damage){ + public int getMetadata(int damage) { return damage; } @Override - public boolean getShareTag(){ + public boolean getShareTag() { return true; } @Override - public void addInformation(ItemStack stack, @Nullable World playerIn, List tooltip, ITooltipFlag advanced){ + public void addInformation(ItemStack stack, @Nullable World playerIn, List tooltip, ITooltipFlag advanced) { PotionEffect[] effects = ActuallyAdditionsAPI.methodHandler.getEffectsFromStack(stack); - if(effects != null){ - for(PotionEffect effect : effects){ - tooltip.add(StringUtil.localize(effect.getEffectName())+" "+(effect.getAmplifier()+1)+", "+StringUtils.ticksToElapsedTime(effect.getDuration()*20)); + if (effects != null) { + for (PotionEffect effect : effects) { + tooltip.add(StringUtil.localize(effect.getEffectName()) + " " + (effect.getAmplifier() + 1) + ", " + StringUtils.ticksToElapsedTime(effect.getDuration() * 20)); } - } - else{ - tooltip.add(StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".coffeeCup.noEffect")); + } else { + tooltip.add(StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".coffeeCup.noEffect")); } } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } - public static class MilkIngredient extends CoffeeIngredient{ + public static class MilkIngredient extends CoffeeIngredient { - public MilkIngredient(Ingredient ingredient){ + public MilkIngredient(Ingredient ingredient) { super(ingredient, 0); } @Override - public boolean effect(ItemStack stack){ + public boolean effect(ItemStack stack) { PotionEffect[] effects = ActuallyAdditionsAPI.methodHandler.getEffectsFromStack(stack); ArrayList effectsNew = new ArrayList<>(); - if(effects != null && effects.length > 0){ - for(PotionEffect effect : effects){ - if(effect.getAmplifier() > 0){ - effectsNew.add(new PotionEffect(effect.getPotion(), effect.getDuration()+120, effect.getAmplifier()-1)); + if (effects != null && effects.length > 0) { + for (PotionEffect effect : effects) { + if (effect.getAmplifier() > 0) { + effectsNew.add(new PotionEffect(effect.getPotion(), effect.getDuration() + 120, effect.getAmplifier() - 1)); } } stack.setTagCompound(new NBTTagCompound()); - if(effectsNew.size() > 0){ + if (effectsNew.size() > 0) { this.effects = effectsNew.toArray(new PotionEffect[effectsNew.size()]); ActuallyAdditionsAPI.methodHandler.addEffectToStack(stack, this); } @@ -158,8 +155,8 @@ public class ItemCoffee extends ItemFoodBase{ } @Override - public String getExtraText(){ - return StringUtil.localize("container.nei."+ActuallyAdditions.MODID+".coffee.extra.milk"); + public String getExtraText() { + return StringUtil.localize("container.nei." + ActuallyAdditions.MODID + ".coffee.extra.milk"); } } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffeeBean.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffeeBean.java index 0c36269a2..90601ec3f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffeeBean.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffeeBean.java @@ -14,16 +14,15 @@ import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; -public class ItemCoffeeBean extends ItemFoodBase{ +public class ItemCoffeeBean extends ItemFoodBase { - public ItemCoffeeBean(String name){ + public ItemCoffeeBean(String name) { super(1, 1F, false, name); this.setMaxDamage(0); } - @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrafterOnAStick.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrafterOnAStick.java index 25fd13b3c..f78cabee1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrafterOnAStick.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrafterOnAStick.java @@ -21,25 +21,23 @@ import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.world.World; -public class ItemCrafterOnAStick extends ItemBase{ +public class ItemCrafterOnAStick extends ItemBase { - public ItemCrafterOnAStick(String name){ + public ItemCrafterOnAStick(String name) { super(name); this.setMaxStackSize(1); } - @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ - if(!world.isRemote){ - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.CRAFTER.ordinal(), world, (int)player.posX, (int)player.posY, (int)player.posZ); + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + if (!world.isRemote) { + player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.CRAFTER.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ); } return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand)); } - @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrystalShard.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrystalShard.java index 68b98110e..ddb89fd2f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrystalShard.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrystalShard.java @@ -24,25 +24,24 @@ import net.minecraftforge.common.IRarity; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class ItemCrystalShard extends ItemBase implements IColorProvidingItem{ +public class ItemCrystalShard extends ItemBase implements IColorProvidingItem { - public ItemCrystalShard(String name){ + public ItemCrystalShard(String name) { super(name); this.setHasSubtypes(true); this.setMaxDamage(0); } @Override - public int getMetadata(int damage){ + public int getMetadata(int damage) { return damage; } @Override - public String getTranslationKey(ItemStack stack){ - return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey()+"_"+BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].name; + public String getTranslationKey(ItemStack stack) { + return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey() + "_" + BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].name; } - @Override public IRarity getForgeRarity(ItemStack stack) { return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length ? EnumRarity.COMMON : BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].rarity; @@ -50,30 +49,29 @@ public class ItemCrystalShard extends ItemBase implements IColorProvidingItem{ @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs tab, NonNullList list){ - if(this.isInCreativeTab(tab)){ - for(int j = 0; j < BlockCrystal.ALL_CRYSTALS.length; j++){ + public void getSubItems(CreativeTabs tab, NonNullList list) { + if (this.isInCreativeTab(tab)) { + for (int j = 0; j < BlockCrystal.ALL_CRYSTALS.length; j++) { list.add(new ItemStack(this, 1, j)); } } } @Override - protected void registerRendering(){ - for(int i = 0; i < BlockCrystal.ALL_CRYSTALS.length; i++){ + protected void registerRendering() { + for (int i = 0; i < BlockCrystal.ALL_CRYSTALS.length; i++) { ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), "inventory"); } } @Override @SideOnly(Side.CLIENT) - public IItemColor getItemColor(){ + public IItemColor getItemColor() { return (stack, tintIndex) -> { int damage = stack.getItemDamage(); - if(damage >= 0 && damage < BlockCrystal.ALL_CRYSTALS.length){ + if (damage >= 0 && damage < BlockCrystal.ALL_CRYSTALS.length) { return BlockCrystal.ALL_CRYSTALS[damage].clusterColor; - } - else{ + } else { return 0; } }; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java index 6f1708235..8cd52e3a3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java @@ -58,12 +58,12 @@ import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; -public class ItemDrill extends ItemEnergy{ +public class ItemDrill extends ItemEnergy { public static final int HARVEST_LEVEL = 4; private static final int ENERGY_USE = 100; - public ItemDrill(String name){ + public ItemDrill(String name) { super(250000, 1000, name); this.setMaxDamage(0); this.setHasSubtypes(true); @@ -76,9 +76,9 @@ public class ItemDrill extends ItemEnergy{ * * @param stack The Drill */ - public static void loadSlotsFromNBT(IItemHandlerModifiable slots, ItemStack stack){ + public static void loadSlotsFromNBT(IItemHandlerModifiable slots, ItemStack stack) { NBTTagCompound compound = stack.getTagCompound(); - if(compound != null){ + if (compound != null) { TileEntityInventoryBase.loadSlots(slots, compound); } } @@ -89,9 +89,9 @@ public class ItemDrill extends ItemEnergy{ * @param slots The Slots * @param stack The Drill */ - public static void writeSlotsToNBT(IItemHandler slots, ItemStack stack){ + public static void writeSlotsToNBT(IItemHandler slots, ItemStack stack) { NBTTagCompound compound = stack.getTagCompound(); - if(compound == null){ + if (compound == null) { compound = new NBTTagCompound(); } TileEntityInventoryBase.saveSlots(slots, compound); @@ -100,30 +100,30 @@ public class ItemDrill extends ItemEnergy{ @Override //Places Blocks if the Placing Upgrade is installed - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ){ + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); ItemStack upgrade = this.getHasUpgradeAsStack(stack, ItemDrillUpgrade.UpgradeType.PLACER); - if(StackUtil.isValid(upgrade)){ + if (StackUtil.isValid(upgrade)) { int slot = ItemDrillUpgrade.getSlotToPlaceFrom(upgrade); - if(slot >= 0 && slot < InventoryPlayer.getHotbarSize()){ + if (slot >= 0 && slot < InventoryPlayer.getHotbarSize()) { ItemStack equip = player.inventory.getStackInSlot(slot); - if(StackUtil.isValid(equip) && equip != stack){ + if (StackUtil.isValid(equip) && equip != stack) { ItemStack toPlaceStack = equip.copy(); WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, toPlaceStack); //tryPlaceItemIntoWorld could throw an Exception - try{ + try { //Places the Block into the World - if(toPlaceStack.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ) != EnumActionResult.FAIL){ - if(!player.capabilities.isCreativeMode){ + if (toPlaceStack.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ) != EnumActionResult.FAIL) { + if (!player.capabilities.isCreativeMode) { WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, toPlaceStack.copy()); } } } //Notify the Player and log the Exception - catch(Exception e){ - ActuallyAdditions.LOGGER.error("Player "+player.getName()+" who should place a Block using a Drill at "+player.posX+", "+player.posY+", "+player.posZ+" in World "+world.provider.getDimension()+" threw an Exception! Don't let that happen again!"); + catch (Exception e) { + ActuallyAdditions.LOGGER.error("Player " + player.getName() + " who should place a Block using a Drill at " + player.posX + ", " + player.posY + ", " + player.posZ + " in World " + world.provider.getDimension() + " threw an Exception! Don't let that happen again!"); } player.inventory.setInventorySlotContents(slot, player.getHeldItem(hand)); @@ -143,43 +143,39 @@ public class ItemDrill extends ItemEnergy{ * @param upgrade The Upgrade to be checked * @return The Upgrade, if it's installed */ - public ItemStack getHasUpgradeAsStack(ItemStack stack, ItemDrillUpgrade.UpgradeType upgrade){ + public ItemStack getHasUpgradeAsStack(ItemStack stack, ItemDrillUpgrade.UpgradeType upgrade) { NBTTagCompound compound = stack.getTagCompound(); - if(compound == null){ - return StackUtil.getEmpty(); - } + if (compound == null) { return StackUtil.getEmpty(); } ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerDrill.SLOT_AMOUNT); loadSlotsFromNBT(inv, stack); - for(int i = 0; i < inv.getSlots(); i++){ + for (int i = 0; i < inv.getSlots(); i++) { ItemStack slotStack = inv.getStackInSlot(i); - if(StackUtil.isValid(slotStack) && slotStack.getItem() instanceof ItemDrillUpgrade){ - if(((ItemDrillUpgrade)slotStack.getItem()).type == upgrade){ - return slotStack; - } + if (StackUtil.isValid(slotStack) && slotStack.getItem() instanceof ItemDrillUpgrade) { + if (((ItemDrillUpgrade) slotStack.getItem()).type == upgrade) { return slotStack; } } } return StackUtil.getEmpty(); } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ - if(!world.isRemote && player.isSneaking() && hand == EnumHand.MAIN_HAND){ - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DRILL.ordinal(), world, (int)player.posX, (int)player.posY, (int)player.posZ); + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + if (!world.isRemote && player.isSneaking() && hand == EnumHand.MAIN_HAND) { + player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DRILL.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ); } return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand)); } @Override - public int getMetadata(int damage){ + public int getMetadata(int damage) { return damage; } @Override - public boolean hitEntity(ItemStack stack, EntityLivingBase entity1, EntityLivingBase entity2){ + public boolean hitEntity(ItemStack stack, EntityLivingBase entity1, EntityLivingBase entity2) { int use = this.getEnergyUsePerBlock(stack); - if(!(entity2 instanceof EntityPlayer) || !((EntityPlayer)entity2).capabilities.isCreativeMode){ - if(this.getEnergyStored(stack) >= use){ + if (!(entity2 instanceof EntityPlayer) || !((EntityPlayer) entity2).capabilities.isCreativeMode) { + if (this.getEnergyStored(stack) >= use) { this.extractEnergyInternal(stack, use, false); } } @@ -187,15 +183,15 @@ public class ItemDrill extends ItemEnergy{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } @Override - public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack){ + public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { Multimap map = super.getAttributeModifiers(slot, stack); - if(slot == EntityEquipmentSlot.MAINHAND){ + if (slot == EntityEquipmentSlot.MAINHAND) { map.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Drill Modifier", this.getEnergyStored(stack) >= ENERGY_USE ? 8.0F : 0.1F, 0)); map.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool Modifier", -2.5F, 0)); } @@ -204,39 +200,36 @@ public class ItemDrill extends ItemEnergy{ } @Override - public float getDestroySpeed(ItemStack stack, IBlockState state){ + public float getDestroySpeed(ItemStack stack, IBlockState state) { return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) ? this.hasExtraWhitelist(state.getBlock()) || state.getBlock().getHarvestTool(state) == null || state.getBlock().getHarvestTool(state).isEmpty() || this.getToolClasses(stack).contains(state.getBlock().getHarvestTool(state)) ? this.getEfficiencyFromUpgrade(stack) : 1.0F : 0.1F; } @Override - public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, EntityPlayer player){ + public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, EntityPlayer player) { boolean toReturn = false; int use = this.getEnergyUsePerBlock(stack); - if(this.getEnergyStored(stack) >= use){ + if (this.getEnergyStored(stack) >= use) { //Enchants the Drill depending on the Upgrades it has - if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SILK_TOUCH)){ + if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SILK_TOUCH)) { ItemUtil.addEnchantment(stack, Enchantments.SILK_TOUCH, 1); - } - else{ - if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE)){ + } else { + if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE)) { ItemUtil.addEnchantment(stack, Enchantments.FORTUNE, this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE_II) ? 3 : 1); } } //Block hit RayTraceResult ray = WorldUtil.getNearestBlockWithDefaultReachDistance(player.world, player); - if(ray != null){ + if (ray != null) { //Breaks the Blocks - if(!player.isSneaking() && this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)){ - if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)){ + if (!player.isSneaking() && this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)) { + if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)) { toReturn = this.breakBlocks(stack, 2, player.world, pos, ray.sideHit, player); - } - else{ + } else { toReturn = this.breakBlocks(stack, 1, player.world, pos, ray.sideHit, player); } - } - else{ + } else { toReturn = this.breakBlocks(stack, 0, player.world, pos, ray.sideHit, player); } @@ -249,13 +242,13 @@ public class ItemDrill extends ItemEnergy{ } @Override - public boolean canHarvestBlock(IBlockState state, ItemStack stack){ + public boolean canHarvestBlock(IBlockState state, ItemStack stack) { Block block = state.getBlock(); return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) && (this.hasExtraWhitelist(block) || state.getMaterial().isToolNotRequired() || block == Blocks.SNOW_LAYER || block == Blocks.SNOW || (block == Blocks.OBSIDIAN ? HARVEST_LEVEL >= 3 : block != Blocks.DIAMOND_BLOCK && block != Blocks.DIAMOND_ORE ? block != Blocks.EMERALD_ORE && block != Blocks.EMERALD_BLOCK ? block != Blocks.GOLD_BLOCK && block != Blocks.GOLD_ORE ? block != Blocks.IRON_BLOCK && block != Blocks.IRON_ORE ? block != Blocks.LAPIS_BLOCK && block != Blocks.LAPIS_ORE ? block != Blocks.REDSTONE_ORE && block != Blocks.LIT_REDSTONE_ORE ? state.getMaterial() == Material.ROCK || state.getMaterial() == Material.IRON || state.getMaterial() == Material.ANVIL : HARVEST_LEVEL >= 2 : HARVEST_LEVEL >= 1 : HARVEST_LEVEL >= 1 : HARVEST_LEVEL >= 2 : HARVEST_LEVEL >= 2 : HARVEST_LEVEL >= 2)); } @Override - public Set getToolClasses(ItemStack stack){ + public Set getToolClasses(ItemStack stack) { HashSet hashSet = new HashSet<>(); hashSet.add("pickaxe"); hashSet.add("shovel"); @@ -263,7 +256,7 @@ public class ItemDrill extends ItemEnergy{ } @Override - public int getHarvestLevel(ItemStack stack, String toolClass, EntityPlayer player, IBlockState blockState){ + public int getHarvestLevel(ItemStack stack, String toolClass, EntityPlayer player, IBlockState blockState) { return HARVEST_LEVEL; } @@ -273,37 +266,37 @@ public class ItemDrill extends ItemEnergy{ * @param stack The Drill * @return The Energy use per Block */ - public int getEnergyUsePerBlock(ItemStack stack){ + public int getEnergyUsePerBlock(ItemStack stack) { int use = ENERGY_USE; //Speed - if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED)){ + if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED)) { use += 50; - if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED_II)){ + if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED_II)) { use += 75; - if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED_III)){ + if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED_III)) { use += 175; } } } //Silk Touch - if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SILK_TOUCH)){ + if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SILK_TOUCH)) { use += 100; } //Fortune - if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE)){ + if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE)) { use += 40; - if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE_II)){ + if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE_II)) { use += 80; } } //Size - if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)){ + if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)) { use += 10; - if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)){ + if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)) { use += 30; } } @@ -318,29 +311,29 @@ public class ItemDrill extends ItemEnergy{ * @param upgrade The Upgrade to be checked * @return Is the Upgrade applied? */ - public boolean getHasUpgrade(ItemStack stack, ItemDrillUpgrade.UpgradeType upgrade){ + public boolean getHasUpgrade(ItemStack stack, ItemDrillUpgrade.UpgradeType upgrade) { return StackUtil.isValid(this.getHasUpgradeAsStack(stack, upgrade)); } @Override - protected void registerRendering(){ - for(int i = 0; i < 16; i++){ - String name = this.getRegistryName()+"_"+TheColoredLampColors.values()[i].regName; + protected void registerRendering() { + for (int i = 0; i < 16; i++) { + String name = this.getRegistryName() + "_" + TheColoredLampColors.values()[i].regName; ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), new ResourceLocation(name), "inventory"); } } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs tabs, NonNullList list){ - if(this.isInCreativeTab(tabs)){ - for(int i = 0; i < 16; i++){ + public void getSubItems(CreativeTabs tabs, NonNullList list) { + if (this.isInCreativeTab(tabs)) { + for (int i = 0; i < 16; i++) { this.addDrillStack(list, i); } } } - private void addDrillStack(List list, int meta){ + private void addDrillStack(List list, int meta) { ItemStack stackFull = new ItemStack(this, 1, meta); this.setEnergy(stackFull, this.getMaxEnergyStored(stackFull)); list.add(stackFull); @@ -356,24 +349,22 @@ public class ItemDrill extends ItemEnergy{ * @param stack The Drill * @return The Mining Speed depending on the Speed Upgrades */ - public float getEfficiencyFromUpgrade(ItemStack stack){ + public float getEfficiencyFromUpgrade(ItemStack stack) { float efficiency = 8.0F; - if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED)){ - if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED_II)){ - if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED_III)){ + if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED)) { + if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED_II)) { + if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED_III)) { efficiency += 37.0F; - } - else{ + } else { efficiency += 25.0F; } - } - else{ + } else { efficiency += 8.0F; } } - if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)){ + if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)) { efficiency *= 0.5F; - if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)){ + if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)) { efficiency *= 0.35F; } } @@ -389,17 +380,17 @@ public class ItemDrill extends ItemEnergy{ * @param world The World * @param player The Player who breaks the Blocks */ - public boolean breakBlocks(ItemStack stack, int radius, World world, BlockPos aPos, EnumFacing side, EntityPlayer player){ + public boolean breakBlocks(ItemStack stack, int radius, World world, BlockPos aPos, EnumFacing side, EntityPlayer player) { int xRange = radius; int yRange = radius; int zRange = 0; //Corrects Blocks to hit depending on Side of original Block hit - if(side.getAxis() == Axis.Y){ + if (side.getAxis() == Axis.Y) { zRange = radius; yRange = 0; } - if(side.getAxis() == Axis.X){ + if (side.getAxis() == Axis.X) { xRange = 0; zRange = radius; } @@ -410,38 +401,34 @@ public class ItemDrill extends ItemEnergy{ //Break Middle Block first int use = this.getEnergyUsePerBlock(stack); - if(this.getEnergyStored(stack) >= use){ - if(!this.tryHarvestBlock(world, aPos, false, stack, player, use)){ - return false; - } - } - else{ + if (this.getEnergyStored(stack) >= use) { + if (!this.tryHarvestBlock(world, aPos, false, stack, player, use)) { return false; } + } else { return false; } - if(radius == 2 && side.getAxis() != Axis.Y) { + if (radius == 2 && side.getAxis() != Axis.Y) { aPos = aPos.up(); IBlockState theState = world.getBlockState(aPos); - if(theState.getBlockHardness(world, aPos) <= mainHardness+5.0F){ + if (theState.getBlockHardness(world, aPos) <= mainHardness + 5.0F) { this.tryHarvestBlock(world, aPos, true, stack, player, use); } } //Break Blocks around - if(radius > 0 && mainHardness >= 0.2F){ - for(int xPos = aPos.getX()-xRange; xPos <= aPos.getX()+xRange; xPos++){ - for(int yPos = aPos.getY()-yRange; yPos <= aPos.getY()+yRange; yPos++){ - for(int zPos = aPos.getZ()-zRange; zPos <= aPos.getZ()+zRange; zPos++){ - if(!(aPos.getX() == xPos && aPos.getY() == yPos && aPos.getZ() == zPos)){ - if(this.getEnergyStored(stack) >= use){ + if (radius > 0 && mainHardness >= 0.2F) { + for (int xPos = aPos.getX() - xRange; xPos <= aPos.getX() + xRange; xPos++) { + for (int yPos = aPos.getY() - yRange; yPos <= aPos.getY() + yRange; yPos++) { + for (int zPos = aPos.getZ() - zRange; zPos <= aPos.getZ() + zRange; zPos++) { + if (!(aPos.getX() == xPos && aPos.getY() == yPos && aPos.getZ() == zPos)) { + if (this.getEnergyStored(stack) >= use) { //Only break Blocks around that are (about) as hard or softer BlockPos thePos = new BlockPos(xPos, yPos, zPos); IBlockState theState = world.getBlockState(thePos); - if(theState.getBlockHardness(world, thePos) <= mainHardness+5.0F){ + if (theState.getBlockHardness(world, thePos) <= mainHardness + 5.0F) { this.tryHarvestBlock(world, thePos, true, stack, player, use); } - } - else{ + } else { return false; } } @@ -463,13 +450,13 @@ public class ItemDrill extends ItemEnergy{ * @param player The Player breaking the Blocks * @param use The Energy that should be extracted per Block */ - private boolean tryHarvestBlock(World world, BlockPos pos, boolean isExtra, ItemStack stack, EntityPlayer player, int use){ + private boolean tryHarvestBlock(World world, BlockPos pos, boolean isExtra, ItemStack stack, EntityPlayer player, int use) { IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); float hardness = state.getBlockHardness(world, pos); boolean canHarvest = (ForgeHooks.canHarvestBlock(block, player, world, pos) || this.canHarvestBlock(state, stack)) && (!isExtra || this.getDestroySpeed(stack, world.getBlockState(pos)) > 1.0F); - if(hardness >= 0.0F && (!isExtra || canHarvest && !block.hasTileEntity(world.getBlockState(pos)))){ - if(!player.capabilities.isCreativeMode){ + if (hardness >= 0.0F && (!isExtra || canHarvest && !block.hasTileEntity(world.getBlockState(pos)))) { + if (!player.capabilities.isCreativeMode) { this.extractEnergyInternal(stack, use, false); } //Break the Block @@ -478,16 +465,14 @@ public class ItemDrill extends ItemEnergy{ return false; } - private boolean hasExtraWhitelist(Block block){ - if(block != null){ + private boolean hasExtraWhitelist(Block block) { + if (block != null) { ResourceLocation location = block.getRegistryName(); - if(location != null){ + if (location != null) { String name = location.toString(); - if(name != null){ - for(String s : ConfigStringListValues.DRILL_EXTRA_MINING_WHITELIST.getValue()){ - if(s != null && s.equals(name)){ - return true; - } + if (name != null) { + for (String s : ConfigStringListValues.DRILL_EXTRA_MINING_WHITELIST.getValue()) { + if (s != null && s.equals(name)) { return true; } } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java index 6ee2a48ac..c12138e06 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java @@ -19,47 +19,44 @@ import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.world.World; -public class ItemDrillUpgrade extends ItemBase{ +public class ItemDrillUpgrade extends ItemBase { public final UpgradeType type; - public ItemDrillUpgrade(UpgradeType type, String unlocName){ + public ItemDrillUpgrade(UpgradeType type, String unlocName) { super(unlocName); this.type = type; this.setMaxStackSize(1); } - public static int getSlotToPlaceFrom(ItemStack stack){ + public static int getSlotToPlaceFrom(ItemStack stack) { NBTTagCompound compound = stack.getTagCompound(); - if(compound != null){ - return compound.getInteger("SlotToPlaceFrom")-1; - } + if (compound != null) { return compound.getInteger("SlotToPlaceFrom") - 1; } return -1; } - @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); - if(!world.isRemote && this.type == UpgradeType.PLACER){ + if (!world.isRemote && this.type == UpgradeType.PLACER) { this.setSlotToPlaceFrom(stack, player.inventory.currentItem); return new ActionResult<>(EnumActionResult.SUCCESS, stack); } return new ActionResult<>(EnumActionResult.FAIL, stack); } - public void setSlotToPlaceFrom(ItemStack stack, int slot){ + public void setSlotToPlaceFrom(ItemStack stack, int slot) { NBTTagCompound compound = stack.getTagCompound(); - if(compound == null){ + if (compound == null) { compound = new NBTTagCompound(); } - compound.setInteger("SlotToPlaceFrom", slot+1); + compound.setInteger("SlotToPlaceFrom", slot + 1); stack.setTagCompound(compound); } - public enum UpgradeType{ + public enum UpgradeType { SPEED, SPEED_II, SPEED_III, diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDust.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDust.java index f8774cf63..376789b7d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDust.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDust.java @@ -23,58 +23,56 @@ import net.minecraft.util.NonNullList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class ItemDust extends ItemBase implements IColorProvidingItem{ +public class ItemDust extends ItemBase implements IColorProvidingItem { public static final TheDusts[] ALL_DUSTS = TheDusts.values(); - public ItemDust(String name){ + public ItemDust(String name) { super(name); this.setHasSubtypes(true); } @Override - public int getMetadata(int damage){ + public int getMetadata(int damage) { return damage; } - @Override - public String getTranslationKey(ItemStack stack){ - return stack.getItemDamage() >= ALL_DUSTS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey()+"_"+ALL_DUSTS[stack.getItemDamage()].name; + public String getTranslationKey(ItemStack stack) { + return stack.getItemDamage() >= ALL_DUSTS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey() + "_" + ALL_DUSTS[stack.getItemDamage()].name; } - @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return stack.getItemDamage() >= ALL_DUSTS.length ? EnumRarity.COMMON : ALL_DUSTS[stack.getItemDamage()].rarity; } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs tab, NonNullList list){ - if(this.isInCreativeTab(tab)){ - for(int j = 0; j < ALL_DUSTS.length; j++){ + public void getSubItems(CreativeTabs tab, NonNullList list) { + if (this.isInCreativeTab(tab)) { + for (int j = 0; j < ALL_DUSTS.length; j++) { list.add(new ItemStack(this, 1, j)); } } } @Override - protected void registerRendering(){ - for(int i = 0; i < ALL_DUSTS.length; i++){ + protected void registerRendering() { + for (int i = 0; i < ALL_DUSTS.length; i++) { ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), "inventory"); } } @SideOnly(Side.CLIENT) @Override - public IItemColor getItemColor(){ + public IItemColor getItemColor() { return (stack, pass) -> stack.getItemDamage() >= ALL_DUSTS.length ? 0xFFFFFF : ALL_DUSTS[stack.getItemDamage()].color; } @Override public int getItemBurnTime(ItemStack stack) { - if(stack.getMetadata() == 6) return 1200; + if (stack.getMetadata() == 6) return 1200; return super.getItemBurnTime(stack); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemEngineerGoggles.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemEngineerGoggles.java index efc320d3d..5aad503f0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemEngineerGoggles.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemEngineerGoggles.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.items; +import java.util.List; +import java.util.Set; + import de.ellpeck.actuallyadditions.api.misc.IGoggles; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.items.base.ItemArmorAA; @@ -27,16 +30,13 @@ import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.List; -import java.util.Set; - -public class ItemEngineerGoggles extends ItemArmorAA implements IGoggles{ +public class ItemEngineerGoggles extends ItemArmorAA implements IGoggles { private final Set cachedGlowingEntities = new ConcurrentSet<>(); private final boolean displayMobs; - public ItemEngineerGoggles(String name, boolean displayMobs){ + public ItemEngineerGoggles(String name, boolean displayMobs) { super(name, InitArmorMaterials.armorMaterialGoggles, 0, StackUtil.getEmpty()); this.displayMobs = displayMobs; this.setMaxDamage(0); @@ -44,33 +44,32 @@ public class ItemEngineerGoggles extends ItemArmorAA implements IGoggles{ MinecraftForge.EVENT_BUS.register(this); } - public static boolean isWearing(EntityPlayer player){ + public static boolean isWearing(EntityPlayer player) { ItemStack face = player.inventory.armorInventory.get(3); return StackUtil.isValid(face) && face.getItem() instanceof IGoggles; } @SideOnly(Side.CLIENT) @SubscribeEvent - public void onClientTick(ClientTickEvent event){ + public void onClientTick(ClientTickEvent event) { EntityPlayer player = ActuallyAdditions.PROXY.getCurrentPlayer(); - if(player != null && isWearing(player)){ + if (player != null && isWearing(player)) { ItemStack face = player.inventory.armorInventory.get(3); - if(((IGoggles)face.getItem()).displaySpectralMobs()){ + if (((IGoggles) face.getItem()).displaySpectralMobs()) { double range = 8; - AxisAlignedBB aabb = new AxisAlignedBB(player.posX-range, player.posY-range, player.posZ-range, player.posX+range, player.posY+range, player.posZ+range); + AxisAlignedBB aabb = new AxisAlignedBB(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range); List entities = player.world.getEntitiesWithinAABB(Entity.class, aabb); - if(entities != null && !entities.isEmpty()){ + if (entities != null && !entities.isEmpty()) { this.cachedGlowingEntities.addAll(entities); } - if(!this.cachedGlowingEntities.isEmpty()){ - for(Entity entity : this.cachedGlowingEntities){ - if(entity.isDead || entity.getDistanceSq(player.posX, player.posY, player.posZ) > range*range){ + if (!this.cachedGlowingEntities.isEmpty()) { + for (Entity entity : this.cachedGlowingEntities) { + if (entity.isDead || entity.getDistanceSq(player.posX, player.posY, player.posZ) > range * range) { entity.setGlowing(false); this.cachedGlowingEntities.remove(entity); - } - else{ + } else { entity.setGlowing(true); } } @@ -80,9 +79,9 @@ public class ItemEngineerGoggles extends ItemArmorAA implements IGoggles{ } } - if(!this.cachedGlowingEntities.isEmpty()){ - for(Entity entity : this.cachedGlowingEntities){ - if(!entity.isDead){ + if (!this.cachedGlowingEntities.isEmpty()) { + for (Entity entity : this.cachedGlowingEntities) { + if (!entity.isDead) { entity.setGlowing(false); } } @@ -91,12 +90,12 @@ public class ItemEngineerGoggles extends ItemArmorAA implements IGoggles{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override - public boolean displaySpectralMobs(){ + public boolean displaySpectralMobs() { return this.displayMobs; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFertilizer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFertilizer.java index 9912eba35..dce158405 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFertilizer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFertilizer.java @@ -23,20 +23,19 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class ItemFertilizer extends ItemBase{ +public class ItemFertilizer extends ItemBase { - public ItemFertilizer(String name){ + public ItemFertilizer(String name) { super(name); BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, new DispenserHandlerFertilize()); } - @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10){ + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) { ItemStack stack = player.getHeldItem(hand); - if(ItemDye.applyBonemeal(stack, world, pos, player, hand)){ - if(!world.isRemote){ + if (ItemDye.applyBonemeal(stack, world, pos, player, hand)) { + if (!world.isRemote) { world.playEvent(2005, pos, 0); } return EnumActionResult.SUCCESS; @@ -44,9 +43,8 @@ public class ItemFertilizer extends ItemBase{ return super.onItemUse(player, world, pos, hand, side, par8, par9, par10); } - @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFillingWand.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFillingWand.java index c3d1c9243..b16e772d7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFillingWand.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFillingWand.java @@ -10,6 +10,10 @@ package de.ellpeck.actuallyadditions.mod.items; +import java.util.List; + +import org.apache.commons.lang3.tuple.Pair; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.util.StackUtil; @@ -34,10 +38,6 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -import java.util.List; - -import org.apache.commons.lang3.tuple.Pair; - public class ItemFillingWand extends ItemEnergy { public ItemFillingWand(String name) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFilter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFilter.java index f8a2477c3..e8658583b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFilter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFilter.java @@ -27,35 +27,35 @@ import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.world.World; -public class ItemFilter extends ItemBase{ +public class ItemFilter extends ItemBase { - public ItemFilter(String name){ + public ItemFilter(String name) { super(name); this.setMaxStackSize(1); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.UNCOMMON; } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ - if(!world.isRemote && hand == EnumHand.MAIN_HAND){ - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FILTER.ordinal(), world, (int)player.posX, (int)player.posY, (int)player.posZ); + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + if (!world.isRemote && hand == EnumHand.MAIN_HAND) { + player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FILTER.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ); } return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand)); } @Override - public void addInformation(ItemStack stack, World playerIn, List tooltip, ITooltipFlag advanced){ + public void addInformation(ItemStack stack, World playerIn, List tooltip, ITooltipFlag advanced) { super.addInformation(stack, playerIn, tooltip, advanced); ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerFilter.SLOT_AMOUNT); ItemDrill.loadSlotsFromNBT(inv, stack); - for(int i = 0; i < inv.getSlots(); i++){ + for (int i = 0; i < inv.getSlots(); i++) { ItemStack slot = inv.getStackInSlot(i); - if(StackUtil.isValid(slot)){ + if (StackUtil.isValid(slot)) { tooltip.add(slot.getItem().getItemStackDisplayName(slot)); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFoods.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFoods.java index f5b22d968..aed981b8c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFoods.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFoods.java @@ -28,11 +28,11 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class ItemFoods extends ItemFoodBase{ +public class ItemFoods extends ItemFoodBase { public static final TheFoods[] ALL_FOODS = TheFoods.values(); - public ItemFoods(String name){ + public ItemFoods(String name) { super(0, 0.0F, false, name); this.setHasSubtypes(true); this.setMaxDamage(0); @@ -40,12 +40,12 @@ public class ItemFoods extends ItemFoodBase{ } @Override - public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase player){ + public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase player) { ItemStack stackToReturn = super.onItemUseFinish(stack, world, player); ItemStack returnItem = stack.getItemDamage() >= ALL_FOODS.length ? null : ALL_FOODS[stack.getItemDamage()].returnItem; - if(StackUtil.isValid(returnItem) && player instanceof EntityPlayer){ - if(!((EntityPlayer)player).inventory.addItemStackToInventory(returnItem.copy())){ - if(!world.isRemote){ + if (StackUtil.isValid(returnItem) && player instanceof EntityPlayer) { + if (!((EntityPlayer) player).inventory.addItemStackToInventory(returnItem.copy())) { + if (!world.isRemote) { EntityItem entityItem = new EntityItem(player.world, player.posX, player.posY, player.posZ, returnItem.copy()); entityItem.setPickupDelay(0); player.world.spawnEntity(entityItem); @@ -56,56 +56,54 @@ public class ItemFoods extends ItemFoodBase{ } @Override - public int getMaxItemUseDuration(ItemStack stack){ + public int getMaxItemUseDuration(ItemStack stack) { return stack.getItemDamage() >= ALL_FOODS.length ? 0 : ALL_FOODS[stack.getItemDamage()].useDuration; } @Override - public EnumAction getItemUseAction(ItemStack stack){ + public EnumAction getItemUseAction(ItemStack stack) { return stack.getItemDamage() >= ALL_FOODS.length ? EnumAction.EAT : ALL_FOODS[stack.getItemDamage()].getsDrunken ? EnumAction.DRINK : EnumAction.EAT; } @Override - public int getHealAmount(ItemStack stack){ + public int getHealAmount(ItemStack stack) { return stack.getItemDamage() >= ALL_FOODS.length ? 0 : ALL_FOODS[stack.getItemDamage()].healAmount; } @Override - public float getSaturationModifier(ItemStack stack){ + public float getSaturationModifier(ItemStack stack) { return stack.getItemDamage() >= ALL_FOODS.length ? 0 : ALL_FOODS[stack.getItemDamage()].saturation; } @Override - public int getMetadata(int damage){ + public int getMetadata(int damage) { return damage; } - @Override - public String getTranslationKey(ItemStack stack){ - return stack.getItemDamage() >= ALL_FOODS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey()+"_"+ALL_FOODS[stack.getItemDamage()].name; + public String getTranslationKey(ItemStack stack) { + return stack.getItemDamage() >= ALL_FOODS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey() + "_" + ALL_FOODS[stack.getItemDamage()].name; } - @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return stack.getItemDamage() >= ALL_FOODS.length ? EnumRarity.COMMON : ALL_FOODS[stack.getItemDamage()].rarity; } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs tab, NonNullList list){ - if(this.isInCreativeTab(tab)){ - for(int j = 0; j < ALL_FOODS.length; j++){ + public void getSubItems(CreativeTabs tab, NonNullList list) { + if (this.isInCreativeTab(tab)) { + for (int j = 0; j < ALL_FOODS.length; j++) { list.add(new ItemStack(this, 1, j)); } } } @Override - protected void registerRendering(){ - for(int i = 0; i < ALL_FOODS.length; i++){ - String name = this.getRegistryName()+"_"+ALL_FOODS[i].name; + protected void registerRendering() { + for (int i = 0; i < ALL_FOODS.length; i++) { + String name = this.getRegistryName() + "_" + ALL_FOODS[i].name; ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), new ModelResourceLocation(name), "inventory"); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGeneric.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGeneric.java index 12eb5a246..fe9ddab4a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGeneric.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGeneric.java @@ -14,16 +14,15 @@ import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; -public class ItemGeneric extends ItemBase{ +public class ItemGeneric extends ItemBase { - public ItemGeneric(String name){ + public ItemGeneric(String name) { super(name); this.setMaxDamage(0); } - @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.UNCOMMON; } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGrowthRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGrowthRing.java index f01bcb1d1..51de42b1a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGrowthRing.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGrowthRing.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.items; +import java.util.ArrayList; +import java.util.List; + import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.Block; @@ -25,40 +28,35 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.IPlantable; -import java.util.ArrayList; -import java.util.List; +public class ItemGrowthRing extends ItemEnergy { -public class ItemGrowthRing extends ItemEnergy{ - - public ItemGrowthRing(String name){ + public ItemGrowthRing(String name) { super(1000000, 2000, name); } @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){ - if(!(entity instanceof EntityPlayer) || world.isRemote || entity.isSneaking()){ - return; - } + public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { + if (!(entity instanceof EntityPlayer) || world.isRemote || entity.isSneaking()) { return; } - EntityPlayer player = (EntityPlayer)entity; + EntityPlayer player = (EntityPlayer) entity; ItemStack equipped = player.getHeldItemMainhand(); int energyUse = 300; - if(StackUtil.isValid(equipped) && equipped == stack && this.getEnergyStored(stack) >= energyUse){ + if (StackUtil.isValid(equipped) && equipped == stack && this.getEnergyStored(stack) >= energyUse) { List blocks = new ArrayList<>(); //Adding all possible Blocks - if(player.world.getTotalWorldTime()%30 == 0){ + if (player.world.getTotalWorldTime() % 30 == 0) { int range = 3; - for(int x = -range; x < range+1; x++){ - for(int z = -range; z < range+1; z++){ - for(int y = -range; y < range+1; y++){ - int theX = MathHelper.floor(player.posX+x); - int theY = MathHelper.floor(player.posY+y); - int theZ = MathHelper.floor(player.posZ+z); + for (int x = -range; x < range + 1; x++) { + for (int z = -range; z < range + 1; z++) { + for (int y = -range; y < range + 1; y++) { + int theX = MathHelper.floor(player.posX + x); + int theY = MathHelper.floor(player.posY + y); + int theZ = MathHelper.floor(player.posZ + z); BlockPos posInQuestion = new BlockPos(theX, theY, theZ); Block theBlock = world.getBlockState(posInQuestion).getBlock(); - if((theBlock instanceof IGrowable || theBlock instanceof IPlantable) && !(theBlock instanceof BlockGrass)){ + if ((theBlock instanceof IGrowable || theBlock instanceof IPlantable) && !(theBlock instanceof BlockGrass)) { blocks.add(posInQuestion); } } @@ -66,9 +64,9 @@ public class ItemGrowthRing extends ItemEnergy{ } //Fertilizing the Blocks - if(!blocks.isEmpty()){ - for(int i = 0; i < 45; i++){ - if(this.getEnergyStored(stack) >= energyUse){ + if (!blocks.isEmpty()) { + for (int i = 0; i < 45; i++) { + if (this.getEnergyStored(stack) >= energyUse) { BlockPos pos = blocks.get(world.rand.nextInt(blocks.size())); IBlockState state = world.getBlockState(pos); @@ -78,15 +76,14 @@ public class ItemGrowthRing extends ItemEnergy{ //Show Particles if Metadata changed IBlockState newState = world.getBlockState(pos); - if(newState.getBlock().getMetaFromState(newState) != metaBefore){ + if (newState.getBlock().getMetaFromState(newState) != metaBefore) { world.playEvent(2005, pos, 0); } - if(!player.capabilities.isCreativeMode){ + if (!player.capabilities.isCreativeMode) { this.extractEnergyInternal(stack, energyUse, false); } - } - else{ + } else { break; } } @@ -95,9 +92,8 @@ public class ItemGrowthRing extends ItemEnergy{ } } - @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemHairyBall.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemHairyBall.java index 6aad84a32..6778174a5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemHairyBall.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemHairyBall.java @@ -33,23 +33,23 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -public class ItemHairyBall extends ItemBase{ +public class ItemHairyBall extends ItemBase { private final UUID KittyVanCatUUID = UUID.fromString("681d4e20-10ef-40c9-a0a5-ba2f1995ef44"); - public ItemHairyBall(String name){ + public ItemHairyBall(String name) { super(name); MinecraftForge.EVENT_BUS.register(this); } @SubscribeEvent - public void livingUpdateEvent(LivingEvent.LivingUpdateEvent event){ + public void livingUpdateEvent(LivingEvent.LivingUpdateEvent event) { //Ocelots dropping Hair Balls - if(ConfigBoolValues.DO_CAT_DROPS.isEnabled() && event.getEntityLiving() != null && event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote){ - if(event.getEntityLiving() instanceof EntityOcelot && ((EntityOcelot)event.getEntityLiving()).isTamed() || event.getEntityLiving() instanceof EntityPlayer && event.getEntityLiving().getUniqueID().equals(this.KittyVanCatUUID)){ - if(event.getEntityLiving().world.rand.nextInt(ConfigIntValues.FUR_CHANCE.getValue()) == 0){ - EntityItem item = new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX+0.5, event.getEntityLiving().posY+0.5, event.getEntityLiving().posZ+0.5, new ItemStack(InitItems.itemHairyBall)); + if (ConfigBoolValues.DO_CAT_DROPS.isEnabled() && event.getEntityLiving() != null && event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote) { + if (event.getEntityLiving() instanceof EntityOcelot && ((EntityOcelot) event.getEntityLiving()).isTamed() || event.getEntityLiving() instanceof EntityPlayer && event.getEntityLiving().getUniqueID().equals(this.KittyVanCatUUID)) { + if (event.getEntityLiving().world.rand.nextInt(ConfigIntValues.FUR_CHANCE.getValue()) == 0) { + EntityItem item = new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX + 0.5, event.getEntityLiving().posY + 0.5, event.getEntityLiving().posZ + 0.5, new ItemStack(InitItems.itemHairyBall)); event.getEntityLiving().world.spawnEntity(item); } } @@ -57,29 +57,28 @@ public class ItemHairyBall extends ItemBase{ } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); - if(!world.isRemote){ + if (!world.isRemote) { ItemStack returnItem = this.getRandomReturnItem(world.rand); - if(!player.inventory.addItemStackToInventory(returnItem)){ + if (!player.inventory.addItemStackToInventory(returnItem)) { EntityItem entityItem = new EntityItem(player.world, player.posX, player.posY, player.posZ, returnItem); entityItem.setPickupDelay(0); player.world.spawnEntity(entityItem); } stack.shrink(1); - world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, world.rand.nextFloat()*0.1F+0.9F); + world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, world.rand.nextFloat() * 0.1F + 0.9F); } return new ActionResult<>(EnumActionResult.SUCCESS, stack); } - public ItemStack getRandomReturnItem(Random rand){ + public ItemStack getRandomReturnItem(Random rand) { return WeightedRandom.getRandomItem(rand, ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS).returnItem.copy(); } - @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemJams.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemJams.java index e4826e794..83b8f3d8f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemJams.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemJams.java @@ -30,11 +30,11 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class ItemJams extends ItemFoodBase implements IColorProvidingItem{ +public class ItemJams extends ItemFoodBase implements IColorProvidingItem { public static final TheJams[] ALL_JAMS = TheJams.values(); - public ItemJams(String name){ + public ItemJams(String name) { super(0, 0.0F, false, name); this.setHasSubtypes(true); this.setMaxDamage(0); @@ -42,37 +42,35 @@ public class ItemJams extends ItemFoodBase implements IColorProvidingItem{ } @Override - public int getMetadata(int damage){ + public int getMetadata(int damage) { return damage; } - @Override - public String getTranslationKey(ItemStack stack){ - return stack.getItemDamage() >= ALL_JAMS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey()+"_"+ALL_JAMS[stack.getItemDamage()].name; + public String getTranslationKey(ItemStack stack) { + return stack.getItemDamage() >= ALL_JAMS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey() + "_" + ALL_JAMS[stack.getItemDamage()].name; } - @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return stack.getItemDamage() >= ALL_JAMS.length ? EnumRarity.COMMON : ALL_JAMS[stack.getItemDamage()].rarity; } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs tab, NonNullList list){ - if(this.isInCreativeTab(tab)){ - for(int j = 0; j < ALL_JAMS.length; j++){ + public void getSubItems(CreativeTabs tab, NonNullList list) { + if (this.isInCreativeTab(tab)) { + for (int j = 0; j < ALL_JAMS.length; j++) { list.add(new ItemStack(this, 1, j)); } } } @Override - public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase player){ + public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase player) { ItemStack stackToReturn = super.onItemUseFinish(stack, world, player); - if(player instanceof EntityPlayer && !world.isRemote && stack.getItemDamage() < ALL_JAMS.length){ + if (player instanceof EntityPlayer && !world.isRemote && stack.getItemDamage() < ALL_JAMS.length) { PotionEffect firstEffectToGet = new PotionEffect(Potion.getPotionById(ALL_JAMS[stack.getItemDamage()].firstEffectToGet), 200); player.addPotionEffect(firstEffectToGet); @@ -80,7 +78,7 @@ public class ItemJams extends ItemFoodBase implements IColorProvidingItem{ player.addPotionEffect(secondEffectToGet); ItemStack returnItem = new ItemStack(Items.GLASS_BOTTLE); - if(!((EntityPlayer)player).inventory.addItemStackToInventory(returnItem.copy())){ + if (!((EntityPlayer) player).inventory.addItemStackToInventory(returnItem.copy())) { EntityItem entityItem = new EntityItem(player.world, player.posX, player.posY, player.posZ, returnItem.copy()); entityItem.setPickupDelay(0); player.world.spawnEntity(entityItem); @@ -90,25 +88,25 @@ public class ItemJams extends ItemFoodBase implements IColorProvidingItem{ } @Override - public int getHealAmount(ItemStack stack){ + public int getHealAmount(ItemStack stack) { return stack.getItemDamage() >= ALL_JAMS.length ? 0 : ALL_JAMS[stack.getItemDamage()].healAmount; } @Override - public float getSaturationModifier(ItemStack stack){ + public float getSaturationModifier(ItemStack stack) { return stack.getItemDamage() >= ALL_JAMS.length ? 0 : ALL_JAMS[stack.getItemDamage()].saturation; } @Override - protected void registerRendering(){ - for(int i = 0; i < ALL_JAMS.length; i++){ + protected void registerRendering() { + for (int i = 0; i < ALL_JAMS.length; i++) { ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), "inventory"); } } @Override @SideOnly(Side.CLIENT) - public IItemColor getItemColor(){ + public IItemColor getItemColor() { return (stack, pass) -> pass > 0 ? stack.getItemDamage() >= ALL_JAMS.length ? 0xFFFFFF : ALL_JAMS[stack.getItemDamage()].color : 0xFFFFFF; } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemKnife.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemKnife.java index 2e1bcfb3a..110315ef6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemKnife.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemKnife.java @@ -19,9 +19,9 @@ import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; -public class ItemKnife extends ItemBase{ +public class ItemKnife extends ItemBase { - public ItemKnife(String name){ + public ItemKnife(String name) { super(name); this.setMaxDamage(100); this.setMaxStackSize(1); @@ -30,31 +30,28 @@ public class ItemKnife extends ItemBase{ } @Override - public boolean getShareTag(){ + public boolean getShareTag() { return true; } - @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } - @Override - public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack){ + public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { Multimap map = super.getAttributeModifiers(slot, stack); - if(slot == EntityEquipmentSlot.MAINHAND){ + if (slot == EntityEquipmentSlot.MAINHAND) { map.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Knife Modifier", 3, 0)); } return map; } - @Override - public ItemStack getContainerItem(ItemStack stack){ + public ItemStack getContainerItem(ItemStack stack) { ItemStack theStack = stack.copy(); - theStack.setItemDamage(theStack.getItemDamage()+1); + theStack.setItemDamage(theStack.getItemDamage() + 1); return theStack; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserRelayUpgrade.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserRelayUpgrade.java index 17818375f..cdfe53048 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserRelayUpgrade.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserRelayUpgrade.java @@ -14,14 +14,14 @@ import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; -public class ItemLaserRelayUpgrade extends ItemBase{ +public class ItemLaserRelayUpgrade extends ItemBase { - public ItemLaserRelayUpgrade(String name){ + public ItemLaserRelayUpgrade(String name) { super(name); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.UNCOMMON; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java index 8eb3a55b6..3c2068efc 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.items; +import java.util.List; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; @@ -28,49 +30,46 @@ import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; -import java.util.List; +public class ItemLaserWrench extends ItemBase { -public class ItemLaserWrench extends ItemBase{ - - public ItemLaserWrench(String name){ + public ItemLaserWrench(String name) { super(name); this.setMaxStackSize(1); } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing par7, float par8, float par9, float par10){ + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing par7, float par8, float par9, float par10) { ItemStack stack = player.getHeldItem(hand); TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityLaserRelay){ - TileEntityLaserRelay relay = (TileEntityLaserRelay)tile; - if(!world.isRemote){ - if(ItemPhantomConnector.getStoredPosition(stack) == null){ + if (tile instanceof TileEntityLaserRelay) { + TileEntityLaserRelay relay = (TileEntityLaserRelay) tile; + if (!world.isRemote) { + if (ItemPhantomConnector.getStoredPosition(stack) == null) { ItemPhantomConnector.storeConnection(stack, pos.getX(), pos.getY(), pos.getZ(), world); - player.sendStatusMessage(new TextComponentTranslation("tooltip."+ActuallyAdditions.MODID+".laser.stored.desc"), true); - } - else{ + player.sendStatusMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".laser.stored.desc"), true); + } else { BlockPos savedPos = ItemPhantomConnector.getStoredPosition(stack); - if(savedPos != null){ + if (savedPos != null) { TileEntity savedTile = world.getTileEntity(savedPos); - if(savedTile instanceof TileEntityLaserRelay){ - int distanceSq = (int)savedPos.distanceSq(pos); - TileEntityLaserRelay savedRelay = (TileEntityLaserRelay)savedTile; + if (savedTile instanceof TileEntityLaserRelay) { + int distanceSq = (int) savedPos.distanceSq(pos); + TileEntityLaserRelay savedRelay = (TileEntityLaserRelay) savedTile; int lowestRange = Math.min(relay.getMaxRange(), savedRelay.getMaxRange()); - int range = lowestRange*lowestRange; - if(ItemPhantomConnector.getStoredWorld(stack) == world && savedRelay.type == relay.type && distanceSq <= range && ActuallyAdditionsAPI.connectionHandler.addConnection(savedPos, pos, relay.type, world, false, true)){ + int range = lowestRange * lowestRange; + if (ItemPhantomConnector.getStoredWorld(stack) == world && savedRelay.type == relay.type && distanceSq <= range && ActuallyAdditionsAPI.connectionHandler.addConnection(savedPos, pos, relay.type, world, false, true)) { ItemPhantomConnector.clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored"); - ((TileEntityLaserRelay)savedTile).sendUpdate(); + ((TileEntityLaserRelay) savedTile).sendUpdate(); relay.sendUpdate(); - player.sendStatusMessage(new TextComponentTranslation("tooltip."+ActuallyAdditions.MODID+".laser.connected.desc"), true); + player.sendStatusMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".laser.connected.desc"), true); return EnumActionResult.SUCCESS; } } - player.sendMessage(new TextComponentTranslation("tooltip."+ActuallyAdditions.MODID+".laser.cantConnect.desc")); + player.sendMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".laser.cantConnect.desc")); ItemPhantomConnector.clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored"); } } @@ -81,24 +80,24 @@ public class ItemLaserWrench extends ItemBase{ } @Override - public boolean getShareTag(){ + public boolean getShareTag() { return true; } @Override - public void addInformation(ItemStack stack, World playerIn, List list, ITooltipFlag advanced){ + public void addInformation(ItemStack stack, World playerIn, List list, ITooltipFlag advanced) { BlockPos coords = ItemPhantomConnector.getStoredPosition(stack); - if(coords != null){ - list.add(StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".boundTo.desc")+":"); - list.add("X: "+coords.getX()); - list.add("Y: "+coords.getY()); - list.add("Z: "+coords.getZ()); - list.add(TextFormatting.ITALIC+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".clearStorage.desc")); + if (coords != null) { + list.add(StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".boundTo.desc") + ":"); + list.add("X: " + coords.getX()); + list.add("Y: " + coords.getY()); + list.add("Z: " + coords.getZ()); + list.add(TextFormatting.ITALIC + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".clearStorage.desc")); } } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLeafBlower.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLeafBlower.java index f99610e58..e07ae858c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLeafBlower.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLeafBlower.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.items; +import java.util.ArrayList; +import java.util.Collections; + import de.ellpeck.actuallyadditions.api.misc.IDisplayStandItem; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import net.minecraft.block.Block; @@ -31,52 +34,46 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.IShearable; -import java.util.ArrayList; -import java.util.Collections; - -public class ItemLeafBlower extends ItemBase implements IDisplayStandItem{ +public class ItemLeafBlower extends ItemBase implements IDisplayStandItem { private final boolean isAdvanced; - public ItemLeafBlower(boolean isAdvanced, String name){ + public ItemLeafBlower(boolean isAdvanced, String name) { super(name); this.isAdvanced = isAdvanced; this.setMaxStackSize(1); } - @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { player.setActiveHand(hand); return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand)); } - @Override - public EnumAction getItemUseAction(ItemStack stack){ + public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.BOW; } @Override - public int getMaxItemUseDuration(ItemStack stack){ + public int getMaxItemUseDuration(ItemStack stack) { //Cuz you won't hold it for that long right-clicking anyways return Integer.MAX_VALUE; } - @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return this.isAdvanced ? EnumRarity.EPIC : EnumRarity.RARE; } @Override - public void onUsingTick(ItemStack stack, EntityLivingBase player, int time){ + public void onUsingTick(ItemStack stack, EntityLivingBase player, int time) { this.doUpdate(player.world, MathHelper.floor(player.posX), MathHelper.floor(player.posY), MathHelper.floor(player.posZ), time, stack); } - private boolean doUpdate(World world, int x, int y, int z, int time, ItemStack stack){ - if(!world.isRemote){ - if(time <= this.getMaxItemUseDuration(stack) && (this.isAdvanced || time%3 == 0)){ + private boolean doUpdate(World world, int x, int y, int z, int time, ItemStack stack) { + if (!world.isRemote) { + if (time <= this.getMaxItemUseDuration(stack) && (this.isAdvanced || time % 3 == 0)) { //Breaks the Blocks boolean broke = this.breakStuff(world, x, y, z); //Plays a Minecart sounds (It really sounds like a Leaf Blower!) @@ -95,26 +92,26 @@ public class ItemLeafBlower extends ItemBase implements IDisplayStandItem{ * @param y The Y Position of the Player * @param z The Z Position of the Player */ - public boolean breakStuff(World world, int x, int y, int z){ + public boolean breakStuff(World world, int x, int y, int z) { ArrayList breakPositions = new ArrayList<>(); int rangeSides = 5; int rangeUp = 1; - for(int reachX = -rangeSides; reachX < rangeSides+1; reachX++){ - for(int reachZ = -rangeSides; reachZ < rangeSides+1; reachZ++){ - for(int reachY = this.isAdvanced ? -rangeSides : -rangeUp; reachY < (this.isAdvanced ? rangeSides : rangeUp)+1; reachY++){ + for (int reachX = -rangeSides; reachX < rangeSides + 1; reachX++) { + for (int reachZ = -rangeSides; reachZ < rangeSides + 1; reachZ++) { + for (int reachY = this.isAdvanced ? -rangeSides : -rangeUp; reachY < (this.isAdvanced ? rangeSides : rangeUp) + 1; reachY++) { //The current Block to break - BlockPos pos = new BlockPos(x+reachX, y+reachY, z+reachZ); + BlockPos pos = new BlockPos(x + reachX, y + reachY, z + reachZ); Block block = world.getBlockState(pos).getBlock(); - if(block != null && (block instanceof BlockBush || block instanceof IShearable) && (this.isAdvanced || !block.isLeaves(world.getBlockState(pos), world, pos))){ + if (block != null && (block instanceof BlockBush || block instanceof IShearable) && (this.isAdvanced || !block.isLeaves(world.getBlockState(pos), world, pos))) { breakPositions.add(pos); } } } } - if(!breakPositions.isEmpty()){ + if (!breakPositions.isEmpty()) { Collections.shuffle(breakPositions); BlockPos theCoord = breakPositions.get(0); @@ -133,12 +130,12 @@ public class ItemLeafBlower extends ItemBase implements IDisplayStandItem{ } @Override - public boolean update(ItemStack stack, TileEntity tile, int elapsedTicks){ + public boolean update(ItemStack stack, TileEntity tile, int elapsedTicks) { return this.doUpdate(tile.getWorld(), tile.getPos().getX(), tile.getPos().getY(), tile.getPos().getZ(), elapsedTicks, stack); } @Override - public int getUsePerTick(ItemStack stack, TileEntity tile, int elapsedTicks){ + public int getUsePerTick(ItemStack stack, TileEntity tile, int elapsedTicks) { return 60; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java index ec15f6cf5..ada7e71c7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java @@ -25,39 +25,39 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.World; -public class ItemMagnetRing extends ItemEnergy{ +public class ItemMagnetRing extends ItemEnergy { - public ItemMagnetRing(String name){ + public ItemMagnetRing(String name) { super(200000, 1000, name); } @Override - public boolean hasEffect(ItemStack stack){ + public boolean hasEffect(ItemStack stack) { return !ItemUtil.isEnabled(stack); } @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){ - if(entity instanceof EntityPlayer && !world.isRemote && !ItemUtil.isEnabled(stack)){ - EntityPlayer player = (EntityPlayer)entity; - if(player.isCreative() || player.isSpectator()) return; - if(!entity.isSneaking()){ + public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { + if (entity instanceof EntityPlayer && !world.isRemote && !ItemUtil.isEnabled(stack)) { + EntityPlayer player = (EntityPlayer) entity; + if (player.isCreative() || player.isSpectator()) return; + if (!entity.isSneaking()) { //Get all the Items in the area int range = 5; - List items = world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(entity.posX-range, entity.posY-range, entity.posZ-range, entity.posX+range, entity.posY+range, entity.posZ+range)); - if(!items.isEmpty()){ - for(EntityItem item : items){ - if(item.getEntityData().getBoolean("PreventRemoteMovement")) continue; - if(!item.isDead && !item.cannotPickup()){ - int energyForItem = 50*item.getItem().getCount(); + List items = world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range)); + if (!items.isEmpty()) { + for (EntityItem item : items) { + if (item.getEntityData().getBoolean("PreventRemoteMovement")) continue; + if (!item.isDead && !item.cannotPickup()) { + int energyForItem = 50 * item.getItem().getCount(); - if(this.getEnergyStored(stack) >= energyForItem){ + if (this.getEnergyStored(stack) >= energyForItem) { ItemStack oldItem = item.getItem().copy(); item.onCollideWithPlayer(player); - if(!player.capabilities.isCreativeMode){ - if(item.isDead || !ItemStack.areItemStacksEqual(item.getItem(), oldItem)){ + if (!player.capabilities.isCreativeMode) { + if (item.isDead || !ItemStack.areItemStacksEqual(item.getItem(), oldItem)) { this.extractEnergyInternal(stack, energyForItem, false); } } @@ -70,8 +70,8 @@ public class ItemMagnetRing extends ItemEnergy{ } @Override - public ActionResult onItemRightClick(World worldIn, EntityPlayer player, EnumHand hand){ - if(!worldIn.isRemote && player.isSneaking()){ + public ActionResult onItemRightClick(World worldIn, EntityPlayer player, EnumHand hand) { + if (!worldIn.isRemote && player.isSneaking()) { ItemUtil.changeEnabled(player, hand); return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand)); } @@ -79,7 +79,7 @@ public class ItemMagnetRing extends ItemEnergy{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMisc.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMisc.java index ab3d5664f..db4f923f6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMisc.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMisc.java @@ -30,37 +30,36 @@ import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class ItemMisc extends ItemBase{ +public class ItemMisc extends ItemBase { public static final TheMiscItems[] ALL_MISC_ITEMS = TheMiscItems.values(); - public ItemMisc(String name){ + public ItemMisc(String name) { super(name); this.setHasSubtypes(true); } @Override - public int getMetadata(int damage){ + public int getMetadata(int damage) { return damage; } @Override - public String getTranslationKey(ItemStack stack){ - return stack.getItemDamage() >= ALL_MISC_ITEMS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey()+"_"+ALL_MISC_ITEMS[stack.getItemDamage()].name; + public String getTranslationKey(ItemStack stack) { + return stack.getItemDamage() >= ALL_MISC_ITEMS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey() + "_" + ALL_MISC_ITEMS[stack.getItemDamage()].name; } - @Override - public IRarity getForgeRarity(ItemStack stack){ + public IRarity getForgeRarity(ItemStack stack) { return stack.getItemDamage() >= ALL_MISC_ITEMS.length ? EnumRarity.COMMON : ALL_MISC_ITEMS[stack.getItemDamage()].rarity; } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs tab, NonNullList list){ - if(this.isInCreativeTab(tab)){ - for(int j = 0; j < ALL_MISC_ITEMS.length; j++){ - if(j != TheMiscItems.YOUTUBE_ICON.ordinal()){ + public void getSubItems(CreativeTabs tab, NonNullList list) { + if (this.isInCreativeTab(tab)) { + for (int j = 0; j < ALL_MISC_ITEMS.length; j++) { + if (j != TheMiscItems.YOUTUBE_ICON.ordinal()) { list.add(new ItemStack(this, 1, j)); } } @@ -68,27 +67,27 @@ public class ItemMisc extends ItemBase{ } @Override - protected void registerRendering(){ - for(int i = 0; i < ALL_MISC_ITEMS.length; i++){ - String name = this.getRegistryName()+"_"+ALL_MISC_ITEMS[i].name; + protected void registerRendering() { + for (int i = 0; i < ALL_MISC_ITEMS.length; i++) { + String name = this.getRegistryName() + "_" + ALL_MISC_ITEMS[i].name; ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), new ResourceLocation(name), "inventory"); } } @Override - public boolean onEntityItemUpdate(EntityItem entity){ - if(!entity.world.isRemote){ + public boolean onEntityItemUpdate(EntityItem entity) { + if (!entity.world.isRemote) { ItemStack stack = entity.getItem(); - if(stack != null){ + if (stack != null) { boolean isEmpowered = stack.getItemDamage() == TheMiscItems.EMPOWERED_CANOLA_SEED.ordinal(); - if(stack.getItemDamage() == TheMiscItems.CRYSTALLIZED_CANOLA_SEED.ordinal() || isEmpowered){ + if (stack.getItemDamage() == TheMiscItems.CRYSTALLIZED_CANOLA_SEED.ordinal() || isEmpowered) { BlockPos pos = entity.getPosition(); IBlockState state = entity.world.getBlockState(pos); Block block = state.getBlock(); - if(block instanceof IFluidBlock && block.getMetaFromState(state) == 0){ - Fluid fluid = ((IFluidBlock)block).getFluid(); - if(fluid != null && fluid == (isEmpowered ? InitFluids.fluidCrystalOil : InitFluids.fluidRefinedCanolaOil)){ + if (block instanceof IFluidBlock && block.getMetaFromState(state) == 0) { + Fluid fluid = ((IFluidBlock) block).getFluid(); + if (fluid != null && fluid == (isEmpowered ? InitFluids.fluidCrystalOil : InitFluids.fluidRefinedCanolaOil)) { entity.setDead(); entity.world.setBlockState(pos, (isEmpowered ? InitFluids.blockEmpoweredOil : InitFluids.blockCrystalOil).getDefaultState()); } @@ -101,7 +100,7 @@ public class ItemMisc extends ItemBase{ } @Override - public boolean hasEffect(ItemStack stack){ + public boolean hasEffect(ItemStack stack) { return stack.getItemDamage() == TheMiscItems.EMPOWERED_CANOLA_SEED.ordinal(); } @@ -109,9 +108,9 @@ public class ItemMisc extends ItemBase{ public int getItemBurnTime(ItemStack stack) { int k = stack.getMetadata(); - if(k == TheMiscItems.TINY_CHAR.ordinal()) return 200; - if(k == TheMiscItems.TINY_COAL.ordinal()) return 200; - if(k == TheMiscItems.BIOCOAL.ordinal()) return 800; + if (k == TheMiscItems.TINY_CHAR.ordinal()) return 200; + if (k == TheMiscItems.TINY_COAL.ordinal()) return 200; + if (k == TheMiscItems.BIOCOAL.ordinal()) return 800; return super.getItemBurnTime(stack); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPhantomConnector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPhantomConnector.java index af78fccad..2555fd0af 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPhantomConnector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPhantomConnector.java @@ -10,6 +10,10 @@ package de.ellpeck.actuallyadditions.mod.items; +import java.util.List; + +import javax.annotation.Nullable; + import de.ellpeck.actuallyadditions.api.tile.IPhantomTile; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; @@ -30,49 +34,42 @@ import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; -import javax.annotation.Nullable; -import java.util.List; +public class ItemPhantomConnector extends ItemBase { -public class ItemPhantomConnector extends ItemBase{ - - public ItemPhantomConnector(String name){ + public ItemPhantomConnector(String name) { super(name); this.setMaxStackSize(1); } - public static World getStoredWorld(ItemStack stack){ + public static World getStoredWorld(ItemStack stack) { NBTTagCompound tag = stack.getTagCompound(); - if(tag != null){ - return DimensionManager.getWorld(tag.getInteger("WorldOfTileStored")); - } + if (tag != null) { return DimensionManager.getWorld(tag.getInteger("WorldOfTileStored")); } return null; } - public static BlockPos getStoredPosition(ItemStack stack){ + public static BlockPos getStoredPosition(ItemStack stack) { NBTTagCompound tag = stack.getTagCompound(); - if(tag != null){ + if (tag != null) { int x = tag.getInteger("XCoordOfTileStored"); int y = tag.getInteger("YCoordOfTileStored"); int z = tag.getInteger("ZCoordOfTileStored"); - if(!(x == 0 && y == 0 && z == 0)){ - return new BlockPos(x, y, z); - } + if (!(x == 0 && y == 0 && z == 0)) { return new BlockPos(x, y, z); } } return null; } - public static void clearStorage(ItemStack stack, String... keys){ - if(stack.hasTagCompound()){ + public static void clearStorage(ItemStack stack, String... keys) { + if (stack.hasTagCompound()) { NBTTagCompound compound = stack.getTagCompound(); - for(String key : keys){ + for (String key : keys) { compound.removeTag(key); } } } - public static void storeConnection(ItemStack stack, int x, int y, int z, World world){ + public static void storeConnection(ItemStack stack, int x, int y, int z, World world) { NBTTagCompound tag = stack.getTagCompound(); - if(tag == null){ + if (tag == null) { tag = new NBTTagCompound(); } @@ -84,24 +81,23 @@ public class ItemPhantomConnector extends ItemBase{ stack.setTagCompound(tag); } - @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing par7, float par8, float par9, float par10){ + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing par7, float par8, float par9, float par10) { ItemStack stack = player.getHeldItem(hand); - if(!world.isRemote){ + if (!world.isRemote) { //Passing Data to Phantoms TileEntity tile = world.getTileEntity(pos); - if(tile != null){ + if (tile != null) { //Passing to Phantom - if(tile instanceof IPhantomTile){ + if (tile instanceof IPhantomTile) { BlockPos stored = getStoredPosition(stack); - if(stored != null && getStoredWorld(stack) == world){ - ((IPhantomTile)tile).setBoundPosition(stored); - if(tile instanceof TileEntityBase){ - ((TileEntityBase)tile).sendUpdate(); + if (stored != null && getStoredWorld(stack) == world) { + ((IPhantomTile) tile).setBoundPosition(stored); + if (tile instanceof TileEntityBase) { + ((TileEntityBase) tile).sendUpdate(); } clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored"); - player.sendStatusMessage(new TextComponentTranslation("tooltip."+ActuallyAdditions.MODID+".phantom.connected.desc"), true); + player.sendStatusMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".phantom.connected.desc"), true); return EnumActionResult.SUCCESS; } return EnumActionResult.FAIL; @@ -109,30 +105,30 @@ public class ItemPhantomConnector extends ItemBase{ } //Storing Connections storeConnection(stack, pos.getX(), pos.getY(), pos.getZ(), world); - player.sendStatusMessage(new TextComponentTranslation("tooltip."+ActuallyAdditions.MODID+".phantom.stored.desc"), true); + player.sendStatusMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".phantom.stored.desc"), true); } return EnumActionResult.SUCCESS; } @Override - public boolean getShareTag(){ + public boolean getShareTag() { return true; } @Override - public void addInformation(ItemStack stack, @Nullable World playerIn, List list, ITooltipFlag advanced){ + public void addInformation(ItemStack stack, @Nullable World playerIn, List list, ITooltipFlag advanced) { BlockPos coords = getStoredPosition(stack); - if(coords != null){ - list.add(StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".boundTo.desc")+":"); - list.add("X: "+coords.getX()); - list.add("Y: "+coords.getY()); - list.add("Z: "+coords.getZ()); - list.add(TextFormatting.ITALIC+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".clearStorage.desc")); + if (coords != null) { + list.add(StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".boundTo.desc") + ":"); + list.add("X: " + coords.getX()); + list.add("Y: " + coords.getY()); + list.add("Z: " + coords.getZ()); + list.add(TextFormatting.ITALIC + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".clearStorage.desc")); } } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPlayerProbe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPlayerProbe.java index 879f9b9b1..a0c78bd3f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPlayerProbe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPlayerProbe.java @@ -10,6 +10,11 @@ package de.ellpeck.actuallyadditions.mod.items; +import java.util.List; +import java.util.UUID; + +import javax.annotation.Nullable; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface; @@ -29,36 +34,31 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; -import javax.annotation.Nullable; -import java.util.List; -import java.util.UUID; +public class ItemPlayerProbe extends ItemBase { -public class ItemPlayerProbe extends ItemBase{ - - public ItemPlayerProbe(String name){ + public ItemPlayerProbe(String name) { super(name); this.setMaxStackSize(1); } @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected){ - if(!world.isRemote){ - if(stack.hasTagCompound()){ + public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) { + if (!world.isRemote) { + if (stack.hasTagCompound()) { NBTTagCompound compound = stack.getTagCompound(); - if(compound.hasKey("UUIDMost")){ + if (compound.hasKey("UUIDMost")) { UUID id = compound.getUniqueId("UUID"); EntityPlayer player = world.getPlayerEntityByUUID(id); - if(player != null){ - if(player.isSneaking()){ + if (player != null) { + if (player.isSneaking()) { ItemPhantomConnector.clearStorage(stack, "UUIDLeast", "UUIDMost", "Name"); - entity.sendMessage(new TextComponentTranslation("tooltip."+ActuallyAdditions.MODID+".playerProbe.disconnect.1")); - player.sendMessage(new TextComponentTranslation("tooltip."+ActuallyAdditions.MODID+".playerProbe.notice")); + entity.sendMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".playerProbe.disconnect.1")); + player.sendMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".playerProbe.notice")); //TheAchievements.GET_UNPROBED.get(player); } - } - else{ + } else { ItemPhantomConnector.clearStorage(stack, "UUIDLeast", "UUIDMost", "Name"); - entity.sendMessage(new TextComponentTranslation("tooltip."+ActuallyAdditions.MODID+".playerProbe.disconnect.2")); + entity.sendMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".playerProbe.disconnect.2")); } } } @@ -66,15 +66,15 @@ public class ItemPlayerProbe extends ItemBase{ } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){ + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityPlayerInterface){ - if(stack.hasTagCompound()){ + if (tile instanceof TileEntityPlayerInterface) { + if (stack.hasTagCompound()) { NBTTagCompound compound = stack.getTagCompound(); - if(compound.hasKey("UUIDMost")){ - if(!world.isRemote){ - TileEntityPlayerInterface face = (TileEntityPlayerInterface)tile; + if (compound.hasKey("UUIDMost")) { + if (!world.isRemote) { + TileEntityPlayerInterface face = (TileEntityPlayerInterface) tile; face.connectedPlayer = compound.getUniqueId("UUID"); face.playerName = compound.getString("Name"); face.markDirty(); @@ -90,15 +90,15 @@ public class ItemPlayerProbe extends ItemBase{ } @Override - public boolean itemInteractionForEntity(ItemStack aStack, EntityPlayer player, EntityLivingBase entity, EnumHand hand){ - if(!player.world.isRemote){ + public boolean itemInteractionForEntity(ItemStack aStack, EntityPlayer player, EntityLivingBase entity, EnumHand hand) { + if (!player.world.isRemote) { ItemStack stack = player.getHeldItemMainhand(); - if(StackUtil.isValid(stack) && stack.getItem() == this){ - if(entity instanceof EntityPlayer){ - EntityPlayer playerHit = (EntityPlayer)entity; + if (StackUtil.isValid(stack) && stack.getItem() == this) { + if (entity instanceof EntityPlayer) { + EntityPlayer playerHit = (EntityPlayer) entity; - if(!playerHit.isSneaking()){ - if(!stack.hasTagCompound()){ + if (!playerHit.isSneaking()) { + if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } @@ -114,11 +114,11 @@ public class ItemPlayerProbe extends ItemBase{ } @Override - public void addInformation(ItemStack stack, @Nullable World playerIn, List tooltip, ITooltipFlag advanced){ - if(stack.hasTagCompound()){ + public void addInformation(ItemStack stack, @Nullable World playerIn, List tooltip, ITooltipFlag advanced) { + if (stack.hasTagCompound()) { String name = stack.getTagCompound().getString("Name"); - if(name != null){ - tooltip.add(StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".playerProbe.probing")+": "+name); + if (name != null) { + tooltip.add(StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".playerProbe.probing") + ": " + name); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPotionRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPotionRing.java index 898515560..3a0c7a1f4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPotionRing.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPotionRing.java @@ -10,6 +10,11 @@ package de.ellpeck.actuallyadditions.mod.items; +import java.util.Collections; +import java.util.List; + +import javax.annotation.Nullable; + import de.ellpeck.actuallyadditions.api.misc.IDisplayStandItem; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; @@ -37,36 +42,31 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import javax.annotation.Nullable; -import java.util.Collections; -import java.util.List; - -public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDisplayStandItem{ +public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDisplayStandItem { public static final ThePotionRings[] ALL_RINGS = ThePotionRings.values(); public static final int MAX_BLAZE = 800; private final boolean isAdvanced; - public ItemPotionRing(boolean isAdvanced, String name){ + public ItemPotionRing(boolean isAdvanced, String name) { super(name); this.setHasSubtypes(true); this.setMaxStackSize(1); this.isAdvanced = isAdvanced; } - public static int getStoredBlaze(ItemStack stack){ - if(!StackUtil.isValid(stack) || !stack.hasTagCompound()){ + public static int getStoredBlaze(ItemStack stack) { + if (!StackUtil.isValid(stack) || !stack.hasTagCompound()) { return 0; - } - else{ + } else { return stack.getTagCompound().getInteger("Blaze"); } } - public static void setStoredBlaze(ItemStack stack, int amount){ - if(StackUtil.isValid(stack)){ - if(!stack.hasTagCompound()){ + public static void setStoredBlaze(ItemStack stack, int amount) { + if (StackUtil.isValid(stack)) { + if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } stack.getTagCompound().setInteger("Blaze", amount); @@ -74,48 +74,48 @@ public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDi } @Override - public int getMetadata(int damage){ + public int getMetadata(int damage) { return damage; } @Override - public double getDurabilityForDisplay(ItemStack stack){ - double diff = MAX_BLAZE-getStoredBlaze(stack); - return diff/MAX_BLAZE; + public double getDurabilityForDisplay(ItemStack stack) { + double diff = MAX_BLAZE - getStoredBlaze(stack); + return diff / MAX_BLAZE; } @Override - public int getRGBDurabilityForDisplay(ItemStack stack){ + public int getRGBDurabilityForDisplay(ItemStack stack) { int curr = getStoredBlaze(stack); - return MathHelper.hsvToRGB(Math.max(0.0F, (float)curr/MAX_BLAZE)/3.0F, 1.0F, 1.0F); + return MathHelper.hsvToRGB(Math.max(0.0F, (float) curr / MAX_BLAZE) / 3.0F, 1.0F, 1.0F); } @Override - public String getTranslationKey(ItemStack stack){ - return stack.getItemDamage() >= ALL_RINGS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey()+ALL_RINGS[stack.getItemDamage()].name; + public String getTranslationKey(ItemStack stack) { + return stack.getItemDamage() >= ALL_RINGS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey() + ALL_RINGS[stack.getItemDamage()].name; } @Override - public boolean showDurabilityBar(ItemStack itemStack){ + public boolean showDurabilityBar(ItemStack itemStack) { return true; } @Override - public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5){ + public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5) { super.onUpdate(stack, world, player, par4, par5); - if(!world.isRemote && stack.getItemDamage() < ALL_RINGS.length){ - if(player instanceof EntityPlayer){ - EntityPlayer thePlayer = (EntityPlayer)player; + if (!world.isRemote && stack.getItemDamage() < ALL_RINGS.length) { + if (player instanceof EntityPlayer) { + EntityPlayer thePlayer = (EntityPlayer) player; int storedBlaze = getStoredBlaze(stack); - if(storedBlaze > 0){ + if (storedBlaze > 0) { ItemStack equippedStack = thePlayer.getHeldItemMainhand(); ItemStack offhandStack = thePlayer.getHeldItemOffhand(); - if(this.effectEntity(thePlayer, stack, StackUtil.isValid(equippedStack) && stack == equippedStack || StackUtil.isValid(offhandStack) && stack == offhandStack)){ - if(world.getTotalWorldTime()%10 == 0){ - setStoredBlaze(stack, storedBlaze-1); + if (this.effectEntity(thePlayer, stack, StackUtil.isValid(equippedStack) && stack == equippedStack || StackUtil.isValid(offhandStack) && stack == offhandStack)) { + if (world.getTotalWorldTime() % 10 == 0) { + setStoredBlaze(stack, storedBlaze - 1); } } } @@ -124,38 +124,38 @@ public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDi } @Override - public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged){ + public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { return slotChanged || !ItemStack.areItemsEqual(oldStack, newStack); } @Override - public String getItemStackDisplayName(ItemStack stack){ - if(Util.isClient()) { - String standardName = StringUtil.localize(this.getTranslationKey()+".name"); - if(stack.getItemDamage() < ALL_RINGS.length){ + public String getItemStackDisplayName(ItemStack stack) { + if (Util.isClient()) { + String standardName = StringUtil.localize(this.getTranslationKey() + ".name"); + if (stack.getItemDamage() < ALL_RINGS.length) { String effect = StringUtil.localize(ALL_RINGS[stack.getItemDamage()].name); - return standardName+" "+effect; + return standardName + " " + effect; } return standardName; } - String standardName = StringUtil.localizeIllegallyOnTheServerDontUseMePls(this.getTranslationKey()+".name"); - if(stack.getItemDamage() < ALL_RINGS.length){ + String standardName = StringUtil.localizeIllegallyOnTheServerDontUseMePls(this.getTranslationKey() + ".name"); + if (stack.getItemDamage() < ALL_RINGS.length) { String effect = StringUtil.localizeIllegallyOnTheServerDontUseMePls(ALL_RINGS[stack.getItemDamage()].name); - return standardName+" "+effect; + return standardName + " " + effect; } return standardName; } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return stack.getItemDamage() >= ALL_RINGS.length ? EnumRarity.COMMON : ALL_RINGS[stack.getItemDamage()].rarity; } @Override @SideOnly(Side.CLIENT) - public void getSubItems(CreativeTabs tab, NonNullList list){ - if(this.isInCreativeTab(tab)){ - for(int j = 0; j < ALL_RINGS.length; j++){ + public void getSubItems(CreativeTabs tab, NonNullList list) { + if (this.isInCreativeTab(tab)) { + for (int j = 0; j < ALL_RINGS.length; j++) { list.add(new ItemStack(this, 1, j)); ItemStack full = new ItemStack(this, 1, j); @@ -166,41 +166,39 @@ public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDi } @Override - protected void registerRendering(){ - for(int i = 0; i < ALL_RINGS.length; i++){ + protected void registerRendering() { + for (int i = 0; i < ALL_RINGS.length; i++) { ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), "inventory"); } } @Override @SideOnly(Side.CLIENT) - public IItemColor getItemColor(){ + public IItemColor getItemColor() { return (stack, tintIndex) -> stack.getItemDamage() >= ALL_RINGS.length ? 0xFFFFFF : ALL_RINGS[stack.getItemDamage()].color; } @Override - public boolean update(ItemStack stack, TileEntity tile, int elapsedTicks){ - boolean advanced = ((ItemPotionRing)stack.getItem()).isAdvanced; + public boolean update(ItemStack stack, TileEntity tile, int elapsedTicks) { + boolean advanced = ((ItemPotionRing) stack.getItem()).isAdvanced; int range = advanced ? 48 : 16; - List entities = tile.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(tile.getPos().getX()-range, tile.getPos().getY()-range, tile.getPos().getZ()-range, tile.getPos().getX()+range, tile.getPos().getY()+range, tile.getPos().getZ()+range)); - if(entities != null && !entities.isEmpty()){ - if(advanced){ + List entities = tile.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(tile.getPos().getX() - range, tile.getPos().getY() - range, tile.getPos().getZ() - range, tile.getPos().getX() + range, tile.getPos().getY() + range, tile.getPos().getZ() + range)); + if (entities != null && !entities.isEmpty()) { + if (advanced) { //Give all entities the effect - for(EntityLivingBase entity : entities){ + for (EntityLivingBase entity : entities) { this.effectEntity(entity, stack, true); } return true; - } - else{ + } else { Potion potion = Potion.getPotionById(ThePotionRings.values()[stack.getItemDamage()].effectID); - for(EntityLivingBase entity : entities){ - if(entity.isPotionActive(potion)){ + for (EntityLivingBase entity : entities) { + if (entity.isPotionActive(potion)) { //Sometimes make the effect switch to someone else - if(tile.getWorld().rand.nextInt(100) <= 0){ + if (tile.getWorld().rand.nextInt(100) <= 0) { entity.removePotionEffect(potion); break; - } - else{ + } else { //Continue giving the entity that already has the potion effect the effect //Otherwise, it will randomly switch around to other entities this.effectEntity(entity, stack, true); @@ -219,22 +217,21 @@ public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDi } @Override - public int getUsePerTick(ItemStack stack, TileEntity tile, int elapsedTicks){ + public int getUsePerTick(ItemStack stack, TileEntity tile, int elapsedTicks) { return 325; } - private boolean effectEntity(EntityLivingBase thePlayer, ItemStack stack, boolean canUseBasic){ + private boolean effectEntity(EntityLivingBase thePlayer, ItemStack stack, boolean canUseBasic) { ThePotionRings effect = ThePotionRings.values()[stack.getItemDamage()]; Potion potion = Potion.getPotionById(effect.effectID); PotionEffect activeEffect = thePlayer.getActivePotionEffect(potion); - if(!effect.needsWaitBeforeActivating || activeEffect == null || activeEffect.getDuration() <= 1){ - if(!((ItemPotionRing)stack.getItem()).isAdvanced){ - if(canUseBasic){ + if (!effect.needsWaitBeforeActivating || activeEffect == null || activeEffect.getDuration() <= 1) { + if (!((ItemPotionRing) stack.getItem()).isAdvanced) { + if (canUseBasic) { thePlayer.addPotionEffect(new PotionEffect(potion, effect.activeTime, effect.normalAmplifier, true, false)); return true; } - } - else{ + } else { thePlayer.addPotionEffect(new PotionEffect(potion, effect.activeTime, effect.advancedAmplifier, true, false)); return true; } @@ -243,8 +240,8 @@ public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDi } @Override - public void addInformation(ItemStack stack, @Nullable World playerIn, List tooltip, ITooltipFlag advanced){ + public void addInformation(ItemStack stack, @Nullable World playerIn, List tooltip, ITooltipFlag advanced) { super.addInformation(stack, playerIn, tooltip, advanced); - tooltip.add(String.format("%d/%d %s", getStoredBlaze(stack), MAX_BLAZE, StringUtil.localize("item."+ActuallyAdditions.MODID+".item_misc_ring.storage"))); + tooltip.add(String.format("%d/%d %s", getStoredBlaze(stack), MAX_BLAZE, StringUtil.localize("item." + ActuallyAdditions.MODID + ".item_misc_ring.storage"))); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemResonantRice.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemResonantRice.java index 9d750457f..78a59f2a4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemResonantRice.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemResonantRice.java @@ -19,26 +19,24 @@ import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.world.World; -public class ItemResonantRice extends ItemBase{ +public class ItemResonantRice extends ItemBase { - public ItemResonantRice(String name){ + public ItemResonantRice(String name) { super(name); } - @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); - if(!world.isRemote){ + if (!world.isRemote) { stack.shrink(1); world.createExplosion(null, player.posX, player.posY, player.posZ, 0.5F, true); } return new ActionResult<>(EnumActionResult.SUCCESS, stack); } - @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSolidifiedExperience.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSolidifiedExperience.java index b14deb15d..37b393c1e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSolidifiedExperience.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSolidifiedExperience.java @@ -28,24 +28,24 @@ import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.event.entity.living.LivingDropsEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -public class ItemSolidifiedExperience extends ItemBase{ +public class ItemSolidifiedExperience extends ItemBase { public static final int SOLID_XP_AMOUNT = 8; - public ItemSolidifiedExperience(String name){ + public ItemSolidifiedExperience(String name) { super(name); MinecraftForge.EVENT_BUS.register(this); } @SubscribeEvent - public void onEntityDropEvent(LivingDropsEvent event){ - if(ConfigBoolValues.DO_XP_DROPS.isEnabled()){ - if(event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote && event.getSource().getTrueSource() instanceof EntityPlayer && event.getEntityLiving().world.getGameRules().getBoolean("doMobLoot")){ + public void onEntityDropEvent(LivingDropsEvent event) { + if (ConfigBoolValues.DO_XP_DROPS.isEnabled()) { + if (event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote && event.getSource().getTrueSource() instanceof EntityPlayer && event.getEntityLiving().world.getGameRules().getBoolean("doMobLoot")) { //Drop Solidified XP - if(event.getEntityLiving() instanceof EntityCreature){ - if(event.getEntityLiving().world.rand.nextInt(10) <= event.getLootingLevel()*2){ - event.getDrops().add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, new ItemStack(InitItems.itemSolidifiedExperience, event.getEntityLiving().world.rand.nextInt(2+event.getLootingLevel())+1))); + if (event.getEntityLiving() instanceof EntityCreature) { + if (event.getEntityLiving().world.rand.nextInt(10) <= event.getLootingLevel() * 2) { + event.getDrops().add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, new ItemStack(InitItems.itemSolidifiedExperience, event.getEntityLiving().world.rand.nextInt(2 + event.getLootingLevel()) + 1))); } } } @@ -53,36 +53,33 @@ public class ItemSolidifiedExperience extends ItemBase{ } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); - if(!world.isRemote){ + if (!world.isRemote) { int amount; - if(!player.isSneaking()){ + if (!player.isSneaking()) { amount = SOLID_XP_AMOUNT; - if(!player.capabilities.isCreativeMode){ + if (!player.capabilities.isCreativeMode) { stack.shrink(1); } - } - else{ - amount = SOLID_XP_AMOUNT*stack.getCount(); - if(!player.capabilities.isCreativeMode){ + } else { + amount = SOLID_XP_AMOUNT * stack.getCount(); + if (!player.capabilities.isCreativeMode) { stack.setCount(0); } } - if(ConfigBoolValues.SOLID_XP_ALWAYS_ORBS.currentValue || player instanceof FakePlayer) { - EntityXPOrb orb = new EntityXPOrb(world, player.posX+0.5, player.posY+0.5, player.posZ+0.5, amount); - orb.getEntityData().setBoolean(ActuallyAdditions.MODID+"FromSolidified", true); + if (ConfigBoolValues.SOLID_XP_ALWAYS_ORBS.currentValue || player instanceof FakePlayer) { + EntityXPOrb orb = new EntityXPOrb(world, player.posX + 0.5, player.posY + 0.5, player.posZ + 0.5, amount); + orb.getEntityData().setBoolean(ActuallyAdditions.MODID + "FromSolidified", true); world.spawnEntity(orb); - } - else player.addExperience(amount); + } else player.addExperience(amount); } return new ActionResult<>(EnumActionResult.SUCCESS, stack); } - @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.UNCOMMON; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSpawnerChanger.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSpawnerChanger.java index 6c4e0ae48..fa805acb3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSpawnerChanger.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSpawnerChanger.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.items; +import java.util.List; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; @@ -33,25 +35,23 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; -import java.util.List; +public class ItemSpawnerChanger extends ItemBase { -public class ItemSpawnerChanger extends ItemBase{ - - public ItemSpawnerChanger(String name){ + public ItemSpawnerChanger(String name) { super(name); this.setMaxStackSize(1); } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){ - if(!world.isRemote){ + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + if (!world.isRemote) { ItemStack stack = player.getHeldItemMainhand(); - if(player.canPlayerEdit(pos.offset(facing), facing, stack)){ + if (player.canPlayerEdit(pos.offset(facing), facing, stack)) { TileEntity tile = world.getTileEntity(pos); - if(tile instanceof TileEntityMobSpawner){ + if (tile instanceof TileEntityMobSpawner) { String entity = this.getStoredEntity(stack); - if(entity != null){ - MobSpawnerBaseLogic logic = ((TileEntityMobSpawner)tile).getSpawnerBaseLogic(); + if (entity != null) { + MobSpawnerBaseLogic logic = ((TileEntityMobSpawner) tile).getSpawnerBaseLogic(); //This is a hacky way to remove the spawn potentials that make the spawner reset from time to time //Don't judge, there isn't a method for it and it's better than Reflection hackiness @@ -70,7 +70,7 @@ public class ItemSpawnerChanger extends ItemBase{ ItemPhantomConnector.clearStorage(stack, "Entity"); - if(!player.capabilities.isCreativeMode){ + if (!player.capabilities.isCreativeMode) { player.setHeldItem(hand, StackUtil.shrink(stack, 1)); } @@ -83,11 +83,11 @@ public class ItemSpawnerChanger extends ItemBase{ } @Override - public boolean itemInteractionForEntity(ItemStack aStack, EntityPlayer player, EntityLivingBase entity, EnumHand hand){ - if(!player.world.isRemote){ + public boolean itemInteractionForEntity(ItemStack aStack, EntityPlayer player, EntityLivingBase entity, EnumHand hand) { + if (!player.world.isRemote) { ItemStack stack = player.getHeldItemMainhand(); - if(this.getStoredEntity(stack) == null){ - if(this.storeClickedEntity(stack, entity)){ + if (this.getStoredEntity(stack) == null) { + if (this.storeClickedEntity(stack, entity)) { entity.setDead(); } } @@ -96,20 +96,18 @@ public class ItemSpawnerChanger extends ItemBase{ return false; } - private boolean storeClickedEntity(ItemStack stack, EntityLivingBase entity){ - if(!stack.hasTagCompound()){ + private boolean storeClickedEntity(ItemStack stack, EntityLivingBase entity) { + if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } - if(!(entity instanceof EntityPlayer) && entity.isNonBoss()){ + if (!(entity instanceof EntityPlayer) && entity.isNonBoss()) { ResourceLocation entityLoc = EntityList.getKey(entity.getClass()); - if(entityLoc != null){ + if (entityLoc != null) { String entityName = entityLoc.toString(); - if(entityName != null && !entityName.isEmpty()){ - for(String name : ConfigStringListValues.SPAWNER_CHANGER_BLACKLIST.getValue()){ - if(entityName.equals(name)){ - return false; - } + if (entityName != null && !entityName.isEmpty()) { + for (String name : ConfigStringListValues.SPAWNER_CHANGER_BLACKLIST.getValue()) { + if (entityName.equals(name)) { return false; } } stack.getTagCompound().setString("Entity", entityName); @@ -120,22 +118,20 @@ public class ItemSpawnerChanger extends ItemBase{ return false; } - private String getStoredEntity(ItemStack stack){ - if(stack.hasTagCompound()){ + private String getStoredEntity(ItemStack stack) { + if (stack.hasTagCompound()) { String entity = stack.getTagCompound().getString("Entity"); - if(entity != null && !entity.isEmpty()){ - return entity; - } + if (entity != null && !entity.isEmpty()) { return entity; } } return null; } @Override - public void addInformation(ItemStack stack, World playerIn, List list, ITooltipFlag advanced){ + public void addInformation(ItemStack stack, World playerIn, List list, ITooltipFlag advanced) { String entity = this.getStoredEntity(stack); - if(entity != null){ - list.add("Entity: "+entity); - list.add(TextFormatting.ITALIC+StringUtil.localize("tooltip."+ActuallyAdditions.MODID+".clearStorage.desc")); + if (entity != null) { + list.add("Entity: " + entity); + list.add(TextFormatting.ITALIC + StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".clearStorage.desc")); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTeleStaff.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTeleStaff.java index 460d6663a..1d3e8fb54 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTeleStaff.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTeleStaff.java @@ -25,30 +25,30 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -public class ItemTeleStaff extends ItemEnergy{ +public class ItemTeleStaff extends ItemEnergy { - public ItemTeleStaff(String name){ + public ItemTeleStaff(String name) { super(250000, 1000, name); } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); - if(!world.isRemote){ + if (!world.isRemote) { RayTraceResult pos = WorldUtil.getNearestPositionWithAir(world, player, 100); - if(pos != null && (pos.typeOfHit == RayTraceResult.Type.BLOCK || player.rotationPitch >= -5)){ + if (pos != null && (pos.typeOfHit == RayTraceResult.Type.BLOCK || player.rotationPitch >= -5)) { int side = pos.sideHit.ordinal(); - if(side != -1){ - double x = pos.hitVec.x-(side == 4 ? 0.5 : 0)+(side == 5 ? 0.5 : 0); - double y = pos.hitVec.y-(side == 0 ? 2.0 : 0)+(side == 1 ? 0.5 : 0); - double z = pos.hitVec.z-(side == 2 ? 0.5 : 0)+(side == 3 ? 0.5 : 0); + if (side != -1) { + double x = pos.hitVec.x - (side == 4 ? 0.5 : 0) + (side == 5 ? 0.5 : 0); + double y = pos.hitVec.y - (side == 0 ? 2.0 : 0) + (side == 1 ? 0.5 : 0); + double z = pos.hitVec.z - (side == 2 ? 0.5 : 0) + (side == 3 ? 0.5 : 0); int baseUse = 200; - int use = baseUse+(int)(baseUse*pos.hitVec.distanceTo(new Vec3d(player.posX, player.posY+(player.getEyeHeight()-player.getDefaultEyeHeight()), player.posZ))); - if(this.getEnergyStored(stack) >= use){ - ((EntityPlayerMP)player).connection.setPlayerLocation(x, y, z, player.rotationYaw, player.rotationPitch); + int use = baseUse + (int) (baseUse * pos.hitVec.distanceTo(new Vec3d(player.posX, player.posY + (player.getEyeHeight() - player.getDefaultEyeHeight()), player.posZ))); + if (this.getEnergyStored(stack) >= use) { + ((EntityPlayerMP) player).connection.setPlayerLocation(x, y, z, player.rotationYaw, player.rotationPitch); player.dismountRidingEntity(); world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1.0F, 1.0F); - if(!player.capabilities.isCreativeMode){ + if (!player.capabilities.isCreativeMode) { this.extractEnergyInternal(stack, use, false); player.getCooldownTracker().setCooldown(this, 50); } @@ -62,7 +62,7 @@ public class ItemTeleStaff extends ItemEnergy{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterBowl.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterBowl.java index 18f1af8f2..ec14ce369 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterBowl.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterBowl.java @@ -26,7 +26,12 @@ import net.minecraft.init.Items; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.*; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; @@ -35,9 +40,9 @@ import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -public class ItemWaterBowl extends ItemBase{ +public class ItemWaterBowl extends ItemBase { - public ItemWaterBowl(String name){ + public ItemWaterBowl(String name) { super(name); this.setMaxStackSize(1); @@ -45,29 +50,28 @@ public class ItemWaterBowl extends ItemBase{ } @SubscribeEvent - public void onPlayerInteractEvent(PlayerInteractEvent.RightClickItem event){ - if(event.getWorld() != null){ - if(ConfigBoolValues.WATER_BOWL.isEnabled()){ - if(StackUtil.isValid(event.getItemStack()) && event.getItemStack().getItem() == Items.BOWL){ + public void onPlayerInteractEvent(PlayerInteractEvent.RightClickItem event) { + if (event.getWorld() != null) { + if (ConfigBoolValues.WATER_BOWL.isEnabled()) { + if (StackUtil.isValid(event.getItemStack()) && event.getItemStack().getItem() == Items.BOWL) { RayTraceResult trace = WorldUtil.getNearestBlockWithDefaultReachDistance(event.getWorld(), event.getEntityPlayer(), true, false, false); ActionResult result = ForgeEventFactory.onBucketUse(event.getEntityPlayer(), event.getWorld(), event.getItemStack(), trace); - if(result == null && trace != null && trace.getBlockPos() != null){ - if(event.getEntityPlayer().canPlayerEdit(trace.getBlockPos().offset(trace.sideHit), trace.sideHit, event.getItemStack())){ + if (result == null && trace != null && trace.getBlockPos() != null) { + if (event.getEntityPlayer().canPlayerEdit(trace.getBlockPos().offset(trace.sideHit), trace.sideHit, event.getItemStack())) { IBlockState state = event.getWorld().getBlockState(trace.getBlockPos()); Block block = state.getBlock(); - if((block == Blocks.WATER || block == Blocks.FLOWING_WATER) && state.getValue(BlockLiquid.LEVEL) == 0){ + if ((block == Blocks.WATER || block == Blocks.FLOWING_WATER) && state.getValue(BlockLiquid.LEVEL) == 0) { event.getEntityPlayer().playSound(SoundEvents.ITEM_BUCKET_FILL, 1.0F, 1.0F); - if(!event.getWorld().isRemote){ + if (!event.getWorld().isRemote) { event.getWorld().setBlockState(trace.getBlockPos(), Blocks.AIR.getDefaultState(), 11); ItemStack reduced = StackUtil.shrink(event.getItemStack(), 1); ItemStack bowl = new ItemStack(InitItems.itemWaterBowl); - if(!StackUtil.isValid(reduced)){ + if (!StackUtil.isValid(reduced)) { event.getEntityPlayer().setHeldItem(event.getHand(), bowl); - } - else if(!event.getEntityPlayer().inventory.addItemStackToInventory(bowl.copy())){ + } else if (!event.getEntityPlayer().inventory.addItemStackToInventory(bowl.copy())) { EntityItem entityItem = new EntityItem(event.getWorld(), event.getEntityPlayer().posX, event.getEntityPlayer().posY, event.getEntityPlayer().posZ, bowl.copy()); entityItem.setPickupDelay(0); event.getWorld().spawnEntity(entityItem); @@ -82,37 +86,30 @@ public class ItemWaterBowl extends ItemBase{ } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand){ + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.getHeldItem(hand); RayTraceResult trace = WorldUtil.getNearestBlockWithDefaultReachDistance(world, player); ActionResult result = ForgeEventFactory.onBucketUse(player, world, stack, trace); - if(result != null){ - return result; - } + if (result != null) { return result; } - if(trace == null){ + if (trace == null) { return new ActionResult<>(EnumActionResult.PASS, stack); - } - else if(trace.typeOfHit != RayTraceResult.Type.BLOCK){ + } else if (trace.typeOfHit != RayTraceResult.Type.BLOCK) { return new ActionResult<>(EnumActionResult.PASS, stack); - } - else{ + } else { BlockPos pos = trace.getBlockPos(); - if(!world.isBlockModifiable(player, pos)){ + if (!world.isBlockModifiable(player, pos)) { return new ActionResult<>(EnumActionResult.FAIL, stack); - } - else{ + } else { BlockPos pos1 = world.getBlockState(pos).getBlock().isReplaceable(world, pos) && trace.sideHit == EnumFacing.UP ? pos : pos.offset(trace.sideHit); - if(!player.canPlayerEdit(pos1, trace.sideHit, stack)){ + if (!player.canPlayerEdit(pos1, trace.sideHit, stack)) { return new ActionResult<>(EnumActionResult.FAIL, stack); - } - else if(this.tryPlaceContainedLiquid(player, world, pos1, false)){ + } else if (this.tryPlaceContainedLiquid(player, world, pos1, false)) { return !player.capabilities.isCreativeMode ? new ActionResult<>(EnumActionResult.SUCCESS, new ItemStack(Items.BOWL)) : new ActionResult<>(EnumActionResult.SUCCESS, stack); - } - else{ + } else { return new ActionResult<>(EnumActionResult.FAIL, stack); } } @@ -120,25 +117,25 @@ public class ItemWaterBowl extends ItemBase{ } @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected){ - if(!world.isRemote){ - if(ConfigBoolValues.WATER_BOWL_LOSS.isEnabled()){ - if(world.getTotalWorldTime()%10 == 0 && world.rand.nextFloat() >= 0.5F){ + public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) { + if (!world.isRemote) { + if (ConfigBoolValues.WATER_BOWL_LOSS.isEnabled()) { + if (world.getTotalWorldTime() % 10 == 0 && world.rand.nextFloat() >= 0.5F) { int lastX = 0; int lastY = 0; - if(stack.hasTagCompound()){ + if (stack.hasTagCompound()) { NBTTagCompound compound = stack.getTagCompound(); lastX = compound.getInteger("lastX"); lastY = compound.getInteger("lastY"); } boolean change = false; - if(lastX != 0 && lastX != (int)entity.posX || lastY != 0 && lastY != (int)entity.posY){ - if(!entity.isSneaking()){ - if(entity instanceof EntityPlayer){ - EntityPlayer player = (EntityPlayer)entity; - if(this.tryPlaceContainedLiquid(player, world, player.getPosition(), true)){ + if (lastX != 0 && lastX != (int) entity.posX || lastY != 0 && lastY != (int) entity.posY) { + if (!entity.isSneaking()) { + if (entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) entity; + if (this.tryPlaceContainedLiquid(player, world, player.getPosition(), true)) { this.checkReplace(player, stack, new ItemStack(Items.BOWL), itemSlot); } } @@ -146,14 +143,14 @@ public class ItemWaterBowl extends ItemBase{ change = true; } - if(change || lastX == 0 || lastY == 0){ - if(!stack.hasTagCompound()){ + if (change || lastX == 0 || lastY == 0) { + if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } NBTTagCompound compound = stack.getTagCompound(); - compound.setInteger("lastX", (int)entity.posX); - compound.setInteger("lastY", (int)entity.posY); + compound.setInteger("lastX", (int) entity.posX); + compound.setInteger("lastY", (int) entity.posY); } } } @@ -161,44 +158,41 @@ public class ItemWaterBowl extends ItemBase{ } private void checkReplace(EntityPlayer player, ItemStack old, ItemStack stack, int slot) { - if(player.inventory.getStackInSlot(slot) == old) player.inventory.setInventorySlotContents(slot, stack); - else if(player.inventory.offHandInventory.get(slot) == old) player.inventory.offHandInventory.set(slot, stack); + if (player.inventory.getStackInSlot(slot) == old) player.inventory.setInventorySlotContents(slot, stack); + else if (player.inventory.offHandInventory.get(slot) == old) player.inventory.offHandInventory.set(slot, stack); } @Override - public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged){ + public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { return !ItemStack.areItemsEqual(oldStack, newStack); } - public boolean tryPlaceContainedLiquid(EntityPlayer player, World world, BlockPos pos, boolean finite){ + public boolean tryPlaceContainedLiquid(EntityPlayer player, World world, BlockPos pos, boolean finite) { IBlockState state = world.getBlockState(pos); Material material = state.getMaterial(); boolean nonSolid = !material.isSolid(); boolean replaceable = state.getBlock().isReplaceable(world, pos); - if(!world.isAirBlock(pos) && !nonSolid && !replaceable){ + if (!world.isAirBlock(pos) && !nonSolid && !replaceable) { return false; - } - else{ - if(world.provider.doesWaterVaporize()){ - world.playSound(player, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F+(world.rand.nextFloat()-world.rand.nextFloat())*0.8F); + } else { + if (world.provider.doesWaterVaporize()) { + world.playSound(player, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); - for(int k = 0; k < 8; k++){ - world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, pos.getX()+Math.random(), pos.getY()+Math.random(), pos.getZ()+Math.random(), 0.0D, 0.0D, 0.0D); + for (int k = 0; k < 8; k++) { + world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 0.0D, 0.0D, 0.0D); } - } - else{ - if(!world.isRemote && (nonSolid || replaceable) && !material.isLiquid()){ + } else { + if (!world.isRemote && (nonSolid || replaceable) && !material.isLiquid()) { world.destroyBlock(pos, true); } world.playSound(player, pos, SoundEvents.ITEM_BUCKET_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); IBlockState placeState; - if(finite){ + if (finite) { placeState = Blocks.FLOWING_WATER.getDefaultState(); - } - else{ + } else { placeState = Blocks.FLOWING_WATER.getDefaultState(); } world.setBlockState(pos, placeState, 3); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java index 04778a76f..ef420d299 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.items; - import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.Block; @@ -23,49 +22,47 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; -public class ItemWaterRemovalRing extends ItemEnergy{ +public class ItemWaterRemovalRing extends ItemEnergy { - public ItemWaterRemovalRing(String name){ + public ItemWaterRemovalRing(String name) { super(800000, 1000, name); } @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){ - if(!(entity instanceof EntityPlayer) || world.isRemote || entity.isSneaking()){ - return; - } + public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { + if (!(entity instanceof EntityPlayer) || world.isRemote || entity.isSneaking()) { return; } - EntityPlayer player = (EntityPlayer)entity; + EntityPlayer player = (EntityPlayer) entity; ItemStack equipped = player.getHeldItemMainhand(); int energyUse = 150; - if(StackUtil.isValid(equipped) && equipped == stack && this.getEnergyStored(stack) >= energyUse){ + if (StackUtil.isValid(equipped) && equipped == stack && this.getEnergyStored(stack) >= energyUse) { //Setting everything to air int range = 3; - for(int x = -range; x < range+1; x++){ - for(int z = -range; z < range+1; z++){ - for(int y = -range; y < range+1; y++){ - int theX = MathHelper.floor(player.posX+x); - int theY = MathHelper.floor(player.posY+y); - int theZ = MathHelper.floor(player.posZ+z); + for (int x = -range; x < range + 1; x++) { + for (int z = -range; z < range + 1; z++) { + for (int y = -range; y < range + 1; y++) { + int theX = MathHelper.floor(player.posX + x); + int theY = MathHelper.floor(player.posY + y); + int theZ = MathHelper.floor(player.posZ + z); //Remove Water BlockPos pos = new BlockPos(theX, theY, theZ); Block block = world.getBlockState(pos).getBlock(); - if((block == Blocks.WATER || block == Blocks.FLOWING_WATER) && this.getEnergyStored(stack) >= energyUse){ + if ((block == Blocks.WATER || block == Blocks.FLOWING_WATER) && this.getEnergyStored(stack) >= energyUse) { world.setBlockToAir(pos); - if(!player.capabilities.isCreativeMode){ + if (!player.capabilities.isCreativeMode) { this.extractEnergyInternal(stack, energyUse, false); } } //Remove Lava - else if((block == Blocks.LAVA || block == Blocks.FLOWING_LAVA) && this.getEnergyStored(stack) >= energyUse*2){ + else if ((block == Blocks.LAVA || block == Blocks.FLOWING_LAVA) && this.getEnergyStored(stack) >= energyUse * 2) { world.setBlockToAir(pos); - if(!player.capabilities.isCreativeMode){ - this.extractEnergyInternal(stack, energyUse*2, false); + if (!player.capabilities.isCreativeMode) { + this.extractEnergyInternal(stack, energyUse * 2, false); } } } @@ -74,9 +71,8 @@ public class ItemWaterRemovalRing extends ItemEnergy{ } } - @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java index 4b2d0f9b2..49291f1bc 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java @@ -33,12 +33,12 @@ import net.minecraftforge.event.entity.living.LivingDropsEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -public class ItemWingsOfTheBats extends ItemBase{ +public class ItemWingsOfTheBats extends ItemBase { public static final String THE_BAT_BAT = "the bat bat"; public static final int MAX_FLY_TIME = 800; - public ItemWingsOfTheBats(String name){ + public ItemWingsOfTheBats(String name) { super(name); this.setMaxStackSize(1); @@ -51,109 +51,104 @@ public class ItemWingsOfTheBats extends ItemBase{ * @param player The Player * @return The Wings */ - public static ItemStack getWingItem(EntityPlayer player){ - for(int i = 0; i < player.inventory.getSizeInventory(); i++){ - if(StackUtil.isValid(player.inventory.getStackInSlot(i)) && player.inventory.getStackInSlot(i).getItem() instanceof ItemWingsOfTheBats){ - return player.inventory.getStackInSlot(i); - } + public static ItemStack getWingItem(EntityPlayer player) { + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { + if (StackUtil.isValid(player.inventory.getStackInSlot(i)) && player.inventory.getStackInSlot(i).getItem() instanceof ItemWingsOfTheBats) { return player.inventory.getStackInSlot(i); } } return StackUtil.getEmpty(); } @Override - public boolean showDurabilityBar(ItemStack stack){ + public boolean showDurabilityBar(ItemStack stack) { return true; } @Override - public double getDurabilityForDisplay(ItemStack stack){ + public double getDurabilityForDisplay(ItemStack stack) { EntityPlayer player = ActuallyAdditions.PROXY.getCurrentPlayer(); - if(player != null){ + if (player != null) { PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player); - if(data != null){ - double diff = MAX_FLY_TIME-data.batWingsFlyTime; - return 1-diff/MAX_FLY_TIME; + if (data != null) { + double diff = MAX_FLY_TIME - data.batWingsFlyTime; + return 1 - diff / MAX_FLY_TIME; } } return super.getDurabilityForDisplay(stack); } @Override - public int getRGBDurabilityForDisplay(ItemStack stack){ + public int getRGBDurabilityForDisplay(ItemStack stack) { EntityPlayer player = ActuallyAdditions.PROXY.getCurrentPlayer(); - if(player != null){ + if (player != null) { PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player); - if(data != null){ + if (data != null) { int curr = data.batWingsFlyTime; - return MathHelper.hsvToRGB(Math.max(0.0F, 1-(float)curr/MAX_FLY_TIME)/3.0F, 1.0F, 1.0F); + return MathHelper.hsvToRGB(Math.max(0.0F, 1 - (float) curr / MAX_FLY_TIME) / 3.0F, 1.0F, 1.0F); } } return super.getRGBDurabilityForDisplay(stack); } @SubscribeEvent - public void onEntityDropEvent(LivingDropsEvent event){ + public void onEntityDropEvent(LivingDropsEvent event) { Entity source = event.getSource().getTrueSource(); - if(event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote && source instanceof EntityPlayer){ + if (event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote && source instanceof EntityPlayer) { //Drop Wings from Bats - if(ConfigBoolValues.DO_BAT_DROPS.isEnabled() && event.getEntityLiving() instanceof EntityBat){ + if (ConfigBoolValues.DO_BAT_DROPS.isEnabled() && event.getEntityLiving() instanceof EntityBat) { int looting = event.getLootingLevel(); Iterable equip = source.getHeldEquipment(); - for(ItemStack stack : equip){ - if(StackUtil.isValid(stack) && ItemWingsOfTheBats.THE_BAT_BAT.equalsIgnoreCase(stack.getDisplayName()) && stack.getItem() instanceof ItemSword){ + for (ItemStack stack : equip) { + if (StackUtil.isValid(stack) && ItemWingsOfTheBats.THE_BAT_BAT.equalsIgnoreCase(stack.getDisplayName()) && stack.getItem() instanceof ItemSword) { looting += 3; break; } } - if(event.getEntityLiving().world.rand.nextInt(15) <= looting*2){ - event.getDrops().add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, new ItemStack(InitItems.itemMisc, event.getEntityLiving().world.rand.nextInt(2+looting)+1, TheMiscItems.BAT_WING.ordinal()))); + if (event.getEntityLiving().world.rand.nextInt(15) <= looting * 2) { + event.getDrops().add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, new ItemStack(InitItems.itemMisc, event.getEntityLiving().world.rand.nextInt(2 + looting) + 1, TheMiscItems.BAT_WING.ordinal()))); } } } } @SubscribeEvent - public void livingUpdateEvent(LivingEvent.LivingUpdateEvent event){ - if(event.getEntityLiving() instanceof EntityPlayer){ - EntityPlayer player = (EntityPlayer)event.getEntityLiving(); + public void livingUpdateEvent(LivingEvent.LivingUpdateEvent event) { + if (event.getEntityLiving() instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) event.getEntityLiving(); - if(!player.capabilities.isCreativeMode && !player.isSpectator()){ + if (!player.capabilities.isCreativeMode && !player.isSpectator()) { PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player); - if(!player.world.isRemote){ + if (!player.world.isRemote) { boolean tryDeduct = false; boolean shouldSend = false; boolean wingsEquipped = StackUtil.isValid(ItemWingsOfTheBats.getWingItem(player)); - if(!data.hasBatWings){ - if(data.batWingsFlyTime <= 0){ - if(wingsEquipped){ + if (!data.hasBatWings) { + if (data.batWingsFlyTime <= 0) { + if (wingsEquipped) { data.hasBatWings = true; shouldSend = true; } - } - else{ + } else { tryDeduct = true; } - } - else{ - if(wingsEquipped && data.batWingsFlyTime < MAX_FLY_TIME){ + } else { + if (wingsEquipped && data.batWingsFlyTime < MAX_FLY_TIME) { player.capabilities.allowFlying = true; - if(player.capabilities.isFlying){ + if (player.capabilities.isFlying) { data.batWingsFlyTime++; - if(player.world.getTotalWorldTime()%10 == 0){ + if (player.world.getTotalWorldTime() % 10 == 0) { shouldSend = true; } } tryDeduct = true; - } - else{ + } else { data.hasBatWings = false; data.shouldDisableBatWings = true; shouldSend = true; @@ -164,39 +159,36 @@ public class ItemWingsOfTheBats extends ItemBase{ } } - if(tryDeduct && data.batWingsFlyTime > 0){ + if (tryDeduct && data.batWingsFlyTime > 0) { int deductTime = 0; - if(!player.capabilities.isFlying){ + if (!player.capabilities.isFlying) { deductTime = 2; - } - else{ - BlockPos pos = new BlockPos(player.posX, player.posY+player.height, player.posZ); + } else { + BlockPos pos = new BlockPos(player.posX, player.posY + player.height, player.posZ); IBlockState state = player.world.getBlockState(pos); - if(state != null && state.isSideSolid(player.world, pos, EnumFacing.DOWN)){ + if (state != null && state.isSideSolid(player.world, pos, EnumFacing.DOWN)) { deductTime = 10; } } - if(deductTime > 0){ - data.batWingsFlyTime = Math.max(0, data.batWingsFlyTime-deductTime); + if (deductTime > 0) { + data.batWingsFlyTime = Math.max(0, data.batWingsFlyTime - deductTime); - if(player.world.getTotalWorldTime()%10 == 0){ + if (player.world.getTotalWorldTime() % 10 == 0) { shouldSend = true; } } } - if(shouldSend){ + if (shouldSend) { PacketHandlerHelper.syncPlayerData(player, false); data.shouldDisableBatWings = false; //was set only temporarily to send it } - } - else{ - if(data.hasBatWings){ + } else { + if (data.hasBatWings) { player.capabilities.allowFlying = true; - } - else if(data.shouldDisableBatWings){ //so that other modded flying won't be disabled + } else if (data.shouldDisableBatWings) { //so that other modded flying won't be disabled data.shouldDisableBatWings = false; player.capabilities.allowFlying = false; @@ -209,7 +201,7 @@ public class ItemWingsOfTheBats extends ItemBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.EPIC; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWorm.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWorm.java index 05645a45b..fc57f8f39 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWorm.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWorm.java @@ -39,35 +39,35 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class ItemWorm extends ItemBase{ +public class ItemWorm extends ItemBase { - public ItemWorm(String name){ + public ItemWorm(String name) { super(name); MinecraftForge.EVENT_BUS.register(this); - this.addPropertyOverride(new ResourceLocation(ActuallyAdditions.MODID, "snail"), new IItemPropertyGetter(){ + this.addPropertyOverride(new ResourceLocation(ActuallyAdditions.MODID, "snail"), new IItemPropertyGetter() { @Override @SideOnly(Side.CLIENT) - public float apply(ItemStack stack, World world, EntityLivingBase entity){ + public float apply(ItemStack stack, World world, EntityLivingBase entity) { return "snail mail".equalsIgnoreCase(stack.getDisplayName()) ? 1F : 0F; } }); } @Override - public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10){ + public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) { ItemStack stack = player.getHeldItem(hand); IBlockState state = world.getBlockState(pos); - if(EntityWorm.canWormify(world, pos, state)){ - List worms = world.getEntitiesWithinAABB(EntityWorm.class, new AxisAlignedBB(pos.getX()-1, pos.getY(), pos.getZ()-1, pos.getX()+2, pos.getY()+1, pos.getZ()+2)); - if(worms == null || worms.isEmpty()){ - if(!world.isRemote){ + if (EntityWorm.canWormify(world, pos, state)) { + List worms = world.getEntitiesWithinAABB(EntityWorm.class, new AxisAlignedBB(pos.getX() - 1, pos.getY(), pos.getZ() - 1, pos.getX() + 2, pos.getY() + 1, pos.getZ() + 2)); + if (worms == null || worms.isEmpty()) { + if (!world.isRemote) { EntityWorm worm = new EntityWorm(world); - worm.setPosition(pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5); + worm.setPosition(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); worm.setCustomNameTag(stack.getDisplayName()); world.spawnEntity(worm); - if(!player.capabilities.isCreativeMode) stack.shrink(1); + if (!player.capabilities.isCreativeMode) stack.shrink(1); } return EnumActionResult.SUCCESS; } @@ -76,16 +76,16 @@ public class ItemWorm extends ItemBase{ } @SubscribeEvent(priority = EventPriority.LOW) - public void onHoe(UseHoeEvent event){ - if(ConfigBoolValues.WORMS.isEnabled() && event.getResult() != Result.DENY){ + public void onHoe(UseHoeEvent event) { + if (ConfigBoolValues.WORMS.isEnabled() && event.getResult() != Result.DENY) { World world = event.getWorld(); - if(!world.isRemote){ + if (!world.isRemote) { BlockPos pos = event.getPos(); - if(world.isAirBlock(pos.up())){ + if (world.isAirBlock(pos.up())) { IBlockState state = world.getBlockState(pos); - if(state.getBlock() instanceof BlockGrass && world.rand.nextFloat() >= 0.95F){ - ItemStack stack = new ItemStack(InitItems.itemWorm, world.rand.nextInt(2)+1); - EntityItem item = new EntityItem(event.getWorld(), pos.getX()+0.5, pos.getY()+1, pos.getZ()+0.5, stack); + if (state.getBlock() instanceof BlockGrass && world.rand.nextFloat() >= 0.95F) { + ItemStack stack = new ItemStack(InitItems.itemWorm, world.rand.nextInt(2) + 1); + EntityItem item = new EntityItem(event.getWorld(), pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, stack); world.spawnEntity(item); } } @@ -94,7 +94,7 @@ public class ItemWorm extends ItemBase{ } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.UNCOMMON; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemBase.java index 57d6cd61b..db0256b6a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemBase.java @@ -15,32 +15,31 @@ import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; - -public class ItemBase extends Item{ +public class ItemBase extends Item { private final String name; - public ItemBase(String name){ + public ItemBase(String name) { this.name = name; this.register(); } - private void register(){ + private void register() { ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative()); this.registerRendering(); } - protected String getBaseName(){ + protected String getBaseName() { return this.name; } - public boolean shouldAddCreative(){ + public boolean shouldAddCreative() { return true; } - protected void registerRendering(){ + protected void registerRendering() { ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemEnergy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemEnergy.java index f492e3400..5f7fc9cfd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemEnergy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemEnergy.java @@ -34,12 +34,12 @@ import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public abstract class ItemEnergy extends ItemBase{ +public abstract class ItemEnergy extends ItemBase { private final int maxPower; private final int transfer; - public ItemEnergy(int maxPower, int transfer, String name){ + public ItemEnergy(int maxPower, int transfer, String name) { super(name); this.maxPower = maxPower; this.transfer = transfer; @@ -49,15 +49,15 @@ public abstract class ItemEnergy extends ItemBase{ } @Override - public boolean getShareTag(){ + public boolean getShareTag() { return true; } @Override - public void addInformation(ItemStack stack, World playerIn, List tooltip, ITooltipFlag advanced){ - if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){ + public void addInformation(ItemStack stack, World playerIn, List tooltip, ITooltipFlag advanced) { + if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) { IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null); - if(storage != null){ + if (storage != null) { NumberFormat format = NumberFormat.getInstance(); tooltip.add(String.format("%s/%s Crystal Flux", format.format(storage.getEnergyStored()), format.format(storage.getMaxEnergyStored()))); } @@ -66,17 +66,17 @@ public abstract class ItemEnergy extends ItemBase{ @Override @SideOnly(Side.CLIENT) - public boolean hasEffect(ItemStack stack){ + public boolean hasEffect(ItemStack stack) { return false; } @Override - public void getSubItems(CreativeTabs tabs, NonNullList list){ - if(this.isInCreativeTab(tabs)){ + public void getSubItems(CreativeTabs tabs, NonNullList list) { + if (this.isInCreativeTab(tabs)) { ItemStack stackFull = new ItemStack(this); - if(stackFull.hasCapability(CapabilityEnergy.ENERGY, null)){ + if (stackFull.hasCapability(CapabilityEnergy.ENERGY, null)) { IEnergyStorage storage = stackFull.getCapability(CapabilityEnergy.ENERGY, null); - if(storage != null){ + if (storage != null) { this.setEnergy(stackFull, storage.getMaxEnergyStored()); list.add(stackFull); } @@ -89,126 +89,117 @@ public abstract class ItemEnergy extends ItemBase{ } @Override - public boolean showDurabilityBar(ItemStack itemStack){ + public boolean showDurabilityBar(ItemStack itemStack) { return true; } @Override - public double getDurabilityForDisplay(ItemStack stack){ - if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){ + public double getDurabilityForDisplay(ItemStack stack) { + if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) { IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null); - if(storage != null){ + if (storage != null) { double maxAmount = storage.getMaxEnergyStored(); - double energyDif = maxAmount-storage.getEnergyStored(); - return energyDif/maxAmount; + double energyDif = maxAmount - storage.getEnergyStored(); + return energyDif / maxAmount; } } return super.getDurabilityForDisplay(stack); } @Override - public int getRGBDurabilityForDisplay(ItemStack stack){ + public int getRGBDurabilityForDisplay(ItemStack stack) { EntityPlayer player = ActuallyAdditions.PROXY.getCurrentPlayer(); - if(player != null && player.world != null){ - float[] color = AssetUtil.getWheelColor(player.world.getTotalWorldTime()%256); - return MathHelper.rgb(color[0]/255F, color[1]/255F, color[2]/255F); + if (player != null && player.world != null) { + float[] color = AssetUtil.getWheelColor(player.world.getTotalWorldTime() % 256); + return MathHelper.rgb(color[0] / 255F, color[1] / 255F, color[2] / 255F); } return super.getRGBDurabilityForDisplay(stack); } - public void setEnergy(ItemStack stack, int energy){ - if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){ + public void setEnergy(ItemStack stack, int energy) { + if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) { IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null); - if(storage instanceof CustomEnergyStorage){ - ((CustomEnergyStorage)storage).setEnergyStored(energy); + if (storage instanceof CustomEnergyStorage) { + ((CustomEnergyStorage) storage).setEnergyStored(energy); } } } - public int receiveEnergyInternal(ItemStack stack, int maxReceive, boolean simulate){ - if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){ + public int receiveEnergyInternal(ItemStack stack, int maxReceive, boolean simulate) { + if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) { IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null); - if(storage instanceof CustomEnergyStorage){ - ((CustomEnergyStorage)storage).receiveEnergyInternal(maxReceive, simulate); + if (storage instanceof CustomEnergyStorage) { + ((CustomEnergyStorage) storage).receiveEnergyInternal(maxReceive, simulate); } } return 0; } - public int extractEnergyInternal(ItemStack stack, int maxExtract, boolean simulate){ - if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){ + public int extractEnergyInternal(ItemStack stack, int maxExtract, boolean simulate) { + if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) { IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null); - if(storage instanceof CustomEnergyStorage){ - ((CustomEnergyStorage)storage).extractEnergyInternal(maxExtract, simulate); + if (storage instanceof CustomEnergyStorage) { + ((CustomEnergyStorage) storage).extractEnergyInternal(maxExtract, simulate); } } return 0; } - public int receiveEnergy(ItemStack stack, int maxReceive, boolean simulate){ - if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){ + public int receiveEnergy(ItemStack stack, int maxReceive, boolean simulate) { + if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) { IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null); - if(storage != null){ - return storage.receiveEnergy(maxReceive, simulate); - } + if (storage != null) { return storage.receiveEnergy(maxReceive, simulate); } } return 0; } - public int extractEnergy(ItemStack stack, int maxExtract, boolean simulate){ - if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){ + public int extractEnergy(ItemStack stack, int maxExtract, boolean simulate) { + if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) { IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null); - if(storage != null){ - return storage.extractEnergy(maxExtract, simulate); - } + if (storage != null) { return storage.extractEnergy(maxExtract, simulate); } } return 0; } - public int getEnergyStored(ItemStack stack){ - if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){ + public int getEnergyStored(ItemStack stack) { + if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) { IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null); - if(storage != null){ - return storage.getEnergyStored(); - } + if (storage != null) { return storage.getEnergyStored(); } } return 0; } - public int getMaxEnergyStored(ItemStack stack){ - if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){ + public int getMaxEnergyStored(ItemStack stack) { + if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) { IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null); - if(storage != null){ - return storage.getMaxEnergyStored(); - } + if (storage != null) { return storage.getMaxEnergyStored(); } } return 0; } @Override - public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt){ + public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { return new EnergyCapabilityProvider(stack, this); } - private static class EnergyCapabilityProvider implements ICapabilityProvider{ + private static class EnergyCapabilityProvider implements ICapabilityProvider { public final CustomEnergyStorage storage; - public EnergyCapabilityProvider(final ItemStack stack, ItemEnergy item){ - this.storage = new CustomEnergyStorage(item.maxPower, item.transfer, item.transfer){ + public EnergyCapabilityProvider(final ItemStack stack, ItemEnergy item) { + this.storage = new CustomEnergyStorage(item.maxPower, item.transfer, item.transfer) { @Override - public int getEnergyStored(){ - if(stack.hasTagCompound()){ + public int getEnergyStored() { + if (stack.hasTagCompound()) { return stack.getTagCompound().getInteger("Energy"); - } - else{ + } else { return 0; } } @Override - public void setEnergyStored(int energy){ - if(!stack.hasTagCompound()){ + public void setEnergyStored(int energy) { + if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } @@ -218,17 +209,14 @@ public abstract class ItemEnergy extends ItemBase{ } @Override - public boolean hasCapability(Capability capability, EnumFacing facing){ + public boolean hasCapability(Capability capability, EnumFacing facing) { return this.getCapability(capability, facing) != null; } - @Nullable @Override - public T getCapability(Capability capability, EnumFacing facing){ - if(capability == CapabilityEnergy.ENERGY){ - return CapabilityEnergy.ENERGY.cast(this.storage); - } + public T getCapability(Capability capability, EnumFacing facing) { + if (capability == CapabilityEnergy.ENERGY) { return CapabilityEnergy.ENERGY.cast(this.storage); } return null; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemFoodBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemFoodBase.java index d1b3559ab..c9d28134a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemFoodBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemFoodBase.java @@ -15,33 +15,32 @@ import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; - -public class ItemFoodBase extends ItemFood{ +public class ItemFoodBase extends ItemFood { private final String name; - public ItemFoodBase(int heal, float saturation, boolean wolfFood, String name){ + public ItemFoodBase(int heal, float saturation, boolean wolfFood, String name) { super(heal, saturation, wolfFood); this.name = name; this.register(); } - private void register(){ + private void register() { ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative()); this.registerRendering(); } - protected String getBaseName(){ + protected String getBaseName() { return this.name; } - public boolean shouldAddCreative(){ + public boolean shouldAddCreative() { return true; } - protected void registerRendering(){ + protected void registerRendering() { ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemFoodSeed.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemFoodSeed.java index 0b4b1021b..9b642a4eb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemFoodSeed.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemFoodSeed.java @@ -23,57 +23,57 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; -public class ItemFoodSeed extends ItemSeedFood{ +public class ItemFoodSeed extends ItemSeedFood { public final Block plant; public final String name; public final String oredictName; private final int maxUseDuration; - public ItemFoodSeed(String name, String oredictName, Block plant, Item returnItem, int returnMeta, int healAmount, float saturation, int maxUseDuration){ + public ItemFoodSeed(String name, String oredictName, Block plant, Item returnItem, int returnMeta, int healAmount, float saturation, int maxUseDuration) { super(healAmount, saturation, plant, Blocks.FARMLAND); this.name = name; this.oredictName = oredictName; this.plant = plant; this.maxUseDuration = maxUseDuration; - if(plant instanceof BlockPlant){ - ((BlockPlant)plant).doStuff(this, returnItem, returnMeta); + if (plant instanceof BlockPlant) { + ((BlockPlant) plant).doStuff(this, returnItem, returnMeta); } this.register(); } - private void register(){ + private void register() { ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative()); this.registerRendering(); } @Override - public int getMaxItemUseDuration(ItemStack stack){ + public int getMaxItemUseDuration(ItemStack stack) { return this.maxUseDuration; } - protected String getBaseName(){ + protected String getBaseName() { return this.name; } - public boolean shouldAddCreative(){ + public boolean shouldAddCreative() { return true; } - protected void registerRendering(){ + protected void registerRendering() { ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override - public IBlockState getPlant(IBlockAccess world, BlockPos pos){ + public IBlockState getPlant(IBlockAccess world, BlockPos pos) { return this.plant.getDefaultState(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemSeed.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemSeed.java index 44394445a..1b7f6708b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemSeed.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemSeed.java @@ -23,50 +23,50 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; -public class ItemSeed extends ItemSeeds{ +public class ItemSeed extends ItemSeeds { public final Block plant; public final String name; public final String oredictName; - public ItemSeed(String name, String oredictName, Block plant, Item returnItem, int returnMeta){ + public ItemSeed(String name, String oredictName, Block plant, Item returnItem, int returnMeta) { super(plant, Blocks.FARMLAND); this.name = name; this.oredictName = oredictName; this.plant = plant; - if(plant instanceof BlockPlant){ - ((BlockPlant)plant).doStuff(this, returnItem, returnMeta); + if (plant instanceof BlockPlant) { + ((BlockPlant) plant).doStuff(this, returnItem, returnMeta); } this.register(); } - private void register(){ + private void register() { ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative()); this.registerRendering(); } - protected String getBaseName(){ + protected String getBaseName() { return this.name; } - public boolean shouldAddCreative(){ + public boolean shouldAddCreative() { return true; } - protected void registerRendering(){ + protected void registerRendering() { ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); } @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.RARE; } @Override - public IBlockState getPlant(IBlockAccess world, BlockPos pos){ + public IBlockState getPlant(IBlockAccess world, BlockPos pos) { return this.plant.getDefaultState(); } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/ItemLens.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/ItemLens.java index defd4e296..eb6d1ba95 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/ItemLens.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/ItemLens.java @@ -16,24 +16,23 @@ import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; -public class ItemLens extends ItemBase implements ILensItem{ +public class ItemLens extends ItemBase implements ILensItem { private final Lens type; - public ItemLens(String name, Lens type){ + public ItemLens(String name, Lens type) { super(name); this.type = type; this.setMaxStackSize(1); } - @Override - public EnumRarity getRarity(ItemStack stack){ + public EnumRarity getRarity(ItemStack stack) { return EnumRarity.UNCOMMON; } @Override - public Lens getLens(){ + public Lens getLens() { return this.type; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java index aaed68a4a..4f897762d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.items.lens; - import java.util.List; import java.util.Map; import java.util.Random; @@ -33,35 +32,34 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; import net.minecraftforge.common.util.FakePlayerFactory; -public class LensColor extends Lens{ +public class LensColor extends Lens { public static final int ENERGY_USE = 200; //Thanks to xdjackiexd for this, as I couldn't be bothered - public static final float[][] POSSIBLE_COLORS = { - {158F, 43F, 39F}, //Red - {234F, 126F, 53F}, //Orange - {194F, 181F, 28F}, //Yellow - {57F, 186F, 46F}, //Lime Green - {54F, 75F, 24F}, //Green - {99F, 135F, 210F}, //Light Blue - {38F, 113F, 145F}, //Cyan - {37F, 49F, 147F}, //Blue - {126F, 52F, 191F}, //Purple - {190F, 73F, 201F}, //Magenta - {217F, 129F, 153F}, //Pink - {86F, 51F, 28F}, //Brown + public static final float[][] POSSIBLE_COLORS = { { 158F, 43F, 39F }, //Red + { 234F, 126F, 53F }, //Orange + { 194F, 181F, 28F }, //Yellow + { 57F, 186F, 46F }, //Lime Green + { 54F, 75F, 24F }, //Green + { 99F, 135F, 210F }, //Light Blue + { 38F, 113F, 145F }, //Cyan + { 37F, 49F, 147F }, //Blue + { 126F, 52F, 191F }, //Purple + { 190F, 73F, 201F }, //Magenta + { 217F, 129F, 153F }, //Pink + { 86F, 51F, 28F }, //Brown }; private final Random rand = new Random(); @Override - public boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile){ - if(hitBlock != null){ - if(tile.getEnergy() >= ENERGY_USE){ + public boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) { + if (hitBlock != null) { + if (tile.getEnergy() >= ENERGY_USE) { IBlockState state = tile.getWorldObject().getBlockState(hitBlock); Block block = state.getBlock(); int meta = block.getMetaFromState(state); ItemStack returnStack = this.tryConvert(new ItemStack(block, 1, meta), hitState, hitBlock, tile); - if(returnStack != null && returnStack.getItem() instanceof ItemBlock){ + if (returnStack != null && returnStack.getItem() instanceof ItemBlock) { Block toPlace = Block.getBlockFromItem(returnStack.getItem()); IBlockState state2Place = toPlace.getStateForPlacement(tile.getWorldObject(), hitBlock, EnumFacing.UP, 0, 0, 0, returnStack.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) tile.getWorldObject()), EnumHand.MAIN_HAND); tile.getWorldObject().setBlockState(hitBlock, state2Place, 2); @@ -69,11 +67,11 @@ public class LensColor extends Lens{ } } - List items = tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), hitBlock.getX()+1, hitBlock.getY()+1, hitBlock.getZ()+1)); - for(EntityItem item : items){ - if(!item.isDead && StackUtil.isValid(item.getItem()) && tile.getEnergy() >= ENERGY_USE){ + List items = tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), hitBlock.getX() + 1, hitBlock.getY() + 1, hitBlock.getZ() + 1)); + for (EntityItem item : items) { + if (!item.isDead && StackUtil.isValid(item.getItem()) && tile.getEnergy() >= ENERGY_USE) { ItemStack newStack = this.tryConvert(item.getItem(), hitState, hitBlock, tile); - if(StackUtil.isValid(newStack)){ + if (StackUtil.isValid(newStack)) { item.setDead(); EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, newStack); @@ -87,31 +85,29 @@ public class LensColor extends Lens{ return false; } - private ItemStack tryConvert(ItemStack stack, IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile){ - if(StackUtil.isValid(stack)){ + private ItemStack tryConvert(ItemStack stack, IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) { + if (StackUtil.isValid(stack)) { Item item = stack.getItem(); - for(Map.Entry changer : ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_COLOR_CHANGERS.entrySet()){ - if(item == changer.getKey()){ - return changer.getValue().modifyItem(stack, hitState, hitBlock, tile); - } + for (Map.Entry changer : ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_COLOR_CHANGERS.entrySet()) { + if (item == changer.getKey()) { return changer.getValue().modifyItem(stack, hitState, hitBlock, tile); } } } return ItemStack.EMPTY; } @Override - public float[] getColor(){ + public float[] getColor() { float[] colors = POSSIBLE_COLORS[this.rand.nextInt(POSSIBLE_COLORS.length)]; - return new float[]{colors[0]/255F, colors[1]/255F, colors[2]/255F}; + return new float[] { colors[0] / 255F, colors[1] / 255F, colors[2] / 255F }; } @Override - public int getDistance(){ + public int getDistance() { return 10; } @Override - public boolean canInvoke(IAtomicReconstructor tile, EnumFacing sideToShootTo, int energyUsePerShot){ - return tile.getEnergy()-energyUsePerShot >= ENERGY_USE; + public boolean canInvoke(IAtomicReconstructor tile, EnumFacing sideToShootTo, int energyUsePerShot) { + return tile.getEnergy() - energyUsePerShot >= ENERGY_USE; } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDeath.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDeath.java index 2efbe20cf..302f495bf 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDeath.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDeath.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.items.lens; +import java.util.ArrayList; + import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import de.ellpeck.actuallyadditions.api.lens.Lens; import de.ellpeck.actuallyadditions.mod.misc.DamageSources; @@ -18,16 +20,14 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import java.util.ArrayList; - -public class LensDeath extends Lens{ +public class LensDeath extends Lens { @Override - public boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile){ - ArrayList entities = (ArrayList)tile.getWorldObject().getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), hitBlock.getX()+1, hitBlock.getY()+1, hitBlock.getZ()+1)); - for(EntityLivingBase entity : entities){ + public boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) { + ArrayList entities = (ArrayList) tile.getWorldObject().getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), hitBlock.getX() + 1, hitBlock.getY() + 1, hitBlock.getZ() + 1)); + for (EntityLivingBase entity : entities) { int use = this.getUsePerEntity(); - if(tile.getEnergy() >= use){ + if (tile.getEnergy() >= use) { tile.extractEnergy(use); this.onAttacked(entity, tile); @@ -37,21 +37,21 @@ public class LensDeath extends Lens{ return hitBlock != null && !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock); } - protected void onAttacked(EntityLivingBase entity, IAtomicReconstructor tile){ + protected void onAttacked(EntityLivingBase entity, IAtomicReconstructor tile) { entity.attackEntityFrom(DamageSources.DAMAGE_ATOMIC_RECONSTRUCTOR, 20F); } - protected int getUsePerEntity(){ + protected int getUsePerEntity() { return 350; } @Override - public float[] getColor(){ - return new float[]{188F/255F, 222F/255F, 1F}; + public float[] getColor() { + return new float[] { 188F / 255F, 222F / 255F, 1F }; } @Override - public int getDistance(){ + public int getDistance() { return 15; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDetonation.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDetonation.java index a1990a9bd..65afac6f2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDetonation.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDetonation.java @@ -16,15 +16,15 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; -public class LensDetonation extends Lens{ +public class LensDetonation extends Lens { private static final int ENERGY_USE = 250000; @Override - public boolean invoke(IBlockState state, BlockPos hitBlock, IAtomicReconstructor tile){ - if(hitBlock != null && !state.getBlock().isAir(state, tile.getWorldObject(), hitBlock)){ - if(tile.getEnergy() >= ENERGY_USE){ - tile.getWorldObject().newExplosion(null, hitBlock.getX()+0.5, hitBlock.getY()+0.5, hitBlock.getZ()+0.5, 10F, true, true); + public boolean invoke(IBlockState state, BlockPos hitBlock, IAtomicReconstructor tile) { + if (hitBlock != null && !state.getBlock().isAir(state, tile.getWorldObject(), hitBlock)) { + if (tile.getEnergy() >= ENERGY_USE) { + tile.getWorldObject().newExplosion(null, hitBlock.getX() + 0.5, hitBlock.getY() + 0.5, hitBlock.getZ() + 0.5, 10F, true, true); tile.extractEnergy(ENERGY_USE); } return true; @@ -33,17 +33,17 @@ public class LensDetonation extends Lens{ } @Override - public float[] getColor(){ - return new float[]{158F/255F, 43F/255F, 39F/255F}; + public float[] getColor() { + return new float[] { 158F / 255F, 43F / 255F, 39F / 255F }; } @Override - public int getDistance(){ + public int getDistance() { return 30; } @Override - public boolean canInvoke(IAtomicReconstructor tile, EnumFacing sideToShootTo, int energyUsePerShot){ - return tile.getEnergy()-energyUsePerShot >= ENERGY_USE; + public boolean canInvoke(IAtomicReconstructor tile, EnumFacing sideToShootTo, int energyUsePerShot) { + return tile.getEnergy() - energyUsePerShot >= ENERGY_USE; } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisenchanting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisenchanting.java index 181d1fd38..e902b69cb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisenchanting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisenchanting.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.items.lens; +import java.util.List; +import java.util.Map; + import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import de.ellpeck.actuallyadditions.api.lens.Lens; import de.ellpeck.actuallyadditions.mod.util.ItemUtil; @@ -27,40 +30,34 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import java.util.List; -import java.util.Map; - -public class LensDisenchanting extends Lens{ +public class LensDisenchanting extends Lens { public static final int ENERGY_USE = 250000; @Override - public boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile){ - if(tile.getEnergy() >= ENERGY_USE){ - List items = tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), hitBlock.getX()+1, hitBlock.getY()+1, hitBlock.getZ()+1)); - if(items != null && !items.isEmpty()){ + public boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) { + if (tile.getEnergy() >= ENERGY_USE) { + List items = tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), hitBlock.getX() + 1, hitBlock.getY() + 1, hitBlock.getZ() + 1)); + if (items != null && !items.isEmpty()) { EntityItem book = null; EntityItem toDisenchant = null; - for(EntityItem item : items){ - if(item != null && !item.isDead){ + for (EntityItem item : items) { + if (item != null && !item.isDead) { ItemStack stack = item.getItem(); - if(StackUtil.isValid(stack) && stack.getCount() == 1){ + if (StackUtil.isValid(stack) && stack.getCount() == 1) { Item stackItem = stack.getItem(); - if(stackItem == Items.BOOK || stackItem == Items.ENCHANTED_BOOK){ - if(book == null){ + if (stackItem == Items.BOOK || stackItem == Items.ENCHANTED_BOOK) { + if (book == null) { book = item; - } - else{ + } else { return false; } - } - else{ + } else { Map enchants = EnchantmentHelper.getEnchantments(stack); - if(enchants != null && !enchants.isEmpty()){ - if(toDisenchant == null){ + if (enchants != null && !enchants.isEmpty()) { + if (toDisenchant == null) { toDisenchant = item; - } - else{ + } else { return false; } } @@ -69,21 +66,20 @@ public class LensDisenchanting extends Lens{ } } - if(book != null && toDisenchant != null){ + if (book != null && toDisenchant != null) { ItemStack disenchantStack = toDisenchant.getItem(); ItemStack bookStack = book.getItem(); Map enchants = EnchantmentHelper.getEnchantments(disenchantStack); - if(enchants != null && !enchants.isEmpty()){ + if (enchants != null && !enchants.isEmpty()) { Enchantment enchant = enchants.keySet().iterator().next(); int level = enchants.get(enchant); ItemStack newDisenchantStack = disenchantStack.copy(); ItemStack newBookStack; - if(bookStack.getItem() == Items.BOOK){ + if (bookStack.getItem() == Items.BOOK) { newBookStack = new ItemStack(Items.ENCHANTED_BOOK); - } - else{ + } else { newBookStack = bookStack.copy(); } @@ -108,17 +104,17 @@ public class LensDisenchanting extends Lens{ } @Override - public float[] getColor(){ - return new float[]{234F/255F, 173F/255F, 255F/255F}; + public float[] getColor() { + return new float[] { 234F / 255F, 173F / 255F, 255F / 255F }; } @Override - public int getDistance(){ + public int getDistance() { return 5; } @Override - public boolean canInvoke(IAtomicReconstructor tile, EnumFacing sideToShootTo, int energyUsePerShot){ - return tile.getEnergy()-energyUsePerShot >= ENERGY_USE; + public boolean canInvoke(IAtomicReconstructor tile, EnumFacing sideToShootTo, int energyUsePerShot) { + return tile.getEnergy() - energyUsePerShot >= ENERGY_USE; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisruption.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisruption.java index 45ba719ad..d2fe0886f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisruption.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisruption.java @@ -27,37 +27,35 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -public class LensDisruption extends Lens{ +public class LensDisruption extends Lens { private static final int ENERGY_USE = 150000; @Override - public boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile){ - if(ConfigIntValues.ELEVEN.getValue() == 11 && tile.getEnergy() >= ENERGY_USE && hitBlock != null && !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock)){ + public boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) { + if (ConfigIntValues.ELEVEN.getValue() == 11 && tile.getEnergy() >= ENERGY_USE && hitBlock != null && !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock)) { int range = 2; - ArrayList items = (ArrayList)tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX()-range, hitBlock.getY()-range, hitBlock.getZ()-range, hitBlock.getX()+range, hitBlock.getY()+range, hitBlock.getZ()+range)); - for(EntityItem item : items){ + ArrayList items = (ArrayList) tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX() - range, hitBlock.getY() - range, hitBlock.getZ() - range, hitBlock.getX() + range, hitBlock.getY() + range, hitBlock.getZ() + range)); + for (EntityItem item : items) { ItemStack stack = item.getItem(); - if(!item.isDead && StackUtil.isValid(stack)){ - if(!stack.hasTagCompound() || !stack.getTagCompound().getBoolean(ActuallyAdditions.MODID+"DisruptedAlready")){ + if (!item.isDead && StackUtil.isValid(stack)) { + if (!stack.hasTagCompound() || !stack.getTagCompound().getBoolean(ActuallyAdditions.MODID + "DisruptedAlready")) { ItemStack newStack; - do{ - if(tile.getWorldObject().rand.nextBoolean()){ + do { + if (tile.getWorldObject().rand.nextBoolean()) { newStack = new ItemStack(Item.REGISTRY.getRandomObject(tile.getWorldObject().rand)); - } - else{ + } else { newStack = new ItemStack(Block.REGISTRY.getRandomObject(tile.getWorldObject().rand)); } - } - while(!StackUtil.isValid(newStack)); + } while (!StackUtil.isValid(newStack)); newStack.setCount(stack.getCount()); - if(!newStack.hasTagCompound()){ + if (!newStack.hasTagCompound()) { newStack.setTagCompound(new NBTTagCompound()); } - newStack.getTagCompound().setBoolean(ActuallyAdditions.MODID+"DisruptedAlready", true); + newStack.getTagCompound().setBoolean(ActuallyAdditions.MODID + "DisruptedAlready", true); item.setDead(); @@ -74,17 +72,17 @@ public class LensDisruption extends Lens{ } @Override - public float[] getColor(){ - return new float[]{246F/255F, 255F/255F, 183F/255F}; + public float[] getColor() { + return new float[] { 246F / 255F, 255F / 255F, 183F / 255F }; } @Override - public int getDistance(){ + public int getDistance() { return 3; } @Override - public boolean canInvoke(IAtomicReconstructor tile, EnumFacing sideToShootTo, int energyUsePerShot){ - return tile.getEnergy()-energyUsePerShot >= ENERGY_USE; + public boolean canInvoke(IAtomicReconstructor tile, EnumFacing sideToShootTo, int energyUsePerShot) { + return tile.getEnergy() - energyUsePerShot >= ENERGY_USE; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java index 634e9d6a4..7e548e2a0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.items.lens; +import java.util.List; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import de.ellpeck.actuallyadditions.api.lens.Lens; @@ -33,13 +35,11 @@ import net.minecraft.world.WorldServer; import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.oredict.OreDictionary; -import java.util.List; - -public class LensMining extends Lens{ +public class LensMining extends Lens { public static final int ENERGY_USE = 60000; - public static void init(){ + public static void init() { ActuallyAdditionsAPI.addMiningLensStoneOre("oreCoal", 5000); ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherCoal", 5000); ActuallyAdditionsAPI.addMiningLensStoneOre("oreIron", 3000); @@ -100,58 +100,55 @@ public class LensMining extends Lens{ ActuallyAdditionsAPI.addMiningLensNetherOre("oreCobalt", 50); ActuallyAdditionsAPI.addMiningLensNetherOre("oreArdite", 50); - for(String conf : ConfigStringListValues.MINING_LENS_EXTRA_WHITELIST.getValue()){ - if(conf.contains("@")){ - try{ + for (String conf : ConfigStringListValues.MINING_LENS_EXTRA_WHITELIST.getValue()) { + if (conf.contains("@")) { + try { String[] split = conf.split("@"); String ore = split[0]; int weight = Integer.parseInt(split[1]); String dim = split[2]; - if("n".equals(dim)){ + if ("n".equals(dim)) { ActuallyAdditionsAPI.addMiningLensNetherOre(ore, weight); - } - else if("s".equals(dim)){ + } else if ("s".equals(dim)) { ActuallyAdditionsAPI.addMiningLensStoneOre(ore, weight); } - } - catch(Exception e){ - ActuallyAdditions.LOGGER.warn("A config option appears to be incorrect: The entry "+conf+" can't be parsed!"); + } catch (Exception e) { + ActuallyAdditions.LOGGER.warn("A config option appears to be incorrect: The entry " + conf + " can't be parsed!"); } } } } @Override - public boolean invoke(IBlockState hitState, BlockPos hitPos, IAtomicReconstructor tile){ - if(!tile.getWorldObject().isAirBlock(hitPos)){ - if(tile.getEnergy() >= ENERGY_USE){ + public boolean invoke(IBlockState hitState, BlockPos hitPos, IAtomicReconstructor tile) { + if (!tile.getWorldObject().isAirBlock(hitPos)) { + if (tile.getEnergy() >= ENERGY_USE) { int adaptedUse = ENERGY_USE; List ores = null; Block hitBlock = hitState.getBlock(); - if(hitBlock instanceof BlockStone){ + if (hitBlock instanceof BlockStone) { ores = ActuallyAdditionsAPI.STONE_ORES; - } - else if(hitBlock instanceof BlockNetherrack){ + } else if (hitBlock instanceof BlockNetherrack) { ores = ActuallyAdditionsAPI.NETHERRACK_ORES; adaptedUse += 10000; } - if(ores != null){ + if (ores != null) { int totalWeight = WeightedRandom.getTotalWeight(ores); ItemStack stack = null; boolean found = false; - while(!found){ + while (!found) { WeightedOre ore = WeightedRandom.getRandomItem(tile.getWorldObject().rand, ores, totalWeight); - if(ore != null){ + if (ore != null) { List stacks = OreDictionary.getOres(ore.name, false); - if(stacks != null && !stacks.isEmpty()){ - for(ItemStack aStack : stacks){ - if(StackUtil.isValid(aStack) && !CrusherRecipeRegistry.hasBlacklistedOutput(aStack, ConfigStringListValues.MINING_LENS_BLACKLIST.getValue()) && aStack.getItem() instanceof ItemBlock){ - adaptedUse += (totalWeight-ore.itemWeight)%40000; + if (stacks != null && !stacks.isEmpty()) { + for (ItemStack aStack : stacks) { + if (StackUtil.isValid(aStack) && !CrusherRecipeRegistry.hasBlacklistedOutput(aStack, ConfigStringListValues.MINING_LENS_BLACKLIST.getValue()) && aStack.getItem() instanceof ItemBlock) { + adaptedUse += (totalWeight - ore.itemWeight) % 40000; stack = aStack; found = true; @@ -162,9 +159,9 @@ public class LensMining extends Lens{ } } - if(tile.getEnergy() >= adaptedUse){ + if (tile.getEnergy() >= adaptedUse) { Block block = Block.getBlockFromItem(stack.getItem()); - if(block != Blocks.AIR){ + if (block != Blocks.AIR) { IBlockState state = block.getStateForPlacement(tile.getWorldObject(), hitPos, EnumFacing.UP, 0, 0, 0, stack.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) tile.getWorldObject()), EnumHand.MAIN_HAND); tile.getWorldObject().setBlockState(hitPos, state, 2); @@ -177,19 +174,18 @@ public class LensMining extends Lens{ } return true; - } - else{ + } else { return false; } } @Override - public float[] getColor(){ - return new float[]{76F/255F, 76F/255F, 76F/255F}; + public float[] getColor() { + return new float[] { 76F / 255F, 76F / 255F, 76F / 255F }; } @Override - public int getDistance(){ + public int getDistance() { return 10; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/Lenses.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/Lenses.java index 7c80cf138..ddff275f9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/Lenses.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/Lenses.java @@ -13,9 +13,9 @@ package de.ellpeck.actuallyadditions.mod.items.lens; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.lens.LensConversion; -public final class Lenses{ +public final class Lenses { - public static void init(){ + public static void init() { ActuallyAdditionsAPI.lensDefaultConversion = new LensConversion(); ActuallyAdditionsAPI.lensDetonation = new LensDetonation(); ActuallyAdditionsAPI.lensDeath = new LensDeath(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheDusts.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheDusts.java index b863f2b93..27b85b0eb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheDusts.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheDusts.java @@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.items.metalists; import de.ellpeck.actuallyadditions.mod.util.StringUtil; import net.minecraft.item.EnumRarity; -public enum TheDusts{ +public enum TheDusts { IRON("iron", 7826534, EnumRarity.COMMON), GOLD("gold", 14335744, EnumRarity.UNCOMMON), @@ -28,11 +28,10 @@ public enum TheDusts{ public final int color; public final EnumRarity rarity; - TheDusts(String name, int color, EnumRarity rarity){ + TheDusts(String name, int color, EnumRarity rarity) { this.name = name; this.color = color; this.rarity = rarity; } - } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheFoods.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheFoods.java index 971ed4c1d..dea0e3b24 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheFoods.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheFoods.java @@ -16,7 +16,7 @@ import net.minecraft.init.Items; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; -public enum TheFoods{ +public enum TheFoods { CHEESE("cheese", 1, 0.05F, false, 3, EnumRarity.COMMON), PUMPKIN_STEW("pumpkin_stew", 6, 0.3F, true, 30, EnumRarity.COMMON), @@ -48,7 +48,7 @@ public enum TheFoods{ public final EnumRarity rarity; public ItemStack returnItem = StackUtil.getEmpty(); - TheFoods(String name, int healAmount, float saturation, boolean getsDrunken, int useDuration, EnumRarity rarity){ + TheFoods(String name, int healAmount, float saturation, boolean getsDrunken, int useDuration, EnumRarity rarity) { this.name = name; this.getsDrunken = getsDrunken; this.healAmount = healAmount; @@ -57,7 +57,7 @@ public enum TheFoods{ this.rarity = rarity; } - public static void setReturnItems(){ + public static void setReturnItems() { SPAGHETTI.returnItem = new ItemStack(Items.BOWL); PUMPKIN_STEW.returnItem = new ItemStack(Items.BOWL); CARROT_JUICE.returnItem = new ItemStack(Items.GLASS_BOTTLE); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheJams.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheJams.java index 64a8136e2..1088a74a5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheJams.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheJams.java @@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.items.metalists; import net.minecraft.item.EnumRarity; -public enum TheJams{ +public enum TheJams { CU_BA_RA("cu_ba_ra", 6, 0.1F, EnumRarity.RARE, 5, 12, 12595273), GRA_KI_BA("gra_ki_ba", 6, 0.1F, EnumRarity.RARE, 16, 13, 5492820), @@ -30,7 +30,7 @@ public enum TheJams{ public final int secondEffectToGet; public final int color; - TheJams(String name, int healAmount, float saturation, EnumRarity rarity, int firstEffectID, int secondEffectID, int color){ + TheJams(String name, int healAmount, float saturation, EnumRarity rarity, int firstEffectID, int secondEffectID, int color) { this.name = name; this.healAmount = healAmount; this.saturation = saturation; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/ThePotionRings.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/ThePotionRings.java index 384c17414..0c812cb79 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/ThePotionRings.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/ThePotionRings.java @@ -17,24 +17,114 @@ import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; -public enum ThePotionRings{ +public enum ThePotionRings { - SPEED(MobEffects.SPEED.getName(), 8171462, MobEffects.SPEED, 0, 1, 10, false, EnumRarity.UNCOMMON, new ItemStack(Items.SUGAR)), + SPEED( + MobEffects.SPEED.getName(), + 8171462, + MobEffects.SPEED, + 0, + 1, + 10, + false, + EnumRarity.UNCOMMON, + new ItemStack(Items.SUGAR)), //Slowness - HASTE(MobEffects.HASTE.getName(), 14270531, MobEffects.HASTE, 0, 1, 10, false, EnumRarity.EPIC, new ItemStack(Items.REPEATER)), + HASTE( + MobEffects.HASTE.getName(), + 14270531, + MobEffects.HASTE, + 0, + 1, + 10, + false, + EnumRarity.EPIC, + new ItemStack(Items.REPEATER)), //Mining Fatigue - STRENGTH(MobEffects.STRENGTH.getName(), 9643043, MobEffects.STRENGTH, 0, 1, 10, false, EnumRarity.RARE, new ItemStack(Items.BLAZE_POWDER)), + STRENGTH( + MobEffects.STRENGTH.getName(), + 9643043, + MobEffects.STRENGTH, + 0, + 1, + 10, + false, + EnumRarity.RARE, + new ItemStack(Items.BLAZE_POWDER)), //Health (Not Happening) //Damage - JUMP_BOOST(MobEffects.JUMP_BOOST.getName(), 7889559, MobEffects.JUMP_BOOST, 0, 1, 10, false, EnumRarity.RARE, new ItemStack(Blocks.PISTON)), + JUMP_BOOST( + MobEffects.JUMP_BOOST.getName(), + 7889559, + MobEffects.JUMP_BOOST, + 0, + 1, + 10, + false, + EnumRarity.RARE, + new ItemStack(Blocks.PISTON)), //Nausea - REGEN(MobEffects.REGENERATION.getName(), 13458603, MobEffects.REGENERATION, 0, 1, 50, true, EnumRarity.RARE, new ItemStack(Items.GHAST_TEAR)), - RESISTANCE(MobEffects.RESISTANCE.getName(), 10044730, MobEffects.RESISTANCE, 0, 1, 10, false, EnumRarity.EPIC, new ItemStack(Items.SLIME_BALL)), - FIRE_RESISTANCE(MobEffects.FIRE_RESISTANCE.getName(), 14981690, MobEffects.FIRE_RESISTANCE, 0, 0, 10, false, EnumRarity.UNCOMMON, new ItemStack(Items.MAGMA_CREAM)), - WATER_BREATHING(MobEffects.WATER_BREATHING.getName(), 3035801, MobEffects.WATER_BREATHING, 0, 0, 10, false, EnumRarity.RARE, new ItemStack(Items.FISH, 1, 3)), - INVISIBILITY(MobEffects.INVISIBILITY.getName(), 8356754, MobEffects.INVISIBILITY, 0, 0, 10, false, EnumRarity.EPIC, new ItemStack(Items.FERMENTED_SPIDER_EYE)), + REGEN( + MobEffects.REGENERATION.getName(), + 13458603, + MobEffects.REGENERATION, + 0, + 1, + 50, + true, + EnumRarity.RARE, + new ItemStack(Items.GHAST_TEAR)), + RESISTANCE( + MobEffects.RESISTANCE.getName(), + 10044730, + MobEffects.RESISTANCE, + 0, + 1, + 10, + false, + EnumRarity.EPIC, + new ItemStack(Items.SLIME_BALL)), + FIRE_RESISTANCE( + MobEffects.FIRE_RESISTANCE.getName(), + 14981690, + MobEffects.FIRE_RESISTANCE, + 0, + 0, + 10, + false, + EnumRarity.UNCOMMON, + new ItemStack(Items.MAGMA_CREAM)), + WATER_BREATHING( + MobEffects.WATER_BREATHING.getName(), + 3035801, + MobEffects.WATER_BREATHING, + 0, + 0, + 10, + false, + EnumRarity.RARE, + new ItemStack(Items.FISH, 1, 3)), + INVISIBILITY( + MobEffects.INVISIBILITY.getName(), + 8356754, + MobEffects.INVISIBILITY, + 0, + 0, + 10, + false, + EnumRarity.EPIC, + new ItemStack(Items.FERMENTED_SPIDER_EYE)), //Blindness - NIGHT_VISION(MobEffects.NIGHT_VISION.getName(), 2039713, MobEffects.NIGHT_VISION, 0, 0, 300, false, EnumRarity.RARE, new ItemStack(Items.GOLDEN_CARROT)); + NIGHT_VISION( + MobEffects.NIGHT_VISION.getName(), + 2039713, + MobEffects.NIGHT_VISION, + 0, + 0, + 300, + false, + EnumRarity.RARE, + new ItemStack(Items.GOLDEN_CARROT)); //Hunger //Weakness //Poison @@ -52,7 +142,7 @@ public enum ThePotionRings{ public final boolean needsWaitBeforeActivating; public final ItemStack craftingItem; - ThePotionRings(String name, int color, Potion effect, int normalAmplifier, int advancedAmplifier, int activeTime, boolean needsWaitBeforeActivating, EnumRarity rarity, ItemStack craftingItem){ + ThePotionRings(String name, int color, Potion effect, int normalAmplifier, int advancedAmplifier, int activeTime, boolean needsWaitBeforeActivating, EnumRarity rarity, ItemStack craftingItem) { this.name = name; this.color = color; this.rarity = rarity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java index 3584e8290..a61f4f20f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java @@ -46,22 +46,16 @@ import mezz.jei.api.recipe.VanillaRecipeCategoryUid; import net.minecraft.item.ItemStack; @JEIPlugin -public class JEIActuallyAdditionsPlugin implements IModPlugin{ +public class JEIActuallyAdditionsPlugin implements IModPlugin { @Override public void registerCategories(IRecipeCategoryRegistration registry) { IJeiHelpers helpers = registry.getJeiHelpers(); - registry.addRecipeCategories( - new CoffeeMachineRecipeCategory(helpers.getGuiHelper()), - new CompostRecipeCategory(helpers.getGuiHelper()), - new CrusherRecipeCategory(helpers.getGuiHelper()), - new ReconstructorRecipeCategory(helpers.getGuiHelper()), - new EmpowererRecipeCategory(helpers.getGuiHelper()), - new BookletRecipeCategory(helpers.getGuiHelper())); + registry.addRecipeCategories(new CoffeeMachineRecipeCategory(helpers.getGuiHelper()), new CompostRecipeCategory(helpers.getGuiHelper()), new CrusherRecipeCategory(helpers.getGuiHelper()), new ReconstructorRecipeCategory(helpers.getGuiHelper()), new EmpowererRecipeCategory(helpers.getGuiHelper()), new BookletRecipeCategory(helpers.getGuiHelper())); } @Override - public void register(IModRegistry registry){ + public void register(IModRegistry registry) { IJeiHelpers helpers = registry.getJeiHelpers(); registry.handleRecipes(IBookletPage.class, BookletRecipeWrapper::new, BookletRecipeCategory.NAME); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/RecipeWrapperWithButton.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/RecipeWrapperWithButton.java index 68d53eb26..14a588fe0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/RecipeWrapperWithButton.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/RecipeWrapperWithButton.java @@ -10,6 +10,11 @@ package de.ellpeck.actuallyadditions.mod.jei; +import java.util.Collections; +import java.util.List; + +import javax.annotation.Nullable; + import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet; @@ -19,15 +24,11 @@ import de.ellpeck.actuallyadditions.mod.util.StringUtil; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.client.Minecraft; -import javax.annotation.Nullable; -import java.util.Collections; -import java.util.List; - -public abstract class RecipeWrapperWithButton implements IRecipeWrapper{ +public abstract class RecipeWrapperWithButton implements IRecipeWrapper { protected final TexturedButton theButton; - public RecipeWrapperWithButton(){ + public RecipeWrapperWithButton() { this.theButton = new TexturedButton(GuiBooklet.RES_LOC_GADGETS, 23782, this.getButtonX(), this.getButtonY(), 0, 0, 20, 20); } @@ -36,12 +37,12 @@ public abstract class RecipeWrapperWithButton implements IRecipeWrapper{ public abstract int getButtonY(); @Override - public boolean handleClick(Minecraft minecraft, int mouseX, int mouseY, int mouseButton){ - if(this.theButton.mousePressed(minecraft, mouseX, mouseY)){ + public boolean handleClick(Minecraft minecraft, int mouseX, int mouseY, int mouseButton) { + if (this.theButton.mousePressed(minecraft, mouseX, mouseY)) { this.theButton.playPressSound(minecraft.getSoundHandler()); IBookletPage page = this.getPage(); - if(page != null){ + if (page != null) { Minecraft.getMinecraft().displayGuiScreen(BookletUtils.createBookletGuiFromPage(Minecraft.getMinecraft().currentScreen, page)); return true; } @@ -52,17 +53,16 @@ public abstract class RecipeWrapperWithButton implements IRecipeWrapper{ public abstract IBookletPage getPage(); @Override - public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY){ + public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { this.theButton.drawButton(minecraft, mouseX, mouseY, 0F); } @Nullable @Override - public List getTooltipStrings(int mouseX, int mouseY){ - if(this.theButton.isMouseOver()){ - return Collections.singletonList(StringUtil.localize("booklet."+ActuallyAdditions.MODID+".clickToSeeRecipe")); - } - else{ + public List getTooltipStrings(int mouseX, int mouseY) { + if (this.theButton.isMouseOver()) { + return Collections.singletonList(StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".clickToSeeRecipe")); + } else { return Collections.emptyList(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/booklet/BookletRecipeCategory.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/booklet/BookletRecipeCategory.java index c1872e489..df974b9ea 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/booklet/BookletRecipeCategory.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/booklet/BookletRecipeCategory.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.jei.booklet; +import java.util.ArrayList; +import java.util.List; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.util.StringUtil; import mezz.jei.api.IGuiHelper; @@ -19,43 +22,38 @@ import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeCategory; import net.minecraft.item.ItemStack; -import java.util.ArrayList; -import java.util.List; - -public class BookletRecipeCategory implements IRecipeCategory{ +public class BookletRecipeCategory implements IRecipeCategory { public static final String NAME = "actuallyadditions.booklet"; private final IDrawable background; - public BookletRecipeCategory(IGuiHelper helper){ + public BookletRecipeCategory(IGuiHelper helper) { this.background = helper.createBlankDrawable(160, 105); } @Override - public String getUid(){ + public String getUid() { return NAME; } - @Override - public String getTitle(){ - return StringUtil.localize("container.nei."+NAME+".name"); + public String getTitle() { + return StringUtil.localize("container.nei." + NAME + ".name"); } @Override - public String getModName(){ + public String getModName() { return ActuallyAdditions.NAME; } - @Override - public IDrawable getBackground(){ + public IDrawable getBackground() { return this.background; } @Override - public void setRecipe(IRecipeLayout recipeLayout, BookletRecipeWrapper wrapper, IIngredients ingredients){ + public void setRecipe(IRecipeLayout recipeLayout, BookletRecipeWrapper wrapper, IIngredients ingredients) { recipeLayout.getItemStacks().init(0, true, 70, -4); List list = new ArrayList<>(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeCategory.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeCategory.java index 539fc8bb8..cda7917a4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeCategory.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeCategory.java @@ -22,38 +22,38 @@ import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeCategory; -public class CoffeeMachineRecipeCategory implements IRecipeCategory{ +public class CoffeeMachineRecipeCategory implements IRecipeCategory { public static final String NAME = "actuallyadditions.coffee"; private final IDrawable background; - public CoffeeMachineRecipeCategory(IGuiHelper helper){ + public CoffeeMachineRecipeCategory(IGuiHelper helper) { this.background = helper.createDrawable(AssetUtil.getGuiLocation("gui_nei_coffee_machine"), 0, 0, 126, 92); } @Override - public String getUid(){ + public String getUid() { return NAME; } @Override - public String getTitle(){ - return StringUtil.localize("container.nei."+NAME+".name"); + public String getTitle() { + return StringUtil.localize("container.nei." + NAME + ".name"); } @Override - public String getModName(){ + public String getModName() { return ActuallyAdditions.NAME; } @Override - public IDrawable getBackground(){ + public IDrawable getBackground() { return this.background; } @Override - public void setRecipe(IRecipeLayout recipeLayout, CoffeeMachineRecipeWrapper wrapper, IIngredients ingredients){ + public void setRecipe(IRecipeLayout recipeLayout, CoffeeMachineRecipeWrapper wrapper, IIngredients ingredients) { recipeLayout.getItemStacks().init(0, true, 89, 20); recipeLayout.getItemStacks().set(0, Arrays.asList(wrapper.ingredient.getInput().getMatchingStacks())); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeWrapper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeWrapper.java index cb7818723..08eb89731 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeWrapper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeWrapper.java @@ -50,8 +50,8 @@ public class CoffeeMachineRecipeWrapper extends RecipeWrapperWithButton { for (ItemStack s : this.ingredient.getInput().getMatchingStacks()) list.add(s); list.add(this.cup); - for(ItemStack s : TileEntityCoffeeMachine.COFFEE.getMatchingStacks()) - list.add(s); + for (ItemStack s : TileEntityCoffeeMachine.COFFEE.getMatchingStacks()) + list.add(s); ingredients.setInputs(VanillaTypes.ITEM, list); ingredients.setOutput(VanillaTypes.ITEM, this.theOutput); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/crusher/CrusherRecipeCategory.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/crusher/CrusherRecipeCategory.java index 568070ab1..06f56fbe9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/crusher/CrusherRecipeCategory.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/crusher/CrusherRecipeCategory.java @@ -22,45 +22,45 @@ import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeCategory; -public class CrusherRecipeCategory implements IRecipeCategory{ +public class CrusherRecipeCategory implements IRecipeCategory { public static final String NAME = "actuallyadditions.crushing"; private final IDrawable background; - public CrusherRecipeCategory(IGuiHelper helper){ + public CrusherRecipeCategory(IGuiHelper helper) { this.background = helper.createDrawable(AssetUtil.getGuiLocation("gui_grinder"), 60, 13, 56, 79); } @Override - public String getUid(){ + public String getUid() { return NAME; } @Override - public String getTitle(){ - return StringUtil.localize("container.nei."+NAME+".name"); + public String getTitle() { + return StringUtil.localize("container.nei." + NAME + ".name"); } @Override - public String getModName(){ + public String getModName() { return ActuallyAdditions.NAME; } @Override - public IDrawable getBackground(){ + public IDrawable getBackground() { return this.background; } @Override - public void setRecipe(IRecipeLayout recipeLayout, CrusherRecipeWrapper wrapper, IIngredients ingredients){ + public void setRecipe(IRecipeLayout recipeLayout, CrusherRecipeWrapper wrapper, IIngredients ingredients) { recipeLayout.getItemStacks().init(0, true, 19, 7); recipeLayout.getItemStacks().set(0, Arrays.asList(wrapper.theRecipe.getInput().getMatchingStacks())); recipeLayout.getItemStacks().init(1, false, 7, 55); recipeLayout.getItemStacks().set(1, wrapper.theRecipe.getOutputOne()); - if(StackUtil.isValid(wrapper.theRecipe.getOutputTwo())){ + if (StackUtil.isValid(wrapper.theRecipe.getOutputTwo())) { recipeLayout.getItemStacks().init(2, false, 31, 55); recipeLayout.getItemStacks().set(2, wrapper.theRecipe.getOutputTwo()); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/empowerer/EmpowererRecipeCategory.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/empowerer/EmpowererRecipeCategory.java index 369956291..341664e70 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/empowerer/EmpowererRecipeCategory.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/empowerer/EmpowererRecipeCategory.java @@ -21,38 +21,38 @@ import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeCategory; -public class EmpowererRecipeCategory implements IRecipeCategory{ +public class EmpowererRecipeCategory implements IRecipeCategory { public static final String NAME = "actuallyadditions.empowerer"; private final IDrawable background; - public EmpowererRecipeCategory(IGuiHelper helper){ + public EmpowererRecipeCategory(IGuiHelper helper) { this.background = helper.createDrawable(AssetUtil.getGuiLocation("gui_nei_empowerer"), 0, 0, 135, 80); } @Override - public String getUid(){ + public String getUid() { return NAME; } @Override - public String getTitle(){ - return StringUtil.localize("container.nei."+NAME+".name"); + public String getTitle() { + return StringUtil.localize("container.nei." + NAME + ".name"); } @Override - public String getModName(){ + public String getModName() { return ActuallyAdditions.NAME; } @Override - public IDrawable getBackground(){ + public IDrawable getBackground() { return this.background; } @Override - public void setRecipe(IRecipeLayout recipeLayout, EmpowererRecipeWrapper wrapper, IIngredients ingredients){ + public void setRecipe(IRecipeLayout recipeLayout, EmpowererRecipeWrapper wrapper, IIngredients ingredients) { recipeLayout.getItemStacks().init(0, true, 31, 31); recipeLayout.getItemStacks().set(0, Arrays.asList(wrapper.theRecipe.getInput().getMatchingStacks())); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/reconstructor/ReconstructorRecipeWrapper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/reconstructor/ReconstructorRecipeWrapper.java index ed5aca2e5..e3b807e78 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/reconstructor/ReconstructorRecipeWrapper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/reconstructor/ReconstructorRecipeWrapper.java @@ -50,7 +50,7 @@ public class ReconstructorRecipeWrapper extends RecipeWrapperWithButton { @Override public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { - minecraft.fontRenderer.drawString(this.theRecipe.getEnergyUsed() + " "+I18n.format("actuallyadditions.cf"), 55, 0, 0xFFFFFF, true); + minecraft.fontRenderer.drawString(this.theRecipe.getEnergyUsed() + " " + I18n.format("actuallyadditions.cf"), 55, 0, 0xFFFFFF, true); super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/material/InitArmorMaterials.java b/src/main/java/de/ellpeck/actuallyadditions/mod/material/InitArmorMaterials.java index 3541af554..93457d79f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/material/InitArmorMaterials.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/material/InitArmorMaterials.java @@ -10,15 +10,15 @@ package de.ellpeck.actuallyadditions.mod.material; +import java.util.Locale; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.util.SoundEvent; import net.minecraftforge.common.util.EnumHelper; -import java.util.Locale; - -public final class InitArmorMaterials{ +public final class InitArmorMaterials { public static ArmorMaterial armorMaterialEmerald; public static ArmorMaterial armorMaterialObsidian; @@ -33,24 +33,24 @@ public final class InitArmorMaterials{ public static ArmorMaterial armorMaterialGoggles; - public static void init(){ + public static void init() { ActuallyAdditions.LOGGER.info("Initializing Armor Materials..."); - armorMaterialEmerald = addArmorMaterial("armorMaterialEmerald", ActuallyAdditions.MODID+":armor_emerald", 50, new int[]{5, 8, 9, 4}, 15, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 2); - armorMaterialObsidian = addArmorMaterial("armorMaterialObsidian", ActuallyAdditions.MODID+":armor_obsidian", 120, new int[]{1, 3, 4, 3}, 10, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 1); - armorMaterialQuartz = addArmorMaterial("armorMaterialQuartz", ActuallyAdditions.MODID+":armor_quartz", 20, new int[]{3, 5, 6, 3}, 8, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 1); + armorMaterialEmerald = addArmorMaterial("armorMaterialEmerald", ActuallyAdditions.MODID + ":armor_emerald", 50, new int[] { 5, 8, 9, 4 }, 15, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 2); + armorMaterialObsidian = addArmorMaterial("armorMaterialObsidian", ActuallyAdditions.MODID + ":armor_obsidian", 120, new int[] { 1, 3, 4, 3 }, 10, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 1); + armorMaterialQuartz = addArmorMaterial("armorMaterialQuartz", ActuallyAdditions.MODID + ":armor_quartz", 20, new int[] { 3, 5, 6, 3 }, 8, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 1); - armorMaterialCrystalRed = addArmorMaterial("armorMaterialCrystalRed", ActuallyAdditions.MODID+":armor_crystal_red", 18, new int[]{3, 6, 7, 3}, 9, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0); - armorMaterialCrystalBlue = addArmorMaterial("armorMaterialCrystalBlue", ActuallyAdditions.MODID+":armor_crystal_blue", 18, new int[]{3, 6, 7, 3}, 10, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0); - armorMaterialCrystalLightBlue = addArmorMaterial("armorMaterialCrystalLightBlue", ActuallyAdditions.MODID+":armor_crystal_light_blue", 35, new int[]{4, 7, 8, 4}, 12, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 3); - armorMaterialCrystalBlack = addArmorMaterial("armorMaterialCrystalBlack", ActuallyAdditions.MODID+":armor_crystal_black", 12, new int[]{1, 3, 4, 1}, 13, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0); - armorMaterialCrystalGreen = addArmorMaterial("armorMaterialCrystalGreen", ActuallyAdditions.MODID+":armor_crystal_green", 60, new int[]{6, 9, 9, 4}, 18, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 3); - armorMaterialCrystalWhite = addArmorMaterial("armorMaterialCrystalWhite", ActuallyAdditions.MODID+":armor_crystal_white", 18, new int[]{3, 6, 6, 3}, 11, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0); + armorMaterialCrystalRed = addArmorMaterial("armorMaterialCrystalRed", ActuallyAdditions.MODID + ":armor_crystal_red", 18, new int[] { 3, 6, 7, 3 }, 9, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0); + armorMaterialCrystalBlue = addArmorMaterial("armorMaterialCrystalBlue", ActuallyAdditions.MODID + ":armor_crystal_blue", 18, new int[] { 3, 6, 7, 3 }, 10, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0); + armorMaterialCrystalLightBlue = addArmorMaterial("armorMaterialCrystalLightBlue", ActuallyAdditions.MODID + ":armor_crystal_light_blue", 35, new int[] { 4, 7, 8, 4 }, 12, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 3); + armorMaterialCrystalBlack = addArmorMaterial("armorMaterialCrystalBlack", ActuallyAdditions.MODID + ":armor_crystal_black", 12, new int[] { 1, 3, 4, 1 }, 13, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0); + armorMaterialCrystalGreen = addArmorMaterial("armorMaterialCrystalGreen", ActuallyAdditions.MODID + ":armor_crystal_green", 60, new int[] { 6, 9, 9, 4 }, 18, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 3); + armorMaterialCrystalWhite = addArmorMaterial("armorMaterialCrystalWhite", ActuallyAdditions.MODID + ":armor_crystal_white", 18, new int[] { 3, 6, 6, 3 }, 11, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0); - armorMaterialGoggles = addArmorMaterial("armorMaterialGoggles", ActuallyAdditions.MODID+":armor_goggles", 0, new int[]{0, 0, 0, 0}, 0, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0); + armorMaterialGoggles = addArmorMaterial("armorMaterialGoggles", ActuallyAdditions.MODID + ":armor_goggles", 0, new int[] { 0, 0, 0, 0 }, 0, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0); } - private static ArmorMaterial addArmorMaterial(String name, String textureName, int durability, int[] reductionAmounts, int enchantability, SoundEvent soundOnEquip, float toughness){ - return EnumHelper.addArmorMaterial((ActuallyAdditions.MODID+"_"+name).toUpperCase(Locale.ROOT), textureName, durability, reductionAmounts, enchantability, soundOnEquip, toughness); + private static ArmorMaterial addArmorMaterial(String name, String textureName, int durability, int[] reductionAmounts, int enchantability, SoundEvent soundOnEquip, float toughness) { + return EnumHelper.addArmorMaterial((ActuallyAdditions.MODID + "_" + name).toUpperCase(Locale.ROOT), textureName, durability, reductionAmounts, enchantability, soundOnEquip, toughness); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/material/InitToolMaterials.java b/src/main/java/de/ellpeck/actuallyadditions/mod/material/InitToolMaterials.java index d348e5c7d..366f19d87 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/material/InitToolMaterials.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/material/InitToolMaterials.java @@ -10,13 +10,13 @@ package de.ellpeck.actuallyadditions.mod.material; +import java.util.Locale; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import net.minecraft.item.Item.ToolMaterial; import net.minecraftforge.common.util.EnumHelper; -import java.util.Locale; - -public final class InitToolMaterials{ +public final class InitToolMaterials { public static ToolMaterial toolMaterialEmerald; public static ToolMaterial toolMaterialObsidian; @@ -29,7 +29,7 @@ public final class InitToolMaterials{ public static ToolMaterial toolMaterialCrystalGreen; public static ToolMaterial toolMaterialCrystalWhite; - public static void init(){ + public static void init() { ActuallyAdditions.LOGGER.info("Initializing Tool Materials..."); toolMaterialEmerald = addToolMaterial("toolMaterialEmerald", 3, 2000, 9.0F, 5.0F, 15); @@ -45,8 +45,8 @@ public final class InitToolMaterials{ } - private static ToolMaterial addToolMaterial(String name, int harvestLevel, int maxUses, float efficiency, float damage, int enchantability){ - return EnumHelper.addToolMaterial((ActuallyAdditions.MODID+"_"+name).toUpperCase(Locale.ROOT), harvestLevel, maxUses, efficiency, damage, enchantability); + private static ToolMaterial addToolMaterial(String name, int harvestLevel, int maxUses, float efficiency, float damage, int enchantability) { + return EnumHelper.addToolMaterial((ActuallyAdditions.MODID + "_" + name).toUpperCase(Locale.ROOT), harvestLevel, maxUses, efficiency, damage, enchantability); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/BannerHelper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/BannerHelper.java index 47044c4b5..322699528 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/BannerHelper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/BannerHelper.java @@ -10,14 +10,14 @@ package de.ellpeck.actuallyadditions.mod.misc; +import java.util.Locale; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.items.InitItems; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.BannerPattern; import net.minecraftforge.common.util.EnumHelper; -import java.util.Locale; - public final class BannerHelper { public static void init() { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DamageSources.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DamageSources.java index 71f5f412c..8253398da 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DamageSources.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DamageSources.java @@ -16,21 +16,20 @@ import net.minecraft.util.DamageSource; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; -public class DamageSources extends DamageSource{ +public class DamageSources extends DamageSource { public static final DamageSource DAMAGE_ATOMIC_RECONSTRUCTOR = new DamageSources("atomicReconstructor", 5).setDamageBypassesArmor(); private final int messageCount; - public DamageSources(String name, int messageCount){ + public DamageSources(String name, int messageCount) { super(name); this.messageCount = messageCount; } - @Override - public ITextComponent getDeathMessage(EntityLivingBase entity){ - String locTag = "death."+ActuallyAdditions.MODID+"."+this.damageType+"."+(entity.world.rand.nextInt(this.messageCount)+1); + public ITextComponent getDeathMessage(EntityLivingBase entity) { + String locTag = "death." + ActuallyAdditions.MODID + "." + this.damageType + "." + (entity.world.rand.nextInt(this.messageCount) + 1); return new TextComponentTranslation(locTag, entity.getName()); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DispenserHandlerFertilize.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DispenserHandlerFertilize.java index 57c8ba903..b8c8524a8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DispenserHandlerFertilize.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DispenserHandlerFertilize.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.misc; - import net.minecraft.block.BlockDispenser; import net.minecraft.dispenser.BehaviorDefaultDispenseItem; import net.minecraft.dispenser.IBlockSource; @@ -19,14 +18,14 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; -public class DispenserHandlerFertilize extends BehaviorDefaultDispenseItem{ +public class DispenserHandlerFertilize extends BehaviorDefaultDispenseItem { @Override - public ItemStack dispenseStack(IBlockSource source, ItemStack stack){ + public ItemStack dispenseStack(IBlockSource source, ItemStack stack) { EnumFacing facing = source.getBlockState().getValue(BlockDispenser.FACING); BlockPos pos = source.getBlockPos().offset(facing); - if(ItemDye.applyBonemeal(stack, source.getWorld(), pos)){ + if (ItemDye.applyBonemeal(stack, source.getWorld(), pos)) { source.getWorld().playEvent(2005, pos, 0); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DungeonLoot.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DungeonLoot.java index 91ba32370..92de05e09 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DungeonLoot.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DungeonLoot.java @@ -21,7 +21,11 @@ import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; -import net.minecraft.world.storage.loot.*; +import net.minecraft.world.storage.loot.LootEntry; +import net.minecraft.world.storage.loot.LootEntryItem; +import net.minecraft.world.storage.loot.LootPool; +import net.minecraft.world.storage.loot.LootTableList; +import net.minecraft.world.storage.loot.RandomValueRange; import net.minecraft.world.storage.loot.conditions.LootCondition; import net.minecraft.world.storage.loot.functions.LootFunction; import net.minecraft.world.storage.loot.functions.SetCount; @@ -30,25 +34,25 @@ import net.minecraft.world.storage.loot.functions.SetMetadata; import net.minecraftforge.event.LootTableLoadEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -public class DungeonLoot{ +public class DungeonLoot { public static final ResourceLocation JAM_HOUSE = new ResourceLocation(ActuallyAdditions.MODID, "jam_house"); public static final ResourceLocation LUSH_CAVES = new ResourceLocation(ActuallyAdditions.MODID, "lush_caves"); public static final ResourceLocation ENGINEER_HOUSE = new ResourceLocation(ActuallyAdditions.MODID, "engineer_house"); - public DungeonLoot(){ + public DungeonLoot() { LootTableList.register(JAM_HOUSE); LootTableList.register(LUSH_CAVES); LootTableList.register(ENGINEER_HOUSE); } @SubscribeEvent - public void onLootTableLoad(LootTableLoadEvent event){ - if(event.getName() != null && event.getTable() != null){ + public void onLootTableLoad(LootTableLoadEvent event) { + if (event.getName() != null && event.getTable() != null) { LootCondition[] noCondition = new LootCondition[0]; LootPool pool = event.getTable().getPool("main"); - if(pool == null){ + if (pool == null) { pool = new LootPool(new LootEntry[0], noCondition, new RandomValueRange(5, 10), new RandomValueRange(0), "main"); event.getTable().addPool(pool); } @@ -58,42 +62,34 @@ public class DungeonLoot{ boolean addQuartz = false; boolean addBatWings = false; - if(ConfigBoolValues.DUNGEON_LOOT.isEnabled()){ - if(LootTableList.CHESTS_SIMPLE_DUNGEON.equals(event.getName())){ + if (ConfigBoolValues.DUNGEON_LOOT.isEnabled()) { + if (LootTableList.CHESTS_SIMPLE_DUNGEON.equals(event.getName())) { addCrystals = true; addDrillCore = true; addQuartz = true; - } - else if(LootTableList.CHESTS_ABANDONED_MINESHAFT.equals(event.getName())){ + } else if (LootTableList.CHESTS_ABANDONED_MINESHAFT.equals(event.getName())) { addCrystals = true; addDrillCore = true; - } - else if(LootTableList.CHESTS_VILLAGE_BLACKSMITH.equals(event.getName())){ + } else if (LootTableList.CHESTS_VILLAGE_BLACKSMITH.equals(event.getName())) { addDrillCore = true; addQuartz = true; - } - else if(LootTableList.CHESTS_STRONGHOLD_LIBRARY.equals(event.getName())){ + } else if (LootTableList.CHESTS_STRONGHOLD_LIBRARY.equals(event.getName())) { addBatWings = true; - } - else if(LootTableList.CHESTS_IGLOO_CHEST.equals(event.getName())){ + } else if (LootTableList.CHESTS_IGLOO_CHEST.equals(event.getName())) { addBatWings = true; - } - else if(LootTableList.CHESTS_DESERT_PYRAMID.equals(event.getName())){ + } else if (LootTableList.CHESTS_DESERT_PYRAMID.equals(event.getName())) { addDrillCore = true; addBatWings = true; - } - else if(LootTableList.CHESTS_NETHER_BRIDGE.equals(event.getName())){ + } else if (LootTableList.CHESTS_NETHER_BRIDGE.equals(event.getName())) { addBatWings = true; addCrystals = true; addDrillCore = true; - } - else if(LootTableList.CHESTS_END_CITY_TREASURE.equals(event.getName())){ + } else if (LootTableList.CHESTS_END_CITY_TREASURE.equals(event.getName())) { addBatWings = true; addCrystals = true; addDrillCore = true; addQuartz = true; - } - else if(LootTableList.CHESTS_WOODLAND_MANSION.equals(event.getName())){ + } else if (LootTableList.CHESTS_WOODLAND_MANSION.equals(event.getName())) { addBatWings = true; addCrystals = true; addDrillCore = true; @@ -101,37 +97,35 @@ public class DungeonLoot{ } } - if(JAM_HOUSE.equals(event.getName())){ - LootFunction jamDamage = new SetMetadata(noCondition, new RandomValueRange(0, TheJams.values().length-1)); + if (JAM_HOUSE.equals(event.getName())) { + LootFunction jamDamage = new SetMetadata(noCondition, new RandomValueRange(0, TheJams.values().length - 1)); LootFunction jamAmount = new SetCount(noCondition, new RandomValueRange(3, 5)); - pool.addEntry(new LootEntryItem(InitItems.itemJams, 2, 0, new LootFunction[]{jamDamage, jamAmount}, noCondition, ActuallyAdditions.MODID+":jams")); + pool.addEntry(new LootEntryItem(InitItems.itemJams, 2, 0, new LootFunction[] { jamDamage, jamAmount }, noCondition, ActuallyAdditions.MODID + ":jams")); LootFunction glassAmount = new SetCount(noCondition, new RandomValueRange(2)); - pool.addEntry(new LootEntryItem(Items.GLASS_BOTTLE, 1, 0, new LootFunction[]{glassAmount}, noCondition, ActuallyAdditions.MODID+":bottles")); - } - else if(LUSH_CAVES.equals(event.getName())){ + pool.addEntry(new LootEntryItem(Items.GLASS_BOTTLE, 1, 0, new LootFunction[] { glassAmount }, noCondition, ActuallyAdditions.MODID + ":bottles")); + } else if (LUSH_CAVES.equals(event.getName())) { addQuartz = true; addBatWings = true; addCrystals = true; - pool.addEntry(new LootEntryItem(Items.BOOK, 50, 0, new LootFunction[0], noCondition, ActuallyAdditions.MODID+":book")); + pool.addEntry(new LootEntryItem(Items.BOOK, 50, 0, new LootFunction[0], noCondition, ActuallyAdditions.MODID + ":book")); LootFunction bonesAmount = new SetCount(noCondition, new RandomValueRange(1, 12)); - pool.addEntry(new LootEntryItem(Items.BONE, 100, 0, new LootFunction[]{bonesAmount}, noCondition, ActuallyAdditions.MODID+":bones")); + pool.addEntry(new LootEntryItem(Items.BONE, 100, 0, new LootFunction[] { bonesAmount }, noCondition, ActuallyAdditions.MODID + ":bones")); - Item[] aiots = new Item[]{InitItems.woodenPaxel, InitItems.stonePaxel, InitItems.quartzPaxel, InitItems.itemPaxelCrystalBlack, InitItems.itemPaxelCrystalWhite}; - for(int i = 0; i < aiots.length; i++){ + Item[] aiots = new Item[] { InitItems.woodenPaxel, InitItems.stonePaxel, InitItems.quartzPaxel, InitItems.itemPaxelCrystalBlack, InitItems.itemPaxelCrystalWhite }; + for (int i = 0; i < aiots.length; i++) { LootFunction damage = new SetDamage(noCondition, new RandomValueRange(0F, 0.25F)); - pool.addEntry(new LootEntryItem(aiots[i], 30-i*5, 0, new LootFunction[]{damage}, noCondition, ActuallyAdditions.MODID+":aiot"+i)); + pool.addEntry(new LootEntryItem(aiots[i], 30 - i * 5, 0, new LootFunction[] { damage }, noCondition, ActuallyAdditions.MODID + ":aiot" + i)); } - Item[] armor = new Item[]{Items.LEATHER_HELMET, Items.LEATHER_CHESTPLATE, Items.LEATHER_LEGGINGS, Items.LEATHER_BOOTS}; - for(int i = 0; i < armor.length; i++){ + Item[] armor = new Item[] { Items.LEATHER_HELMET, Items.LEATHER_CHESTPLATE, Items.LEATHER_LEGGINGS, Items.LEATHER_BOOTS }; + for (int i = 0; i < armor.length; i++) { LootFunction damage = new SetDamage(noCondition, new RandomValueRange(0F, 0.75F)); - pool.addEntry(new LootEntryItem(armor[i], 50, 0, new LootFunction[]{damage}, noCondition, ActuallyAdditions.MODID+":armor"+i)); + pool.addEntry(new LootEntryItem(armor[i], 50, 0, new LootFunction[] { damage }, noCondition, ActuallyAdditions.MODID + ":armor" + i)); } - } - else if(ENGINEER_HOUSE.equals(event.getName())){ + } else if (ENGINEER_HOUSE.equals(event.getName())) { addQuartz = true; addBatWings = true; addCrystals = true; @@ -139,37 +133,37 @@ public class DungeonLoot{ LootFunction woodCaseAmount = new SetCount(noCondition, new RandomValueRange(3, 10)); LootFunction woodCaseDamage = new SetMetadata(noCondition, new RandomValueRange(TheMiscBlocks.WOOD_CASING.ordinal())); - pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockMisc), 60, 0, new LootFunction[]{woodCaseAmount, woodCaseDamage}, noCondition, ActuallyAdditions.MODID+":woodenCase")); + pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockMisc), 60, 0, new LootFunction[] { woodCaseAmount, woodCaseDamage }, noCondition, ActuallyAdditions.MODID + ":woodenCase")); LootFunction ironCaseAmount = new SetCount(noCondition, new RandomValueRange(1, 3)); LootFunction ironCaseDamage = new SetMetadata(noCondition, new RandomValueRange(TheMiscBlocks.IRON_CASING.ordinal())); - pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockMisc), 40, 0, new LootFunction[]{ironCaseAmount, ironCaseDamage}, noCondition, ActuallyAdditions.MODID+":ironCase")); + pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockMisc), 40, 0, new LootFunction[] { ironCaseAmount, ironCaseDamage }, noCondition, ActuallyAdditions.MODID + ":ironCase")); } - if(addCrystals){ - LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(0, TheCrystals.values().length-1)); + if (addCrystals) { + LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(0, TheCrystals.values().length - 1)); LootFunction amount = new SetCount(noCondition, new RandomValueRange(1, 3)); - LootFunction[] functions = new LootFunction[]{damage, amount}; + LootFunction[] functions = new LootFunction[] { damage, amount }; - pool.addEntry(new LootEntryItem(InitItems.itemCrystal, 20, 0, functions, noCondition, ActuallyAdditions.MODID+":crystalItems")); - pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockCrystal), 3, 0, functions, noCondition, ActuallyAdditions.MODID+":crystalBlocks")); + pool.addEntry(new LootEntryItem(InitItems.itemCrystal, 20, 0, functions, noCondition, ActuallyAdditions.MODID + ":crystalItems")); + pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockCrystal), 3, 0, functions, noCondition, ActuallyAdditions.MODID + ":crystalBlocks")); } - if(addDrillCore){ + if (addDrillCore) { LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(TheMiscItems.DRILL_CORE.ordinal())); - pool.addEntry(new LootEntryItem(InitItems.itemMisc, 5, 0, new LootFunction[]{damage}, noCondition, ActuallyAdditions.MODID+":drillCore")); + pool.addEntry(new LootEntryItem(InitItems.itemMisc, 5, 0, new LootFunction[] { damage }, noCondition, ActuallyAdditions.MODID + ":drillCore")); } - if(addQuartz){ + if (addQuartz) { LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(TheMiscItems.QUARTZ.ordinal())); LootFunction amount = new SetCount(noCondition, new RandomValueRange(1, 5)); - pool.addEntry(new LootEntryItem(InitItems.itemMisc, 20, 0, new LootFunction[]{damage, amount}, noCondition, ActuallyAdditions.MODID+":quartz")); + pool.addEntry(new LootEntryItem(InitItems.itemMisc, 20, 0, new LootFunction[] { damage, amount }, noCondition, ActuallyAdditions.MODID + ":quartz")); } - if(addBatWings){ + if (addBatWings) { LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(TheMiscItems.BAT_WING.ordinal())); LootFunction amount = new SetCount(noCondition, new RandomValueRange(1, 2)); - pool.addEntry(new LootEntryItem(InitItems.itemMisc, 5, 0, new LootFunction[]{damage, amount}, noCondition, ActuallyAdditions.MODID+":batWings")); + pool.addEntry(new LootEntryItem(InitItems.itemMisc, 5, 0, new LootFunction[] { damage, amount }, noCondition, ActuallyAdditions.MODID + ":batWings")); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/SoundHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/SoundHandler.java index e5901fa69..3384ecc27 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/SoundHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/SoundHandler.java @@ -15,21 +15,21 @@ import de.ellpeck.actuallyadditions.mod.RegistryHandler; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; -public final class SoundHandler{ +public final class SoundHandler { public static SoundEvent duhDuhDuhDuuuh; public static SoundEvent coffeeMachine; public static SoundEvent reconstructor; public static SoundEvent crusher; - public static void init(){ + public static void init() { duhDuhDuhDuuuh = registerSound("duh_duh_duh_duuuh"); coffeeMachine = registerSound("coffee_machine"); reconstructor = registerSound("reconstructor"); crusher = registerSound("crusher"); } - private static SoundEvent registerSound(String name){ + private static SoundEvent registerSound(String name) { ResourceLocation resLoc = new ResourceLocation(ActuallyAdditions.MODID, name); SoundEvent event = new SoundEvent(resLoc); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/ConnectionPair.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/ConnectionPair.java index 7b990a6a3..fcf47ea26 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/ConnectionPair.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/ConnectionPair.java @@ -15,17 +15,17 @@ import de.ellpeck.actuallyadditions.api.laser.LaserType; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; -public class ConnectionPair implements IConnectionPair{ +public class ConnectionPair implements IConnectionPair { private final BlockPos[] positions = new BlockPos[2]; private boolean suppressConnectionRender; private LaserType type; - public ConnectionPair(){ + public ConnectionPair() { } - public ConnectionPair(BlockPos firstRelay, BlockPos secondRelay, LaserType type, boolean suppressConnectionRender){ + public ConnectionPair(BlockPos firstRelay, BlockPos secondRelay, LaserType type, boolean suppressConnectionRender) { this.positions[0] = firstRelay; this.positions[1] = secondRelay; this.suppressConnectionRender = suppressConnectionRender; @@ -33,75 +33,71 @@ public class ConnectionPair implements IConnectionPair{ } @Override - public void readFromNBT(NBTTagCompound compound){ - if(compound != null){ - for(int i = 0; i < this.positions.length; i++){ - int anX = compound.getInteger("x"+i); - int aY = compound.getInteger("y"+i); - int aZ = compound.getInteger("z"+i); + public void readFromNBT(NBTTagCompound compound) { + if (compound != null) { + for (int i = 0; i < this.positions.length; i++) { + int anX = compound.getInteger("x" + i); + int aY = compound.getInteger("y" + i); + int aZ = compound.getInteger("z" + i); this.positions[i] = new BlockPos(anX, aY, aZ); } this.suppressConnectionRender = compound.getBoolean("SuppressRender"); String typeStrg = compound.getString("Type"); - if(typeStrg != null && !typeStrg.isEmpty()){ + if (typeStrg != null && !typeStrg.isEmpty()) { this.type = LaserType.valueOf(typeStrg); } } } @Override - public BlockPos[] getPositions(){ + public BlockPos[] getPositions() { return this.positions; } @Override - public boolean doesSuppressRender(){ + public boolean doesSuppressRender() { return this.suppressConnectionRender; } @Override - public LaserType getType(){ + public LaserType getType() { return this.type; } @Override - public boolean contains(BlockPos relay){ - for(BlockPos position : this.positions){ - if(position != null && position.equals(relay)){ - return true; - } + public boolean contains(BlockPos relay) { + for (BlockPos position : this.positions) { + if (position != null && position.equals(relay)) { return true; } } return false; } @Override - public String toString(){ - return (this.positions[0] == null ? "-" : this.positions[0].toString())+" | "+(this.positions[1] == null ? "-" : this.positions[1].toString()); + public String toString() { + return (this.positions[0] == null ? "-" : this.positions[0].toString()) + " | " + (this.positions[1] == null ? "-" : this.positions[1].toString()); } @Override - public void writeToNBT(NBTTagCompound compound){ - for(int i = 0; i < this.positions.length; i++){ + public void writeToNBT(NBTTagCompound compound) { + for (int i = 0; i < this.positions.length; i++) { BlockPos relay = this.positions[i]; - compound.setInteger("x"+i, relay.getX()); - compound.setInteger("y"+i, relay.getY()); - compound.setInteger("z"+i, relay.getZ()); + compound.setInteger("x" + i, relay.getX()); + compound.setInteger("y" + i, relay.getY()); + compound.setInteger("z" + i, relay.getZ()); } - if(this.type != null){ + if (this.type != null) { compound.setString("Type", this.type.name()); } compound.setBoolean("SuppressRender", this.suppressConnectionRender); } @Override - public boolean equals(Object obj){ - if(obj instanceof ConnectionPair){ - ConnectionPair pair = (ConnectionPair)obj; - for(int i = 0; i < this.positions.length; i++){ - if(this.positions[i] == pair.positions[i] || this.positions[i] != null && this.positions[i].equals(pair.positions[i])){ - return true; - } + public boolean equals(Object obj) { + if (obj instanceof ConnectionPair) { + ConnectionPair pair = (ConnectionPair) obj; + for (int i = 0; i < this.positions.length; i++) { + if (this.positions[i] == pair.positions[i] || this.positions[i] != null && this.positions[i].equals(pair.positions[i])) { return true; } } } return super.equals(obj); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/LaserRelayConnectionHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/LaserRelayConnectionHandler.java index d4952991f..bffff80e7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/LaserRelayConnectionHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/LaserRelayConnectionHandler.java @@ -23,11 +23,11 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public final class LaserRelayConnectionHandler implements ILaserRelayConnectionHandler{ +public final class LaserRelayConnectionHandler implements ILaserRelayConnectionHandler { - public static NBTTagCompound writeNetworkToNBT(Network network){ + public static NBTTagCompound writeNetworkToNBT(Network network) { NBTTagList list = new NBTTagList(); - for(IConnectionPair pair : network.connections){ + for (IConnectionPair pair : network.connections) { NBTTagCompound tag = new NBTTagCompound(); pair.writeToNBT(tag); list.appendTag(tag); @@ -37,10 +37,10 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH return compound; } - public static Network readNetworkFromNBT(NBTTagCompound tag){ + public static Network readNetworkFromNBT(NBTTagCompound tag) { NBTTagList list = tag.getTagList("Network", 10); Network network = new Network(); - for(int i = 0; i < list.tagCount(); i++){ + for (int i = 0; i < list.tagCount(); i++) { ConnectionPair pair = new ConnectionPair(); pair.readFromNBT(list.getCompoundTagAt(i)); network.connections.add(pair); @@ -52,8 +52,8 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH * Merges two laserRelayNetworks together * (Actually puts everything from the second network into the first one and removes the second one) */ - private static void mergeNetworks(Network firstNetwork, Network secondNetwork, World world){ - for(IConnectionPair secondPair : secondNetwork.connections){ + private static void mergeNetworks(Network firstNetwork, Network secondNetwork, World world) { + for (IConnectionPair secondPair : secondNetwork.connections) { firstNetwork.connections.add(secondPair); } @@ -68,11 +68,11 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH * Gets all Connections for a Relay */ @Override - public ConcurrentSet getConnectionsFor(BlockPos relay, World world){ + public ConcurrentSet getConnectionsFor(BlockPos relay, World world) { ConcurrentSet allPairs = new ConcurrentSet<>(); - for(Network aNetwork : WorldData.get(world).laserRelayNetworks){ - for(IConnectionPair pair : aNetwork.connections){ - if(pair.contains(relay)){ + for (Network aNetwork : WorldData.get(world).laserRelayNetworks) { + for (IConnectionPair pair : aNetwork.connections) { + if (pair.contains(relay)) { allPairs.add(pair); } } @@ -84,17 +84,17 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH * Removes a Relay from its Network */ @Override - public void removeRelayFromNetwork(BlockPos relay, World world){ + public void removeRelayFromNetwork(BlockPos relay, World world) { Network network = this.getNetworkFor(relay, world); - if(network != null){ + if (network != null) { network.changeAmount++; //Setup new network (so that splitting a network will cause it to break into two) WorldData data = WorldData.get(world); data.laserRelayNetworks.remove(network); data.markDirty(); - for(IConnectionPair pair : network.connections){ - if(!pair.contains(relay)){ + for (IConnectionPair pair : network.connections) { + if (!pair.contains(relay)) { this.addConnection(pair.getPositions()[0], pair.getPositions()[1], pair.getType(), world, pair.doesSuppressRender()); } } @@ -106,20 +106,17 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH * Gets a Network for a Relay */ @Override - public Network getNetworkFor(BlockPos relay, World world){ - if(world != null) - for(Network aNetwork : WorldData.get(world).laserRelayNetworks){ - for(IConnectionPair pair : aNetwork.connections){ - if(pair.contains(relay)){ - return aNetwork; - } - } + public Network getNetworkFor(BlockPos relay, World world) { + if (world != null) for (Network aNetwork : WorldData.get(world).laserRelayNetworks) { + for (IConnectionPair pair : aNetwork.connections) { + if (pair.contains(relay)) { return aNetwork; } } + } return null; } @Override - public boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world){ + public boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world) { return this.addConnection(firstRelay, secondRelay, type, world, false); } @@ -128,50 +125,47 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH * (Puts it into the correct network!) */ @Override - public boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world, boolean suppressConnectionRender){ + public boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world, boolean suppressConnectionRender) { return this.addConnection(firstRelay, secondRelay, type, world, suppressConnectionRender, false); } @Override - public boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world, boolean suppressConnectionRender, boolean removeIfConnected){ - if(firstRelay == null || secondRelay == null || firstRelay == secondRelay || firstRelay.equals(secondRelay)){ - return false; - } + public boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world, boolean suppressConnectionRender, boolean removeIfConnected) { + if (firstRelay == null || secondRelay == null || firstRelay == secondRelay || firstRelay.equals(secondRelay)) { return false; } WorldData data = WorldData.get(world); Network firstNetwork = this.getNetworkFor(firstRelay, world); Network secondNetwork = this.getNetworkFor(secondRelay, world); //No Network exists - if(firstNetwork == null && secondNetwork == null){ + if (firstNetwork == null && secondNetwork == null) { firstNetwork = new Network(); data.laserRelayNetworks.add(firstNetwork); firstNetwork.connections.add(new ConnectionPair(firstRelay, secondRelay, type, suppressConnectionRender)); firstNetwork.changeAmount++; } //The same Network - else if(firstNetwork == secondNetwork){ - if(removeIfConnected){ + else if (firstNetwork == secondNetwork) { + if (removeIfConnected) { this.removeConnection(world, firstRelay, secondRelay); return true; - } - else{ + } else { return false; } } //Both relays have laserRelayNetworks - else if(firstNetwork != null && secondNetwork != null){ + else if (firstNetwork != null && secondNetwork != null) { mergeNetworks(firstNetwork, secondNetwork, world); firstNetwork.connections.add(new ConnectionPair(firstRelay, secondRelay, type, suppressConnectionRender)); firstNetwork.changeAmount++; } //Only first network exists - else if(firstNetwork != null){ + else if (firstNetwork != null) { firstNetwork.connections.add(new ConnectionPair(firstRelay, secondRelay, type, suppressConnectionRender)); firstNetwork.changeAmount++; } //Only second network exists - else{ + else { secondNetwork.connections.add(new ConnectionPair(firstRelay, secondRelay, type, suppressConnectionRender)); secondNetwork.changeAmount++; } @@ -183,19 +177,19 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH } @Override - public void removeConnection(World world, BlockPos firstRelay, BlockPos secondRelay){ - if(world != null && firstRelay != null && secondRelay != null){ + public void removeConnection(World world, BlockPos firstRelay, BlockPos secondRelay) { + if (world != null && firstRelay != null && secondRelay != null) { Network network = this.getNetworkFor(firstRelay, world); - if(network != null){ + if (network != null) { network.changeAmount++; WorldData data = WorldData.get(world); data.laserRelayNetworks.remove(network); data.markDirty(); - for(IConnectionPair pair : network.connections){ - if(!pair.contains(firstRelay) || !pair.contains(secondRelay)){ + for (IConnectionPair pair : network.connections) { + if (!pair.contains(firstRelay) || !pair.contains(secondRelay)) { this.addConnection(pair.getPositions()[0], pair.getPositions()[1], pair.getType(), world, pair.doesSuppressRender()); } } @@ -204,17 +198,16 @@ public final class LaserRelayConnectionHandler implements ILaserRelayConnectionH } @Override - public LaserType getTypeFromLaser(TileEntity tile){ - if(tile instanceof TileEntityLaserRelay){ - return ((TileEntityLaserRelay)tile).type; - } - else{ + public LaserType getTypeFromLaser(TileEntity tile) { + if (tile instanceof TileEntityLaserRelay) { + return ((TileEntityLaserRelay) tile).type; + } else { return null; } } @Override - public LaserType getTypeFromLaser(BlockPos pos, World world){ + public LaserType getTypeFromLaser(BlockPos pos, World world) { return this.getTypeFromLaser(world.getTileEntity(pos)); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/MethodHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/MethodHandler.java index 09343122d..c697a5e3e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/MethodHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/MethodHandler.java @@ -51,23 +51,22 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; import net.minecraftforge.common.util.FakePlayerFactory; -public class MethodHandler implements IMethodHandler{ +public class MethodHandler implements IMethodHandler { @Override - public boolean addEffectToStack(ItemStack stack, CoffeeIngredient ingredient){ + public boolean addEffectToStack(ItemStack stack, CoffeeIngredient ingredient) { boolean worked = false; - if(ingredient != null){ + if (ingredient != null) { PotionEffect[] effects = ingredient.getEffects(); - if(effects != null && effects.length > 0){ - for(PotionEffect effect : effects){ + if (effects != null && effects.length > 0) { + for (PotionEffect effect : effects) { PotionEffect effectHas = this.getSameEffectFromStack(stack, effect); - if(effectHas != null){ - if(effectHas.getAmplifier() < ingredient.getMaxAmplifier()-1){ + if (effectHas != null) { + if (effectHas.getAmplifier() < ingredient.getMaxAmplifier() - 1) { this.addEffectProperties(stack, effect, false, true); worked = true; } - } - else{ + } else { this.addEffectToStack(stack, effect); worked = true; } @@ -78,34 +77,32 @@ public class MethodHandler implements IMethodHandler{ } @Override - public PotionEffect getSameEffectFromStack(ItemStack stack, PotionEffect effect){ + public PotionEffect getSameEffectFromStack(ItemStack stack, PotionEffect effect) { PotionEffect[] effectsStack = this.getEffectsFromStack(stack); - if(effectsStack != null && effectsStack.length > 0){ - for(PotionEffect effectStack : effectsStack){ - if(effect.getPotion() == effectStack.getPotion()){ - return effectStack; - } + if (effectsStack != null && effectsStack.length > 0) { + for (PotionEffect effectStack : effectsStack) { + if (effect.getPotion() == effectStack.getPotion()) { return effectStack; } } } return null; } @Override - public void addEffectProperties(ItemStack stack, PotionEffect effect, boolean addDur, boolean addAmp){ + public void addEffectProperties(ItemStack stack, PotionEffect effect, boolean addDur, boolean addAmp) { PotionEffect[] effects = this.getEffectsFromStack(stack); stack.setTagCompound(new NBTTagCompound()); - for(int i = 0; i < effects.length; i++){ - if(effects[i].getPotion() == effect.getPotion()){ - effects[i] = new PotionEffect(effects[i].getPotion(), effects[i].getDuration()+(addDur ? effect.getDuration() : 0), effects[i].getAmplifier()+(addAmp ? effect.getAmplifier() > 0 ? effect.getAmplifier() : 1 : 0)); + for (int i = 0; i < effects.length; i++) { + if (effects[i].getPotion() == effect.getPotion()) { + effects[i] = new PotionEffect(effects[i].getPotion(), effects[i].getDuration() + (addDur ? effect.getDuration() : 0), effects[i].getAmplifier() + (addAmp ? effect.getAmplifier() > 0 ? effect.getAmplifier() : 1 : 0)); } this.addEffectToStack(stack, effects[i]); } } @Override - public void addEffectToStack(ItemStack stack, PotionEffect effect){ + public void addEffectToStack(ItemStack stack, PotionEffect effect) { NBTTagCompound tag = stack.getTagCompound(); - if(tag == null){ + if (tag == null) { tag = new NBTTagCompound(); } @@ -115,21 +112,21 @@ public class MethodHandler implements IMethodHandler{ compound.setInteger("Duration", effect.getDuration()); compound.setInteger("Amplifier", effect.getAmplifier()); - int counter = prevCounter+1; - tag.setTag(counter+"", compound); + int counter = prevCounter + 1; + tag.setTag(counter + "", compound); tag.setInteger("Counter", counter); stack.setTagCompound(tag); } @Override - public PotionEffect[] getEffectsFromStack(ItemStack stack){ + public PotionEffect[] getEffectsFromStack(ItemStack stack) { ArrayList effects = new ArrayList<>(); NBTTagCompound tag = stack.getTagCompound(); - if(tag != null){ + if (tag != null) { int counter = tag.getInteger("Counter"); - while(counter > 0){ - NBTTagCompound compound = (NBTTagCompound)tag.getTag(counter+""); + while (counter > 0) { + NBTTagCompound compound = (NBTTagCompound) tag.getTag(counter + ""); PotionEffect effect = new PotionEffect(Potion.getPotionById(compound.getInteger("ID")), compound.getInteger("Duration"), compound.getByte("Amplifier")); effects.add(effect); counter--; @@ -139,50 +136,47 @@ public class MethodHandler implements IMethodHandler{ } @Override - public boolean invokeConversionLens(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile){ - if(hitBlock != null){ + public boolean invokeConversionLens(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) { + if (hitBlock != null) { int range = 1; int rangeX = 0; int rangeY = 0; int rangeZ = 0; EnumFacing facing = tile.getOrientation(); - if(facing != EnumFacing.UP && facing != EnumFacing.DOWN){ + if (facing != EnumFacing.UP && facing != EnumFacing.DOWN) { rangeY = range; - if(facing == EnumFacing.NORTH || facing == EnumFacing.SOUTH){ + if (facing == EnumFacing.NORTH || facing == EnumFacing.SOUTH) { rangeX = range; - } - else{ + } else { rangeZ = range; } - } - else{ + } else { rangeX = range; rangeZ = range; } //Converting the Blocks - for(int reachX = -rangeX; reachX <= rangeX; reachX++){ - for(int reachZ = -rangeZ; reachZ <= rangeZ; reachZ++){ - for(int reachY = -rangeY; reachY <= rangeY; reachY++){ - BlockPos pos = new BlockPos(hitBlock.getX()+reachX, hitBlock.getY()+reachY, hitBlock.getZ()+reachZ); - if(!tile.getWorldObject().isAirBlock(pos)){ + for (int reachX = -rangeX; reachX <= rangeX; reachX++) { + for (int reachZ = -rangeZ; reachZ <= rangeZ; reachZ++) { + for (int reachY = -rangeY; reachY <= rangeY; reachY++) { + BlockPos pos = new BlockPos(hitBlock.getX() + reachX, hitBlock.getY() + reachY, hitBlock.getZ() + reachZ); + if (!tile.getWorldObject().isAirBlock(pos)) { IBlockState state = tile.getWorldObject().getBlockState(pos); - if(state.getBlock() instanceof BlockLaserRelay) continue; + if (state.getBlock() instanceof BlockLaserRelay) continue; LensConversionRecipe recipe = LensRecipeHandler.findMatchingRecipe(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)), tile.getLens()); - if(recipe != null && tile.getEnergy() >= recipe.getEnergyUsed()){ + if (recipe != null && tile.getEnergy() >= recipe.getEnergyUsed()) { ItemStack output = recipe.getOutput(); - if(StackUtil.isValid(output)){ + if (StackUtil.isValid(output)) { tile.getWorldObject().playEvent(2001, pos, Block.getStateId(state)); recipe.transformHook(ItemStack.EMPTY, state, pos, tile); - if(output.getItem() instanceof ItemBlock){ + if (output.getItem() instanceof ItemBlock) { Block toPlace = Block.getBlockFromItem(output.getItem()); IBlockState state2Place = toPlace.getStateForPlacement(tile.getWorldObject(), pos, facing, 0, 0, 0, output.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) tile.getWorldObject()), EnumHand.MAIN_HAND); tile.getWorldObject().setBlockState(pos, state2Place, 2); - } - else{ - EntityItem item = new EntityItem(tile.getWorldObject(), pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, output.copy()); + } else { + EntityItem item = new EntityItem(tile.getWorldObject(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output.copy()); tile.getWorldObject().spawnEntity(item); tile.getWorldObject().setBlockToAir(pos); } @@ -197,19 +191,19 @@ public class MethodHandler implements IMethodHandler{ } //Converting the Items - List items = tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX()-rangeX, hitBlock.getY()-rangeY, hitBlock.getZ()-rangeZ, hitBlock.getX()+1+rangeX, hitBlock.getY()+1+rangeY, hitBlock.getZ()+1+rangeZ)); - for(EntityItem item : items){ + List items = tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX() - rangeX, hitBlock.getY() - rangeY, hitBlock.getZ() - rangeZ, hitBlock.getX() + 1 + rangeX, hitBlock.getY() + 1 + rangeY, hitBlock.getZ() + 1 + rangeZ)); + for (EntityItem item : items) { ItemStack stack = item.getItem(); - if(!item.isDead && StackUtil.isValid(stack)){ + if (!item.isDead && StackUtil.isValid(stack)) { LensConversionRecipe recipe = LensRecipeHandler.findMatchingRecipe(stack, tile.getLens()); - if(recipe != null){ - int itemsPossible = Math.min(tile.getEnergy()/recipe.getEnergyUsed(), stack.getCount()); + if (recipe != null) { + int itemsPossible = Math.min(tile.getEnergy() / recipe.getEnergyUsed(), stack.getCount()); - if(itemsPossible > 0){ + if (itemsPossible > 0) { recipe.transformHook(item.getItem(), null, item.getPosition(), tile); item.setDead(); - if(stack.getCount()-itemsPossible > 0){ + if (stack.getCount() - itemsPossible > 0) { ItemStack stackCopy = stack.copy(); stackCopy.shrink(itemsPossible); @@ -223,7 +217,7 @@ public class MethodHandler implements IMethodHandler{ EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, outputCopy); tile.getWorldObject().spawnEntity(newItem); - tile.extractEnergy(recipe.getEnergyUsed()*itemsPossible); + tile.extractEnergy(recipe.getEnergyUsed() * itemsPossible); break; } } @@ -235,18 +229,18 @@ public class MethodHandler implements IMethodHandler{ } @Override - public boolean invokeReconstructor(IAtomicReconstructor tile){ - if(tile.getEnergy() >= TileEntityAtomicReconstructor.ENERGY_USE){ + public boolean invokeReconstructor(IAtomicReconstructor tile) { + if (tile.getEnergy() >= TileEntityAtomicReconstructor.ENERGY_USE) { EnumFacing sideToManipulate = tile.getOrientation(); Lens currentLens = tile.getLens(); - if(currentLens.canInvoke(tile, sideToManipulate, TileEntityAtomicReconstructor.ENERGY_USE)){ + if (currentLens.canInvoke(tile, sideToManipulate, TileEntityAtomicReconstructor.ENERGY_USE)) { tile.extractEnergy(TileEntityAtomicReconstructor.ENERGY_USE); int distance = currentLens.getDistance(); - for(int i = 0; i < distance; i++){ - BlockPos hitBlock = tile.getPosition().offset(sideToManipulate, i+1); + for (int i = 0; i < distance; i++) { + BlockPos hitBlock = tile.getPosition().offset(sideToManipulate, i + 1); - if(currentLens.invoke(tile.getWorldObject().getBlockState(hitBlock), hitBlock, tile) || i >= distance-1){ + if (currentLens.invoke(tile.getWorldObject().getBlockState(hitBlock), hitBlock, tile) || i >= distance - 1) { TileEntityAtomicReconstructor.shootLaser(tile.getWorldObject(), tile.getX(), tile.getY(), tile.getZ(), hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens); break; } @@ -259,22 +253,21 @@ public class MethodHandler implements IMethodHandler{ } @Override - public boolean addCrusherRecipes(List inputs, List outputOnes, int outputOneAmounts, List outputTwos, int outputTwoAmounts, int outputTwoChance){ + public boolean addCrusherRecipes(List inputs, List outputOnes, int outputOneAmounts, List outputTwos, int outputTwoAmounts, int outputTwoChance) { boolean hasWorkedOnce = false; - for(ItemStack input : inputs){ - if(StackUtil.isValid(input) && CrusherRecipeRegistry.getRecipeFromInput(input) == null){ - for(ItemStack outputOne : outputOnes){ - if(StackUtil.isValid(outputOne) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputOne, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())){ + for (ItemStack input : inputs) { + if (StackUtil.isValid(input) && CrusherRecipeRegistry.getRecipeFromInput(input) == null) { + for (ItemStack outputOne : outputOnes) { + if (StackUtil.isValid(outputOne) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputOne, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())) { ItemStack outputOneCopy = outputOne.copy(); outputOneCopy.setCount(outputOneAmounts); - if(outputTwos.isEmpty()){ + if (outputTwos.isEmpty()) { ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, StackUtil.getEmpty(), 0); hasWorkedOnce = true; - } - else{ - for(ItemStack outputTwo : outputTwos){ - if(StackUtil.isValid(outputTwo) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputTwo, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())){ + } else { + for (ItemStack outputTwo : outputTwos) { + if (StackUtil.isValid(outputTwo) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputTwo, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())) { ItemStack outputTwoCopy = outputTwo.copy(); outputTwoCopy.setCount(outputTwoAmounts); @@ -291,19 +284,18 @@ public class MethodHandler implements IMethodHandler{ } @Override - public boolean addCrusherRecipes(List inputs, ItemStack outputOne, int outputOneAmount, ItemStack outputTwo, int outputTwoAmount, int outputTwoChance){ + public boolean addCrusherRecipes(List inputs, ItemStack outputOne, int outputOneAmount, ItemStack outputTwo, int outputTwoAmount, int outputTwoChance) { boolean hasWorkedOnce = false; - for(ItemStack input : inputs){ - if(StackUtil.isValid(input) && CrusherRecipeRegistry.getRecipeFromInput(input) == null){ - if(StackUtil.isValid(outputOne) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputOne, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())){ + for (ItemStack input : inputs) { + if (StackUtil.isValid(input) && CrusherRecipeRegistry.getRecipeFromInput(input) == null) { + if (StackUtil.isValid(outputOne) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputOne, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())) { ItemStack outputOneCopy = outputOne.copy(); outputOneCopy.setCount(outputOneAmount); - if(!StackUtil.isValid(outputTwo)){ + if (!StackUtil.isValid(outputTwo)) { ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, StackUtil.getEmpty(), 0); hasWorkedOnce = true; - } - else if(StackUtil.isValid(outputTwo) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputTwo, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())){ + } else if (StackUtil.isValid(outputTwo) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputTwo, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())) { ItemStack outputTwoCopy = outputTwo.copy(); outputTwoCopy.setCount(outputTwoAmount); @@ -317,57 +309,57 @@ public class MethodHandler implements IMethodHandler{ } @Override - public IBookletPage generateTextPage(int id){ + public IBookletPage generateTextPage(int id) { return this.generateTextPage(id, 0); } @Override - public IBookletPage generatePicturePage(int id, ResourceLocation resLoc, int textStartY){ + public IBookletPage generatePicturePage(int id, ResourceLocation resLoc, int textStartY) { return this.generatePicturePage(id, resLoc, textStartY, 0); } @Override - public IBookletPage generateCraftingPage(int id, IRecipe... recipes){ + public IBookletPage generateCraftingPage(int id, IRecipe... recipes) { return this.generateCraftingPage(id, 0, recipes); } @Override - public IBookletPage generateFurnacePage(int id, ItemStack input, ItemStack result){ + public IBookletPage generateFurnacePage(int id, ItemStack input, ItemStack result) { return this.generateFurnacePage(id, input, result, 0); } @Override - public IBookletChapter generateBookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages){ + public IBookletChapter generateBookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages) { return this.generateBookletChapter(identifier, entry, displayStack, 0, pages); } @Override - public IBookletPage generateTextPage(int id, int priority){ + public IBookletPage generateTextPage(int id, int priority) { return new PageTextOnly(id, priority); } @Override - public IBookletPage generatePicturePage(int id, ResourceLocation resLoc, int textStartY, int priority){ + public IBookletPage generatePicturePage(int id, ResourceLocation resLoc, int textStartY, int priority) { return new PagePicture(id, resLoc, textStartY, priority); } @Override - public IBookletPage generateCraftingPage(int id, int priority, IRecipe... recipes){ + public IBookletPage generateCraftingPage(int id, int priority, IRecipe... recipes) { return new PageCrafting(id, priority, recipes); } @Override - public IBookletPage generateFurnacePage(int id, ItemStack input, ItemStack result, int priority){ + public IBookletPage generateFurnacePage(int id, ItemStack input, ItemStack result, int priority) { return new PageFurnace(id, result, priority); } @Override - public IBookletChapter generateBookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, int priority, IBookletPage... pages){ + public IBookletChapter generateBookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, int priority, IBookletPage... pages) { return new BookletChapter(identifier, entry, displayStack, priority, pages); } @Override - public IBookletChapter createTrial(String identifier, ItemStack displayStack, boolean textOnSecondPage){ + public IBookletChapter createTrial(String identifier, ItemStack displayStack, boolean textOnSecondPage) { return new BookletChapterTrials(identifier, displayStack, textOnSecondPage); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/CactusFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/CactusFarmerBehavior.java index bda96953d..17c5b92be 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/CactusFarmerBehavior.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/CactusFarmerBehavior.java @@ -23,17 +23,17 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class CactusFarmerBehavior implements IFarmerBehavior{ +public class CactusFarmerBehavior implements IFarmerBehavior { @Override - public FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer){ + public FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer) { int use = 250; - if(farmer.getEnergy() >= use){ + if (farmer.getEnergy() >= use) { Item item = seed.getItem(); - if(item instanceof ItemBlock){ + if (item instanceof ItemBlock) { Block block = Block.getBlockFromItem(item); - if(block instanceof BlockCactus){ - if(block.canPlaceBlockAt(world, pos)){ + if (block instanceof BlockCactus) { + if (block.canPlaceBlockAt(world, pos)) { IBlockState state = block.getDefaultState(); world.setBlockState(pos, state, 2); world.playEvent(2001, pos, Block.getStateId(state)); @@ -49,23 +49,23 @@ public class CactusFarmerBehavior implements IFarmerBehavior{ } @Override - public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer){ + public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer) { int use = 250; - if(farmer.getEnergy() >= use){ + if (farmer.getEnergy() >= use) { IBlockState state = world.getBlockState(pos); - if(state.getBlock() instanceof BlockCactus){ + if (state.getBlock() instanceof BlockCactus) { FarmerResult result = FarmerResult.STOP_PROCESSING; - for(int i = 2; i >= 1; i--){ - if(farmer.getEnergy() >= use){ + for (int i = 2; i >= 1; i--) { + if (farmer.getEnergy() >= use) { BlockPos up = pos.up(i); IBlockState upState = world.getBlockState(up); - if(upState.getBlock() instanceof BlockCactus){ + if (upState.getBlock() instanceof BlockCactus) { NonNullList drops = NonNullList.create(); upState.getBlock().getDrops(drops, world, up, upState, 0); - if(!drops.isEmpty()){ - if(farmer.canAddToOutput(drops)){ + if (!drops.isEmpty()) { + if (farmer.canAddToOutput(drops)) { world.playEvent(2001, up, Block.getStateId(upState)); world.setBlockToAir(up); @@ -85,7 +85,7 @@ public class CactusFarmerBehavior implements IFarmerBehavior{ } @Override - public int getPriority(){ + public int getPriority() { return 4; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/NetherWartFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/NetherWartFarmerBehavior.java index 9afc494c2..23fe4e854 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/NetherWartFarmerBehavior.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/NetherWartFarmerBehavior.java @@ -25,14 +25,14 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.IPlantable; -public class NetherWartFarmerBehavior implements IFarmerBehavior{ +public class NetherWartFarmerBehavior implements IFarmerBehavior { @Override - public FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer){ + public FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer) { int use = 500; - if(farmer.getEnergy() >= use){ - if(seed.getItem() == Items.NETHER_WART){ - if(world.getBlockState(pos.down()).getBlock().canSustainPlant(world.getBlockState(pos.down()), world, pos.down(), EnumFacing.UP, (IPlantable) Items.NETHER_WART)){ + if (farmer.getEnergy() >= use) { + if (seed.getItem() == Items.NETHER_WART) { + if (world.getBlockState(pos.down()).getBlock().canSustainPlant(world.getBlockState(pos.down()), world, pos.down(), EnumFacing.UP, (IPlantable) Items.NETHER_WART)) { world.setBlockState(pos, Blocks.NETHER_WART.getDefaultState(), 2); farmer.extractEnergy(use); return FarmerResult.SUCCESS; @@ -44,24 +44,23 @@ public class NetherWartFarmerBehavior implements IFarmerBehavior{ } @Override - public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer){ + public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer) { int use = 500; - if(farmer.getEnergy() >= use){ + if (farmer.getEnergy() >= use) { IBlockState state = world.getBlockState(pos); - if(state.getBlock() instanceof BlockNetherWart){ - if(state.getValue(BlockNetherWart.AGE) >= 3){ + if (state.getBlock() instanceof BlockNetherWart) { + if (state.getValue(BlockNetherWart.AGE) >= 3) { NonNullList drops = NonNullList.create(); state.getBlock().getDrops(drops, world, pos, state, 0); - if(!drops.isEmpty()){ + if (!drops.isEmpty()) { boolean toInput = farmer.canAddToSeeds(drops); - if(toInput || farmer.canAddToOutput(drops)){ + if (toInput || farmer.canAddToOutput(drops)) { world.playEvent(2001, pos, Block.getStateId(state)); world.setBlockToAir(pos); - if(toInput){ + if (toInput) { farmer.addToSeeds(drops); - } - else{ + } else { farmer.addToOutput(drops); } @@ -77,7 +76,7 @@ public class NetherWartFarmerBehavior implements IFarmerBehavior{ } @Override - public int getPriority(){ + public int getPriority() { return 3; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/EnderlillyFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/EnderlillyFarmerBehavior.java index 14540eeca..b8e1db5a6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/EnderlillyFarmerBehavior.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/EnderlillyFarmerBehavior.java @@ -15,20 +15,20 @@ import net.minecraft.block.BlockDirt; import net.minecraft.block.BlockGrass; import net.minecraft.init.Blocks; -public class EnderlillyFarmerBehavior extends ExUPlantFarmerBehavior{ +public class EnderlillyFarmerBehavior extends ExUPlantFarmerBehavior { @Override - protected String getPlantName(){ + protected String getPlantName() { return "extrautils2:enderlilly"; } @Override - protected boolean canPlaceOn(Block block){ + protected boolean canPlaceOn(Block block) { return block == Blocks.END_STONE || block instanceof BlockDirt || block instanceof BlockGrass; } @Override - protected int getMaxStage(){ + protected int getMaxStage() { return 7; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/ExUPlantFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/ExUPlantFarmerBehavior.java index a2e30635f..a956657b8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/ExUPlantFarmerBehavior.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/ExUPlantFarmerBehavior.java @@ -24,28 +24,28 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public abstract class ExUPlantFarmerBehavior implements IFarmerBehavior{ +public abstract class ExUPlantFarmerBehavior implements IFarmerBehavior { @Override - public FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer){ + public FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer) { int use = 600; - if(farmer.getEnergy() >= use){ - if(StackUtil.isValid(seed)){ + if (farmer.getEnergy() >= use) { + if (StackUtil.isValid(seed)) { Item item = seed.getItem(); ResourceLocation reg = item.getRegistryName(); - if(reg != null && this.getPlantName().equals(reg.toString())){ - if(item instanceof ItemBlock){ - Block block = ((ItemBlock)item).getBlock(); - if(block != null){ + if (reg != null && this.getPlantName().equals(reg.toString())) { + if (item instanceof ItemBlock) { + Block block = ((ItemBlock) item).getBlock(); + if (block != null) { IBlockState stateThere = world.getBlockState(pos); Block blockThere = stateThere.getBlock(); - if(world.isAirBlock(pos) || blockThere.isReplaceable(world, pos)){ + if (world.isAirBlock(pos) || blockThere.isReplaceable(world, pos)) { BlockPos posBelow = pos.down(); IBlockState stateBelow = world.getBlockState(posBelow); - if(this.canPlaceOn(stateBelow.getBlock())){ + if (this.canPlaceOn(stateBelow.getBlock())) { world.setBlockState(pos, block.getDefaultState(), 2); farmer.extractEnergy(use); @@ -63,34 +63,33 @@ public abstract class ExUPlantFarmerBehavior implements IFarmerBehavior{ } @Override - public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer){ + public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer) { int use = 600; - if(farmer.getEnergy() >= use){ + if (farmer.getEnergy() >= use) { IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); ResourceLocation reg = block.getRegistryName(); - if(reg != null && this.getPlantName().equals(reg.toString())){ - if(block.getMetaFromState(state) >= this.getMaxStage()){ + if (reg != null && this.getPlantName().equals(reg.toString())) { + if (block.getMetaFromState(state) >= this.getMaxStage()) { NonNullList drops = NonNullList.create(); block.getDrops(drops, world, pos, state, 0); - if(StackUtil.isEmpty(drops)) return FarmerResult.FAIL; - for(ItemStack stack : drops){ - if(StackUtil.isValid(stack)){ + if (StackUtil.isEmpty(drops)) return FarmerResult.FAIL; + for (ItemStack stack : drops) { + if (StackUtil.isValid(stack)) { ResourceLocation itemReg = stack.getItem().getRegistryName(); - if(itemReg != null && this.getPlantName().equals(itemReg.toString())){ - if(stack.getCount() <= 1){ + if (itemReg != null && this.getPlantName().equals(itemReg.toString())) { + if (stack.getCount() <= 1) { drops.remove(stack); break; - } - else{ + } else { stack.shrink(1); } } } } - if(farmer.canAddToOutput(drops)){ + if (farmer.canAddToOutput(drops)) { farmer.addToOutput(drops); world.playEvent(2001, pos, Block.getStateId(state)); @@ -109,7 +108,7 @@ public abstract class ExUPlantFarmerBehavior implements IFarmerBehavior{ } @Override - public int getPriority(){ + public int getPriority() { return 10; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/RedOrchidFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/RedOrchidFarmerBehavior.java index 3bbd29115..45556c491 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/RedOrchidFarmerBehavior.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/RedOrchidFarmerBehavior.java @@ -13,20 +13,20 @@ package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.exu; import net.minecraft.block.Block; import net.minecraft.block.BlockRedstoneOre; -public class RedOrchidFarmerBehavior extends ExUPlantFarmerBehavior{ +public class RedOrchidFarmerBehavior extends ExUPlantFarmerBehavior { @Override - protected String getPlantName(){ + protected String getPlantName() { return "extrautils2:redorchid"; } @Override - protected boolean canPlaceOn(Block block){ + protected boolean canPlaceOn(Block block) { return block instanceof BlockRedstoneOre; } @Override - protected int getMaxStage(){ + protected int getMaxStage() { return 6; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/cloud/ISmileyCloudEasterEgg.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/cloud/ISmileyCloudEasterEgg.java index 7bc29c15e..e8d8e1f0f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/cloud/ISmileyCloudEasterEgg.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/cloud/ISmileyCloudEasterEgg.java @@ -10,7 +10,7 @@ package de.ellpeck.actuallyadditions.mod.misc.cloud; -public interface ISmileyCloudEasterEgg{ +public interface ISmileyCloudEasterEgg { /** * Extra rendering function diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/cloud/SmileyCloudEasterEggs.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/cloud/SmileyCloudEasterEggs.java index 3e376a68c..fb425f85c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/cloud/SmileyCloudEasterEggs.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/cloud/SmileyCloudEasterEggs.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.misc.cloud; +import java.util.ArrayList; +import java.util.List; + import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods; @@ -21,469 +24,466 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -import java.util.ArrayList; -import java.util.List; - -public final class SmileyCloudEasterEggs{ +public final class SmileyCloudEasterEggs { public static final List CLOUD_STUFF = new ArrayList<>(); - static{ + static { //Glenthor - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"glenthor", "glenthorlp", "twoofeight"}; + public String[] getTriggerNames() { + return new String[] { "glenthor", "glenthorlp", "twoofeight" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(true, new ItemStack(Items.DYE, 1, 2)); renderHeadBlock(InitBlocks.blockHeatCollector, 0, 5F); } }); //Ellpeck - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"ellpeck", "ellopecko", "peck"}; + public String[] getTriggerNames() { + return new String[] { "ellpeck", "ellopecko", "peck" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(InitItems.itemPhantomConnector)); renderHeadBlock(InitBlocks.blockPhantomLiquiface, 0, 25F); } }); //Tyrex - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"tyrex", "lord_tobinho", "tobinho"}; + public String[] getTriggerNames() { + return new String[] { "tyrex", "lord_tobinho", "tobinho" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(Items.FISHING_ROD)); renderHoldingItem(true, new ItemStack(Items.FISH)); } }); //Hose - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"dqmhose", "xdqmhose", "hose"}; + public String[] getTriggerNames() { + return new String[] { "dqmhose", "xdqmhose", "hose" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(Items.REEDS)); renderHeadBlock(Blocks.TORCH, 0, 15F); } }); //Tobi - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"jemx", "jemxx", "jemxxx", "spielertobi200"}; + public String[] getTriggerNames() { + return new String[] { "jemx", "jemxx", "jemxxx", "spielertobi200" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(true, new ItemStack(Items.MILK_BUCKET)); renderHeadBlock(Blocks.REDSTONE_LAMP, 0, 35F); } }); //Vazkii - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"vazkii", "vaski", "waskie"}; + public String[] getTriggerNames() { + return new String[] { "vazkii", "vaski", "waskie" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(true, new ItemStack(Items.DYE, 1, 15)); renderHeadBlock(Blocks.RED_FLOWER, 5, 20F); } }); //Kitty - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"kitty", "kiddy", "kittyvancat", "kittyvancatlp"}; + public String[] getTriggerNames() { + return new String[] { "kitty", "kiddy", "kittyvancat", "kittyvancatlp" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(true, new ItemStack(Items.FISH)); renderHoldingItem(false, new ItemStack(Items.MILK_BUCKET)); renderHeadBlock(Blocks.WOOL, 10, 15F); } }); //Canitzp - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"canitz", "canitzp", "kannnichts", "kannnichtsp"}; + public String[] getTriggerNames() { + return new String[] { "canitz", "canitzp", "kannnichts", "kannnichtsp" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(Items.WOODEN_SWORD)); renderHeadBlock(Blocks.CHEST, 0, 70F); } }); //Lari - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"lari", "larixine", "xine", "laxi", "lachsirine", "lala", "lalilu"}; + public String[] getTriggerNames() { + return new String[] { "lari", "larixine", "xine", "laxi", "lachsirine", "lala", "lalilu" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(Items.IRON_HELMET)); renderHeadBlock(InitBlocks.blockBlackLotus, 0, 28F); } }); //RotesDing - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"rotesding", "dotesring"}; + public String[] getTriggerNames() { + return new String[] { "rotesding", "dotesring" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(Items.MILK_BUCKET)); renderHoldingItem(true, new ItemStack(Items.DYE, 1, 1)); renderHeadBlock(Blocks.WOOL, 14, 18F); } }); //Bande - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"bande", "bandelenth"}; + public String[] getTriggerNames() { + return new String[] { "bande", "bandelenth" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(Items.DIAMOND_PICKAXE)); renderHeadBlock(Blocks.WOOL, 4, 18F); } }); //Wolle - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"wolle", "wuitoi"}; + public String[] getTriggerNames() { + return new String[] { "wolle", "wuitoi" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(Items.STRING)); renderHeadBlock(Blocks.WOOL, 0, 18F); } }); //Pakto - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"pakto", "paktosan", "paktosanlp"}; + public String[] getTriggerNames() { + return new String[] { "pakto", "paktosan", "paktosanlp" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(Items.DYE, 1, 9)); renderHeadBlock(InitBlocks.blockColoredLampOn, 6, 18F); } }); //Honka - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"honka", "honkalonka", "lonka", "lonki"}; + public String[] getTriggerNames() { + return new String[] { "honka", "honkalonka", "lonka", "lonki" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(InitItems.itemLeafBlowerAdvanced, 1, 9)); renderHeadBlock(Blocks.HAY_BLOCK, 0, 74F); } }); //Acid - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"acid", "acid_blues", "acidblues"}; + public String[] getTriggerNames() { + return new String[] { "acid", "acid_blues", "acidblues" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(InitItems.itemFoods, 1, TheFoods.PIZZA.ordinal())); renderHeadBlock(Blocks.BOOKSHELF, 0, 27F); } }); //Jasin - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"jasin", "jasindow"}; + public String[] getTriggerNames() { + return new String[] { "jasin", "jasindow" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(Items.WRITTEN_BOOK)); renderHeadBlock(Blocks.WEB, 0, 56F); } }); //ShadowNinjaCat - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"shadowninjacat", "ninja", "tl"}; + public String[] getTriggerNames() { + return new String[] { "shadowninjacat", "ninja", "tl" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(Items.DIAMOND_SWORD)); renderHeadBlock(Blocks.DIAMOND_BLOCK, 0, 26F); } }); //NihonTiger - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"nihon", "nihontiger", "tiger"}; + public String[] getTriggerNames() { + return new String[] { "nihon", "nihontiger", "tiger" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(Items.STONE_PICKAXE)); renderHoldingItem(true, new ItemStack(Items.POISONOUS_POTATO)); renderHeadBlock(Blocks.GRAVEL, 0, 47F); } }); //FrauBaerchen - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"fraubaerchen", "baerchen", "nina"}; + public String[] getTriggerNames() { + return new String[] { "fraubaerchen", "baerchen", "nina" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(Items.COOKIE)); renderHoldingItem(true, new ItemStack(Items.PAPER)); renderHeadBlock(Blocks.COAL_BLOCK, 0, 60F); } }); //Diddi - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"0xdd", "didi", "diddi", "theultimatehose"}; + public String[] getTriggerNames() { + return new String[] { "0xdd", "didi", "diddi", "theultimatehose" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(true, new ItemStack(InitItems.itemDrill)); renderHeadBlock(Blocks.REDSTONE_BLOCK, 0, 30F); } }); //MineLoad - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"mineload", "miney", "loady", "mineyloady"}; + public String[] getTriggerNames() { + return new String[] { "mineload", "miney", "loady", "mineyloady" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(InitItems.itemMagnetRing)); renderHeadBlock(Blocks.CRAFTING_TABLE, 0, 35F); } }); //Kilobyte (When I asked him if he liked the mod, he just looked at the code. Maybe he'll find this eventually.) - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"kilobyte", "kilo", "byte"}; + public String[] getTriggerNames() { + return new String[] { "kilobyte", "kilo", "byte" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.DRILL_CORE.ordinal())); renderHeadBlock(Blocks.REDSTONE_ORE, 0, 80F); } }); //XDjackieXD - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"jackie", "xdjackiexd", "xdjackie", "jackiexd"}; + public String[] getTriggerNames() { + return new String[] { "jackie", "xdjackiexd", "xdjackie", "jackiexd" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(Items.ENCHANTED_BOOK)); renderHeadBlock(InitBlocks.blockDirectionalBreaker, 0, 40F); } }); //Little Lampi (I still can't get over it) - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"lampi", "littlelampi", "little lampi"}; + public String[] getTriggerNames() { + return new String[] { "lampi", "littlelampi", "little lampi" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(Items.GLOWSTONE_DUST)); renderHeadBlock(InitBlocks.blockColoredLampOn, 4, 40F); } }); //AtomSponge - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"sponge", "atomsponge", "atom", "explosions", "explosion"}; + public String[] getTriggerNames() { + return new String[] { "sponge", "atomsponge", "atom", "explosions", "explosion" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(Items.GUNPOWDER)); renderHeadBlock(Blocks.SPONGE, 0, 20F); } }); //Mattzimann - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"mattzimann", "mattziman", "matziman", "marzipan", "mattzi"}; + public String[] getTriggerNames() { + return new String[] { "mattzimann", "mattziman", "matziman", "marzipan", "mattzi" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(InitItems.itemSwordEmerald)); renderHeadBlock(InitBlocks.blockCoffeeMachine, 0, 35F); } }); //Etho - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"etho", "ethoslab"}; + public String[] getTriggerNames() { + return new String[] { "etho", "ethoslab" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(Items.REDSTONE)); renderHeadBlock(Blocks.REDSTONE_BLOCK, 0, 48F); } }); //Direwolf20 - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"direwolf", "dire", "direwolf20", "dw20"}; + public String[] getTriggerNames() { + return new String[] { "direwolf", "dire", "direwolf20", "dw20" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(Items.BONE)); renderHeadBlock(Blocks.BONE_BLOCK, 0, 48F); } }); //Jessassin - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"jessassin", "thejessassin"}; + public String[] getTriggerNames() { + return new String[] { "jessassin", "thejessassin" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHeadBlock(InitBlocks.blockLaserRelayItem, 0, 27F); renderHoldingItem(false, new ItemStack(InitItems.itemLaserWrench)); } }); //Biffa - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"biffa", "biffatech", "biffaplays", "biffa2001"}; + public String[] getTriggerNames() { + return new String[] { "biffa", "biffatech", "biffaplays", "biffa2001" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(InitItems.itemCoffee)); } }); //Xisuma - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"xisuma", "xisumavoid"}; + public String[] getTriggerNames() { + return new String[] { "xisuma", "xisumavoid" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHeadBlock(Blocks.REDSTONE_BLOCK, 0, 93F); renderHoldingItem(false, new ItemStack(Items.ELYTRA)); } }); //Welsknight - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"welsknight", "wels"}; + public String[] getTriggerNames() { + return new String[] { "welsknight", "wels" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHeadBlock(Blocks.STONE_BRICK_STAIRS, 0, 10F); renderHoldingItem(false, new ItemStack(Items.DIAMOND_PICKAXE)); } }); //xbony2 - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"bony", "xbony", "xbony2"}; + public String[] getTriggerNames() { + return new String[] { "bony", "xbony", "xbony2" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHoldingItem(false, new ItemStack(InitItems.itemBooklet)); renderHeadBlock(InitBlocks.blockSmileyCloud, 0, 13F); } }); //MattaBase - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"themattabase", "mattabase", "matt", "mad"}; + public String[] getTriggerNames() { + return new String[] { "themattabase", "mattabase", "matt", "mad" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHeadBlock(Blocks.WOOL, 13, 35F); renderHoldingItem(false, new ItemStack(InitItems.itemSwordQuartz)); renderHoldingItem(true, new ItemStack(Items.SHIELD)); } }); //Cloudy - register(new ISmileyCloudEasterEgg(){ + register(new ISmileyCloudEasterEgg() { @Override - public String[] getTriggerNames(){ - return new String[]{"cloudy", "cloudhunter"}; + public String[] getTriggerNames() { + return new String[] { "cloudy", "cloudhunter" }; } @Override - public void renderExtra(float f){ + public void renderExtra(float f) { renderHeadBlock(Blocks.REDSTONE_BLOCK, 0, 17F); //other hand is for fapping renderHoldingItem(true, new ItemStack(Items.BOW)); @@ -491,11 +491,11 @@ public final class SmileyCloudEasterEggs{ }); } - private static void register(ISmileyCloudEasterEgg egg){ + private static void register(ISmileyCloudEasterEgg egg) { CLOUD_STUFF.add(egg); } - private static void renderHoldingItem(boolean leftHand, ItemStack stack){ + private static void renderHoldingItem(boolean leftHand, ItemStack stack) { GlStateManager.pushMatrix(); GlStateManager.rotate(180F, 0F, 0F, 1F); GlStateManager.rotate(90, 0, 1, 0); @@ -507,7 +507,7 @@ public final class SmileyCloudEasterEggs{ GlStateManager.popMatrix(); } - private static void renderHeadBlock(Block block, int meta, float rotation){ + private static void renderHeadBlock(Block block, int meta, float rotation) { GlStateManager.pushMatrix(); GlStateManager.disableLighting(); GlStateManager.translate(-0.015F, 0.625F, 0.04F); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/RenderSpecial.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/RenderSpecial.java index 5828dc19c..1d6907db8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/RenderSpecial.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/RenderSpecial.java @@ -20,37 +20,35 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.math.Vec3d; -public class RenderSpecial{ +public class RenderSpecial { private final ItemStack theThingToRender; - public RenderSpecial(ItemStack stack){ + public RenderSpecial(ItemStack stack) { this.theThingToRender = stack; } - public void render(EntityPlayer player, float partialTicks){ - if(player.isInvisible() || !player.isWearing(EnumPlayerModelParts.CAPE) || player.isElytraFlying()){ - return; - } + public void render(EntityPlayer player, float partialTicks) { + if (player.isInvisible() || !player.isWearing(EnumPlayerModelParts.CAPE) || player.isElytraFlying()) { return; } GlStateManager.pushMatrix(); Vec3d currentPos = Minecraft.getMinecraft().player.getPositionEyes(partialTicks); Vec3d playerPos = player.getPositionEyes(partialTicks); - GlStateManager.translate(playerPos.x-currentPos.x, playerPos.y-currentPos.y, playerPos.z-currentPos.z); - GlStateManager.translate(0D, 2.575D-(player.isSneaking() ? 0.125D : 0D), 0D); + GlStateManager.translate(playerPos.x - currentPos.x, playerPos.y - currentPos.y, playerPos.z - currentPos.z); + GlStateManager.translate(0D, 2.575D - (player.isSneaking() ? 0.125D : 0D), 0D); this.render(); GlStateManager.popMatrix(); } - public void render(){ - if(StackUtil.isValid(this.theThingToRender)){ + public void render() { + if (StackUtil.isValid(this.theThingToRender)) { boolean isBlock = this.theThingToRender.getItem() instanceof ItemBlock; GlStateManager.pushMatrix(); - if(isBlock){ + if (isBlock) { GlStateManager.translate(0D, -0.1875D, 0D); } GlStateManager.rotate(180F, 1.0F, 0.0F, 1.0F); @@ -60,14 +58,14 @@ public class RenderSpecial{ //Make the floaty stuff look nice using sine waves \o/ -xdjackiexd //Peck edit: What do you mean by "nice" you jackass? >_> - double boop = Minecraft.getSystemTime()/1000D; - GlStateManager.translate(0D, Math.sin(boop%(2*Math.PI))*0.25, 0D); - GlStateManager.rotate((float)(boop*40D%360), 0, 1, 0); + double boop = Minecraft.getSystemTime() / 1000D; + GlStateManager.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.25, 0D); + GlStateManager.rotate((float) (boop * 40D % 360), 0, 1, 0); GlStateManager.disableLighting(); GlStateManager.pushMatrix(); - if(!isBlock){ + if (!isBlock) { GlStateManager.translate(0D, 0.5D, 0D); } GlStateManager.rotate(180F, 1F, 0F, 0F); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/SpecialRenderInit.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/SpecialRenderInit.java index 35caf2542..f7ca4b0be 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/SpecialRenderInit.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/SpecialRenderInit.java @@ -10,6 +10,10 @@ package de.ellpeck.actuallyadditions.mod.misc.special; +import java.util.HashMap; +import java.util.Locale; +import java.util.Properties; + import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -20,30 +24,25 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import java.util.HashMap; -import java.util.Locale; -import java.util.Properties; - -public class SpecialRenderInit{ +public class SpecialRenderInit { public static final HashMap SPECIAL_LIST = new HashMap<>(); - public SpecialRenderInit(){ + public SpecialRenderInit() { new ThreadSpecialFetcher(); MinecraftForge.EVENT_BUS.register(this); } - public static void parse(Properties properties){ - for(String key : properties.stringPropertyNames()){ + public static void parse(Properties properties) { + for (String key : properties.stringPropertyNames()) { String[] values = properties.getProperty(key).split("@"); - if(values.length > 0){ + if (values.length > 0) { String itemName = values[0]; int meta; - try{ + try { meta = Integer.parseInt(values[1]); - } - catch(Exception e){ + } catch (Exception e) { meta = 0; } @@ -51,52 +50,46 @@ public class SpecialRenderInit{ ItemStack stack = findItem(resLoc, meta); //TODO Remove this block once the transition to 1.11 is done and the special people stuff file has been converted to snake_case - if(!StackUtil.isValid(stack)){ + if (!StackUtil.isValid(stack)) { String convertedItemName = ""; - for(char c : itemName.toCharArray()){ - if(Character.isUpperCase(c)){ + for (char c : itemName.toCharArray()) { + if (Character.isUpperCase(c)) { convertedItemName += "_"; convertedItemName += Character.toLowerCase(c); - } - else{ + } else { convertedItemName += c; } } stack = findItem(new ResourceLocation(convertedItemName), meta); } - if(StackUtil.isValid(stack)){ + if (StackUtil.isValid(stack)) { SPECIAL_LIST.put(key.toLowerCase(Locale.ROOT), new RenderSpecial(stack)); } } } } - private static ItemStack findItem(ResourceLocation resLoc, int meta){ - if(Item.REGISTRY.containsKey(resLoc)){ + private static ItemStack findItem(ResourceLocation resLoc, int meta) { + if (Item.REGISTRY.containsKey(resLoc)) { Item item = Item.REGISTRY.getObject(resLoc); - if(item != null){ - return new ItemStack(item, 1, meta); - } - } - else if(Block.REGISTRY.containsKey(resLoc)){ + if (item != null) { return new ItemStack(item, 1, meta); } + } else if (Block.REGISTRY.containsKey(resLoc)) { Block block = Block.REGISTRY.getObject(resLoc); - if(block != null){ - return new ItemStack(block, 1, meta); - } + if (block != null) { return new ItemStack(block, 1, meta); } } return StackUtil.getEmpty(); } @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onPlayerRender(RenderPlayerEvent.Pre event){ - if(event.getEntityPlayer() != null){ + public void onPlayerRender(RenderPlayerEvent.Pre event) { + if (event.getEntityPlayer() != null) { String name = event.getEntityPlayer().getName(); - if(name != null){ + if (name != null) { String lower = name.toLowerCase(Locale.ROOT); - if(SPECIAL_LIST.containsKey(lower)){ + if (SPECIAL_LIST.containsKey(lower)) { RenderSpecial render = SPECIAL_LIST.get(lower); - if(render != null){ + if (render != null) { render.render(event.getEntityPlayer(), event.getPartialRenderTick()); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/ThreadSpecialFetcher.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/ThreadSpecialFetcher.java index d2ac6c121..7648727ed 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/ThreadSpecialFetcher.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/ThreadSpecialFetcher.java @@ -10,32 +10,31 @@ package de.ellpeck.actuallyadditions.mod.misc.special; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; - import java.io.InputStreamReader; import java.net.URL; import java.util.Properties; -public class ThreadSpecialFetcher extends Thread{ +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; - public ThreadSpecialFetcher(){ - this.setName(ActuallyAdditions.NAME+" Special Fetcher"); +public class ThreadSpecialFetcher extends Thread { + + public ThreadSpecialFetcher() { + this.setName(ActuallyAdditions.NAME + " Special Fetcher"); this.setDaemon(true); this.start(); } @Override - public void run(){ + public void run() { ActuallyAdditions.LOGGER.info("Fetching Special People Stuff..."); - try{ + try { URL url = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/specialPeopleStuff.properties"); Properties specialProperties = new Properties(); specialProperties.load(new InputStreamReader(url.openStream())); SpecialRenderInit.parse(specialProperties); ActuallyAdditions.LOGGER.info("Fetching Special People Stuff done!"); - } - catch(Exception e){ + } catch (Exception e) { ActuallyAdditions.LOGGER.error("Fetching Special People Stuff failed! (You can ignore this error technically.)", e); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/IDataHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/IDataHandler.java index 8f0d92e27..78aaff5ee 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/IDataHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/IDataHandler.java @@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.network; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -public interface IDataHandler{ +public interface IDataHandler { void handleData(NBTTagCompound compound, MessageContext context); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketClientToServer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketClientToServer.java index 0fc993cd7..04253eec9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketClientToServer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketClientToServer.java @@ -19,50 +19,49 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -public class PacketClientToServer implements IMessage{ +public class PacketClientToServer implements IMessage { private NBTTagCompound data; private IDataHandler handler; - public PacketClientToServer(){ + public PacketClientToServer() { } - public PacketClientToServer(NBTTagCompound data, IDataHandler handler){ + public PacketClientToServer(NBTTagCompound data, IDataHandler handler) { this.data = data; this.handler = handler; } @Override - public void fromBytes(ByteBuf buf){ + public void fromBytes(ByteBuf buf) { PacketBuffer buffer = new PacketBuffer(buf); - try{ + try { this.data = buffer.readCompoundTag(); int handlerId = buffer.readInt(); - if(handlerId >= 0 && handlerId < PacketHandler.DATA_HANDLERS.size()){ + if (handlerId >= 0 && handlerId < PacketHandler.DATA_HANDLERS.size()) { this.handler = PacketHandler.DATA_HANDLERS.get(handlerId); } - } - catch(Exception e){ + } catch (Exception e) { ActuallyAdditions.LOGGER.error("Something went wrong trying to receive a server packet!", e); } } @Override - public void toBytes(ByteBuf buf){ + public void toBytes(ByteBuf buf) { PacketBuffer buffer = new PacketBuffer(buf); buffer.writeCompoundTag(this.data); buffer.writeInt(PacketHandler.DATA_HANDLERS.indexOf(this.handler)); } - public static class Handler implements IMessageHandler{ + public static class Handler implements IMessageHandler { @Override - public IMessage onMessage(final PacketClientToServer message, final MessageContext ctx){ + public IMessage onMessage(final PacketClientToServer message, final MessageContext ctx) { FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(() -> { - if(message.data != null && message.handler != null){ + if (message.data != null && message.handler != null) { message.handler.handleData(message.data, ctx); } }); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java index d65398100..43afce109 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.network; +import java.util.ArrayList; +import java.util.List; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.data.PlayerData; import de.ellpeck.actuallyadditions.mod.data.WorldData; @@ -36,46 +39,43 @@ import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.ArrayList; -import java.util.List; - -public final class PacketHandler{ +public final class PacketHandler { public static final List DATA_HANDLERS = new ArrayList<>(); - public static final IDataHandler LASER_HANDLER = new IDataHandler(){ + public static final IDataHandler LASER_HANDLER = new IDataHandler() { @Override @SideOnly(Side.CLIENT) - public void handleData(NBTTagCompound compound, MessageContext context){ - AssetUtil.spawnLaserWithTimeClient(compound.getDouble("StartX"), compound.getDouble("StartY"), compound.getDouble("StartZ"), compound.getDouble("EndX"), compound.getDouble("EndY"), compound.getDouble("EndZ"), new float[]{compound.getFloat("Color1"), compound.getFloat("Color2"), compound.getFloat("Color3")}, compound.getInteger("MaxAge"), compound.getDouble("RotationTime"), compound.getFloat("Size"), compound.getFloat("Alpha")); + public void handleData(NBTTagCompound compound, MessageContext context) { + AssetUtil.spawnLaserWithTimeClient(compound.getDouble("StartX"), compound.getDouble("StartY"), compound.getDouble("StartZ"), compound.getDouble("EndX"), compound.getDouble("EndY"), compound.getDouble("EndZ"), new float[] { compound.getFloat("Color1"), compound.getFloat("Color2"), compound.getFloat("Color3") }, compound.getInteger("MaxAge"), compound.getDouble("RotationTime"), compound.getFloat("Size"), compound.getFloat("Alpha")); } }; - public static final IDataHandler TILE_ENTITY_HANDLER = new IDataHandler(){ + public static final IDataHandler TILE_ENTITY_HANDLER = new IDataHandler() { @Override @SideOnly(Side.CLIENT) - public void handleData(NBTTagCompound compound, MessageContext context){ + public void handleData(NBTTagCompound compound, MessageContext context) { World world = Minecraft.getMinecraft().world; - if(world != null){ + if (world != null) { TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z"))); - if(tile instanceof TileEntityBase){ - ((TileEntityBase)tile).readSyncableNBT(compound.getCompoundTag("Data"), TileEntityBase.NBTType.SYNC); + if (tile instanceof TileEntityBase) { + ((TileEntityBase) tile).readSyncableNBT(compound.getCompoundTag("Data"), TileEntityBase.NBTType.SYNC); } } } }; - public static final IDataHandler LASER_PARTICLE_HANDLER = new IDataHandler(){ + public static final IDataHandler LASER_PARTICLE_HANDLER = new IDataHandler() { @Override @SideOnly(Side.CLIENT) - public void handleData(NBTTagCompound compound, MessageContext context){ + public void handleData(NBTTagCompound compound, MessageContext context) { Minecraft mc = Minecraft.getMinecraft(); ItemStack stack = new ItemStack(compound); - double inX = compound.getDouble("InX")+0.5; - double inY = compound.getDouble("InY")+0.78; - double inZ = compound.getDouble("InZ")+0.5; + double inX = compound.getDouble("InX") + 0.5; + double inY = compound.getDouble("InY") + 0.78; + double inZ = compound.getDouble("InZ") + 0.5; - double outX = compound.getDouble("OutX")+0.5; - double outY = compound.getDouble("OutY")+0.525; - double outZ = compound.getDouble("OutZ")+0.5; + double outX = compound.getDouble("OutX") + 0.5; + double outY = compound.getDouble("OutY") + 0.525; + double outZ = compound.getDouble("OutZ") + 0.5; Particle fx = new ParticleLaserItem(mc.world, outX, outY, outZ, stack, 0.025, inX, inY, inZ); mc.effectRenderer.addEffect(fx); @@ -85,21 +85,21 @@ public final class PacketHandler{ World world = DimensionManager.getWorld(compound.getInteger("WorldID")); TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z"))); - if(tile instanceof IButtonReactor){ - IButtonReactor reactor = (IButtonReactor)tile; + if (tile instanceof IButtonReactor) { + IButtonReactor reactor = (IButtonReactor) tile; Entity entity = world.getEntityByID(compound.getInteger("PlayerID")); - if(entity instanceof EntityPlayer){ - reactor.onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer)entity); + if (entity instanceof EntityPlayer) { + reactor.onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer) entity); } } }; public static final IDataHandler GUI_BUTTON_TO_CONTAINER_HANDLER = (compound, context) -> { World world = DimensionManager.getWorld(compound.getInteger("WorldID")); Entity entity = world.getEntityByID(compound.getInteger("PlayerID")); - if(entity instanceof EntityPlayer){ - Container container = ((EntityPlayer)entity).openContainer; - if(container instanceof IButtonReactor){ - ((IButtonReactor)container).onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer)entity); + if (entity instanceof EntityPlayer) { + Container container = ((EntityPlayer) entity).openContainer; + if (container instanceof IButtonReactor) { + ((IButtonReactor) container).onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer) entity); } } }; @@ -107,35 +107,34 @@ public final class PacketHandler{ World world = DimensionManager.getWorld(compound.getInteger("WorldID")); TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z"))); - if(tile instanceof INumberReactor){ - INumberReactor reactor = (INumberReactor)tile; - reactor.onNumberReceived(compound.getDouble("Number"), compound.getInteger("NumberID"), (EntityPlayer)world.getEntityByID(compound.getInteger("PlayerID"))); + if (tile instanceof INumberReactor) { + INumberReactor reactor = (INumberReactor) tile; + reactor.onNumberReceived(compound.getDouble("Number"), compound.getInteger("NumberID"), (EntityPlayer) world.getEntityByID(compound.getInteger("PlayerID"))); } }; public static final IDataHandler GUI_STRING_TO_TILE_HANDLER = (compound, context) -> { World world = DimensionManager.getWorld(compound.getInteger("WorldID")); TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z"))); - if(tile instanceof IStringReactor){ - IStringReactor reactor = (IStringReactor)tile; - reactor.onTextReceived(compound.getString("Text"), compound.getInteger("TextID"), (EntityPlayer)world.getEntityByID(compound.getInteger("PlayerID"))); + if (tile instanceof IStringReactor) { + IStringReactor reactor = (IStringReactor) tile; + reactor.onTextReceived(compound.getString("Text"), compound.getInteger("TextID"), (EntityPlayer) world.getEntityByID(compound.getInteger("PlayerID"))); } }; - public static final IDataHandler SYNC_PLAYER_DATA = new IDataHandler(){ + public static final IDataHandler SYNC_PLAYER_DATA = new IDataHandler() { @Override @SideOnly(Side.CLIENT) - public void handleData(NBTTagCompound compound, MessageContext context){ + public void handleData(NBTTagCompound compound, MessageContext context) { NBTTagCompound dataTag = compound.getCompoundTag("Data"); EntityPlayer player = ActuallyAdditions.PROXY.getCurrentPlayer(); - if(player != null){ + if (player != null) { PlayerData.getDataFromPlayer(player).readFromNBT(dataTag, false); - if(compound.getBoolean("Log")){ - ActuallyAdditions.LOGGER.info("Receiving (new or changed) Player Data for player "+player.getName()+"."); + if (compound.getBoolean("Log")) { + ActuallyAdditions.LOGGER.info("Receiving (new or changed) Player Data for player " + player.getName() + "."); } - } - else{ + } else { ActuallyAdditions.LOGGER.error("Tried to receive Player Data for the current player, but he doesn't seem to be present!"); } } @@ -143,37 +142,34 @@ public final class PacketHandler{ public static final IDataHandler PLAYER_DATA_TO_SERVER = (compound, context) -> { World world = DimensionManager.getWorld(compound.getInteger("World")); EntityPlayer player = world.getPlayerEntityByUUID(compound.getUniqueId("UUID")); - if(player != null){ + if (player != null) { PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player); int type = compound.getInteger("Type"); - if(type == 0){ + if (type == 0) { data.loadBookmarks(compound.getTagList("Bookmarks", 8)); - } - else if(type == 1){ + } else if (type == 1) { data.didBookTutorial = compound.getBoolean("DidBookTutorial"); - } - else if(type == 2){ + } else if (type == 2) { data.loadTrials(compound.getTagList("Trials", 8)); - if(compound.getBoolean("Achievement")){ + if (compound.getBoolean("Achievement")) { //TheAchievements.COMPLETE_TRIALS.get(player); } } WorldData.get(world).markDirty(); - if(compound.getBoolean("Log")){ - ActuallyAdditions.LOGGER.info("Receiving changed Player Data for player "+player.getName()+"."); + if (compound.getBoolean("Log")) { + ActuallyAdditions.LOGGER.info("Receiving changed Player Data for player " + player.getName() + "."); } - } - else{ - ActuallyAdditions.LOGGER.error("Tried to receive Player Data for UUID "+compound.getUniqueId("UUID")+", but he doesn't seem to be present!"); + } else { + ActuallyAdditions.LOGGER.error("Tried to receive Player Data for UUID " + compound.getUniqueId("UUID") + ", but he doesn't seem to be present!"); } }; public static SimpleNetworkWrapper theNetwork; - public static void init(){ + public static void init() { theNetwork = NetworkRegistry.INSTANCE.newSimpleChannel(ActuallyAdditions.MODID); theNetwork.registerMessage(PacketServerToClient.Handler.class, PacketServerToClient.class, 0, Side.CLIENT); theNetwork.registerMessage(PacketClientToServer.Handler.class, PacketClientToServer.class, 1, Side.SERVER); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java index a4deed7bd..294b5a8c4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java @@ -24,10 +24,10 @@ import net.minecraft.util.math.BlockPos; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public final class PacketHandlerHelper{ +public final class PacketHandlerHelper { @SideOnly(Side.CLIENT) - public static void sendButtonPacket(TileEntity tile, int buttonId){ + public static void sendButtonPacket(TileEntity tile, int buttonId) { NBTTagCompound compound = new NBTTagCompound(); BlockPos pos = tile.getPos(); compound.setInteger("X", pos.getX()); @@ -39,7 +39,7 @@ public final class PacketHandlerHelper{ PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER)); } - public static void syncPlayerData(EntityPlayer player, boolean log){ + public static void syncPlayerData(EntityPlayer player, boolean log) { NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("Log", log); @@ -47,41 +47,39 @@ public final class PacketHandlerHelper{ PlayerData.getDataFromPlayer(player).writeToNBT(data, false); compound.setTag("Data", data); - if(player instanceof EntityPlayerMP){ - PacketHandler.theNetwork.sendTo(new PacketServerToClient(compound, PacketHandler.SYNC_PLAYER_DATA), (EntityPlayerMP)player); + if (player instanceof EntityPlayerMP) { + PacketHandler.theNetwork.sendTo(new PacketServerToClient(compound, PacketHandler.SYNC_PLAYER_DATA), (EntityPlayerMP) player); } } @SideOnly(Side.CLIENT) - public static void sendPlayerDataToServer(boolean log, int type){ + public static void sendPlayerDataToServer(boolean log, int type) { NBTTagCompound compound = new NBTTagCompound(); compound.setBoolean("Log", log); compound.setInteger("Type", type); EntityPlayer player = Minecraft.getMinecraft().player; - if(player != null){ + if (player != null) { compound.setInteger("World", player.world.provider.getDimension()); compound.setUniqueId("UUID", player.getUniqueID()); PlayerSave data = PlayerData.getDataFromPlayer(player); - if(type == 0){ + if (type == 0) { compound.setTag("Bookmarks", data.saveBookmarks()); - } - else if(type == 1){ + } else if (type == 1) { compound.setBoolean("DidBookTutorial", data.didBookTutorial); - } - else if(type == 2){ + } else if (type == 2) { compound.setTag("Trials", data.saveTrials()); int total = 0; - for(IBookletChapter chapter : ActuallyAdditionsAPI.entryTrials.getAllChapters()){ - if(chapter instanceof BookletChapterTrials){ + for (IBookletChapter chapter : ActuallyAdditionsAPI.entryTrials.getAllChapters()) { + if (chapter instanceof BookletChapterTrials) { total++; } } - if(data.completedTrials.size() >= total){ + if (data.completedTrials.size() >= total) { compound.setBoolean("Achievement", true); } } @@ -91,7 +89,7 @@ public final class PacketHandlerHelper{ } @SideOnly(Side.CLIENT) - public static void sendNumberPacket(TileEntity tile, double number, int id){ + public static void sendNumberPacket(TileEntity tile, double number, int id) { NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("X", tile.getPos().getX()); compound.setInteger("Y", tile.getPos().getY()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketServerToClient.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketServerToClient.java index 9b1dfe9e4..53896b25f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketServerToClient.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketServerToClient.java @@ -21,51 +21,50 @@ import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class PacketServerToClient implements IMessage{ +public class PacketServerToClient implements IMessage { private NBTTagCompound data; private IDataHandler handler; - public PacketServerToClient(){ + public PacketServerToClient() { } - public PacketServerToClient(NBTTagCompound data, IDataHandler handler){ + public PacketServerToClient(NBTTagCompound data, IDataHandler handler) { this.data = data; this.handler = handler; } @Override - public void fromBytes(ByteBuf buf){ + public void fromBytes(ByteBuf buf) { PacketBuffer buffer = new PacketBuffer(buf); - try{ + try { this.data = buffer.readCompoundTag(); int handlerId = buffer.readInt(); - if(handlerId >= 0 && handlerId < PacketHandler.DATA_HANDLERS.size()){ + if (handlerId >= 0 && handlerId < PacketHandler.DATA_HANDLERS.size()) { this.handler = PacketHandler.DATA_HANDLERS.get(handlerId); } - } - catch(Exception e){ + } catch (Exception e) { ActuallyAdditions.LOGGER.error("Something went wrong trying to receive a client packet!", e); } } @Override - public void toBytes(ByteBuf buf){ + public void toBytes(ByteBuf buf) { PacketBuffer buffer = new PacketBuffer(buf); buffer.writeCompoundTag(this.data); buffer.writeInt(PacketHandler.DATA_HANDLERS.indexOf(this.handler)); } - public static class Handler implements IMessageHandler{ + public static class Handler implements IMessageHandler { @Override @SideOnly(Side.CLIENT) - public IMessage onMessage(final PacketServerToClient message, final MessageContext ctx){ + public IMessage onMessage(final PacketServerToClient message, final MessageContext ctx) { Minecraft.getMinecraft().addScheduledTask(() -> { - if(message.data != null && message.handler != null){ + if (message.data != null && message.handler != null) { message.handler.handleData(message.data, ctx); } }); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/gui/IButtonReactor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/gui/IButtonReactor.java index 0796dc58f..594504b6f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/gui/IButtonReactor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/gui/IButtonReactor.java @@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.network.gui; import net.minecraft.entity.player.EntityPlayer; -public interface IButtonReactor{ +public interface IButtonReactor { /** * Called when a Button in a GUI is pressed diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/gui/INumberReactor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/gui/INumberReactor.java index 887eae071..78f05a36d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/gui/INumberReactor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/gui/INumberReactor.java @@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.network.gui; import net.minecraft.entity.player.EntityPlayer; -public interface INumberReactor{ +public interface INumberReactor { /** * Called when a Number gets received after typing it in in the GUI diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/gui/IStringReactor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/gui/IStringReactor.java index e02d8d6da..a86347a9e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/gui/IStringReactor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/gui/IStringReactor.java @@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.network.gui; import net.minecraft.entity.player.EntityPlayer; -public interface IStringReactor{ +public interface IStringReactor { /** * Called when a text gets received after typing it in in the GUI diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ore/InitOreDict.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ore/InitOreDict.java index 02d4a9bf0..70a85a075 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/ore/InitOreDict.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/ore/InitOreDict.java @@ -23,9 +23,9 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; -public final class InitOreDict{ +public final class InitOreDict { - public static void init(){ + public static void init() { ActuallyAdditions.LOGGER.info("Initializing OreDictionary Entries..."); //Vanilla Ores @@ -62,19 +62,19 @@ public final class InitOreDict{ addOre(InitItems.itemMisc, TheMiscItems.BLACK_DYE.ordinal(), "dye"); } - private static void addOre(Item item, int meta, String name){ + private static void addOre(Item item, int meta, String name) { addOre(new ItemStack(item, 1, meta), name); } - private static void addOre(Item item, String name){ + private static void addOre(Item item, String name) { addOre(item, 0, name); } - private static void addOre(Block block, int meta, String name){ + private static void addOre(Block block, int meta, String name) { addOre(new ItemStack(block, 1, meta), name); } - private static void addOre(ItemStack stack, String name){ + private static void addOre(ItemStack stack, String name) { OreDictionary.registerOre(name, stack); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/particle/ParticleBeam.java b/src/main/java/de/ellpeck/actuallyadditions/mod/particle/ParticleBeam.java index 59e884b29..450d850a9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/particle/ParticleBeam.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/particle/ParticleBeam.java @@ -19,7 +19,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class ParticleBeam extends Particle{ +public class ParticleBeam extends Particle { private final double endX; private final double endY; @@ -29,7 +29,7 @@ public class ParticleBeam extends Particle{ private final float size; private final float alpha; - public ParticleBeam(World world, double startX, double startY, double startZ, double endX, double endY, double endZ, float[] color, int maxAge, double rotationTime, float size, float alpha){ + public ParticleBeam(World world, double startX, double startY, double startZ, double endX, double endY, double endZ, float[] color, int maxAge, double rotationTime, float size, float alpha) { super(world, startX, startY, startZ); this.endX = endX; this.endY = endY; @@ -42,14 +42,14 @@ public class ParticleBeam extends Particle{ } @Override - public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ){ - float ageRatio = (float)this.particleAge/(float)this.particleMaxAge; - float currAlpha = this.alpha-ageRatio*this.alpha; - AssetUtil.renderLaser(this.posX+0.5, this.posY+0.5, this.posZ+0.5, this.endX+0.5, this.endY+0.5, this.endZ+0.5, this.rotationTime, currAlpha, this.size, this.color); + public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { + float ageRatio = (float) this.particleAge / (float) this.particleMaxAge; + float currAlpha = this.alpha - ageRatio * this.alpha; + AssetUtil.renderLaser(this.posX + 0.5, this.posY + 0.5, this.posZ + 0.5, this.endX + 0.5, this.endY + 0.5, this.endZ + 0.5, this.rotationTime, currAlpha, this.size, this.color); } @Override - public int getFXLayer(){ + public int getFXLayer() { return 3; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/particle/ParticleLaserItem.java b/src/main/java/de/ellpeck/actuallyadditions/mod/particle/ParticleLaserItem.java index e209446b0..f6e9cde1b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/particle/ParticleLaserItem.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/particle/ParticleLaserItem.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.particle; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.Particle; @@ -22,11 +25,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; @SideOnly(Side.CLIENT) -public class ParticleLaserItem extends Particle{ +public class ParticleLaserItem extends Particle { private final double otherX; private final double otherY; @@ -34,12 +35,12 @@ public class ParticleLaserItem extends Particle{ private final ItemStack stack; - private ParticleLaserItem(World world, double posX, double posY, double posZ, ItemStack stack, double motionY){ + private ParticleLaserItem(World world, double posX, double posY, double posZ, ItemStack stack, double motionY) { this(world, posX, posY, posZ, stack, motionY, 0, 0, 0); } - public ParticleLaserItem(World world, double posX, double posY, double posZ, ItemStack stack, double motionY, double otherX, double otherY, double otherZ){ - super(world, posX+(world.rand.nextDouble()-0.5)/8, posY, posZ+(world.rand.nextDouble()-0.5)/8); + public ParticleLaserItem(World world, double posX, double posY, double posZ, ItemStack stack, double motionY, double otherX, double otherY, double otherZ) { + super(world, posX + (world.rand.nextDouble() - 0.5) / 8, posY, posZ + (world.rand.nextDouble() - 0.5) / 8); this.stack = stack; this.otherX = otherX; this.otherY = otherY; @@ -54,31 +55,31 @@ public class ParticleLaserItem extends Particle{ } @Override - public void setExpired(){ + public void setExpired() { super.setExpired(); - if(this.otherX != 0 || this.otherY != 0 || this.otherZ != 0){ + if (this.otherX != 0 || this.otherY != 0 || this.otherZ != 0) { Particle fx = new ParticleLaserItem(this.world, this.otherX, this.otherY, this.otherZ, this.stack, -0.025); Minecraft.getMinecraft().effectRenderer.addEffect(fx); } } @Override - public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ){ + public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { GlStateManager.pushMatrix(); RenderHelper.enableStandardItemLighting(); - GlStateManager.translate(this.posX-TileEntityRendererDispatcher.staticPlayerX, this.posY-TileEntityRendererDispatcher.staticPlayerY, this.posZ-TileEntityRendererDispatcher.staticPlayerZ); + GlStateManager.translate(this.posX - TileEntityRendererDispatcher.staticPlayerX, this.posY - TileEntityRendererDispatcher.staticPlayerY, this.posZ - TileEntityRendererDispatcher.staticPlayerZ); GlStateManager.scale(0.3F, 0.3F, 0.3F); - double boop = Minecraft.getSystemTime()/600D; - GlStateManager.rotate((float)(boop*40D%360), 0, 1, 0); + double boop = Minecraft.getSystemTime() / 600D; + GlStateManager.rotate((float) (boop * 40D % 360), 0, 1, 0); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_CONSTANT_COLOR, GlStateManager.SourceFactor.ONE.factor, GlStateManager.DestFactor.ZERO.factor); - float ageRatio = (float)this.particleAge/(float)this.particleMaxAge; - float color = this.motionY < 0 ? 1F-ageRatio : ageRatio; + float ageRatio = (float) this.particleAge / (float) this.particleMaxAge; + float color = this.motionY < 0 ? 1F - ageRatio : ageRatio; GL14.glBlendColor(color, color, color, color); AssetUtil.renderItemWithoutScrewingWithColors(this.stack); @@ -88,7 +89,7 @@ public class ParticleLaserItem extends Particle{ } @Override - public int getFXLayer(){ + public int getFXLayer() { return 3; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java index 99314c012..10414c6a4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.proxy; - import java.util.ArrayList; import java.util.List; @@ -62,13 +61,13 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -public class ClientProxy implements IProxy{ +public class ClientProxy implements IProxy { private static final List COLOR_PRODIVIDING_ITEMS_FOR_REGISTERING = new ArrayList<>(); private static final List COLOR_PRODIVIDING_BLOCKS_FOR_REGISTERING = new ArrayList<>(); @Override - public void preInit(FMLPreInitializationEvent event){ + public void preInit(FMLPreInitializationEvent event) { ActuallyAdditions.LOGGER.info("PreInitializing ClientProxy..."); MinecraftForge.EVENT_BUS.register(new ClientRegistryHandler()); @@ -77,7 +76,7 @@ public class ClientProxy implements IProxy{ } @Override - public void init(FMLInitializationEvent event){ + public void init(FMLInitializationEvent event) { ActuallyAdditions.LOGGER.info("Initializing ClientProxy..."); RenderWorm.fixItemStack(); @@ -99,18 +98,18 @@ public class ClientProxy implements IProxy{ ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLaserRelayItemWhitelist.class, laser); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLaserRelayFluids.class, laser); - for(Item item : COLOR_PRODIVIDING_ITEMS_FOR_REGISTERING){ - if(item instanceof IColorProvidingItem){ - Minecraft.getMinecraft().getItemColors().registerItemColorHandler(((IColorProvidingItem)item).getItemColor(), item); + for (Item item : COLOR_PRODIVIDING_ITEMS_FOR_REGISTERING) { + if (item instanceof IColorProvidingItem) { + Minecraft.getMinecraft().getItemColors().registerItemColorHandler(((IColorProvidingItem) item).getItemColor(), item); } } - for(Block block : COLOR_PRODIVIDING_BLOCKS_FOR_REGISTERING){ - if(block instanceof IColorProvidingBlock){ - Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(((IColorProvidingBlock)block).getBlockColor(), block); + for (Block block : COLOR_PRODIVIDING_BLOCKS_FOR_REGISTERING) { + if (block instanceof IColorProvidingBlock) { + Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(((IColorProvidingBlock) block).getBlockColor(), block); } - if(block instanceof IColorProvidingItem){ - Minecraft.getMinecraft().getItemColors().registerItemColorHandler(((IColorProvidingItem)block).getItemColor(), block); + if (block instanceof IColorProvidingItem) { + Minecraft.getMinecraft().getItemColors().registerItemColorHandler(((IColorProvidingItem) block).getItemColor(), block); } } @@ -128,29 +127,29 @@ public class ClientProxy implements IProxy{ } @Override - public void postInit(FMLPostInitializationEvent event){ + public void postInit(FMLPostInitializationEvent event) { ActuallyAdditions.LOGGER.info("PostInitializing ClientProxy..."); new SpecialRenderInit(); } @Override - public void addRenderRegister(ItemStack stack, ResourceLocation location, String variant){ + public void addRenderRegister(ItemStack stack, ResourceLocation location, String variant) { ClientRegistryHandler.MODEL_LOCATIONS_FOR_REGISTERING.put(stack, new ModelResourceLocation(location, variant)); } @Override - public void addColoredItem(Item item){ + public void addColoredItem(Item item) { COLOR_PRODIVIDING_ITEMS_FOR_REGISTERING.add(item); } @Override - public void addColoredBlock(Block block){ + public void addColoredBlock(Block block) { COLOR_PRODIVIDING_BLOCKS_FOR_REGISTERING.add(block); } @Override - public EntityPlayer getCurrentPlayer(){ + public EntityPlayer getCurrentPlayer() { return Minecraft.getMinecraft().player; } @@ -158,7 +157,6 @@ public class ClientProxy implements IProxy{ public void sendBreakPacket(BlockPos pos) { NetHandlerPlayClient netHandlerPlayClient = Minecraft.getMinecraft().getConnection(); assert netHandlerPlayClient != null; - netHandlerPlayClient.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, pos, Minecraft - .getMinecraft().objectMouseOver.sideHit)); + netHandlerPlayClient.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.STOP_DESTROY_BLOCK, pos, Minecraft.getMinecraft().objectMouseOver.sideHit)); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/IProxy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/IProxy.java index e01d65aac..be9f5f760 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/IProxy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/IProxy.java @@ -20,7 +20,7 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -public interface IProxy{ +public interface IProxy { void preInit(FMLPreInitializationEvent event); @@ -36,6 +36,7 @@ public interface IProxy{ EntityPlayer getCurrentPlayer(); - default void sendBreakPacket(BlockPos pos) {}; + default void sendBreakPacket(BlockPos pos) { + }; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ServerProxy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ServerProxy.java index 7d27a2412..ff61b6efa 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ServerProxy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ServerProxy.java @@ -20,40 +20,40 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -public class ServerProxy implements IProxy{ +public class ServerProxy implements IProxy { @Override - public void preInit(FMLPreInitializationEvent event){ + public void preInit(FMLPreInitializationEvent event) { ActuallyAdditions.LOGGER.info("PreInitializing ServerProxy..."); } @Override - public void init(FMLInitializationEvent event){ + public void init(FMLInitializationEvent event) { ActuallyAdditions.LOGGER.info("Initializing ServerProxy..."); } @Override - public void postInit(FMLPostInitializationEvent event){ + public void postInit(FMLPostInitializationEvent event) { ActuallyAdditions.LOGGER.info("PostInitializing ServerProxy..."); } @Override - public void addRenderRegister(ItemStack stack, ResourceLocation location, String variant){ + public void addRenderRegister(ItemStack stack, ResourceLocation location, String variant) { } @Override - public void addColoredItem(Item item){ + public void addColoredItem(Item item) { } @Override - public void addColoredBlock(Block block){ + public void addColoredBlock(Block block) { } @Override - public EntityPlayer getCurrentPlayer(){ + public EntityPlayer getCurrentPlayer() { return null; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/CrusherRecipeRegistry.java b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/CrusherRecipeRegistry.java index 77866a5f9..b48bffdfb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/CrusherRecipeRegistry.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/CrusherRecipeRegistry.java @@ -23,26 +23,25 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreIngredient; - -public final class CrusherRecipeRegistry{ +public final class CrusherRecipeRegistry { public static final ArrayList SEARCH_CASES = new ArrayList<>(); - public static void registerFinally(){ + public static void registerFinally() { ArrayList oresNoResult = new ArrayList<>(); int recipeStartedAt = ActuallyAdditionsAPI.CRUSHER_RECIPES.size(); - for(String ore : OreDictionary.getOreNames()){ - if(!hasException(ore)){ - for(SearchCase theCase : SEARCH_CASES){ - if(ore.length() > theCase.theCase.length()){ - if(ore.substring(0, theCase.theCase.length()).equals(theCase.theCase)){ - String outputOre = theCase.resultPreString+ore.substring(theCase.theCase.length()); + for (String ore : OreDictionary.getOreNames()) { + if (!hasException(ore)) { + for (SearchCase theCase : SEARCH_CASES) { + if (ore.length() > theCase.theCase.length()) { + if (ore.substring(0, theCase.theCase.length()).equals(theCase.theCase)) { + String outputOre = theCase.resultPreString + ore.substring(theCase.theCase.length()); List outputs = OreDictionary.getOres(outputOre, false); ItemStack output = outputs.isEmpty() ? ItemStack.EMPTY : outputs.get(0).copy(); output.setCount(theCase.resultAmount); - if(output.isEmpty()){ - if(!oresNoResult.contains(ore)){ + if (output.isEmpty()) { + if (!oresNoResult.contains(ore)) { oresNoResult.add(ore); } } else ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient(ore), output, StackUtil.getEmpty(), 0); @@ -53,26 +52,26 @@ public final class CrusherRecipeRegistry{ } ArrayList addedRecipes = new ArrayList<>(); - for(int i = recipeStartedAt; i < ActuallyAdditionsAPI.CRUSHER_RECIPES.size(); i++){ + for (int i = recipeStartedAt; i < ActuallyAdditionsAPI.CRUSHER_RECIPES.size(); i++) { CrusherRecipe recipe = ActuallyAdditionsAPI.CRUSHER_RECIPES.get(i); - addedRecipes.add(recipe.getInput().getMatchingStacks()+" -> "+recipe.getOutputOne()); + addedRecipes.add(recipe.getInput().getMatchingStacks() + " -> " + recipe.getOutputOne()); } - ActuallyAdditions.LOGGER.debug("Added "+addedRecipes.size()+" Crusher Recipes automatically: "+addedRecipes); - ActuallyAdditions.LOGGER.debug("Couldn't add "+oresNoResult.size()+" Crusher Recipes automatically, either because the inputs were missing outputs, or because they exist already: "+oresNoResult); + ActuallyAdditions.LOGGER.debug("Added " + addedRecipes.size() + " Crusher Recipes automatically: " + addedRecipes); + ActuallyAdditions.LOGGER.debug("Couldn't add " + oresNoResult.size() + " Crusher Recipes automatically, either because the inputs were missing outputs, or because they exist already: " + oresNoResult); removeDuplicateRecipes(); } public static void removeDuplicateRecipes() { ArrayList usable = new ArrayList<>(); ArrayList removed = new ArrayList<>(); - for(CrusherRecipe r : ActuallyAdditionsAPI.CRUSHER_RECIPES) { + for (CrusherRecipe r : ActuallyAdditionsAPI.CRUSHER_RECIPES) { boolean canUse = true; - if(r.getInput().getMatchingStacks().length == 0) canUse = false; - else for(CrusherRecipe re : usable) { - if(re.getInput().apply(r.getInput().getMatchingStacks()[0])) canUse = false; + if (r.getInput().getMatchingStacks().length == 0) canUse = false; + else for (CrusherRecipe re : usable) { + if (re.getInput().apply(r.getInput().getMatchingStacks()[0])) canUse = false; } - if(canUse) usable.add(r); + if (canUse) usable.add(r); else removed.add(r); } @@ -81,30 +80,27 @@ public final class CrusherRecipeRegistry{ ActuallyAdditions.LOGGER.debug(String.format("Removed %s crusher recipes that had dupliate inputs, %s remain.", removed.size(), usable.size())); } - public static boolean hasBlacklistedOutput(ItemStack output, String[] config){ - if(StackUtil.isValid(output)){ + public static boolean hasBlacklistedOutput(ItemStack output, String[] config) { + if (StackUtil.isValid(output)) { Item item = output.getItem(); - if(item != null){ + if (item != null) { String reg = item.getRegistryName().toString(); - for(String conf : config){ + for (String conf : config) { String confReg = conf; int meta = 0; - if(conf.contains("@")){ - try{ + if (conf.contains("@")) { + try { String[] split = conf.split("@"); confReg = split[0]; meta = Integer.parseInt(split[1]); - } - catch(Exception e){ - ActuallyAdditions.LOGGER.warn("A config option appears to be incorrect: The entry "+conf+" can't be parsed!"); + } catch (Exception e) { + ActuallyAdditions.LOGGER.warn("A config option appears to be incorrect: The entry " + conf + " can't be parsed!"); } } - if(reg.equals(confReg) && output.getItemDamage() == meta){ - return true; - } + if (reg.equals(confReg) && output.getItemDamage() == meta) { return true; } } return false; @@ -113,32 +109,30 @@ public final class CrusherRecipeRegistry{ return true; } - public static boolean hasException(String ore){ - for(String conf : ConfigStringListValues.CRUSHER_RECIPE_EXCEPTIONS.getValue()){ - if(conf.equals(ore)){ - return true; - } + public static boolean hasException(String ore) { + for (String conf : ConfigStringListValues.CRUSHER_RECIPE_EXCEPTIONS.getValue()) { + if (conf.equals(ore)) { return true; } } return false; } - public static CrusherRecipe getRecipeFromInput(ItemStack input){ - for(CrusherRecipe recipe : ActuallyAdditionsAPI.CRUSHER_RECIPES) - if(recipe.matches(input)) return recipe; + public static CrusherRecipe getRecipeFromInput(ItemStack input) { + for (CrusherRecipe recipe : ActuallyAdditionsAPI.CRUSHER_RECIPES) + if (recipe.matches(input)) return recipe; return null; } - public static class SearchCase{ + public static class SearchCase { final String theCase; final int resultAmount; final String resultPreString; - public SearchCase(String theCase, int resultAmount){ + public SearchCase(String theCase, int resultAmount) { this(theCase, resultAmount, "dust"); } - public SearchCase(String theCase, int resultAmount, String resultPreString){ + public SearchCase(String theCase, int resultAmount, String resultPreString) { this.theCase = theCase; this.resultAmount = resultAmount; this.resultPreString = resultPreString; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/EnchBookConversion.java b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/EnchBookConversion.java index 066839441..7052a3fa5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/EnchBookConversion.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/EnchBookConversion.java @@ -24,7 +24,7 @@ public class EnchBookConversion extends LensConversionRecipe { @Override public void transformHook(ItemStack stack, IBlockState state, BlockPos pos, IAtomicReconstructor tile) { - for(Map.Entry e : EnchantmentHelper.getEnchantments(stack).entrySet()) { + for (Map.Entry e : EnchantmentHelper.getEnchantments(stack).entrySet()) { ItemStack book = new ItemStack(Items.ENCHANTED_BOOK); Map ench = ImmutableMap.of(e.getKey(), e.getValue()); EnchantmentHelper.setEnchantments(ench, book); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/HairyBallHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/HairyBallHandler.java index 1314f9313..5677d581c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/HairyBallHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/HairyBallHandler.java @@ -16,9 +16,9 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -public final class HairyBallHandler{ +public final class HairyBallHandler { - public static void init(){ + public static void init() { ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Items.STRING), 100); ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Items.DIAMOND), 2); ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Items.NAME_TAG), 1); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/TreasureChestHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/TreasureChestHandler.java index 08ebdb49c..bed4671dd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/TreasureChestHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/TreasureChestHandler.java @@ -16,9 +16,9 @@ import de.ellpeck.actuallyadditions.mod.items.metalists.TheJams; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -public final class TreasureChestHandler{ +public final class TreasureChestHandler { - public static void init(){ + public static void init() { ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.DIAMOND), 5, 1, 2); ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.IRON_INGOT), 30, 1, 5); ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.GOLD_NUGGET), 60, 1, 8); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CustomEnergyStorage.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CustomEnergyStorage.java index cc7445626..f564c0cc0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CustomEnergyStorage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CustomEnergyStorage.java @@ -13,13 +13,13 @@ package de.ellpeck.actuallyadditions.mod.tile; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.energy.EnergyStorage; -public class CustomEnergyStorage extends EnergyStorage{ +public class CustomEnergyStorage extends EnergyStorage { - public CustomEnergyStorage(int capacity, int maxReceive, int maxExtract){ + public CustomEnergyStorage(int capacity, int maxReceive, int maxExtract) { super(capacity, maxReceive, maxExtract); } - public int extractEnergyInternal(int maxExtract, boolean simulate){ + public int extractEnergyInternal(int maxExtract, boolean simulate) { int before = this.maxExtract; this.maxExtract = Integer.MAX_VALUE; @@ -29,7 +29,7 @@ public class CustomEnergyStorage extends EnergyStorage{ return toReturn; } - public int receiveEnergyInternal(int maxReceive, boolean simulate){ + public int receiveEnergyInternal(int maxReceive, boolean simulate) { int before = this.maxReceive; this.maxReceive = Integer.MAX_VALUE; @@ -39,48 +39,44 @@ public class CustomEnergyStorage extends EnergyStorage{ return toReturn; } - public void addEnergyRaw(int energy){ + public void addEnergyRaw(int energy) { this.energy = Math.min(this.energy + energy, this.capacity); } @Override - public int receiveEnergy(int maxReceive, boolean simulate){ - if(!this.canReceive()){ - return 0; - } + public int receiveEnergy(int maxReceive, boolean simulate) { + if (!this.canReceive()) { return 0; } int energy = this.getEnergyStored(); - int energyReceived = Math.min(this.capacity-energy, Math.min(this.maxReceive, maxReceive)); - if(!simulate){ - this.setEnergyStored(energy+energyReceived); + int energyReceived = Math.min(this.capacity - energy, Math.min(this.maxReceive, maxReceive)); + if (!simulate) { + this.setEnergyStored(energy + energyReceived); } return energyReceived; } @Override - public int extractEnergy(int maxExtract, boolean simulate){ - if(!this.canExtract()){ - return 0; - } + public int extractEnergy(int maxExtract, boolean simulate) { + if (!this.canExtract()) { return 0; } int energy = this.getEnergyStored(); int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); - if(!simulate){ - this.setEnergyStored(energy-energyExtracted); + if (!simulate) { + this.setEnergyStored(energy - energyExtracted); } return energyExtracted; } - public void readFromNBT(NBTTagCompound compound){ + public void readFromNBT(NBTTagCompound compound) { this.setEnergyStored(compound.getInteger("Energy")); } - public void writeToNBT(NBTTagCompound compound){ + public void writeToNBT(NBTTagCompound compound) { compound.setInteger("Energy", this.getEnergyStored()); } - public void setEnergyStored(int energy){ + public void setEnergyStored(int energy) { this.energy = energy; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IEnergyDisplay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IEnergyDisplay.java index c5fea9e8d..d601a039e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IEnergyDisplay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IEnergyDisplay.java @@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public interface IEnergyDisplay{ +public interface IEnergyDisplay { @SideOnly(Side.CLIENT) CustomEnergyStorage getEnergyStorage(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ISharingEnergyProvider.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ISharingEnergyProvider.java index 2b1b46559..a5d3c39f1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ISharingEnergyProvider.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ISharingEnergyProvider.java @@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; -public interface ISharingEnergyProvider{ +public interface ISharingEnergyProvider { int getEnergyToSplitShare(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ISharingFluidHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ISharingFluidHandler.java index 9aaae0658..0a05d1c70 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ISharingFluidHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ISharingFluidHandler.java @@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.tile; import net.minecraft.util.EnumFacing; -public interface ISharingFluidHandler{ +public interface ISharingFluidHandler { int getMaxFluidAmountToSplitShare(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java index 8b5880a53..006fe5ac5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java @@ -36,7 +36,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; -public abstract class TileEntityBase extends TileEntity implements ITickable{ +public abstract class TileEntityBase extends TileEntity implements ITickable { public final String name; public boolean isRedstonePowered; @@ -46,11 +46,11 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{ protected TileEntity[] tilesAround = new TileEntity[6]; protected boolean hasSavedDataOnChangeOrWorldStart; - public TileEntityBase(String name){ + public TileEntityBase(String name) { this.name = name; } - public static void init(){ + public static void init() { ActuallyAdditions.LOGGER.info("Registering TileEntities..."); register(TileEntityCompost.class); @@ -112,59 +112,58 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{ register(TileEntityBatteryBox.class); } - private static void register(Class tileClass){ - try{ + private static void register(Class tileClass) { + try { //This is hacky and dirty but it works so whatever ResourceLocation name = new ResourceLocation(ActuallyAdditions.MODID, tileClass.newInstance().name); GameRegistry.registerTileEntity(tileClass, name); - } - catch(Exception e){ + } catch (Exception e) { ActuallyAdditions.LOGGER.fatal("Registering a TileEntity failed!", e); } } @Override - public final NBTTagCompound writeToNBT(NBTTagCompound compound){ + public final NBTTagCompound writeToNBT(NBTTagCompound compound) { this.writeSyncableNBT(compound, NBTType.SAVE_TILE); return compound; } @Override - public final void readFromNBT(NBTTagCompound compound){ + public final void readFromNBT(NBTTagCompound compound) { this.readSyncableNBT(compound, NBTType.SAVE_TILE); } @Override - public final SPacketUpdateTileEntity getUpdatePacket(){ + public final SPacketUpdateTileEntity getUpdatePacket() { NBTTagCompound compound = new NBTTagCompound(); this.writeSyncableNBT(compound, NBTType.SYNC); return new SPacketUpdateTileEntity(this.pos, -1, compound); } @Override - public final void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt){ + public final void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { this.readSyncableNBT(pkt.getNbtCompound(), NBTType.SYNC); } @Override - public final NBTTagCompound getUpdateTag(){ + public final NBTTagCompound getUpdateTag() { NBTTagCompound compound = new NBTTagCompound(); this.writeSyncableNBT(compound, NBTType.SYNC); return compound; } @Override - public final void handleUpdateTag(NBTTagCompound compound){ + public final void handleUpdateTag(NBTTagCompound compound) { this.readSyncableNBT(compound, NBTType.SYNC); } - public final void sendUpdate(){ - if(this.world != null && !this.world.isRemote) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); + public final void sendUpdate() { + if (this.world != null && !this.world.isRemote) VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); /* if(this.world != null && !this.world.isRemote){ NBTTagCompound compound = new NBTTagCompound(); this.writeSyncableNBT(compound, NBTType.SYNC); - + NBTTagCompound data = new NBTTagCompound(); data.setTag("Data", compound); data.setInteger("X", this.pos.getX()); @@ -174,81 +173,79 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{ }*/ } - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ - if(type != NBTType.SAVE_BLOCK) super.writeToNBT(compound); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { + if (type != NBTType.SAVE_BLOCK) super.writeToNBT(compound); - if(type == NBTType.SAVE_TILE){ + if (type == NBTType.SAVE_TILE) { compound.setBoolean("Redstone", this.isRedstonePowered); compound.setInteger("TicksElapsed", this.ticksElapsed); compound.setBoolean("StopDrop", this.stopFromDropping); - } - else if(type == NBTType.SYNC && this.stopFromDropping) compound.setBoolean("StopDrop", this.stopFromDropping); + } else if (type == NBTType.SYNC && this.stopFromDropping) compound.setBoolean("StopDrop", this.stopFromDropping); - if(this.isRedstoneToggle() && (type != NBTType.SAVE_BLOCK || this.isPulseMode)){ + if (this.isRedstoneToggle() && (type != NBTType.SAVE_BLOCK || this.isPulseMode)) { compound.setBoolean("IsPulseMode", this.isPulseMode); } } - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ - if(type != NBTType.SAVE_BLOCK) super.readFromNBT(compound); + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { + if (type != NBTType.SAVE_BLOCK) super.readFromNBT(compound); - if(type == NBTType.SAVE_TILE){ + if (type == NBTType.SAVE_TILE) { this.isRedstonePowered = compound.getBoolean("Redstone"); this.ticksElapsed = compound.getInteger("TicksElapsed"); this.stopFromDropping = compound.getBoolean("StopDrop"); - } - else if(type == NBTType.SYNC) this.stopFromDropping = compound.getBoolean("StopDrop"); + } else if (type == NBTType.SYNC) this.stopFromDropping = compound.getBoolean("StopDrop"); - if(this.isRedstoneToggle()){ + if (this.isRedstoneToggle()) { this.isPulseMode = compound.getBoolean("IsPulseMode"); } } @Override - public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState){ + public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) { return !oldState.getBlock().isAssociatedBlock(newState.getBlock()); } - public String getNameForTranslation(){ - return "container."+ActuallyAdditions.MODID+"."+this.name+".name"; + public String getNameForTranslation() { + return "container." + ActuallyAdditions.MODID + "." + this.name + ".name"; } @Override - public ITextComponent getDisplayName(){ + public ITextComponent getDisplayName() { return new TextComponentTranslation(this.getNameForTranslation()); } @Override - public final void update(){ + public final void update() { this.updateEntity(); } - public int getComparatorStrength(){ + public int getComparatorStrength() { return 0; } private boolean shareEnergy = this instanceof ISharingEnergyProvider; private boolean shareFluid = this instanceof ISharingFluidHandler; - public void updateEntity(){ + public void updateEntity() { this.ticksElapsed++; - if(!this.world.isRemote){ - if(this.shareEnergy){ - ISharingEnergyProvider provider = (ISharingEnergyProvider)this; - if(provider.doesShareEnergy()){ + if (!this.world.isRemote) { + if (this.shareEnergy) { + ISharingEnergyProvider provider = (ISharingEnergyProvider) this; + if (provider.doesShareEnergy()) { int total = provider.getEnergyToSplitShare(); - if(total > 0){ + if (total > 0) { EnumFacing[] sides = provider.getEnergyShareSides(); - int amount = total/sides.length; - if(amount <= 0){ + int amount = total / sides.length; + if (amount <= 0) { amount = total; } - for(EnumFacing side : sides){ + for (EnumFacing side : sides) { TileEntity tile = this.tilesAround[side.ordinal()]; - if(tile != null && provider.canShareTo(tile)){ + if (tile != null && provider.canShareTo(tile)) { WorldUtil.doEnergyInteraction(this, tile, side, amount); } } @@ -256,21 +253,21 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{ } } - if(this.shareFluid){ - ISharingFluidHandler handler = (ISharingFluidHandler)this; - if(handler.doesShareFluid()){ + if (this.shareFluid) { + ISharingFluidHandler handler = (ISharingFluidHandler) this; + if (handler.doesShareFluid()) { int total = handler.getMaxFluidAmountToSplitShare(); - if(total > 0){ + if (total > 0) { EnumFacing[] sides = handler.getFluidShareSides(); - int amount = total/sides.length; - if(amount <= 0){ + int amount = total / sides.length; + if (amount <= 0) { amount = total; } - for(EnumFacing side : sides){ + for (EnumFacing side : sides) { TileEntity tile = this.tilesAround[side.ordinal()]; - if(tile != null){ + if (tile != null) { WorldUtil.doFluidInteraction(this, tile, side, amount); } } @@ -278,8 +275,8 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{ } } - if(!this.hasSavedDataOnChangeOrWorldStart){ - if(this.shouldSaveDataOnChangeOrWorldStart()){ + if (!this.hasSavedDataOnChangeOrWorldStart) { + if (this.shouldSaveDataOnChangeOrWorldStart()) { this.saveDataOnChangeOrWorldStart(); } @@ -288,88 +285,79 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{ } } - public void saveDataOnChangeOrWorldStart(){ - for(EnumFacing side : EnumFacing.values()){ + public void saveDataOnChangeOrWorldStart() { + for (EnumFacing side : EnumFacing.values()) { BlockPos pos = this.pos.offset(side); - if(this.world.isBlockLoaded(pos)){ + if (this.world.isBlockLoaded(pos)) { this.tilesAround[side.ordinal()] = this.world.getTileEntity(pos); } } } - public boolean shouldSaveDataOnChangeOrWorldStart(){ + public boolean shouldSaveDataOnChangeOrWorldStart() { return this instanceof ISharingEnergyProvider || this instanceof ISharingFluidHandler; } - public void setRedstonePowered(boolean powered){ + public void setRedstonePowered(boolean powered) { this.isRedstonePowered = powered; this.markDirty(); } - public boolean canPlayerUse(EntityPlayer player){ - return player.getDistanceSq(this.getPos().getX()+0.5D, this.pos.getY()+0.5D, this.pos.getZ()+0.5D) <= 64 && !this.isInvalid() && this.world.getTileEntity(this.pos) == this; + public boolean canPlayerUse(EntityPlayer player) { + return player.getDistanceSq(this.getPos().getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D) <= 64 && !this.isInvalid() && this.world.getTileEntity(this.pos) == this; } - protected boolean sendUpdateWithInterval(){ - if(this.ticksElapsed%ConfigIntValues.TILE_ENTITY_UPDATE_INTERVAL.getValue() == 0){ + protected boolean sendUpdateWithInterval() { + if (this.ticksElapsed % ConfigIntValues.TILE_ENTITY_UPDATE_INTERVAL.getValue() == 0) { this.sendUpdate(); return true; - } - else{ + } else { return false; } } @Override - public boolean hasCapability(Capability capability, EnumFacing facing){ + public boolean hasCapability(Capability capability, EnumFacing facing) { return this.getCapability(capability, facing) != null; } @SuppressWarnings("unchecked") @Override - public T getCapability(Capability capability, EnumFacing facing){ - if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY){ + public T getCapability(Capability capability, EnumFacing facing) { + if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { IItemHandler handler = this.getItemHandler(facing); - if(handler != null){ - return (T)handler; - } - } - else if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY){ + if (handler != null) { return (T) handler; } + } else if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { IFluidHandler tank = this.getFluidHandler(facing); - if(tank != null){ - return (T)tank; - } - } - else if(capability == CapabilityEnergy.ENERGY){ + if (tank != null) { return (T) tank; } + } else if (capability == CapabilityEnergy.ENERGY) { IEnergyStorage storage = this.getEnergyStorage(facing); - if(storage != null){ - return (T)storage; - } + if (storage != null) { return (T) storage; } } return super.getCapability(capability, facing); } - public IFluidHandler getFluidHandler(EnumFacing facing){ + public IFluidHandler getFluidHandler(EnumFacing facing) { return null; } - public IEnergyStorage getEnergyStorage(EnumFacing facing){ + public IEnergyStorage getEnergyStorage(EnumFacing facing) { return null; } - public IItemHandler getItemHandler(EnumFacing facing){ + public IItemHandler getItemHandler(EnumFacing facing) { return null; } - public boolean isRedstoneToggle(){ + public boolean isRedstoneToggle() { return false; } - public void activateOnPulse(){ + public void activateOnPulse() { } - public boolean respondsToPulses(){ + public boolean respondsToPulses() { return this.isRedstoneToggle() && this.isPulseMode; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBatteryBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBatteryBox.java index 3494456cb..5666d55e8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBatteryBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBatteryBox.java @@ -23,60 +23,58 @@ import net.minecraft.util.EnumFacing; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; -public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISharingEnergyProvider{ +public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISharingEnergyProvider { private int lastEnergyStored; private int lastCompare; - public TileEntityBatteryBox(){ + public TileEntityBatteryBox() { super(1, "batteryBox"); } @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing){ + public IEnergyStorage getEnergyStorage(EnumFacing facing) { ItemStack stack = this.inv.getStackInSlot(0); - if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery){ - if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){ - return stack.getCapability(CapabilityEnergy.ENERGY, null); - } + if (StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery) { + if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) { return stack.getCapability(CapabilityEnergy.ENERGY, null); } } return null; } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ + if (!this.world.isRemote) { int currStorage = 0; IEnergyStorage storage = this.getEnergyStorage(null); - if(storage != null){ + if (storage != null) { ItemStack stack = this.inv.getStackInSlot(0); - if(StackUtil.isValid(stack) && ItemUtil.isEnabled(stack)){ - if(storage.getEnergyStored() > 0){ + if (StackUtil.isValid(stack) && ItemUtil.isEnabled(stack)) { + if (storage.getEnergyStored() > 0) { List tiles = new ArrayList<>(); this.energyPushOffLoop(this, tiles); - if(!tiles.isEmpty()){ + if (!tiles.isEmpty()) { int amount = tiles.size(); - int energyPer = storage.getEnergyStored()/amount; - if(energyPer <= 0){ + int energyPer = storage.getEnergyStored() / amount; + if (energyPer <= 0) { energyPer = storage.getEnergyStored(); } int maxPer = storage.extractEnergy(energyPer, true); - for(TileEntityBatteryBox tile : tiles){ + for (TileEntityBatteryBox tile : tiles) { ItemStack battery = tile.inv.getStackInSlot(0); - if(StackUtil.isValid(battery) && !ItemUtil.isEnabled(battery)){ - if(tile.hasCapability(CapabilityEnergy.ENERGY, null)){ + if (StackUtil.isValid(battery) && !ItemUtil.isEnabled(battery)) { + if (tile.hasCapability(CapabilityEnergy.ENERGY, null)) { IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, null); - if(cap != null){ + if (cap != null) { int received = cap.receiveEnergy(maxPer, false); storage.extractEnergy(received, false); - if(storage.getEnergyStored() <= 0){ + if (storage.getEnergyStored() <= 0) { break; } } @@ -90,52 +88,49 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh currStorage = storage.getEnergyStored(); } - if(this.lastCompare != this.getComparatorStrength()){ + if (this.lastCompare != this.getComparatorStrength()) { this.lastCompare = this.getComparatorStrength(); this.markDirty(); } - if(this.lastEnergyStored != currStorage && this.sendUpdateWithInterval()){ + if (this.lastEnergyStored != currStorage && this.sendUpdateWithInterval()) { this.lastEnergyStored = currStorage; } } } @Override - public int getComparatorStrength(){ + public int getComparatorStrength() { IEnergyStorage storage = this.getEnergyStorage(null); - if(storage != null){ - float calc = (float)storage.getEnergyStored()/(float)storage.getMaxEnergyStored()*15F; - return (int)calc; - } - else{ + if (storage != null) { + float calc = (float) storage.getEnergyStored() / (float) storage.getMaxEnergyStored() * 15F; + return (int) calc; + } else { return 0; } } @Override - public boolean respondsToPulses(){ + public boolean respondsToPulses() { return true; } @Override - public void activateOnPulse(){ + public void activateOnPulse() { ItemStack stack = this.inv.getStackInSlot(0); - if(StackUtil.isValid(stack)){ + if (StackUtil.isValid(stack)) { ItemUtil.changeEnabled(stack); this.markDirty(); } } - private void energyPushOffLoop(TileEntityBatteryBox startTile, List pushOffTo){ - if(pushOffTo.size() >= 15){ - return; - } + private void energyPushOffLoop(TileEntityBatteryBox startTile, List pushOffTo) { + if (pushOffTo.size() >= 15) { return; } - for(TileEntity tile : startTile.tilesAround){ - if(tile instanceof TileEntityBatteryBox){ - TileEntityBatteryBox box = (TileEntityBatteryBox)tile; - if(!pushOffTo.contains(box)){ + for (TileEntity tile : startTile.tilesAround) { + if (tile instanceof TileEntityBatteryBox) { + TileEntityBatteryBox box = (TileEntityBatteryBox) tile; + if (!pushOffTo.contains(box)) { pushOffTo.add(box); this.energyPushOffLoop(box, pushOffTo); @@ -145,38 +140,37 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh } @Override - public IAcceptor getAcceptor(){ + public IAcceptor getAcceptor() { return (slot, stack, automation) -> stack.getItem() instanceof ItemBattery; } @Override - public boolean shouldSyncSlots(){ + public boolean shouldSyncSlots() { return true; } @Override - public int getEnergyToSplitShare(){ + public int getEnergyToSplitShare() { IEnergyStorage storage = this.getEnergyStorage(null); - if(storage != null){ + if (storage != null) { return storage.getEnergyStored(); - } - else{ + } else { return 0; } } @Override - public boolean doesShareEnergy(){ + public boolean doesShareEnergy() { return true; } @Override - public EnumFacing[] getEnergyShareSides(){ + public EnumFacing[] getEnergyShareSides() { return EnumFacing.values(); } @Override - public boolean canShareTo(TileEntity tile){ + public boolean canShareTo(TileEntity tile) { return !(tile instanceof TileEntityBatteryBox); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java index bf31ae601..6057499b4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java @@ -20,85 +20,82 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraftforge.energy.IEnergyStorage; -public class TileEntityDisplayStand extends TileEntityInventoryBase implements IEnergyDisplay{ +public class TileEntityDisplayStand extends TileEntityInventoryBase implements IEnergyDisplay { public final CustomEnergyStorage storage = new CustomEnergyStorage(80000, 1000, 0); private int oldEnergy; - public TileEntityDisplayStand(){ + public TileEntityDisplayStand() { super(1, "displayStand"); } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ - if(StackUtil.isValid(this.inv.getStackInSlot(0)) && !this.isRedstonePowered){ + if (!this.world.isRemote) { + if (StackUtil.isValid(this.inv.getStackInSlot(0)) && !this.isRedstonePowered) { IDisplayStandItem item = this.convertToDisplayStandItem(this.inv.getStackInSlot(0).getItem()); - if(item != null){ + if (item != null) { int energy = item.getUsePerTick(this.inv.getStackInSlot(0), this, this.ticksElapsed); - if(this.storage.getEnergyStored() >= energy){ - if(item.update(this.inv.getStackInSlot(0), this, this.ticksElapsed)){ + if (this.storage.getEnergyStored() >= energy) { + if (item.update(this.inv.getStackInSlot(0), this, this.ticksElapsed)) { this.storage.extractEnergyInternal(energy, false); } } } } - if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){ + if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { this.oldEnergy = this.storage.getEnergyStored(); } } } @Override - public boolean shouldSyncSlots(){ + public boolean shouldSyncSlots() { return true; } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); } - private IDisplayStandItem convertToDisplayStandItem(Item item){ - if(item instanceof IDisplayStandItem){ - return (IDisplayStandItem)item; - } - else if(item instanceof ItemBlock){ + private IDisplayStandItem convertToDisplayStandItem(Item item) { + if (item instanceof IDisplayStandItem) { + return (IDisplayStandItem) item; + } else if (item instanceof ItemBlock) { Block block = Block.getBlockFromItem(item); - if(block instanceof IDisplayStandItem){ - return (IDisplayStandItem)block; - } + if (block instanceof IDisplayStandItem) { return (IDisplayStandItem) block; } } return null; } @Override - public CustomEnergyStorage getEnergyStorage(){ + public CustomEnergyStorage getEnergyStorage() { return this.storage; } @Override - public boolean needsHoldShift(){ + public boolean needsHoldShift() { return false; } @Override - public int getMaxStackSize(int slot){ + public int getMaxStackSize(int slot) { return 1; } @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing){ + public IEnergyStorage getEnergyStorage(EnumFacing facing) { return this.storage; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java index eb26f6380..e7cb15f6b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java @@ -16,52 +16,50 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class TileEntityDropper extends TileEntityInventoryBase{ +public class TileEntityDropper extends TileEntityInventoryBase { private int currentTime; - public TileEntityDropper(){ + public TileEntityDropper() { super(9, "dropper"); } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { compound.setInteger("CurrentTime", this.currentTime); } } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { this.currentTime = compound.getInteger("CurrentTime"); } } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ - if(!this.isRedstonePowered && !this.isPulseMode){ - if(this.currentTime > 0){ + if (!this.world.isRemote) { + if (!this.isRedstonePowered && !this.isPulseMode) { + if (this.currentTime > 0) { this.currentTime--; - if(this.currentTime <= 0){ + if (this.currentTime <= 0) { this.doWork(); } - } - else{ + } else { this.currentTime = 5; } } } } - - private void doWork(){ + private void doWork() { ItemStack theoreticalRemove = this.removeFromInventory(false); - if(StackUtil.isValid(theoreticalRemove)){ + if (StackUtil.isValid(theoreticalRemove)) { IBlockState state = this.world.getBlockState(this.pos); ItemStack drop = theoreticalRemove.copy(); drop.setCount(1); @@ -70,11 +68,11 @@ public class TileEntityDropper extends TileEntityInventoryBase{ } } - public ItemStack removeFromInventory(boolean actuallyDo){ - for(int i = 0; i < this.inv.getSlots(); i++){ - if(StackUtil.isValid(this.inv.getStackInSlot(i))){ + public ItemStack removeFromInventory(boolean actuallyDo) { + for (int i = 0; i < this.inv.getSlots(); i++) { + if (StackUtil.isValid(this.inv.getStackInSlot(i))) { ItemStack slot = this.inv.getStackInSlot(i).copy(); - if(actuallyDo){ + if (actuallyDo) { this.inv.setStackInSlot(i, StackUtil.shrink(this.inv.getStackInSlot(i), 1)); this.markDirty(); } @@ -85,12 +83,12 @@ public class TileEntityDropper extends TileEntityInventoryBase{ } @Override - public boolean isRedstoneToggle(){ + public boolean isRedstoneToggle() { return true; } @Override - public void activateOnPulse(){ + public void activateOnPulse() { this.doWork(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java index d41c5b6cf..961e9b8e5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java @@ -18,9 +18,9 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.farmer.FarmerResult; import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior; import de.ellpeck.actuallyadditions.api.internal.IFarmer; +import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.BlockHorizontal; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java index 9bcd9ea19..2827558f0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java @@ -21,23 +21,23 @@ import net.minecraftforge.fluids.capability.templates.FluidHandlerFluidMap; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityFermentingBarrel extends TileEntityBase implements ISharingFluidHandler{ +public class TileEntityFermentingBarrel extends TileEntityBase implements ISharingFluidHandler { private static final int PROCESS_TIME = 100; - public final FluidTank canolaTank = new FluidTank(2*Util.BUCKET){ + public final FluidTank canolaTank = new FluidTank(2 * Util.BUCKET) { @Override - public boolean canDrain(){ + public boolean canDrain() { return false; } @Override - public boolean canFillFluidType(FluidStack fluid){ + public boolean canFillFluidType(FluidStack fluid) { return fluid.getFluid() == InitFluids.fluidCanolaOil; } }; - public final FluidTank oilTank = new FluidTank(2*Util.BUCKET){ + public final FluidTank oilTank = new FluidTank(2 * Util.BUCKET) { @Override - public boolean canFill(){ + public boolean canFill() { return false; } }; @@ -49,7 +49,7 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari private int lastProcessTime; private int lastCompare; - public TileEntityFermentingBarrel(){ + public TileEntityFermentingBarrel() { super("fermentingBarrel"); this.handlerMap = new FluidHandlerFluidMap(); @@ -58,7 +58,7 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { compound.setInteger("ProcessTime", this.currentProcessTime); this.canolaTank.writeToNBT(compound); NBTTagCompound tag = new NBTTagCompound(); @@ -68,42 +68,41 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { this.currentProcessTime = compound.getInteger("ProcessTime"); this.canolaTank.readFromNBT(compound); NBTTagCompound tag = compound.getCompoundTag("OilTank"); - if(tag != null){ + if (tag != null) { this.oilTank.readFromNBT(tag); } super.readSyncableNBT(compound, type); } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ + if (!this.world.isRemote) { int produce = 80; - if(this.canolaTank.getFluidAmount() >= produce && produce <= this.oilTank.getCapacity()-this.oilTank.getFluidAmount()){ + if (this.canolaTank.getFluidAmount() >= produce && produce <= this.oilTank.getCapacity() - this.oilTank.getFluidAmount()) { this.currentProcessTime++; - if(this.currentProcessTime >= PROCESS_TIME){ + if (this.currentProcessTime >= PROCESS_TIME) { this.currentProcessTime = 0; this.oilTank.fillInternal(new FluidStack(InitFluids.fluidRefinedCanolaOil, produce), true); this.canolaTank.drainInternal(produce, true); } - } - else{ + } else { this.currentProcessTime = 0; } int compare = this.getComparatorStrength(); - if(compare != this.lastCompare){ + if (compare != this.lastCompare) { this.lastCompare = compare; this.markDirty(); } - if((this.canolaTank.getFluidAmount() != this.lastCanola || this.oilTank.getFluidAmount() != this.lastOil || this.currentProcessTime != this.lastProcessTime) && this.sendUpdateWithInterval()){ + if ((this.canolaTank.getFluidAmount() != this.lastCanola || this.oilTank.getFluidAmount() != this.lastOil || this.currentProcessTime != this.lastProcessTime) && this.sendUpdateWithInterval()) { this.lastProcessTime = this.currentProcessTime; this.lastCanola = this.canolaTank.getFluidAmount(); this.lastOil = this.oilTank.getFluidAmount(); @@ -112,43 +111,43 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari } @Override - public int getComparatorStrength(){ - float calc = (float)this.oilTank.getFluidAmount()/(float)this.oilTank.getCapacity()*15F; - return (int)calc; + public int getComparatorStrength() { + float calc = (float) this.oilTank.getFluidAmount() / (float) this.oilTank.getCapacity() * 15F; + return (int) calc; } @SideOnly(Side.CLIENT) - public int getProcessScaled(int i){ - return this.currentProcessTime*i/PROCESS_TIME; + public int getProcessScaled(int i) { + return this.currentProcessTime * i / PROCESS_TIME; } @SideOnly(Side.CLIENT) - public int getOilTankScaled(int i){ - return this.oilTank.getFluidAmount()*i/this.oilTank.getCapacity(); + public int getOilTankScaled(int i) { + return this.oilTank.getFluidAmount() * i / this.oilTank.getCapacity(); } @SideOnly(Side.CLIENT) - public int getCanolaTankScaled(int i){ - return this.canolaTank.getFluidAmount()*i/this.canolaTank.getCapacity(); + public int getCanolaTankScaled(int i) { + return this.canolaTank.getFluidAmount() * i / this.canolaTank.getCapacity(); } @Override - public IFluidHandler getFluidHandler(EnumFacing facing){ + public IFluidHandler getFluidHandler(EnumFacing facing) { return this.handlerMap; } @Override - public int getMaxFluidAmountToSplitShare(){ + public int getMaxFluidAmountToSplitShare() { return this.oilTank.getFluidAmount(); } @Override - public boolean doesShareFluid(){ + public boolean doesShareFluid() { return true; } @Override - public EnumFacing[] getFluidShareSides(){ + public EnumFacing[] getFluidShareSides() { return EnumFacing.values(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java index cde1c0b27..6593f1158 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.tile; +import java.util.ArrayList; +import java.util.List; + import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor; import net.minecraft.entity.item.EntityFireworkRocket; import net.minecraft.entity.player.EntityPlayer; @@ -25,10 +28,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.energy.IEnergyStorage; -import java.util.ArrayList; -import java.util.List; - -public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisplay, INumberReactor{ +public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisplay, INumberReactor { public static final int USE_PER_SHOT = 500; public final CustomEnergyStorage storage = new CustomEnergyStorage(20000, 200, 0); @@ -47,16 +47,16 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp private int timeUntilNextFirework; private int oldEnergy; - public TileEntityFireworkBox(){ + public TileEntityFireworkBox() { super("fireworkBox"); } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { compound.setInteger("Play", this.intValuePlay); compound.setInteger("ChargeAmount", this.chargeAmount); compound.setInteger("FlightTime", this.flightTime); @@ -73,11 +73,11 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { this.intValuePlay = compound.getInteger("Play"); this.chargeAmount = compound.getInteger("ChargeAmount"); this.flightTime = compound.getInteger("FlightTime"); @@ -94,79 +94,78 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp } @Override - public void onNumberReceived(double number, int id, EntityPlayer player){ - switch(id){ + public void onNumberReceived(double number, int id, EntityPlayer player) { + switch (id) { case 0: - this.intValuePlay = (int)number; + this.intValuePlay = (int) number; break; case 1: - this.chargeAmount = (int)number; + this.chargeAmount = (int) number; break; case 2: - this.flightTime = (int)number; + this.flightTime = (int) number; break; case 3: - this.trailOrFlickerChance = (float)number; + this.trailOrFlickerChance = (float) number; break; case 4: - this.flickerChance = (float)number; + this.flickerChance = (float) number; break; case 5: - this.colorAmount = (int)number; + this.colorAmount = (int) number; break; case 6: - this.typeChance0 = (float)number; + this.typeChance0 = (float) number; break; case 7: - this.typeChance1 = (float)number; + this.typeChance1 = (float) number; break; case 8: - this.typeChance2 = (float)number; + this.typeChance2 = (float) number; break; case 9: - this.typeChance3 = (float)number; + this.typeChance3 = (float) number; break; case 10: - this.typeChance4 = (float)number; + this.typeChance4 = (float) number; break; case 11: - this.areaOfEffect = (int)number; + this.areaOfEffect = (int) number; break; } this.sendUpdate(); } - public void spawnFireworks(World world, double x, double y, double z){ + public void spawnFireworks(World world, double x, double y, double z) { ItemStack firework = this.makeFirework(); - double newX = x+this.getRandomAoe(); - double newZ = z+this.getRandomAoe(); + double newX = x + this.getRandomAoe(); + double newZ = z + this.getRandomAoe(); - if(world.isBlockLoaded(new BlockPos(newX, y, newZ))){ - EntityFireworkRocket rocket = new EntityFireworkRocket(world, newX, y+1, newZ, firework); + if (world.isBlockLoaded(new BlockPos(newX, y, newZ))) { + EntityFireworkRocket rocket = new EntityFireworkRocket(world, newX, y + 1, newZ, firework); world.spawnEntity(rocket); } } - private double getRandomAoe(){ - if(this.areaOfEffect <= 0){ + private double getRandomAoe() { + if (this.areaOfEffect <= 0) { return 0.5; - } - else{ - return MathHelper.nextDouble(this.world.rand, 0, this.areaOfEffect*2)-this.areaOfEffect; + } else { + return MathHelper.nextDouble(this.world.rand, 0, this.areaOfEffect * 2) - this.areaOfEffect; } } - private ItemStack makeFirework(){ + private ItemStack makeFirework() { NBTTagList list = new NBTTagList(); - for(int i = 0; i < this.getRandomWithPlay(this.chargeAmount); i++){ + for (int i = 0; i < this.getRandomWithPlay(this.chargeAmount); i++) { list.appendTag(this.makeFireworkCharge()); } NBTTagCompound compound1 = new NBTTagCompound(); compound1.setTag("Explosions", list); - compound1.setByte("Flight", (byte)this.getRandomWithPlay(this.flightTime)); + compound1.setByte("Flight", (byte) this.getRandomWithPlay(this.flightTime)); NBTTagCompound compound = new NBTTagCompound(); compound.setTag("Fireworks", compound1); @@ -177,34 +176,33 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp return firework; } - private NBTTagCompound makeFireworkCharge(){ + private NBTTagCompound makeFireworkCharge() { NBTTagCompound compound = new NBTTagCompound(); - if(this.world.rand.nextFloat() <= this.trailOrFlickerChance){ - if(this.world.rand.nextFloat() <= this.flickerChance){ + if (this.world.rand.nextFloat() <= this.trailOrFlickerChance) { + if (this.world.rand.nextFloat() <= this.flickerChance) { compound.setBoolean("Flicker", true); - } - else{ + } else { compound.setBoolean("Trail", true); } } int[] colors = new int[this.getRandomWithPlay(this.colorAmount)]; - for(int i = 0; i < colors.length; i++){ + for (int i = 0; i < colors.length; i++) { colors[i] = ItemDye.DYE_COLORS[this.world.rand.nextInt(ItemDye.DYE_COLORS.length)]; } compound.setIntArray("Colors", colors); - compound.setByte("Type", (byte)this.getRandomType()); + compound.setByte("Type", (byte) this.getRandomType()); return compound; } - private int getRandomWithPlay(int value){ - return MathHelper.clamp(MathHelper.getInt(this.world.rand, value-this.intValuePlay, value+this.intValuePlay), 1, 6); + private int getRandomWithPlay(int value) { + return MathHelper.clamp(MathHelper.getInt(this.world.rand, value - this.intValuePlay, value + this.intValuePlay), 1, 6); } - private int getRandomType(){ + private int getRandomType() { List possible = new ArrayList<>(); possible.add(new WeightedFireworkType(0, this.typeChance0)); @@ -214,39 +212,37 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp possible.add(new WeightedFireworkType(4, this.typeChance4)); int weight = WeightedRandom.getTotalWeight(possible); - if(weight <= 0){ + if (weight <= 0) { return 0; - } - else{ + } else { return WeightedRandom.getRandomItem(this.world.rand, possible, weight).type; } } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ - if(!this.isRedstonePowered && !this.isPulseMode){ - if(this.timeUntilNextFirework > 0){ + if (!this.world.isRemote) { + if (!this.isRedstonePowered && !this.isPulseMode) { + if (this.timeUntilNextFirework > 0) { this.timeUntilNextFirework--; - if(this.timeUntilNextFirework <= 0){ + if (this.timeUntilNextFirework <= 0) { this.doWork(); } - } - else{ + } else { this.timeUntilNextFirework = 100; } } - if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){ + if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { this.oldEnergy = this.storage.getEnergyStored(); } } } - private void doWork(){ - if(this.storage.getEnergyStored() >= USE_PER_SHOT){ + private void doWork() { + if (this.storage.getEnergyStored() >= USE_PER_SHOT) { this.spawnFireworks(this.world, this.pos.getX(), this.pos.getY(), this.pos.getZ()); this.storage.extractEnergyInternal(USE_PER_SHOT, false); @@ -254,36 +250,36 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp } @Override - public boolean isRedstoneToggle(){ + public boolean isRedstoneToggle() { return true; } @Override - public void activateOnPulse(){ + public void activateOnPulse() { this.doWork(); } @Override - public CustomEnergyStorage getEnergyStorage(){ + public CustomEnergyStorage getEnergyStorage() { return this.storage; } @Override - public boolean needsHoldShift(){ + public boolean needsHoldShift() { return false; } @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing){ + public IEnergyStorage getEnergyStorage(EnumFacing facing) { return this.storage; } - private static class WeightedFireworkType extends WeightedRandom.Item{ + private static class WeightedFireworkType extends WeightedRandom.Item { public final int type; - public WeightedFireworkType(int type, float chance){ - super((int)(chance*100F)); + public WeightedFireworkType(int type, float chance) { + super((int) (chance * 100F)); this.type = type; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFishingNet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFishingNet.java index 070dbfc0c..27d060cf3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFishingNet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFishingNet.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.tile; +import java.util.List; + import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.material.Material; import net.minecraft.entity.item.EntityItem; @@ -23,75 +25,70 @@ import net.minecraft.world.storage.loot.LootTableList; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; -import java.util.List; - -public class TileEntityFishingNet extends TileEntityBase{ +public class TileEntityFishingNet extends TileEntityBase { public int timeUntilNextDrop; - public TileEntityFishingNet(){ + public TileEntityFishingNet() { super("fishingNet"); } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { compound.setInteger("TimeUntilNextDrop", this.timeUntilNextDrop); } } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { this.timeUntilNextDrop = compound.getInteger("TimeUntilNextDrop"); } } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ - if(!this.isRedstonePowered){ - if(this.world.getBlockState(this.pos.down()).getMaterial() == Material.WATER){ - if(this.timeUntilNextDrop > 0){ + if (!this.world.isRemote) { + if (!this.isRedstonePowered) { + if (this.world.getBlockState(this.pos.down()).getMaterial() == Material.WATER) { + if (this.timeUntilNextDrop > 0) { this.timeUntilNextDrop--; - if(this.timeUntilNextDrop <= 0){ - LootContext.Builder builder = new LootContext.Builder((WorldServer)this.world); + if (this.timeUntilNextDrop <= 0) { + LootContext.Builder builder = new LootContext.Builder((WorldServer) this.world); List fishables = this.world.getLootTableManager().getLootTableFromLocation(LootTableList.GAMEPLAY_FISHING).generateLootForPools(this.world.rand, builder.build()); - for(ItemStack fishable : fishables){ + for (ItemStack fishable : fishables) { ItemStack leftover = this.storeInContainer(fishable); - if(StackUtil.isValid(leftover)){ - EntityItem item = new EntityItem(this.world, this.pos.getX()+0.5, this.pos.getY()+0.5, this.pos.getZ()+0.5, leftover.copy()); + if (StackUtil.isValid(leftover)) { + EntityItem item = new EntityItem(this.world, this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5, leftover.copy()); item.lifespan = 2000; this.world.spawnEntity(item); } } } - } - else{ + } else { int time = 15000; - this.timeUntilNextDrop = time+this.world.rand.nextInt(time/2); + this.timeUntilNextDrop = time + this.world.rand.nextInt(time / 2); } } } } } - private ItemStack storeInContainer(ItemStack stack){ - for(EnumFacing side : EnumFacing.values()){ + private ItemStack storeInContainer(ItemStack stack) { + for (EnumFacing side : EnumFacing.values()) { TileEntity tile = this.tilesAround[side.ordinal()]; - if(tile != null){ - if(tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite())){ + if (tile != null) { + if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite())) { IItemHandler cap = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite()); - if(cap != null){ - for(int i = 0; i < cap.getSlots(); i++){ + if (cap != null) { + for (int i = 0; i < cap.getSlots(); i++) { stack = cap.insertItem(i, stack, false); - if(!StackUtil.isValid(stack)){ - return StackUtil.getEmpty(); - } + if (!StackUtil.isValid(stack)) { return StackUtil.getEmpty(); } } } } @@ -101,7 +98,7 @@ public class TileEntityFishingNet extends TileEntityBase{ } @Override - public boolean shouldSaveDataOnChangeOrWorldStart(){ + public boolean shouldSaveDataOnChangeOrWorldStart() { return true; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java index 47befd07c..47edf2a6f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java @@ -29,17 +29,17 @@ import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.capability.IFluidHandler; -public class TileEntityFluidCollector extends TileEntityBase implements ISharingFluidHandler{ +public class TileEntityFluidCollector extends TileEntityBase implements ISharingFluidHandler { public boolean isPlacer; - public final FluidTank tank = new FluidTank(8*Util.BUCKET){ + public final FluidTank tank = new FluidTank(8 * Util.BUCKET) { @Override - public boolean canFill(){ + public boolean canFill() { return TileEntityFluidCollector.this.isPlacer; } @Override - public boolean canDrain(){ + public boolean canDrain() { return !TileEntityFluidCollector.this.isPlacer; } }; @@ -47,72 +47,68 @@ public class TileEntityFluidCollector extends TileEntityBase implements ISharing private int currentTime; private int lastCompare; - public TileEntityFluidCollector(String name){ + public TileEntityFluidCollector(String name) { super(name); } - public TileEntityFluidCollector(){ + public TileEntityFluidCollector() { this("fluidCollector"); this.isPlacer = false; } @Override - public boolean isRedstoneToggle(){ + public boolean isRedstoneToggle() { return true; } @Override - public void activateOnPulse(){ + public void activateOnPulse() { this.doWork(); } - private void doWork(){ + private void doWork() { IBlockState state = this.world.getBlockState(this.pos); EnumFacing sideToManipulate = WorldUtil.getDirectionByPistonRotation(state); BlockPos coordsBlock = this.pos.offset(sideToManipulate); IBlockState stateToBreak = this.world.getBlockState(coordsBlock); Block blockToBreak = stateToBreak.getBlock(); - if(!this.isPlacer && blockToBreak != null && blockToBreak.getMetaFromState(stateToBreak) == 0 && Util.BUCKET <= this.tank.getCapacity()-this.tank.getFluidAmount()){ - if(blockToBreak instanceof IFluidBlock && ((IFluidBlock)blockToBreak).getFluid() != null){ - if(this.tank.fillInternal(new FluidStack(((IFluidBlock)blockToBreak).getFluid(), Util.BUCKET), false) >= Util.BUCKET){ - this.tank.fillInternal(new FluidStack(((IFluidBlock)blockToBreak).getFluid(), Util.BUCKET), true); + if (!this.isPlacer && blockToBreak != null && blockToBreak.getMetaFromState(stateToBreak) == 0 && Util.BUCKET <= this.tank.getCapacity() - this.tank.getFluidAmount()) { + if (blockToBreak instanceof IFluidBlock && ((IFluidBlock) blockToBreak).getFluid() != null) { + if (this.tank.fillInternal(new FluidStack(((IFluidBlock) blockToBreak).getFluid(), Util.BUCKET), false) >= Util.BUCKET) { + this.tank.fillInternal(new FluidStack(((IFluidBlock) blockToBreak).getFluid(), Util.BUCKET), true); this.world.setBlockToAir(coordsBlock); } - } - else if(blockToBreak == Blocks.LAVA || blockToBreak == Blocks.FLOWING_LAVA){ - if(this.tank.fillInternal(new FluidStack(FluidRegistry.LAVA, Util.BUCKET), false) >= Util.BUCKET){ + } else if (blockToBreak == Blocks.LAVA || blockToBreak == Blocks.FLOWING_LAVA) { + if (this.tank.fillInternal(new FluidStack(FluidRegistry.LAVA, Util.BUCKET), false) >= Util.BUCKET) { this.tank.fillInternal(new FluidStack(FluidRegistry.LAVA, Util.BUCKET), true); this.world.setBlockToAir(coordsBlock); } - } - else if(blockToBreak == Blocks.WATER || blockToBreak == Blocks.FLOWING_WATER){ - if(this.tank.fillInternal(new FluidStack(FluidRegistry.WATER, Util.BUCKET), false) >= Util.BUCKET){ + } else if (blockToBreak == Blocks.WATER || blockToBreak == Blocks.FLOWING_WATER) { + if (this.tank.fillInternal(new FluidStack(FluidRegistry.WATER, Util.BUCKET), false) >= Util.BUCKET) { this.tank.fillInternal(new FluidStack(FluidRegistry.WATER, Util.BUCKET), true); this.world.setBlockToAir(coordsBlock); } } - } - else if(this.isPlacer && blockToBreak.isReplaceable(this.world, coordsBlock)){ - if(this.tank.getFluidAmount() >= Util.BUCKET){ + } else if (this.isPlacer && blockToBreak.isReplaceable(this.world, coordsBlock)) { + if (this.tank.getFluidAmount() >= Util.BUCKET) { FluidStack stack = this.tank.getFluid(); Block fluid = stack.getFluid().getBlock(); - if(fluid != null){ + if (fluid != null) { BlockPos offsetPos = this.pos.offset(sideToManipulate); boolean placeable = !(blockToBreak instanceof BlockLiquid) && !(blockToBreak instanceof IFluidBlock) && blockToBreak.isReplaceable(this.world, offsetPos); - if(placeable){ + if (placeable) { this.tank.drainInternal(Util.BUCKET, true); - if(this.world.provider.doesWaterVaporize() && stack.getFluid().doesVaporize(stack)){ - this.world.playSound(null, offsetPos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F+(this.world.rand.nextFloat()-this.world.rand.nextFloat())*0.8F); + if (this.world.provider.doesWaterVaporize() && stack.getFluid().doesVaporize(stack)) { + this.world.playSound(null, offsetPos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (this.world.rand.nextFloat() - this.world.rand.nextFloat()) * 0.8F); - if(this.world instanceof WorldServer){ - for(int l = 0; l < 8; ++l){ - ((WorldServer)this.world).spawnParticle(EnumParticleTypes.SMOKE_LARGE, false, offsetPos.getX()+Math.random(), offsetPos.getY()+Math.random(), offsetPos.getZ()+Math.random(), 1, 0.0D, 0.0D, 0.0D, 0); + if (this.world instanceof WorldServer) { + for (int l = 0; l < 8; ++l) { + ((WorldServer) this.world).spawnParticle(EnumParticleTypes.SMOKE_LARGE, false, offsetPos.getX() + Math.random(), offsetPos.getY() + Math.random(), offsetPos.getZ() + Math.random(), 1, 0.0D, 0.0D, 0.0D, 0); } } - } - else{ + } else { this.world.setBlockState(offsetPos, fluid.getDefaultState(), 3); } } @@ -122,74 +118,73 @@ public class TileEntityFluidCollector extends TileEntityBase implements ISharing } @Override - public int getComparatorStrength(){ - float calc = (float)this.tank.getFluidAmount()/(float)this.tank.getCapacity()*15F; - return (int)calc; + public int getComparatorStrength() { + float calc = (float) this.tank.getFluidAmount() / (float) this.tank.getCapacity() * 15F; + return (int) calc; } @Override - public IFluidHandler getFluidHandler(EnumFacing facing){ + public IFluidHandler getFluidHandler(EnumFacing facing) { return this.tank; } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { compound.setInteger("CurrentTime", this.currentTime); } this.tank.writeToNBT(compound); } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { this.currentTime = compound.getInteger("CurrentTime"); } this.tank.readFromNBT(compound); } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ - if(!this.isRedstonePowered && !this.isPulseMode){ - if(this.currentTime > 0){ + if (!this.world.isRemote) { + if (!this.isRedstonePowered && !this.isPulseMode) { + if (this.currentTime > 0) { this.currentTime--; - if(this.currentTime <= 0){ + if (this.currentTime <= 0) { this.doWork(); } - } - else{ + } else { this.currentTime = 15; } } - if(this.lastCompare != this.getComparatorStrength()){ + if (this.lastCompare != this.getComparatorStrength()) { this.lastCompare = this.getComparatorStrength(); this.markDirty(); } - if(this.lastTankAmount != this.tank.getFluidAmount() && this.sendUpdateWithInterval()){ + if (this.lastTankAmount != this.tank.getFluidAmount() && this.sendUpdateWithInterval()) { this.lastTankAmount = this.tank.getFluidAmount(); } } } @Override - public int getMaxFluidAmountToSplitShare(){ + public int getMaxFluidAmountToSplitShare() { return this.tank.getFluidAmount(); } @Override - public boolean doesShareFluid(){ + public boolean doesShareFluid() { return !this.isPlacer; } @Override - public EnumFacing[] getFluidShareSides(){ + public EnumFacing[] getFluidShareSides() { return EnumFacing.values(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidPlacer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidPlacer.java index 83d5d6a62..e579674c2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidPlacer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidPlacer.java @@ -10,9 +10,9 @@ package de.ellpeck.actuallyadditions.mod.tile; -public class TileEntityFluidPlacer extends TileEntityFluidCollector{ +public class TileEntityFluidPlacer extends TileEntityFluidCollector { - public TileEntityFluidPlacer(){ + public TileEntityFluidPlacer() { super("fluidPlacer"); this.isPlacer = true; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java index bafa67843..c9d572919 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java @@ -17,60 +17,58 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraftforge.energy.IEnergyStorage; -public class TileEntityFurnaceSolar extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay{ +public class TileEntityFurnaceSolar extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay { public static final int PRODUCE = 8; public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 0, 100); private int oldEnergy; - public TileEntityFurnaceSolar(){ + public TileEntityFurnaceSolar() { super("solarPanel"); } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ + if (!this.world.isRemote) { int power = this.getPowerToGenerate(PRODUCE); - if(this.world.isDaytime() && power > 0){ - if(power <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored()){ + if (this.world.isDaytime() && power > 0) { + if (power <= this.storage.getMaxEnergyStored() - this.storage.getEnergyStored()) { this.storage.receiveEnergyInternal(power, false); this.markDirty(); } } - if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){ + if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { this.oldEnergy = this.storage.getEnergyStored(); } } } - public int getPowerToGenerate(int power){ - for(int y = 1; y <= this.world.getHeight()-this.pos.getY(); y++){ - if(power > 0){ + public int getPowerToGenerate(int power) { + for (int y = 1; y <= this.world.getHeight() - this.pos.getY(); y++) { + if (power > 0) { BlockPos pos = this.pos.up(y); IBlockState state = this.world.getBlockState(pos); - if(state.getMaterial().isOpaque()){ + if (state.getMaterial().isOpaque()) { power = 0; - } - else if(!state.getBlock().isAir(state, this.world, pos)){ + } else if (!state.getBlock().isAir(state, this.world, pos)) { power--; } - } - else{ + } else { break; } } @@ -79,37 +77,37 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements ISharingEn } @Override - public CustomEnergyStorage getEnergyStorage(){ + public CustomEnergyStorage getEnergyStorage() { return this.storage; } @Override - public boolean needsHoldShift(){ + public boolean needsHoldShift() { return false; } @Override - public int getEnergyToSplitShare(){ + public int getEnergyToSplitShare() { return this.storage.getEnergyStored(); } @Override - public boolean doesShareEnergy(){ + public boolean doesShareEnergy() { return true; } @Override - public EnumFacing[] getEnergyShareSides(){ + public EnumFacing[] getEnergyShareSides() { return EnumFacing.values(); } @Override - public boolean canShareTo(TileEntity tile){ + public boolean canShareTo(TileEntity tile) { return true; } @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing){ + public IEnergyStorage getEnergyStorage(EnumFacing facing) { return this.storage; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChest.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChest.java index 7699eaadf..cd9920b0b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChest.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChest.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.tile; - import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; @@ -23,48 +22,46 @@ import net.minecraft.world.storage.loot.ILootContainer; import net.minecraft.world.storage.loot.LootContext; import net.minecraft.world.storage.loot.LootTable; -public class TileEntityGiantChest extends TileEntityInventoryBase implements IButtonReactor, ILootContainer{ +public class TileEntityGiantChest extends TileEntityInventoryBase implements IButtonReactor, ILootContainer { public ResourceLocation lootTable; - public TileEntityGiantChest(int slotAmount, String name){ + public TileEntityGiantChest(int slotAmount, String name) { super(slotAmount, name); } - public TileEntityGiantChest(){ - this(9*13, "giantChest"); + public TileEntityGiantChest() { + this(9 * 13, "giantChest"); } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); - if(this.lootTable != null){ + if (this.lootTable != null) { compound.setString("LootTable", this.lootTable.toString()); } } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); - if(compound.hasKey("LootTable")){ + if (compound.hasKey("LootTable")) { this.lootTable = new ResourceLocation(compound.getString("LootTable")); } } @Override - public void onButtonPressed(int buttonID, EntityPlayer player){ - if(player != null && this.pos != null){ + public void onButtonPressed(int buttonID, EntityPlayer player) { + if (player != null && this.pos != null) { GuiHandler.GuiTypes type; - if(buttonID == 0){ + if (buttonID == 0) { type = GuiHandler.GuiTypes.GIANT_CHEST; - } - else if(buttonID == 1){ + } else if (buttonID == 1) { type = GuiHandler.GuiTypes.GIANT_CHEST_PAGE_2; - } - else{ + } else { type = GuiHandler.GuiTypes.GIANT_CHEST_PAGE_3; } @@ -73,17 +70,17 @@ public class TileEntityGiantChest extends TileEntityInventoryBase implements IBu } @Override - public ResourceLocation getLootTable(){ + public ResourceLocation getLootTable() { return this.lootTable; } - public void fillWithLoot(EntityPlayer player){ - if(this.lootTable != null && !this.world.isRemote && this.world instanceof WorldServer){ + public void fillWithLoot(EntityPlayer player) { + if (this.lootTable != null && !this.world.isRemote && this.world instanceof WorldServer) { LootTable table = this.world.getLootTableManager().getLootTableFromLocation(this.lootTable); this.lootTable = null; - LootContext.Builder builder = new LootContext.Builder((WorldServer)this.world); - if(player != null){ + LootContext.Builder builder = new LootContext.Builder((WorldServer) this.world); + if (player != null) { builder.withLuck(player.getLuck()); } AwfulUtil.fillInventory(table, this.inv, this.world.rand, builder.build()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestLarge.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestLarge.java index 52c9e9f36..d1107b3bd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestLarge.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestLarge.java @@ -10,9 +10,9 @@ package de.ellpeck.actuallyadditions.mod.tile; -public class TileEntityGiantChestLarge extends TileEntityGiantChest{ +public class TileEntityGiantChestLarge extends TileEntityGiantChest { - public TileEntityGiantChestLarge(){ - super(9*13*3, "giantChestLarge"); + public TileEntityGiantChestLarge() { + super(9 * 13 * 3, "giantChestLarge"); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestMedium.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestMedium.java index 3a0e6c4f1..4ee048b31 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestMedium.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestMedium.java @@ -10,9 +10,9 @@ package de.ellpeck.actuallyadditions.mod.tile; -public class TileEntityGiantChestMedium extends TileEntityGiantChest{ +public class TileEntityGiantChestMedium extends TileEntityGiantChest { - public TileEntityGiantChestMedium(){ - super(9*13*2, "giantChestMedium"); + public TileEntityGiantChestMedium() { + super(9 * 13 * 2, "giantChestMedium"); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinderDouble.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinderDouble.java index 43869a514..f44310209 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinderDouble.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinderDouble.java @@ -10,9 +10,9 @@ package de.ellpeck.actuallyadditions.mod.tile; -public class TileEntityGrinderDouble extends TileEntityGrinder{ +public class TileEntityGrinderDouble extends TileEntityGrinder { - public TileEntityGrinderDouble(){ + public TileEntityGrinderDouble() { super(6, "grinderDouble"); this.isDouble = true; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java index 9a82be61d..2374fc118 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.tile; +import java.util.ArrayList; + import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.Block; import net.minecraft.block.BlockMagma; @@ -21,9 +23,7 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraftforge.energy.IEnergyStorage; -import java.util.ArrayList; - -public class TileEntityHeatCollector extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay{ +public class TileEntityHeatCollector extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay { public static final int ENERGY_PRODUCE = 40; public static final int BLOCKS_NEEDED = 4; @@ -31,54 +31,54 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE private int oldEnergy; private int disappearTime; - public TileEntityHeatCollector(){ + public TileEntityHeatCollector() { super("heatCollector"); } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); - if(type == NBTType.SAVE_TILE){ + if (type == NBTType.SAVE_TILE) { compound.setInteger("DisappearTime", this.disappearTime); } } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); - if(type == NBTType.SAVE_TILE){ + if (type == NBTType.SAVE_TILE) { this.disappearTime = compound.getInteger("DisappearTime"); } } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ + if (!this.world.isRemote) { ArrayList blocksAround = new ArrayList<>(); - if(ENERGY_PRODUCE <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored()){ - for(int i = 1; i <= 5; i++){ + if (ENERGY_PRODUCE <= this.storage.getMaxEnergyStored() - this.storage.getEnergyStored()) { + for (int i = 1; i <= 5; i++) { BlockPos coords = this.pos.offset(WorldUtil.getDirectionBySidesInOrder(i)); IBlockState state = this.world.getBlockState(coords); Block block = state.getBlock(); - if(block != null && this.world.getBlockState(coords).getMaterial() == Material.LAVA && block.getMetaFromState(state) == 0 || this.world.getBlockState(coords).getBlock() instanceof BlockMagma){ + if (block != null && this.world.getBlockState(coords).getMaterial() == Material.LAVA && block.getMetaFromState(state) == 0 || this.world.getBlockState(coords).getBlock() instanceof BlockMagma) { blocksAround.add(i); } } - if(blocksAround.size() >= BLOCKS_NEEDED){ + if (blocksAround.size() >= BLOCKS_NEEDED) { this.storage.receiveEnergyInternal(ENERGY_PRODUCE, false); this.markDirty(); this.disappearTime++; - if(this.disappearTime >= 1000){ + if (this.disappearTime >= 1000) { this.disappearTime = 0; - if(this.world.rand.nextInt(200) == 0){ + if (this.world.rand.nextInt(200) == 0) { int randomSide = blocksAround.get(this.world.rand.nextInt(blocksAround.size())); this.world.setBlockToAir(this.pos.offset(WorldUtil.getDirectionBySidesInOrder(randomSide))); } @@ -86,44 +86,44 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE } } - if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){ + if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { this.oldEnergy = this.storage.getEnergyStored(); } } } @Override - public CustomEnergyStorage getEnergyStorage(){ + public CustomEnergyStorage getEnergyStorage() { return this.storage; } @Override - public boolean needsHoldShift(){ + public boolean needsHoldShift() { return false; } @Override - public int getEnergyToSplitShare(){ + public int getEnergyToSplitShare() { return this.storage.getEnergyStored(); } @Override - public boolean doesShareEnergy(){ + public boolean doesShareEnergy() { return true; } @Override - public EnumFacing[] getEnergyShareSides(){ + public EnumFacing[] getEnergyShareSides() { return EnumFacing.values(); } @Override - public boolean canShareTo(TileEntity tile){ + public boolean canShareTo(TileEntity tile) { return true; } @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing){ + public IEnergyStorage getEnergyStorage(EnumFacing facing) { return this.storage; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputterAdvanced.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputterAdvanced.java index cc45ae624..fc334bd2c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputterAdvanced.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputterAdvanced.java @@ -10,9 +10,9 @@ package de.ellpeck.actuallyadditions.mod.tile; -public class TileEntityInputterAdvanced extends TileEntityInputter{ +public class TileEntityInputterAdvanced extends TileEntityInputter { - public TileEntityInputterAdvanced(){ + public TileEntityInputterAdvanced() { super(1, "inputterAdvanced"); this.isAdvanced = true; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java index 5ce6689a4..f862c6158 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java @@ -10,6 +10,15 @@ package de.ellpeck.actuallyadditions.mod.tile; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler; +import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig; + import de.ellpeck.actuallyadditions.api.laser.Network; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.network.PacketHandler; @@ -27,12 +36,8 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.items.IItemHandler; -import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler; -import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig; -import java.util.*; - -public class TileEntityItemViewer extends TileEntityBase{ +public class TileEntityItemViewer extends TileEntityBase { public final List genericInfos = new ArrayList<>(); public final Map itemHandlerInfos = new HashMap<>(); @@ -41,20 +46,20 @@ public class TileEntityItemViewer extends TileEntityBase{ public TileEntityLaserRelayItem connectedRelay; private int lastNetworkChangeAmount = -1; - public TileEntityItemViewer(String name){ + public TileEntityItemViewer(String name) { super(name); - IItemHandler normalHandler = new IItemHandler(){ + IItemHandler normalHandler = new IItemHandler() { @Override - public int getSlots(){ + public int getSlots() { int size = 0; List infos = TileEntityItemViewer.this.getItemHandlerInfos(); - if(infos != null){ - for(GenericItemHandlerInfo info : infos){ - if(info.isLoaded()){ - for(SlotlessableItemHandlerWrapper handler : info.handlers){ + if (infos != null) { + for (GenericItemHandlerInfo info : infos) { + if (info.isLoaded()) { + for (SlotlessableItemHandlerWrapper handler : info.handlers) { IItemHandler normalHandler = handler.getNormalHandler(); - if(normalHandler != null){ + if (normalHandler != null) { size += normalHandler.getSlots(); } } @@ -65,20 +70,18 @@ public class TileEntityItemViewer extends TileEntityBase{ } @Override - public ItemStack getStackInSlot(int slot){ + public ItemStack getStackInSlot(int slot) { IItemHandlerInfo handler = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); - if(handler != null && handler.isLoaded()){ - return handler.handler.getStackInSlot(handler.switchedIndex); - } + if (handler != null && handler.isLoaded()) { return handler.handler.getStackInSlot(handler.switchedIndex); } return StackUtil.getEmpty(); } @Override - public ItemStack insertItem(int slot, ItemStack stack, boolean simulate){ + public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { IItemHandlerInfo info = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); - if(info != null && info.isLoaded() && TileEntityItemViewer.this.isWhitelisted(info, stack, false)){ + if (info != null && info.isLoaded() && TileEntityItemViewer.this.isWhitelisted(info, stack, false)) { ItemStack remain = info.handler.insertItem(info.switchedIndex, stack, simulate); - if(!ItemStack.areItemStacksEqual(remain, stack) && !simulate){ + if (!ItemStack.areItemStacksEqual(remain, stack) && !simulate) { TileEntityItemViewer.this.markDirty(); TileEntityItemViewer.this.doItemParticle(stack, info.relayInQuestion.getPos(), TileEntityItemViewer.this.connectedRelay.getPos()); } @@ -88,13 +91,13 @@ public class TileEntityItemViewer extends TileEntityBase{ } @Override - public ItemStack extractItem(int slot, int amount, boolean simulate){ + public ItemStack extractItem(int slot, int amount, boolean simulate) { ItemStack stackIn = this.getStackInSlot(slot); - if(StackUtil.isValid(stackIn)){ + if (StackUtil.isValid(stackIn)) { IItemHandlerInfo info = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); - if(info != null && info.isLoaded() && TileEntityItemViewer.this.isWhitelisted(info, stackIn, true)){ + if (info != null && info.isLoaded() && TileEntityItemViewer.this.isWhitelisted(info, stackIn, true)) { ItemStack extracted = info.handler.extractItem(info.switchedIndex, amount, simulate); - if(StackUtil.isValid(extracted) && !simulate){ + if (StackUtil.isValid(extracted) && !simulate) { TileEntityItemViewer.this.markDirty(); TileEntityItemViewer.this.doItemParticle(extracted, TileEntityItemViewer.this.connectedRelay.getPos(), info.relayInQuestion.getPos()); } @@ -105,55 +108,52 @@ public class TileEntityItemViewer extends TileEntityBase{ } @Override - public int getSlotLimit(int slot){ + public int getSlotLimit(int slot) { IItemHandlerInfo info = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); - if(info != null && info.isLoaded()){ + if (info != null && info.isLoaded()) { return info.handler.getSlotLimit(info.switchedIndex); - } - else{ + } else { return 0; } } }; Object slotlessHandler = null; - if(ActuallyAdditions.commonCapsLoaded){ + if (ActuallyAdditions.commonCapsLoaded) { slotlessHandler = CommonCapsUtil.createSlotlessItemViewerHandler(this, normalHandler); } this.itemHandler = new SlotlessableItemHandlerWrapper(normalHandler, slotlessHandler); } - public TileEntityItemViewer(){ + public TileEntityItemViewer() { this("itemViewer"); } @Override - public IItemHandler getItemHandler(EnumFacing facing){ + public IItemHandler getItemHandler(EnumFacing facing) { return this.itemHandler.getNormalHandler(); } @SuppressWarnings("unchecked") @Override - public T getCapability(Capability capability, EnumFacing facing){ - if(ActuallyAdditions.commonCapsLoaded){ - if(capability == SlotlessItemHandlerConfig.CAPABILITY){ + public T getCapability(Capability capability, EnumFacing facing) { + if (ActuallyAdditions.commonCapsLoaded) { + if (capability == SlotlessItemHandlerConfig.CAPABILITY) { Object handler = this.itemHandler.getSlotlessHandler(); - if(handler != null){ - return (T)handler; - } + if (handler != null) { return (T) handler; } } } return super.getCapability(capability, facing); } - private List getItemHandlerInfos(){ + private List getItemHandlerInfos() { this.queryAndSaveData(); return this.genericInfos; } - public void doItemParticle(ItemStack stack, BlockPos input, BlockPos output){ - if(!this.world.isRemote){ + public void doItemParticle(ItemStack stack, BlockPos input, BlockPos output) { + if (!this.world.isRemote) { NBTTagCompound compound = new NBTTagCompound(); stack.writeToNBT(compound); @@ -165,42 +165,42 @@ public class TileEntityItemViewer extends TileEntityBase{ compound.setDouble("OutY", output.getY()); compound.setDouble("OutZ", output.getZ()); - int rangeSq = 16*16; - for(EntityPlayer player : this.world.playerEntities){ - if(player instanceof EntityPlayerMP){ - if(player.getDistanceSq(input) <= rangeSq || player.getDistanceSq(output) <= rangeSq){ - PacketHandler.theNetwork.sendTo(new PacketServerToClient(compound, PacketHandler.LASER_PARTICLE_HANDLER), (EntityPlayerMP)player); + int rangeSq = 16 * 16; + for (EntityPlayer player : this.world.playerEntities) { + if (player instanceof EntityPlayerMP) { + if (player.getDistanceSq(input) <= rangeSq || player.getDistanceSq(output) <= rangeSq) { + PacketHandler.theNetwork.sendTo(new PacketServerToClient(compound, PacketHandler.LASER_PARTICLE_HANDLER), (EntityPlayerMP) player); } } } } } - private void queryAndSaveData(){ - if(this.connectedRelay != null){ + private void queryAndSaveData() { + if (this.connectedRelay != null) { Network network = this.connectedRelay.getNetwork(); - if(network != null){ - if(this.lastNetworkChangeAmount != network.changeAmount){ + if (network != null) { + if (this.lastNetworkChangeAmount != network.changeAmount) { this.clearInfos(); this.connectedRelay.getItemHandlersInNetwork(network, this.genericInfos); - if(!this.genericInfos.isEmpty()){ + if (!this.genericInfos.isEmpty()) { Collections.sort(this.genericInfos); int slotsQueried = 0; - for(GenericItemHandlerInfo info : this.genericInfos){ - for(SlotlessableItemHandlerWrapper handler : info.handlers){ + for (GenericItemHandlerInfo info : this.genericInfos) { + for (SlotlessableItemHandlerWrapper handler : info.handlers) { IItemHandler normalHandler = handler.getNormalHandler(); - if(normalHandler != null){ - for(int i = 0; i < normalHandler.getSlots(); i++){ + if (normalHandler != null) { + for (int i = 0; i < normalHandler.getSlots(); i++) { this.itemHandlerInfos.put(slotsQueried, new IItemHandlerInfo(normalHandler, i, info.relayInQuestion)); slotsQueried++; } } - if(ActuallyAdditions.commonCapsLoaded){ + if (ActuallyAdditions.commonCapsLoaded) { Object slotlessHandler = handler.getSlotlessHandler(); - if(slotlessHandler instanceof ISlotlessItemHandler){ + if (slotlessHandler instanceof ISlotlessItemHandler) { this.slotlessInfos.add(new SlotlessItemHandlerInfo(slotlessHandler, info.relayInQuestion)); } } @@ -218,48 +218,47 @@ public class TileEntityItemViewer extends TileEntityBase{ this.lastNetworkChangeAmount = -1; } - private void clearInfos(){ - if(!this.genericInfos.isEmpty()){ + private void clearInfos() { + if (!this.genericInfos.isEmpty()) { this.genericInfos.clear(); } - if(!this.itemHandlerInfos.isEmpty()){ + if (!this.itemHandlerInfos.isEmpty()) { this.itemHandlerInfos.clear(); } - if(!this.slotlessInfos.isEmpty()){ + if (!this.slotlessInfos.isEmpty()) { this.slotlessInfos.clear(); } } - private IItemHandlerInfo getSwitchedIndexHandler(int i){ + private IItemHandlerInfo getSwitchedIndexHandler(int i) { this.queryAndSaveData(); return this.itemHandlerInfos.get(i); } @Override - public boolean shouldSaveDataOnChangeOrWorldStart(){ + public boolean shouldSaveDataOnChangeOrWorldStart() { return true; } @Override - public void saveDataOnChangeOrWorldStart(){ + public void saveDataOnChangeOrWorldStart() { TileEntityLaserRelayItem tileFound = null; - if(this.world != null){ //Why is that even possible..? - for(int i = 0; i <= 5; i++){ + if (this.world != null) { //Why is that even possible..? + for (int i = 0; i <= 5; i++) { EnumFacing side = WorldUtil.getDirectionBySidesInOrder(i); BlockPos pos = this.getPos().offset(side); - if(this.world.isBlockLoaded(pos)){ + if (this.world.isBlockLoaded(pos)) { TileEntity tile = this.world.getTileEntity(pos); - if(tile instanceof TileEntityLaserRelayItem){ - if(tileFound != null){ + if (tile instanceof TileEntityLaserRelayItem) { + if (tileFound != null) { this.connectedRelay = null; return; - } - else{ - tileFound = (TileEntityLaserRelayItem)tile; + } else { + tileFound = (TileEntityLaserRelayItem) tile; } } } @@ -268,77 +267,74 @@ public class TileEntityItemViewer extends TileEntityBase{ this.connectedRelay = tileFound; } - public boolean isWhitelisted(SpecificItemHandlerInfo handler, ItemStack stack, boolean output){ + public boolean isWhitelisted(SpecificItemHandlerInfo handler, ItemStack stack, boolean output) { boolean whitelisted = handler.relayInQuestion.isWhitelisted(stack, output); TileEntityLaserRelayItem connected = this.connectedRelay; - if(connected != null && connected != handler.relayInQuestion){ + if (connected != null && connected != handler.relayInQuestion) { return whitelisted && connected.isWhitelisted(stack, output); - } - else{ + } else { return whitelisted; } } - public static class SlotlessItemHandlerInfo extends SpecificItemHandlerInfo{ + public static class SlotlessItemHandlerInfo extends SpecificItemHandlerInfo { public final Object handler; - public SlotlessItemHandlerInfo(Object handler, TileEntityLaserRelayItem relayInQuestion){ + public SlotlessItemHandlerInfo(Object handler, TileEntityLaserRelayItem relayInQuestion) { super(relayInQuestion); this.handler = handler; } } - private static class IItemHandlerInfo extends SpecificItemHandlerInfo{ + private static class IItemHandlerInfo extends SpecificItemHandlerInfo { public final IItemHandler handler; public final int switchedIndex; - public IItemHandlerInfo(IItemHandler handler, int switchedIndex, TileEntityLaserRelayItem relayInQuestion){ + public IItemHandlerInfo(IItemHandler handler, int switchedIndex, TileEntityLaserRelayItem relayInQuestion) { super(relayInQuestion); this.handler = handler; this.switchedIndex = switchedIndex; } } - private static class SpecificItemHandlerInfo{ + private static class SpecificItemHandlerInfo { public final TileEntityLaserRelayItem relayInQuestion; - public SpecificItemHandlerInfo(TileEntityLaserRelayItem relayInQuestion){ + public SpecificItemHandlerInfo(TileEntityLaserRelayItem relayInQuestion) { this.relayInQuestion = relayInQuestion; } - public boolean isLoaded(){ + public boolean isLoaded() { return this.relayInQuestion.hasWorld() && this.relayInQuestion.getWorld().isBlockLoaded(this.relayInQuestion.getPos()); } } - public static class GenericItemHandlerInfo implements Comparable{ + public static class GenericItemHandlerInfo implements Comparable { public final List handlers = new ArrayList<>(); public final TileEntityLaserRelayItem relayInQuestion; - public GenericItemHandlerInfo(TileEntityLaserRelayItem relayInQuestion){ + public GenericItemHandlerInfo(TileEntityLaserRelayItem relayInQuestion) { this.relayInQuestion = relayInQuestion; } - public boolean isLoaded(){ + public boolean isLoaded() { return this.relayInQuestion.hasWorld() && this.relayInQuestion.getWorld().isBlockLoaded(this.relayInQuestion.getPos()); } @Override - public int compareTo(GenericItemHandlerInfo other){ + public int compareTo(GenericItemHandlerInfo other) { int thisPrio = this.relayInQuestion.getPriority(); int otherPrio = other.relayInQuestion.getPriority(); - if(thisPrio == otherPrio){ + if (thisPrio == otherPrio) { return 0; - } - else if(thisPrio > otherPrio){ + } else if (thisPrio > otherPrio) { return -1; - } - else{ + } else { return 1; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewerHopping.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewerHopping.java index fcc6fe4e1..db6bfc7ce 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewerHopping.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewerHopping.java @@ -10,6 +10,11 @@ package de.ellpeck.actuallyadditions.mod.tile; +import java.util.List; + +import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler; +import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; @@ -24,41 +29,36 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; -import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler; -import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig; -import java.util.List; - -public class TileEntityItemViewerHopping extends TileEntityItemViewer{ +public class TileEntityItemViewerHopping extends TileEntityItemViewer { private SlotlessableItemHandlerWrapper handlerToPullFrom; private SlotlessableItemHandlerWrapper handlerToPushTo; - public TileEntityItemViewerHopping(){ + public TileEntityItemViewerHopping() { super("itemViewerHopping"); } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote && this.world.getTotalWorldTime()%10 == 0){ - if(this.handlerToPullFrom != null){ + if (!this.world.isRemote && this.world.getTotalWorldTime() % 10 == 0) { + if (this.handlerToPullFrom != null) { WorldUtil.doItemInteraction(this.handlerToPullFrom, this.itemHandler, 4); - } - else{ - if(this.world.getTotalWorldTime()%20 == 0){ - List items = this.world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(this.pos.getX(), this.pos.getY()+0.5, this.pos.getZ(), this.pos.getX()+1, this.pos.getY()+2, this.pos.getZ()+1)); - if(items != null && !items.isEmpty()){ - for(EntityItem item : items){ - if(item != null && !item.isDead){ - if(ActuallyAdditions.commonCapsLoaded){ + } else { + if (this.world.getTotalWorldTime() % 20 == 0) { + List items = this.world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(this.pos.getX(), this.pos.getY() + 0.5, this.pos.getZ(), this.pos.getX() + 1, this.pos.getY() + 2, this.pos.getZ() + 1)); + if (items != null && !items.isEmpty()) { + for (EntityItem item : items) { + if (item != null && !item.isDead) { + if (ActuallyAdditions.commonCapsLoaded) { Object slotless = this.itemHandler.getSlotlessHandler(); - if(slotless instanceof ISlotlessItemHandler){ - ItemStack left = ((ISlotlessItemHandler)slotless).insertItem(item.getItem(), false); + if (slotless instanceof ISlotlessItemHandler) { + ItemStack left = ((ISlotlessItemHandler) slotless).insertItem(item.getItem(), false); item.setItem(left); - if(!StackUtil.isValid(left)){ + if (!StackUtil.isValid(left)) { item.setDead(); continue; } @@ -66,12 +66,12 @@ public class TileEntityItemViewerHopping extends TileEntityItemViewer{ } IItemHandler handler = this.itemHandler.getNormalHandler(); - if(handler != null){ - for(int i = 0; i < handler.getSlots(); i++){ + if (handler != null) { + for (int i = 0; i < handler.getSlots(); i++) { ItemStack left = handler.insertItem(i, item.getItem(), false); item.setItem(left); - if(!StackUtil.isValid(left)){ + if (!StackUtil.isValid(left)) { item.setDead(); break; } @@ -83,29 +83,29 @@ public class TileEntityItemViewerHopping extends TileEntityItemViewer{ } } - if(this.handlerToPushTo != null){ + if (this.handlerToPushTo != null) { WorldUtil.doItemInteraction(this.itemHandler, this.handlerToPushTo, 4); } } } @Override - public void saveDataOnChangeOrWorldStart(){ + public void saveDataOnChangeOrWorldStart() { super.saveDataOnChangeOrWorldStart(); this.handlerToPullFrom = null; this.handlerToPushTo = null; TileEntity from = this.world.getTileEntity(this.pos.offset(EnumFacing.UP)); - if(from != null && !(from instanceof TileEntityItemViewer)){ + if (from != null && !(from instanceof TileEntityItemViewer)) { IItemHandler normal = null; - if(from.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)){ + if (from.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)) { normal = from.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN); } Object slotless = null; - if(ActuallyAdditions.commonCapsLoaded){ - if(from.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, EnumFacing.DOWN)){ + if (ActuallyAdditions.commonCapsLoaded) { + if (from.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, EnumFacing.DOWN)) { slotless = from.getCapability(SlotlessItemHandlerConfig.CAPABILITY, EnumFacing.DOWN); } } @@ -117,17 +117,17 @@ public class TileEntityItemViewerHopping extends TileEntityItemViewer{ EnumFacing facing = state.getValue(BlockHopper.FACING); BlockPos toPos = this.pos.offset(facing); - if(this.world.isBlockLoaded(toPos)){ + if (this.world.isBlockLoaded(toPos)) { TileEntity to = this.world.getTileEntity(toPos); - if(to != null && !(to instanceof TileEntityItemViewer)){ + if (to != null && !(to instanceof TileEntityItemViewer)) { IItemHandler normal = null; - if(to.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite())){ + if (to.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite())) { normal = to.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()); } Object slotless = null; - if(ActuallyAdditions.commonCapsLoaded){ - if(to.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, facing.getOpposite())){ + if (ActuallyAdditions.commonCapsLoaded) { + if (to.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, facing.getOpposite())) { slotless = to.getCapability(SlotlessItemHandlerConfig.CAPABILITY, facing.getOpposite()); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java index 5e6269ad5..858a08401 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java @@ -28,7 +28,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.IItemHandler; -public abstract class TileEntityLaserRelay extends TileEntityInventoryBase{ +public abstract class TileEntityLaserRelay extends TileEntityInventoryBase { public static final int MAX_DISTANCE = 15; public static final int MAX_DISTANCE_RANGED = 35; @@ -39,21 +39,21 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase{ private int changeAmountAtCaching = -1; private int lastRange; - public TileEntityLaserRelay(String name, LaserType type){ + public TileEntityLaserRelay(String name, LaserType type) { super(1, name); this.type = type; } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); - if(type == NBTType.SYNC){ + if (type == NBTType.SYNC) { ActuallyAdditionsAPI.connectionHandler.removeRelayFromNetwork(this.pos, this.world); NBTTagList list = compound.getTagList("Connections", 10); - if(!list.isEmpty()){ - for(int i = 0; i < list.tagCount(); i++){ + if (!list.isEmpty()) { + for (int i = 0; i < list.tagCount(); i++) { ConnectionPair pair = new ConnectionPair(); pair.readFromNBT(list.getCompoundTagAt(i)); ActuallyAdditionsAPI.connectionHandler.addConnection(pair.getPositions()[0], pair.getPositions()[1], this.type, this.world, pair.doesSuppressRender()); @@ -63,15 +63,15 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase{ } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); - if(type == NBTType.SYNC){ + if (type == NBTType.SYNC) { NBTTagList list = new NBTTagList(); ConcurrentSet connections = ActuallyAdditionsAPI.connectionHandler.getConnectionsFor(this.pos, this.world); - if(connections != null && !connections.isEmpty()){ - for(IConnectionPair pair : connections){ + if (connections != null && !connections.isEmpty()) { + for (IConnectionPair pair : connections) { NBTTagCompound tag = new NBTTagCompound(); pair.writeToNBT(tag); list.appendTag(tag); @@ -83,16 +83,16 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase{ } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); int range = this.getMaxRange(); - if(this.lastRange != range){ + if (this.lastRange != range) { ConcurrentSet connections = ActuallyAdditionsAPI.connectionHandler.getConnectionsFor(this.pos, this.world); - if(connections != null && !connections.isEmpty()){ - for(IConnectionPair pair : connections){ - int distanceSq = (int)pair.getPositions()[0].distanceSq(pair.getPositions()[1]); - if(distanceSq > range*range){ + if (connections != null && !connections.isEmpty()) { + for (IConnectionPair pair : connections) { + int distanceSq = (int) pair.getPositions()[0].distanceSq(pair.getPositions()[1]); + if (distanceSq > range * range) { ActuallyAdditionsAPI.connectionHandler.removeConnection(this.world, pair.getPositions()[0], pair.getPositions()[1]); } } @@ -109,7 +109,7 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase{ this.renderParticles(); } } - + @SideOnly(Side.CLIENT) public void renderParticles(){ if(this.world.rand.nextInt(8) == 0){ @@ -134,14 +134,13 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase{ } }*/ - public Network getNetwork(){ - if(this.cachedNetwork == null || this.cachedNetwork.changeAmount != this.changeAmountAtCaching){ + public Network getNetwork() { + if (this.cachedNetwork == null || this.cachedNetwork.changeAmount != this.changeAmountAtCaching) { this.cachedNetwork = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(this.pos, this.world); - if(this.cachedNetwork != null){ + if (this.cachedNetwork != null) { this.changeAmountAtCaching = this.cachedNetwork.changeAmount; - } - else{ + } else { this.changeAmountAtCaching = -1; } } @@ -151,26 +150,25 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase{ @Override @SideOnly(Side.CLIENT) - public AxisAlignedBB getRenderBoundingBox(){ + public AxisAlignedBB getRenderBoundingBox() { return INFINITE_EXTENT_AABB; } @Override - public boolean shouldSyncSlots(){ + public boolean shouldSyncSlots() { return true; } @Override - public IItemHandler getItemHandler(EnumFacing facing){ + public IItemHandler getItemHandler(EnumFacing facing) { return null; } - public int getMaxRange(){ + public int getMaxRange() { ItemStack upgrade = this.inv.getStackInSlot(0); - if(StackUtil.isValid(upgrade) && upgrade.getItem() == InitItems.itemLaserUpgradeRange){ + if (StackUtil.isValid(upgrade) && upgrade.getItem() == InitItems.itemLaserUpgradeRange) { return MAX_DISTANCE_RANGED; - } - else{ + } else { return MAX_DISTANCE; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java index 205052564..0d95f4dc4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java @@ -34,62 +34,62 @@ import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{ +public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay { public static final int CAP = 1000; public final ConcurrentHashMap receiversAround = new ConcurrentHashMap<>(); private final IEnergyStorage[] energyStorages = new IEnergyStorage[6]; private Mode mode = Mode.BOTH; - public TileEntityLaserRelayEnergy(String name){ + public TileEntityLaserRelayEnergy(String name) { super(name, LaserType.ENERGY); - for(int i = 0; i < this.energyStorages.length; i++){ + for (int i = 0; i < this.energyStorages.length; i++) { final EnumFacing facing = EnumFacing.values()[i]; - this.energyStorages[i] = new IEnergyStorage(){ + this.energyStorages[i] = new IEnergyStorage() { @Override - public int receiveEnergy(int amount, boolean simulate){ + public int receiveEnergy(int amount, boolean simulate) { return TileEntityLaserRelayEnergy.this.transmitEnergy(facing, amount, simulate); } @Override - public int extractEnergy(int maxExtract, boolean simulate){ + public int extractEnergy(int maxExtract, boolean simulate) { return 0; } @Override - public int getEnergyStored(){ + public int getEnergyStored() { return 0; } @Override - public int getMaxEnergyStored(){ + public int getMaxEnergyStored() { return TileEntityLaserRelayEnergy.this.getEnergyCap(); } @Override - public boolean canExtract(){ + public boolean canExtract() { return false; } @Override - public boolean canReceive(){ + public boolean canReceive() { return true; } }; } } - public TileEntityLaserRelayEnergy(){ + public TileEntityLaserRelayEnergy() { this("laserRelay"); } - private int transmitEnergy(EnumFacing from, int maxTransmit, boolean simulate){ + private int transmitEnergy(EnumFacing from, int maxTransmit, boolean simulate) { int transmitted = 0; - if(maxTransmit > 0 && this.mode != Mode.OUTPUT_ONLY){ + if (maxTransmit > 0 && this.mode != Mode.OUTPUT_ONLY) { Network network = this.getNetwork(); - if(network != null){ + if (network != null) { transmitted = this.transferEnergyToReceiverInNeed(from, network, maxTransmit, simulate); } } @@ -97,31 +97,31 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{ } @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing){ + public IEnergyStorage getEnergyStorage(EnumFacing facing) { return this.energyStorages[facing == null ? 0 : facing.ordinal()]; } @Override - public boolean shouldSaveDataOnChangeOrWorldStart(){ + public boolean shouldSaveDataOnChangeOrWorldStart() { return true; } @Override - public void saveDataOnChangeOrWorldStart(){ + public void saveDataOnChangeOrWorldStart() { Map old = new HashMap<>(this.receiversAround); boolean change = false; this.receiversAround.clear(); - for(EnumFacing side : EnumFacing.values()){ + for (EnumFacing side : EnumFacing.values()) { BlockPos pos = this.getPos().offset(side); - if(this.world.isBlockLoaded(pos)){ + if (this.world.isBlockLoaded(pos)) { TileEntity tile = this.world.getTileEntity(pos); - if(tile != null && !(tile instanceof TileEntityLaserRelay)){ - if(tile.hasCapability(CapabilityEnergy.ENERGY, side.getOpposite())){ + if (tile != null && !(tile instanceof TileEntityLaserRelay)) { + if (tile.hasCapability(CapabilityEnergy.ENERGY, side.getOpposite())) { this.receiversAround.put(side, tile); TileEntity oldTile = old.get(side); - if(oldTile == null || !tile.equals(oldTile)){ + if (oldTile == null || !tile.equals(oldTile)) { change = true; } } @@ -129,15 +129,15 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{ } } - if(change || old.size() != this.receiversAround.size()){ + if (change || old.size() != this.receiversAround.size()) { Network network = this.getNetwork(); - if(network != null){ + if (network != null) { network.changeAmount++; } } } - private int transferEnergyToReceiverInNeed(EnumFacing from, Network network, int maxTransfer, boolean simulate){ + private int transferEnergyToReceiverInNeed(EnumFacing from, Network network, int maxTransfer, boolean simulate) { int transmitted = 0; //Keeps track of all the Laser Relays and Energy Acceptors that have been checked already to make nothing run multiple times Set alreadyChecked = new ObjectOpenHashSet<>(); @@ -145,25 +145,25 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{ Set relaysThatWork = new ObjectOpenHashSet<>(); int totalReceiverAmount = 0; - for(IConnectionPair pair : network.connections){ - for(BlockPos relay : pair.getPositions()){ - if(relay != null && this.world.isBlockLoaded(relay) && !alreadyChecked.contains(relay)){ + for (IConnectionPair pair : network.connections) { + for (BlockPos relay : pair.getPositions()) { + if (relay != null && this.world.isBlockLoaded(relay) && !alreadyChecked.contains(relay)) { alreadyChecked.add(relay); TileEntity relayTile = this.world.getTileEntity(relay); - if(relayTile instanceof TileEntityLaserRelayEnergy){ - TileEntityLaserRelayEnergy theRelay = (TileEntityLaserRelayEnergy)relayTile; - if(theRelay.mode != Mode.INPUT_ONLY){ + if (relayTile instanceof TileEntityLaserRelayEnergy) { + TileEntityLaserRelayEnergy theRelay = (TileEntityLaserRelayEnergy) relayTile; + if (theRelay.mode != Mode.INPUT_ONLY) { boolean workedOnce = false; - for(EnumFacing facing : theRelay.receiversAround.keySet()){ - if(theRelay != this || facing != from){ + for (EnumFacing facing : theRelay.receiversAround.keySet()) { + if (theRelay != this || facing != from) { TileEntity tile = theRelay.receiversAround.get(facing); EnumFacing opp = facing.getOpposite(); - if(tile != null){ - if(tile.hasCapability(CapabilityEnergy.ENERGY, opp)){ + if (tile != null) { + if (tile.hasCapability(CapabilityEnergy.ENERGY, opp)) { IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, opp); - if(cap != null && cap.receiveEnergy(maxTransfer, true) > 0){ + if (cap != null && cap.receiveEnergy(maxTransfer, true) > 0) { totalReceiverAmount++; workedOnce = true; } @@ -172,7 +172,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{ } } - if(workedOnce){ + if (workedOnce) { relaysThatWork.add(theRelay); } } @@ -181,43 +181,41 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{ } } - if(totalReceiverAmount > 0 && !relaysThatWork.isEmpty()){ - int amountPer = maxTransfer/totalReceiverAmount; - if(amountPer <= 0){ + if (totalReceiverAmount > 0 && !relaysThatWork.isEmpty()) { + int amountPer = maxTransfer / totalReceiverAmount; + if (amountPer <= 0) { amountPer = maxTransfer; } - for(TileEntityLaserRelayEnergy theRelay : relaysThatWork){ + for (TileEntityLaserRelayEnergy theRelay : relaysThatWork) { double highestLoss = Math.max(theRelay.getLossPercentage(), this.getLossPercentage()); int lowestCap = Math.min(theRelay.getEnergyCap(), this.getEnergyCap()); - for(Map.Entry receiver : theRelay.receiversAround.entrySet()){ - if(receiver != null){ + for (Map.Entry receiver : theRelay.receiversAround.entrySet()) { + if (receiver != null) { EnumFacing side = receiver.getKey(); EnumFacing opp = side.getOpposite(); TileEntity tile = receiver.getValue(); - if(!alreadyChecked.contains(tile.getPos())){ + if (!alreadyChecked.contains(tile.getPos())) { alreadyChecked.add(tile.getPos()); - if(theRelay != this || side != from){ - if(tile.hasCapability(CapabilityEnergy.ENERGY, opp)){ + if (theRelay != this || side != from) { + if (tile.hasCapability(CapabilityEnergy.ENERGY, opp)) { IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, opp); - if(cap != null){ + if (cap != null) { int theoreticalReceived = cap.receiveEnergy(Math.min(amountPer, lowestCap), true); - if(theoreticalReceived > 0){ + if (theoreticalReceived > 0) { int deduct = this.calcDeduction(theoreticalReceived, highestLoss); - if(deduct >= theoreticalReceived){ //Happens with small numbers + if (deduct >= theoreticalReceived) { //Happens with small numbers deduct = 0; } - transmitted += cap.receiveEnergy(theoreticalReceived-deduct, simulate); + transmitted += cap.receiveEnergy(theoreticalReceived - deduct, simulate); transmitted += deduct; } } } //If everything that could be transmitted was transmitted - if(transmitted >= maxTransfer){ - return transmitted; - } + if (transmitted >= maxTransfer) { return transmitted; } } } } @@ -228,71 +226,71 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{ return transmitted; } - private int calcDeduction(int theoreticalReceived, double highestLoss){ - return ConfigBoolValues.LASER_RELAY_LOSS.isEnabled() ? MathHelper.ceil(theoreticalReceived*(highestLoss/100)) : 0; + private int calcDeduction(int theoreticalReceived, double highestLoss) { + return ConfigBoolValues.LASER_RELAY_LOSS.isEnabled() ? MathHelper.ceil(theoreticalReceived * (highestLoss / 100)) : 0; } - public int getEnergyCap(){ + public int getEnergyCap() { return CAP; } - public double getLossPercentage(){ + public double getLossPercentage() { return 5; } @Override @SideOnly(Side.CLIENT) - public String getExtraDisplayString(){ - return StringUtil.localize("info."+ActuallyAdditions.MODID+".laserRelay.energy.extra")+": "+TextFormatting.DARK_RED+StringUtil.localize(this.mode.name)+TextFormatting.RESET; + public String getExtraDisplayString() { + return StringUtil.localize("info." + ActuallyAdditions.MODID + ".laserRelay.energy.extra") + ": " + TextFormatting.DARK_RED + StringUtil.localize(this.mode.name) + TextFormatting.RESET; } @Override @SideOnly(Side.CLIENT) - public String getCompassDisplayString(){ - return TextFormatting.GREEN+StringUtil.localize("info."+ActuallyAdditions.MODID+".laserRelay.energy.display"); + public String getCompassDisplayString() { + return TextFormatting.GREEN + StringUtil.localize("info." + ActuallyAdditions.MODID + ".laserRelay.energy.display"); } @Override - public void onCompassAction(EntityPlayer player){ + public void onCompassAction(EntityPlayer player) { this.mode = this.mode.getNext(); } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { compound.setString("Mode", this.mode.toString()); } } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { String modeStrg = compound.getString("Mode"); - if(modeStrg != null && !modeStrg.isEmpty()){ + if (modeStrg != null && !modeStrg.isEmpty()) { this.mode = Mode.valueOf(modeStrg); } } } - public enum Mode{ - BOTH("info."+ActuallyAdditions.MODID+".laserRelay.mode.both"), - OUTPUT_ONLY("info."+ActuallyAdditions.MODID+".laserRelay.mode.outputOnly"), - INPUT_ONLY("info."+ActuallyAdditions.MODID+".laserRelay.mode.inputOnly"); + public enum Mode { + BOTH("info." + ActuallyAdditions.MODID + ".laserRelay.mode.both"), + OUTPUT_ONLY("info." + ActuallyAdditions.MODID + ".laserRelay.mode.outputOnly"), + INPUT_ONLY("info." + ActuallyAdditions.MODID + ".laserRelay.mode.inputOnly"); public final String name; - Mode(String name){ + Mode(String name) { this.name = name; } - public Mode getNext(){ - int ordinal = this.ordinal()+1; + public Mode getNext() { + int ordinal = this.ordinal() + 1; - if(ordinal >= values().length){ + if (ordinal >= values().length) { ordinal = 0; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyAdvanced.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyAdvanced.java index 987aad35d..e3f601fbf 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyAdvanced.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyAdvanced.java @@ -10,21 +10,21 @@ package de.ellpeck.actuallyadditions.mod.tile; -public class TileEntityLaserRelayEnergyAdvanced extends TileEntityLaserRelayEnergy{ +public class TileEntityLaserRelayEnergyAdvanced extends TileEntityLaserRelayEnergy { public static final int CAP = 10000; - public TileEntityLaserRelayEnergyAdvanced(){ + public TileEntityLaserRelayEnergyAdvanced() { super("laserRelayAdvanced"); } @Override - public int getEnergyCap(){ + public int getEnergyCap() { return CAP; } @Override - public double getLossPercentage(){ + public double getLossPercentage() { return 8; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyExtreme.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyExtreme.java index b12a1fc48..951207f92 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyExtreme.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyExtreme.java @@ -10,21 +10,21 @@ package de.ellpeck.actuallyadditions.mod.tile; -public class TileEntityLaserRelayEnergyExtreme extends TileEntityLaserRelayEnergy{ +public class TileEntityLaserRelayEnergyExtreme extends TileEntityLaserRelayEnergy { public static final int CAP = 100000; - public TileEntityLaserRelayEnergyExtreme(){ + public TileEntityLaserRelayEnergyExtreme() { super("laserRelayExtreme"); } @Override - public int getEnergyCap(){ + public int getEnergyCap() { return CAP; } @Override - public double getLossPercentage(){ + public double getLossPercentage() { return 10; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java index 651630c9a..b3c82c6da 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java @@ -10,6 +10,12 @@ package de.ellpeck.actuallyadditions.mod.tile; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + import de.ellpeck.actuallyadditions.api.laser.IConnectionPair; import de.ellpeck.actuallyadditions.api.laser.LaserType; import de.ellpeck.actuallyadditions.api.laser.Network; @@ -30,41 +36,35 @@ import net.minecraftforge.fluids.capability.IFluidTankProperties; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -public class TileEntityLaserRelayFluids extends TileEntityLaserRelay{ +public class TileEntityLaserRelayFluids extends TileEntityLaserRelay { public final ConcurrentHashMap handlersAround = new ConcurrentHashMap<>(); private final IFluidHandler[] fluidHandlers = new IFluidHandler[6]; private Mode mode = Mode.BOTH; - public TileEntityLaserRelayFluids(){ + public TileEntityLaserRelayFluids() { super("laserRelayFluids", LaserType.FLUID); - for(int i = 0; i < this.fluidHandlers.length; i++){ + for (int i = 0; i < this.fluidHandlers.length; i++) { final EnumFacing facing = EnumFacing.values()[i]; - this.fluidHandlers[i] = new IFluidHandler(){ + this.fluidHandlers[i] = new IFluidHandler() { @Override - public IFluidTankProperties[] getTankProperties(){ + public IFluidTankProperties[] getTankProperties() { return new IFluidTankProperties[0]; } @Override - public int fill(FluidStack resource, boolean doFill){ + public int fill(FluidStack resource, boolean doFill) { return TileEntityLaserRelayFluids.this.transmitFluid(facing, resource, doFill); } @Override - public FluidStack drain(FluidStack resource, boolean doDrain){ + public FluidStack drain(FluidStack resource, boolean doDrain) { return null; } @Override - public FluidStack drain(int maxDrain, boolean doDrain){ + public FluidStack drain(int maxDrain, boolean doDrain) { return null; } }; @@ -72,12 +72,12 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay{ } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ - if(this.mode == Mode.INPUT_ONLY){ - for(EnumFacing side : this.handlersAround.keySet()){ + if (!this.world.isRemote) { + if (this.mode == Mode.INPUT_ONLY) { + for (EnumFacing side : this.handlersAround.keySet()) { WorldUtil.doFluidInteraction(this.handlersAround.get(side), this, side.getOpposite(), Integer.MAX_VALUE); } } @@ -85,26 +85,26 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay{ } @Override - public boolean shouldSaveDataOnChangeOrWorldStart(){ + public boolean shouldSaveDataOnChangeOrWorldStart() { return true; } @Override - public void saveDataOnChangeOrWorldStart(){ + public void saveDataOnChangeOrWorldStart() { Map old = new HashMap<>(this.handlersAround); boolean change = false; this.handlersAround.clear(); - for(EnumFacing side : EnumFacing.values()){ + for (EnumFacing side : EnumFacing.values()) { BlockPos pos = this.getPos().offset(side); - if(this.world.isBlockLoaded(pos)){ + if (this.world.isBlockLoaded(pos)) { TileEntity tile = this.world.getTileEntity(pos); - if(tile != null && !(tile instanceof TileEntityLaserRelay)){ - if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())){ + if (tile != null && !(tile instanceof TileEntityLaserRelay)) { + if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())) { this.handlersAround.put(side, tile); TileEntity oldTile = old.get(side); - if(oldTile == null || !tile.equals(oldTile)){ + if (oldTile == null || !tile.equals(oldTile)) { change = true; } } @@ -112,31 +112,31 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay{ } } - if(change || old.size() != this.handlersAround.size()){ + if (change || old.size() != this.handlersAround.size()) { Network network = this.getNetwork(); - if(network != null){ + if (network != null) { network.changeAmount++; } } } @Override - public IFluidHandler getFluidHandler(EnumFacing facing){ + public IFluidHandler getFluidHandler(EnumFacing facing) { return this.fluidHandlers[facing == null ? 0 : facing.ordinal()]; } - private int transmitFluid(EnumFacing from, FluidStack stack, boolean doFill){ + private int transmitFluid(EnumFacing from, FluidStack stack, boolean doFill) { int transmitted = 0; - if(stack != null && this.mode != Mode.OUTPUT_ONLY){ + if (stack != null && this.mode != Mode.OUTPUT_ONLY) { Network network = this.getNetwork(); - if(network != null){ + if (network != null) { transmitted = this.transferFluidToReceiverInNeed(from, network, stack, doFill); } } return transmitted; } - private int transferFluidToReceiverInNeed(EnumFacing from, Network network, FluidStack stack, boolean doFill){ + private int transferFluidToReceiverInNeed(EnumFacing from, Network network, FluidStack stack, boolean doFill) { int transmitted = 0; //Keeps track of all the Laser Relays and Energy Acceptors that have been checked already to make nothing run multiple times Set alreadyChecked = new HashSet<>(); @@ -144,24 +144,24 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay{ Set relaysThatWork = new HashSet<>(); int totalReceiverAmount = 0; - for(IConnectionPair pair : network.connections){ - for(BlockPos relay : pair.getPositions()){ - if(relay != null && this.world.isBlockLoaded(relay) && !alreadyChecked.contains(relay)){ + for (IConnectionPair pair : network.connections) { + for (BlockPos relay : pair.getPositions()) { + if (relay != null && this.world.isBlockLoaded(relay) && !alreadyChecked.contains(relay)) { alreadyChecked.add(relay); TileEntity relayTile = this.world.getTileEntity(relay); - if(relayTile instanceof TileEntityLaserRelayFluids){ - TileEntityLaserRelayFluids theRelay = (TileEntityLaserRelayFluids)relayTile; - if(theRelay.mode != Mode.INPUT_ONLY){ + if (relayTile instanceof TileEntityLaserRelayFluids) { + TileEntityLaserRelayFluids theRelay = (TileEntityLaserRelayFluids) relayTile; + if (theRelay.mode != Mode.INPUT_ONLY) { boolean workedOnce = false; - for(EnumFacing facing : theRelay.handlersAround.keySet()){ - if(theRelay != this || facing != from){ + for (EnumFacing facing : theRelay.handlersAround.keySet()) { + if (theRelay != this || facing != from) { TileEntity tile = theRelay.handlersAround.get(facing); EnumFacing opp = facing.getOpposite(); - if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp)){ + if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp)) { IFluidHandler cap = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp); - if(cap != null && cap.fill(stack, false) > 0){ + if (cap != null && cap.fill(stack, false) > 0) { totalReceiverAmount++; workedOnce = true; } @@ -169,7 +169,7 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay{ } } - if(workedOnce){ + if (workedOnce) { relaysThatWork.add(theRelay); } } @@ -178,24 +178,24 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay{ } } - if(totalReceiverAmount > 0 && !relaysThatWork.isEmpty()){ - int amountPer = stack.amount/totalReceiverAmount; - if(amountPer <= 0){ + if (totalReceiverAmount > 0 && !relaysThatWork.isEmpty()) { + int amountPer = stack.amount / totalReceiverAmount; + if (amountPer <= 0) { amountPer = stack.amount; } - for(TileEntityLaserRelayFluids theRelay : relaysThatWork){ - for(Map.Entry receiver : theRelay.handlersAround.entrySet()){ - if(receiver != null){ + for (TileEntityLaserRelayFluids theRelay : relaysThatWork) { + for (Map.Entry receiver : theRelay.handlersAround.entrySet()) { + if (receiver != null) { EnumFacing side = receiver.getKey(); EnumFacing opp = side.getOpposite(); TileEntity tile = receiver.getValue(); - if(!alreadyChecked.contains(tile.getPos())){ + if (!alreadyChecked.contains(tile.getPos())) { alreadyChecked.add(tile.getPos()); - if(theRelay != this || side != from){ - if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp)){ + if (theRelay != this || side != from) { + if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp)) { IFluidHandler cap = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp); - if(cap != null){ + if (cap != null) { FluidStack copy = stack.copy(); copy.amount = amountPer; transmitted += cap.fill(copy, doFill); @@ -203,9 +203,7 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay{ } //If everything that could be transmitted was transmitted - if(transmitted >= stack.amount){ - return transmitted; - } + if (transmitted >= stack.amount) { return transmitted; } } } } @@ -218,37 +216,37 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay{ @Override @SideOnly(Side.CLIENT) - public String getExtraDisplayString(){ - return StringUtil.localize("info."+ActuallyAdditions.MODID+".laserRelay.fluid.extra")+": "+TextFormatting.DARK_RED+StringUtil.localize(this.mode.name)+TextFormatting.RESET; + public String getExtraDisplayString() { + return StringUtil.localize("info." + ActuallyAdditions.MODID + ".laserRelay.fluid.extra") + ": " + TextFormatting.DARK_RED + StringUtil.localize(this.mode.name) + TextFormatting.RESET; } @Override @SideOnly(Side.CLIENT) - public String getCompassDisplayString(){ - return TextFormatting.GREEN+StringUtil.localize("info."+ActuallyAdditions.MODID+".laserRelay.energy.display"); + public String getCompassDisplayString() { + return TextFormatting.GREEN + StringUtil.localize("info." + ActuallyAdditions.MODID + ".laserRelay.energy.display"); } @Override - public void onCompassAction(EntityPlayer player){ + public void onCompassAction(EntityPlayer player) { this.mode = this.mode.getNext(); } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { compound.setString("Mode", this.mode.toString()); } } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { String modeStrg = compound.getString("Mode"); - if(modeStrg != null && !modeStrg.isEmpty()){ + if (modeStrg != null && !modeStrg.isEmpty()) { this.mode = Mode.valueOf(modeStrg); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java index 4f3985402..1e5e8dc68 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java @@ -10,6 +10,15 @@ package de.ellpeck.actuallyadditions.mod.tile; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig; + import de.ellpeck.actuallyadditions.api.laser.IConnectionPair; import de.ellpeck.actuallyadditions.api.laser.LaserType; import de.ellpeck.actuallyadditions.api.laser.Network; @@ -29,67 +38,63 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; -import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; - -public class TileEntityLaserRelayItem extends TileEntityLaserRelay{ +public class TileEntityLaserRelayItem extends TileEntityLaserRelay { public final Map handlersAround = new ConcurrentHashMap<>(); public int priority; - public TileEntityLaserRelayItem(String name){ + public TileEntityLaserRelayItem(String name) { super(name, LaserType.ITEM); } - public TileEntityLaserRelayItem(){ + public TileEntityLaserRelayItem() { this("laserRelayItem"); } - public int getPriority(){ + public int getPriority() { return this.priority; } - public boolean isWhitelisted(ItemStack stack, boolean output){ + public boolean isWhitelisted(ItemStack stack, boolean output) { return true; } @Override - public boolean shouldSaveDataOnChangeOrWorldStart(){ + public boolean shouldSaveDataOnChangeOrWorldStart() { return true; } @Override - public void saveDataOnChangeOrWorldStart(){ + public void saveDataOnChangeOrWorldStart() { Map old = new HashMap<>(this.handlersAround); boolean change = false; this.handlersAround.clear(); - for(int i = 0; i <= 5; i++){ + for (int i = 0; i <= 5; i++) { EnumFacing side = WorldUtil.getDirectionBySidesInOrder(i); BlockPos pos = this.getPos().offset(side); - if(this.world.isBlockLoaded(pos)){ + if (this.world.isBlockLoaded(pos)) { TileEntity tile = this.world.getTileEntity(pos); - if(tile != null && !(tile instanceof TileEntityItemViewer) && !(tile instanceof TileEntityLaserRelay)){ + if (tile != null && !(tile instanceof TileEntityItemViewer) && !(tile instanceof TileEntityLaserRelay)) { IItemHandler itemHandler = null; - if(tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite())){ + if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite())) { itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite()); } Object slotlessHandler = null; - if(ActuallyAdditions.commonCapsLoaded){ - if(tile.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, side.getOpposite())){ + if (ActuallyAdditions.commonCapsLoaded) { + if (tile.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, side.getOpposite())) { slotlessHandler = tile.getCapability(SlotlessItemHandlerConfig.CAPABILITY, side.getOpposite()); } } - if(itemHandler != null || slotlessHandler != null){ + if (itemHandler != null || slotlessHandler != null) { SlotlessableItemHandlerWrapper handler = new SlotlessableItemHandlerWrapper(itemHandler, slotlessHandler); this.handlersAround.put(pos, handler); SlotlessableItemHandlerWrapper oldHandler = old.get(pos); - if(oldHandler == null || !handler.equals(oldHandler)){ + if (oldHandler == null || !handler.equals(oldHandler)) { change = true; } } @@ -97,29 +102,29 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay{ } } - if(change || old.size() != this.handlersAround.size()){ + if (change || old.size() != this.handlersAround.size()) { Network network = this.getNetwork(); - if(network != null){ + if (network != null) { network.changeAmount++; } } } - public void getItemHandlersInNetwork(Network network, List storeList){ + public void getItemHandlersInNetwork(Network network, List storeList) { //Keeps track of all the Laser Relays and Item Handlers that have been checked already to make nothing run multiple times Set alreadyChecked = new HashSet<>(); - for(IConnectionPair pair : network.connections){ - for(BlockPos relay : pair.getPositions()){ - if(relay != null && this.world.isBlockLoaded(relay) && !alreadyChecked.contains(relay)){ + for (IConnectionPair pair : network.connections) { + for (BlockPos relay : pair.getPositions()) { + if (relay != null && this.world.isBlockLoaded(relay) && !alreadyChecked.contains(relay)) { alreadyChecked.add(relay); TileEntity aRelayTile = this.world.getTileEntity(relay); - if(aRelayTile instanceof TileEntityLaserRelayItem){ - TileEntityLaserRelayItem relayTile = (TileEntityLaserRelayItem)aRelayTile; + if (aRelayTile instanceof TileEntityLaserRelayItem) { + TileEntityLaserRelayItem relayTile = (TileEntityLaserRelayItem) aRelayTile; GenericItemHandlerInfo info = new GenericItemHandlerInfo(relayTile); - for(Map.Entry handler : relayTile.handlersAround.entrySet()){ - if(!alreadyChecked.contains(handler.getKey())){ + for (Map.Entry handler : relayTile.handlersAround.entrySet()) { + if (!alreadyChecked.contains(handler.getKey())) { alreadyChecked.add(handler.getKey()); info.handlers.add(handler.getValue()); @@ -134,39 +139,38 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay{ } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { compound.setInteger("Priority", this.priority); } } @Override @SideOnly(Side.CLIENT) - public String getExtraDisplayString(){ - return StringUtil.localize("info."+ActuallyAdditions.MODID+".laserRelay.item.extra")+": "+TextFormatting.DARK_RED+this.getPriority()+TextFormatting.RESET; + public String getExtraDisplayString() { + return StringUtil.localize("info." + ActuallyAdditions.MODID + ".laserRelay.item.extra") + ": " + TextFormatting.DARK_RED + this.getPriority() + TextFormatting.RESET; } @Override @SideOnly(Side.CLIENT) - public String getCompassDisplayString(){ - return TextFormatting.GREEN+StringUtil.localize("info."+ActuallyAdditions.MODID+".laserRelay.item.display.1")+"\n"+StringUtil.localize("info."+ActuallyAdditions.MODID+".laserRelay.item.display.2"); + public String getCompassDisplayString() { + return TextFormatting.GREEN + StringUtil.localize("info." + ActuallyAdditions.MODID + ".laserRelay.item.display.1") + "\n" + StringUtil.localize("info." + ActuallyAdditions.MODID + ".laserRelay.item.display.2"); } @Override - public void onCompassAction(EntityPlayer player){ - if(player.isSneaking()){ + public void onCompassAction(EntityPlayer player) { + if (player.isSneaking()) { this.priority--; - } - else{ + } else { this.priority++; } } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { this.priority = compound.getInteger("Priority"); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java index 74c0586d5..26400564b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java @@ -22,27 +22,27 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.items.IItemHandler; -public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem implements IButtonReactor{ +public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem implements IButtonReactor { public FilterSettings leftFilter = new FilterSettings(12, true, true, false, false, 0, -1000); public FilterSettings rightFilter = new FilterSettings(12, true, true, false, false, 0, -2000); - public TileEntityLaserRelayItemWhitelist(){ + public TileEntityLaserRelayItemWhitelist() { super("laserRelayItemWhitelist"); } @Override - public int getPriority(){ - return super.getPriority()+10; + public int getPriority() { + return super.getPriority() + 10; } @Override - public boolean isWhitelisted(ItemStack stack, boolean output){ + public boolean isWhitelisted(ItemStack stack, boolean output) { return output ? this.rightFilter.check(stack) : this.leftFilter.check(stack); } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); this.leftFilter.writeToNBT(compound, "LeftFilter"); @@ -50,7 +50,7 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); this.leftFilter.readFromNBT(compound, "LeftFilter"); @@ -58,24 +58,23 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem } @Override - public void onButtonPressed(int buttonID, EntityPlayer player){ + public void onButtonPressed(int buttonID, EntityPlayer player) { this.leftFilter.onButtonPressed(buttonID); this.rightFilter.onButtonPressed(buttonID); - if(buttonID == 2){ + if (buttonID == 2) { this.addWhitelistSmart(false); - } - else if(buttonID == 3){ + } else if (buttonID == 3) { this.addWhitelistSmart(true); } } - private void addWhitelistSmart(boolean output){ - for(SlotlessableItemHandlerWrapper handler : this.handlersAround.values()){ + private void addWhitelistSmart(boolean output) { + for (SlotlessableItemHandlerWrapper handler : this.handlersAround.values()) { IItemHandler itemHandler = handler.getNormalHandler(); - if(itemHandler != null){ - for(int i = 0; i < itemHandler.getSlots(); i++){ + if (itemHandler != null) { + for (int i = 0; i < itemHandler.getSlots(); i++) { ItemStack stack = itemHandler.getStackInSlot(i); - if(StackUtil.isValid(stack)){ + if (StackUtil.isValid(stack)) { this.addWhitelistSmart(output, stack); } } @@ -83,35 +82,34 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem } } - private void addWhitelistSmart(boolean output, ItemStack stack){ + private void addWhitelistSmart(boolean output, ItemStack stack) { FilterSettings usedSettings = output ? this.rightFilter : this.leftFilter; ItemStack copy = stack.copy(); copy.setCount(1); - if(!FilterSettings.check(copy, usedSettings.filterInventory, true, usedSettings.respectMeta, usedSettings.respectNBT, usedSettings.respectMod, usedSettings.respectOredict)){ - for(int k = 0; k < usedSettings.filterInventory.getSlots(); k++){ + if (!FilterSettings.check(copy, usedSettings.filterInventory, true, usedSettings.respectMeta, usedSettings.respectNBT, usedSettings.respectMod, usedSettings.respectOredict)) { + for (int k = 0; k < usedSettings.filterInventory.getSlots(); k++) { ItemStack slot = usedSettings.filterInventory.getStackInSlot(k); - if(StackUtil.isValid(slot)){ - if(SlotFilter.isFilter(slot)){ + if (StackUtil.isValid(slot)) { + if (SlotFilter.isFilter(slot)) { ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerFilter.SLOT_AMOUNT); ItemDrill.loadSlotsFromNBT(inv, slot); boolean did = false; - for(int j = 0; j < inv.getSlots(); j++){ - if(!StackUtil.isValid(inv.getStackInSlot(j))){ + for (int j = 0; j < inv.getSlots(); j++) { + if (!StackUtil.isValid(inv.getStackInSlot(j))) { inv.setStackInSlot(j, copy); did = true; break; } } - if(did){ + if (did) { ItemDrill.writeSlotsToNBT(inv, slot); break; } } - } - else{ + } else { usedSettings.filterInventory.setStackInSlot(k, copy); break; } @@ -120,11 +118,11 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ - if((this.leftFilter.needsUpdateSend() || this.rightFilter.needsUpdateSend()) && this.sendUpdateWithInterval()){ + if (!this.world.isRemote) { + if ((this.leftFilter.needsUpdateSend() || this.rightFilter.needsUpdateSend()) && this.sendUpdateWithInterval()) { this.leftFilter.updateLasts(); this.rightFilter.updateLasts(); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLavaFactoryController.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLavaFactoryController.java index 0c052d3c0..9ddf1b666 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLavaFactoryController.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLavaFactoryController.java @@ -21,7 +21,7 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraftforge.energy.IEnergyStorage; -public class TileEntityLavaFactoryController extends TileEntityBase implements IEnergyDisplay{ +public class TileEntityLavaFactoryController extends TileEntityBase implements IEnergyDisplay { public static final int NOT_MULTI = 0; public static final int HAS_LAVA = 1; @@ -31,85 +31,75 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I private int currentWorkTime; private int oldEnergy; - public TileEntityLavaFactoryController(){ + public TileEntityLavaFactoryController() { super("lavaFactory"); } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { compound.setInteger("WorkTime", this.currentWorkTime); } } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { this.currentWorkTime = compound.getInteger("WorkTime"); } } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ - if(this.storage.getEnergyStored() >= ENERGY_USE && this.isMultiblock() == HAS_AIR){ + if (!this.world.isRemote) { + if (this.storage.getEnergyStored() >= ENERGY_USE && this.isMultiblock() == HAS_AIR) { this.currentWorkTime++; - if(this.currentWorkTime >= 200){ + if (this.currentWorkTime >= 200) { this.currentWorkTime = 0; this.world.setBlockState(this.pos.up(), Blocks.LAVA.getDefaultState(), 2); this.storage.extractEnergyInternal(ENERGY_USE, false); } - } - else{ + } else { this.currentWorkTime = 0; } - if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){ + if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { this.oldEnergy = this.storage.getEnergyStored(); } } } - public int isMultiblock(){ + public int isMultiblock() { BlockPos thisPos = this.pos; - BlockPos[] positions = new BlockPos[]{ - thisPos.add(1, 1, 0), - thisPos.add(-1, 1, 0), - thisPos.add(0, 1, 1), - thisPos.add(0, 1, -1) - }; + BlockPos[] positions = new BlockPos[] { thisPos.add(1, 1, 0), thisPos.add(-1, 1, 0), thisPos.add(0, 1, 1), thisPos.add(0, 1, -1) }; - if(WorldUtil.hasBlocksInPlacesGiven(positions, InitBlocks.blockMisc, TheMiscBlocks.LAVA_FACTORY_CASE.ordinal(), this.world)){ + if (WorldUtil.hasBlocksInPlacesGiven(positions, InitBlocks.blockMisc, TheMiscBlocks.LAVA_FACTORY_CASE.ordinal(), this.world)) { BlockPos pos = thisPos.up(); IBlockState state = this.world.getBlockState(pos); Block block = state.getBlock(); - if(block == Blocks.LAVA || block == Blocks.FLOWING_LAVA){ - return HAS_LAVA; - } - if(block == null || this.world.isAirBlock(pos)){ - return HAS_AIR; - } + if (block == Blocks.LAVA || block == Blocks.FLOWING_LAVA) { return HAS_LAVA; } + if (block == null || this.world.isAirBlock(pos)) { return HAS_AIR; } } return NOT_MULTI; } @Override - public CustomEnergyStorage getEnergyStorage(){ + public CustomEnergyStorage getEnergyStorage() { return this.storage; } @Override - public boolean needsHoldShift(){ + public boolean needsHoldShift() { return false; } @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing){ + public IEnergyStorage getEnergyStorage(EnumFacing facing) { return this.storage; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java index 6a8f90619..f748ca7cb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java @@ -10,6 +10,10 @@ package de.ellpeck.actuallyadditions.mod.tile; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; @@ -18,11 +22,7 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraftforge.energy.IEnergyStorage; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class TileEntityLeafGenerator extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay{ +public class TileEntityLeafGenerator extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay { public static final int RANGE = 7; public static final int ENERGY_PRODUCED = 300; @@ -30,47 +30,47 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE private int nextUseCounter; private int oldEnergy; - public TileEntityLeafGenerator(){ + public TileEntityLeafGenerator() { super("leafGenerator"); } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ - if(!this.isRedstonePowered){ + if (!this.world.isRemote) { + if (!this.isRedstonePowered) { - if(this.nextUseCounter >= 5){ + if (this.nextUseCounter >= 5) { this.nextUseCounter = 0; - if(ENERGY_PRODUCED <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored()){ + if (ENERGY_PRODUCED <= this.storage.getMaxEnergyStored() - this.storage.getEnergyStored()) { List breakPositions = new ArrayList<>(); - for(int reachX = -RANGE; reachX < RANGE+1; reachX++){ - for(int reachZ = -RANGE; reachZ < RANGE+1; reachZ++){ - for(int reachY = -RANGE; reachY < RANGE+1; reachY++){ + for (int reachX = -RANGE; reachX < RANGE + 1; reachX++) { + for (int reachZ = -RANGE; reachZ < RANGE + 1; reachZ++) { + for (int reachY = -RANGE; reachY < RANGE + 1; reachY++) { BlockPos pos = this.pos.add(reachX, reachY, reachZ); Block block = this.world.getBlockState(pos).getBlock(); - if(block != null && block.isLeaves(this.world.getBlockState(pos), this.world, pos)){ + if (block != null && block.isLeaves(this.world.getBlockState(pos), this.world, pos)) { breakPositions.add(pos); } } } } - if(!breakPositions.isEmpty()){ + if (!breakPositions.isEmpty()) { Collections.shuffle(breakPositions); BlockPos theCoord = breakPositions.get(0); @@ -80,53 +80,52 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE this.storage.receiveEnergyInternal(ENERGY_PRODUCED, false); - AssetUtil.spawnLaserWithTimeServer(this.world, this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), theCoord.getX(), theCoord.getY(), theCoord.getZ(), new float[]{62F/255F, 163F/255F, 74F/255F}, 25, 0, 0.075F, 0.8F); + AssetUtil.spawnLaserWithTimeServer(this.world, this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), theCoord.getX(), theCoord.getY(), theCoord.getZ(), new float[] { 62F / 255F, 163F / 255F, 74F / 255F }, 25, 0, 0.075F, 0.8F); } } - } - else{ + } else { this.nextUseCounter++; } } - if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){ + if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { this.oldEnergy = this.storage.getEnergyStored(); } } } @Override - public CustomEnergyStorage getEnergyStorage(){ + public CustomEnergyStorage getEnergyStorage() { return this.storage; } @Override - public boolean needsHoldShift(){ + public boolean needsHoldShift() { return false; } @Override - public int getEnergyToSplitShare(){ + public int getEnergyToSplitShare() { return this.storage.getEnergyStored(); } @Override - public boolean doesShareEnergy(){ + public boolean doesShareEnergy() { return true; } @Override - public EnumFacing[] getEnergyShareSides(){ + public EnumFacing[] getEnergyShareSides() { return EnumFacing.values(); } @Override - public boolean canShareTo(TileEntity tile){ + public boolean canShareTo(TileEntity tile) { return true; } @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing){ + public IEnergyStorage getEnergyStorage(EnumFacing facing) { return this.storage; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java index e360fdc32..efa538591 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java @@ -25,19 +25,19 @@ import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityOilGenerator extends TileEntityBase implements ISharingEnergyProvider, ISharingFluidHandler{ +public class TileEntityOilGenerator extends TileEntityBase implements ISharingEnergyProvider, ISharingFluidHandler { int[] i = ConfigIntListValues.OIL_POWER.getValue(); public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 0, Math.max(Math.max(this.i[0], this.i[1]), Math.max(this.i[2], this.i[3])) + 20); - public final FluidTank tank = new FluidTank(2*Util.BUCKET){ + public final FluidTank tank = new FluidTank(2 * Util.BUCKET) { @Override - public boolean canDrain(){ + public boolean canDrain() { return false; } @Override - public boolean canFillFluidType(FluidStack stack){ + public boolean canFillFluidType(FluidStack stack) { Fluid fluid = stack == null ? null : stack.getFluid(); return fluid != null && getRecipeForFluid(fluid.getName()) != null; } @@ -52,40 +52,36 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn private int lastEnergyProduce; private int lastCompare; - public TileEntityOilGenerator(){ + public TileEntityOilGenerator() { super("oilGenerator"); } - private static OilGenRecipe getRecipeForFluid(String fluidName){ - if(fluidName != null){ - for(OilGenRecipe recipe : ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES){ - if(recipe != null && fluidName.equals(recipe.fluidName)){ - return recipe; - } + private static OilGenRecipe getRecipeForFluid(String fluidName) { + if (fluidName != null) { + for (OilGenRecipe recipe : ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES) { + if (recipe != null && fluidName.equals(recipe.fluidName)) { return recipe; } } } return null; } @SideOnly(Side.CLIENT) - public int getBurningScaled(int i){ - return this.currentBurnTime*i/this.maxBurnTime; + public int getBurningScaled(int i) { + return this.currentBurnTime * i / this.maxBurnTime; } - private OilGenRecipe getRecipeForCurrentFluid(){ + private OilGenRecipe getRecipeForCurrentFluid() { FluidStack stack = this.tank.getFluid(); - if(stack != null){ + if (stack != null) { Fluid fluid = stack.getFluid(); - if(fluid != null){ - return getRecipeForFluid(fluid.getName()); - } + if (fluid != null) { return getRecipeForFluid(fluid.getName()); } } return null; } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ - if(type != NBTType.SAVE_BLOCK){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { + if (type != NBTType.SAVE_BLOCK) { compound.setInteger("BurnTime", this.currentBurnTime); compound.setInteger("CurrentEnergy", this.currentEnergyProduce); compound.setInteger("MaxBurnTime", this.maxBurnTime); @@ -96,8 +92,8 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ - if(type != NBTType.SAVE_BLOCK){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { + if (type != NBTType.SAVE_BLOCK) { this.currentBurnTime = compound.getInteger("BurnTime"); this.currentEnergyProduce = compound.getInteger("CurrentEnergy"); this.maxBurnTime = compound.getInteger("MaxBurnTime"); @@ -108,41 +104,39 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ + if (!this.world.isRemote) { boolean flag = this.currentBurnTime > 0; - if(this.currentBurnTime > 0 && this.currentEnergyProduce > 0){ + if (this.currentBurnTime > 0 && this.currentEnergyProduce > 0) { this.currentBurnTime--; this.storage.receiveEnergyInternal(this.currentEnergyProduce, false); - } - else if(!this.isRedstonePowered){ + } else if (!this.isRedstonePowered) { int fuelUsed = 50; OilGenRecipe recipe = this.getRecipeForCurrentFluid(); - if(recipe != null && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored() && this.tank.getFluidAmount() >= fuelUsed){ + if (recipe != null && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored() && this.tank.getFluidAmount() >= fuelUsed) { this.currentEnergyProduce = recipe.genAmount; this.maxBurnTime = recipe.genTime; this.currentBurnTime = this.maxBurnTime; this.tank.drainInternal(fuelUsed, true); - } - else{ + } else { this.currentEnergyProduce = 0; this.currentBurnTime = 0; this.maxBurnTime = 0; } } - if(flag != this.currentBurnTime > 0 || this.lastCompare != this.getComparatorStrength()){ + if (flag != this.currentBurnTime > 0 || this.lastCompare != this.getComparatorStrength()) { this.lastCompare = this.getComparatorStrength(); this.markDirty(); } - if((this.storage.getEnergyStored() != this.lastEnergy || this.tank.getFluidAmount() != this.lastTank || this.lastBurnTime != this.currentBurnTime || this.lastEnergyProduce != this.currentEnergyProduce || this.lastMaxBurnTime != this.maxBurnTime) && this.sendUpdateWithInterval()){ + if ((this.storage.getEnergyStored() != this.lastEnergy || this.tank.getFluidAmount() != this.lastTank || this.lastBurnTime != this.currentBurnTime || this.lastEnergyProduce != this.currentEnergyProduce || this.lastMaxBurnTime != this.maxBurnTime) && this.sendUpdateWithInterval()) { this.lastEnergy = this.storage.getEnergyStored(); this.lastTank = this.tank.getFluidAmount(); this.lastBurnTime = this.currentBurnTime; @@ -153,53 +147,53 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn } @Override - public int getComparatorStrength(){ - float calc = (float)this.storage.getEnergyStored()/(float)this.storage.getMaxEnergyStored()*15F; - return (int)calc; + public int getComparatorStrength() { + float calc = (float) this.storage.getEnergyStored() / (float) this.storage.getMaxEnergyStored() * 15F; + return (int) calc; } @Override - public IFluidHandler getFluidHandler(EnumFacing facing){ + public IFluidHandler getFluidHandler(EnumFacing facing) { return this.tank; } @Override - public int getMaxFluidAmountToSplitShare(){ + public int getMaxFluidAmountToSplitShare() { return 0; } @Override - public boolean doesShareFluid(){ + public boolean doesShareFluid() { return false; } @Override - public EnumFacing[] getFluidShareSides(){ + public EnumFacing[] getFluidShareSides() { return null; } @Override - public int getEnergyToSplitShare(){ + public int getEnergyToSplitShare() { return this.storage.getEnergyStored(); } @Override - public boolean doesShareEnergy(){ + public boolean doesShareEnergy() { return true; } @Override - public EnumFacing[] getEnergyShareSides(){ + public EnumFacing[] getEnergyShareSides() { return EnumFacing.values(); } @Override - public boolean canShareTo(TileEntity tile){ + public boolean canShareTo(TileEntity tile) { return true; } @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing){ + public IEnergyStorage getEnergyStorage(EnumFacing facing) { return this.storage; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomBooster.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomBooster.java index 5788c05c4..66866f48e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomBooster.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomBooster.java @@ -10,9 +10,9 @@ package de.ellpeck.actuallyadditions.mod.tile; -public class TileEntityPhantomBooster extends TileEntityBase{ +public class TileEntityPhantomBooster extends TileEntityBase { - public TileEntityPhantomBooster(){ + public TileEntityPhantomBooster() { super("phantomBooster"); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomEnergyface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomEnergyface.java index 71e6146ca..951a4cd68 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomEnergyface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomEnergyface.java @@ -16,22 +16,20 @@ import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.energy.CapabilityEnergy; -public class TileEntityPhantomEnergyface extends TileEntityPhantomface implements ISharingEnergyProvider{ +public class TileEntityPhantomEnergyface extends TileEntityPhantomface implements ISharingEnergyProvider { - public TileEntityPhantomEnergyface(){ + public TileEntityPhantomEnergyface() { super("energyface"); this.type = BlockPhantom.Type.ENERGYFACE; } @Override - public boolean isBoundThingInRange(){ - if(super.isBoundThingInRange()){ + public boolean isBoundThingInRange() { + if (super.isBoundThingInRange()) { TileEntity tile = this.world.getTileEntity(this.boundPosition); - if(tile != null && !(tile instanceof TileEntityLaserRelayEnergy)){ - for(EnumFacing facing : EnumFacing.values()){ - if(tile.hasCapability(CapabilityEnergy.ENERGY, facing)){ - return true; - } + if (tile != null && !(tile instanceof TileEntityLaserRelayEnergy)) { + for (EnumFacing facing : EnumFacing.values()) { + if (tile.hasCapability(CapabilityEnergy.ENERGY, facing)) { return true; } } } } @@ -39,27 +37,27 @@ public class TileEntityPhantomEnergyface extends TileEntityPhantomface implement } @Override - protected boolean isCapabilitySupported(Capability capability){ + protected boolean isCapabilitySupported(Capability capability) { return capability == CapabilityEnergy.ENERGY; } @Override - public int getEnergyToSplitShare(){ + public int getEnergyToSplitShare() { return Integer.MAX_VALUE; } @Override - public boolean doesShareEnergy(){ + public boolean doesShareEnergy() { return true; } @Override - public EnumFacing[] getEnergyShareSides(){ + public EnumFacing[] getEnergyShareSides() { return EnumFacing.values(); } @Override - public boolean canShareTo(TileEntity tile){ + public boolean canShareTo(TileEntity tile) { return true; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomLiquiface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomLiquiface.java index d080443df..013efe8ed 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomLiquiface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomLiquiface.java @@ -16,22 +16,20 @@ import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; -public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements ISharingFluidHandler{ +public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements ISharingFluidHandler { - public TileEntityPhantomLiquiface(){ + public TileEntityPhantomLiquiface() { super("liquiface"); this.type = BlockPhantom.Type.LIQUIFACE; } @Override - public boolean isBoundThingInRange(){ - if(super.isBoundThingInRange()){ + public boolean isBoundThingInRange() { + if (super.isBoundThingInRange()) { TileEntity tile = this.world.getTileEntity(this.boundPosition); - if(tile != null && !(tile instanceof TileEntityLaserRelayFluids)){ - for(EnumFacing facing : EnumFacing.values()){ - if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing)){ - return true; - } + if (tile != null && !(tile instanceof TileEntityLaserRelayFluids)) { + for (EnumFacing facing : EnumFacing.values()) { + if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing)) { return true; } } } } @@ -39,22 +37,22 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements } @Override - protected boolean isCapabilitySupported(Capability capability){ + protected boolean isCapabilitySupported(Capability capability) { return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY; } @Override - public int getMaxFluidAmountToSplitShare(){ + public int getMaxFluidAmountToSplitShare() { return Integer.MAX_VALUE; } @Override - public boolean doesShareFluid(){ + public boolean doesShareFluid() { return true; } @Override - public EnumFacing[] getFluidShareSides(){ + public EnumFacing[] getFluidShareSides() { return EnumFacing.values(); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java index 2a6acd8c9..50a9547e6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java @@ -13,9 +13,9 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.api.tile.IPhantomTile; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; +import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.Block; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomRedstoneface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomRedstoneface.java index 9d3d78cb7..f4a2c1257 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomRedstoneface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomRedstoneface.java @@ -10,14 +10,14 @@ package de.ellpeck.actuallyadditions.mod.tile; +import java.util.Arrays; + import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; -import java.util.Arrays; - -public class TileEntityPhantomRedstoneface extends TileEntityPhantomface{ +public class TileEntityPhantomRedstoneface extends TileEntityPhantomface { public final int[] providesStrong = new int[EnumFacing.values().length]; public final int[] providesWeak = new int[EnumFacing.values().length]; @@ -25,19 +25,19 @@ public class TileEntityPhantomRedstoneface extends TileEntityPhantomface{ private final int[] lastProvidesStrong = new int[this.providesStrong.length]; private final int[] lastProvidesWeak = new int[this.providesWeak.length]; - public TileEntityPhantomRedstoneface(){ + public TileEntityPhantomRedstoneface() { super("redstoneface"); } @Override - public void updateEntity(){ - if(!this.world.isRemote){ - if(this.isBoundThingInRange()){ + public void updateEntity() { + if (!this.world.isRemote) { + if (this.isBoundThingInRange()) { IBlockState boundState = this.world.getBlockState(this.boundPosition); - if(boundState != null){ + if (boundState != null) { Block boundBlock = boundState.getBlock(); - if(boundBlock != null){ - for(int i = 0; i < EnumFacing.values().length; i++){ + if (boundBlock != null) { + for (int i = 0; i < EnumFacing.values().length; i++) { EnumFacing facing = EnumFacing.values()[i]; this.providesWeak[i] = boundState.getWeakPower(this.world, this.boundPosition, facing); this.providesStrong[i] = boundState.getStrongPower(this.world, this.boundPosition, facing); @@ -51,12 +51,12 @@ public class TileEntityPhantomRedstoneface extends TileEntityPhantomface{ } @Override - protected boolean doesNeedUpdateSend(){ + protected boolean doesNeedUpdateSend() { return super.doesNeedUpdateSend() || !Arrays.equals(this.providesStrong, this.lastProvidesStrong) || !Arrays.equals(this.providesWeak, this.lastProvidesWeak); } @Override - protected void onUpdateSent(){ + protected void onUpdateSent() { System.arraycopy(this.providesWeak, 0, this.lastProvidesWeak, 0, this.providesWeak.length); System.arraycopy(this.providesStrong, 0, this.lastProvidesStrong, 0, this.providesStrong.length); @@ -64,7 +64,7 @@ public class TileEntityPhantomRedstoneface extends TileEntityPhantomface{ } @Override - protected boolean isCapabilitySupported(Capability capability){ + protected boolean isCapabilitySupported(Capability capability) { return false; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java index 968113f89..619406ded 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java @@ -25,7 +25,7 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public abstract class TileEntityPhantomface extends TileEntityInventoryBase implements IPhantomTile{ +public abstract class TileEntityPhantomface extends TileEntityInventoryBase implements IPhantomTile { public static final int RANGE = 16; public BlockPos boundPosition; @@ -36,18 +36,17 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl private Block boundBlockBefore; private int lastStrength; - public TileEntityPhantomface(String name){ + public TileEntityPhantomface(String name) { super(0, name); } - public static int upgradeRange(int defaultRange, World world, BlockPos pos){ + public static int upgradeRange(int defaultRange, World world, BlockPos pos) { int newRange = defaultRange; - for(int i = 0; i < 3; i++){ - Block block = world.getBlockState(pos.up(1+i)).getBlock(); - if(block == InitBlocks.blockPhantomBooster){ - newRange = newRange*2; - } - else{ + for (int i = 0; i < 3; i++) { + Block block = world.getBlockState(pos.up(1 + i)).getBlock(); + if (block == InitBlocks.blockPhantomBooster) { + newRange = newRange * 2; + } else { break; } } @@ -55,11 +54,11 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { compound.setInteger("Range", this.range); - if(this.boundPosition != null){ + if (this.boundPosition != null) { compound.setInteger("xOfTileStored", this.boundPosition.getX()); compound.setInteger("yOfTileStored", this.boundPosition.getY()); compound.setInteger("zOfTileStored", this.boundPosition.getZ()); @@ -68,14 +67,14 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { int x = compound.getInteger("xOfTileStored"); int y = compound.getInteger("yOfTileStored"); int z = compound.getInteger("zOfTileStored"); this.range = compound.getInteger("Range"); - if(!(x == 0 && y == 0 && z == 0)){ + if (!(x == 0 && y == 0 && z == 0)) { this.boundPosition = new BlockPos(x, y, z); this.markDirty(); } @@ -83,43 +82,42 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ + if (!this.world.isRemote) { this.range = upgradeRange(RANGE, this.world, this.getPos()); - if(!this.hasBoundPosition()){ + if (!this.hasBoundPosition()) { this.boundPosition = null; } - if(this.doesNeedUpdateSend()){ + if (this.doesNeedUpdateSend()) { this.onUpdateSent(); } int strength = this.getComparatorStrength(); - if(this.lastStrength != strength){ + if (this.lastStrength != strength) { this.lastStrength = strength; this.markDirty(); } - } - else{ - if(this.boundPosition != null){ + } else { + if (this.boundPosition != null) { this.renderParticles(); } } } - protected boolean doesNeedUpdateSend(){ + protected boolean doesNeedUpdateSend() { return this.boundPosition != this.boundPosBefore || this.boundPosition != null && this.world.getBlockState(this.boundPosition).getBlock() != this.boundBlockBefore || this.rangeBefore != this.range; } - protected void onUpdateSent(){ + protected void onUpdateSent() { this.rangeBefore = this.range; this.boundPosBefore = this.boundPosition; this.boundBlockBefore = this.boundPosition == null ? null : this.world.getBlockState(this.boundPosition).getBlock(); - if(this.boundPosition != null){ + if (this.boundPosition != null) { this.world.notifyNeighborsOfStateChange(this.pos, this.world.getBlockState(this.boundPosition).getBlock(), false); } @@ -128,9 +126,9 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl } @Override - public boolean hasBoundPosition(){ - if(this.boundPosition != null){ - if(this.world.getTileEntity(this.boundPosition) instanceof IPhantomTile || this.getPos().getX() == this.boundPosition.getX() && this.getPos().getY() == this.boundPosition.getY() && this.getPos().getZ() == this.boundPosition.getZ()){ + public boolean hasBoundPosition() { + if (this.boundPosition != null) { + if (this.world.getTileEntity(this.boundPosition) instanceof IPhantomTile || this.getPos().getX() == this.boundPosition.getX() && this.getPos().getY() == this.boundPosition.getY() && this.getPos().getZ() == this.boundPosition.getZ()) { this.boundPosition = null; return false; } @@ -140,78 +138,72 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl } @SideOnly(Side.CLIENT) - public void renderParticles(){ - if(this.world.rand.nextInt(2) == 0){ - double d1 = this.boundPosition.getY()+this.world.rand.nextFloat(); - int i1 = this.world.rand.nextInt(2)*2-1; - int j1 = this.world.rand.nextInt(2)*2-1; - double d4 = (this.world.rand.nextFloat()-0.5D)*0.125D; - double d2 = this.boundPosition.getZ()+0.5D+0.25D*j1; - double d5 = this.world.rand.nextFloat()*1.0F*j1; - double d0 = this.boundPosition.getX()+0.5D+0.25D*i1; - double d3 = this.world.rand.nextFloat()*1.0F*i1; + public void renderParticles() { + if (this.world.rand.nextInt(2) == 0) { + double d1 = this.boundPosition.getY() + this.world.rand.nextFloat(); + int i1 = this.world.rand.nextInt(2) * 2 - 1; + int j1 = this.world.rand.nextInt(2) * 2 - 1; + double d4 = (this.world.rand.nextFloat() - 0.5D) * 0.125D; + double d2 = this.boundPosition.getZ() + 0.5D + 0.25D * j1; + double d5 = this.world.rand.nextFloat() * 1.0F * j1; + double d0 = this.boundPosition.getX() + 0.5D + 0.25D * i1; + double d3 = this.world.rand.nextFloat() * 1.0F * i1; this.world.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5); } } @Override - public boolean isBoundThingInRange(){ - return this.hasBoundPosition() && this.boundPosition.distanceSq(this.getPos()) <= this.range*this.range; + public boolean isBoundThingInRange() { + return this.hasBoundPosition() && this.boundPosition.distanceSq(this.getPos()) <= this.range * this.range; } @Override - public BlockPos getBoundPosition(){ + public BlockPos getBoundPosition() { return this.boundPosition; } @Override - public void setBoundPosition(BlockPos pos){ + public void setBoundPosition(BlockPos pos) { this.boundPosition = pos; } @Override - public int getGuiID(){ + public int getGuiID() { return -1; } @Override - public int getRange(){ + public int getRange() { return this.range; } protected abstract boolean isCapabilitySupported(Capability capability); @Override - public boolean hasCapability(Capability capability, EnumFacing facing){ - if(this.isBoundThingInRange() && this.isCapabilitySupported(capability)){ + public boolean hasCapability(Capability capability, EnumFacing facing) { + if (this.isBoundThingInRange() && this.isCapabilitySupported(capability)) { TileEntity tile = this.world.getTileEntity(this.getBoundPosition()); - if(tile != null){ - return tile.hasCapability(capability, facing); - } + if (tile != null) { return tile.hasCapability(capability, facing); } } return super.hasCapability(capability, facing); } @Override - public T getCapability(Capability capability, EnumFacing facing){ - if(this.isBoundThingInRange() && this.isCapabilitySupported(capability)){ + public T getCapability(Capability capability, EnumFacing facing) { + if (this.isBoundThingInRange() && this.isCapabilitySupported(capability)) { TileEntity tile = this.world.getTileEntity(this.getBoundPosition()); - if(tile != null){ - return tile.getCapability(capability, facing); - } + if (tile != null) { return tile.getCapability(capability, facing); } } return super.getCapability(capability, facing); } @Override - public int getComparatorStrength(){ - if(this.isBoundThingInRange()){ + public int getComparatorStrength() { + if (this.isBoundThingInRange()) { BlockPos pos = this.getBoundPosition(); IBlockState state = this.world.getBlockState(pos); - if(state.hasComparatorInputOverride()){ - return state.getComparatorInputOverride(this.world, pos); - } + if (state.hasComparatorInputOverride()) { return state.getComparatorInputOverride(this.world, pos); } } return 0; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java index 146f96c01..cfba2d526 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java @@ -22,7 +22,7 @@ import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.wrapper.PlayerInvWrapper; -public class TileEntityPlayerInterface extends TileEntityBase implements IEnergyDisplay{ +public class TileEntityPlayerInterface extends TileEntityBase implements IEnergyDisplay { public static final int DEFAULT_RANGE = 32; private final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 50, 0); @@ -33,27 +33,25 @@ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergy private int oldEnergy; private int range; - public TileEntityPlayerInterface(){ + public TileEntityPlayerInterface() { super("playerInterface"); } - private EntityPlayer getPlayer(){ - if(this.connectedPlayer != null){ + private EntityPlayer getPlayer() { + if (this.connectedPlayer != null) { EntityPlayer player = this.world.getPlayerEntityByUUID(this.connectedPlayer); - if(player != null){ - if(player.getDistance(this.pos.getX(), this.pos.getY(), this.pos.getZ()) <= this.range){ - return player; - } + if (player != null) { + if (player.getDistance(this.pos.getX(), this.pos.getY(), this.pos.getZ()) <= this.range) { return player; } } } return null; } @Override - public IItemHandler getItemHandler(EnumFacing facing){ + public IItemHandler getItemHandler(EnumFacing facing) { EntityPlayer player = this.getPlayer(); - if(this.oldPlayer != player){ + if (this.oldPlayer != player) { this.oldPlayer = player; this.playerHandler = player == null ? null : new PlayerInvWrapper(player.inventory); @@ -63,84 +61,83 @@ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergy } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ + if (!this.world.isRemote) { boolean changed = false; this.range = TileEntityPhantomface.upgradeRange(DEFAULT_RANGE, this.world, this.pos); EntityPlayer player = this.getPlayer(); - if(player != null){ - for(int i = 0; i < player.inventory.getSizeInventory(); i++){ - if(this.storage.getEnergyStored() > 0){ + if (player != null) { + for (int i = 0; i < player.inventory.getSizeInventory(); i++) { + if (this.storage.getEnergyStored() > 0) { ItemStack slot = player.inventory.getStackInSlot(i); - if(StackUtil.isValid(slot) && slot.getCount() == 1){ + if (StackUtil.isValid(slot) && slot.getCount() == 1) { int received = 0; - if(slot.hasCapability(CapabilityEnergy.ENERGY, null)){ + if (slot.hasCapability(CapabilityEnergy.ENERGY, null)) { IEnergyStorage cap = slot.getCapability(CapabilityEnergy.ENERGY, null); - if(cap != null){ + if (cap != null) { received = cap.receiveEnergy(this.storage.getEnergyStored(), false); } } - if(received > 0){ + if (received > 0) { this.storage.extractEnergyInternal(received, false); } } - } - else{ + } else { break; } } } - if(changed){ + if (changed) { this.markDirty(); this.sendUpdate(); } - if(this.storage.getEnergyStored() != this.oldEnergy && this.sendUpdateWithInterval()){ + if (this.storage.getEnergyStored() != this.oldEnergy && this.sendUpdateWithInterval()) { this.oldEnergy = this.storage.getEnergyStored(); } } } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); - if(this.connectedPlayer != null && type != NBTType.SAVE_BLOCK){ + if (this.connectedPlayer != null && type != NBTType.SAVE_BLOCK) { compound.setUniqueId("Player", this.connectedPlayer); compound.setString("PlayerName", this.playerName); } } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); - if(compound.hasKey("PlayerLeast") && type != NBTType.SAVE_BLOCK){ + if (compound.hasKey("PlayerLeast") && type != NBTType.SAVE_BLOCK) { this.connectedPlayer = compound.getUniqueId("Player"); this.playerName = compound.getString("PlayerName"); } } @Override - public CustomEnergyStorage getEnergyStorage(){ + public CustomEnergyStorage getEnergyStorage() { return this.storage; } @Override - public boolean needsHoldShift(){ + public boolean needsHoldShift() { return false; } @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing){ + public IEnergyStorage getEnergyStorage(EnumFacing facing) { return this.storage; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityShockSuppressor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityShockSuppressor.java index 9a714736a..e5445b14f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityShockSuppressor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityShockSuppressor.java @@ -10,14 +10,14 @@ package de.ellpeck.actuallyadditions.mod.tile; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraftforge.energy.IEnergyStorage; -import java.util.ArrayList; -import java.util.List; - -public class TileEntityShockSuppressor extends TileEntityBase implements IEnergyDisplay{ +public class TileEntityShockSuppressor extends TileEntityBase implements IEnergyDisplay { public static final List SUPPRESSORS = new ArrayList<>(); @@ -27,67 +27,67 @@ public class TileEntityShockSuppressor extends TileEntityBase implements IEnergy public CustomEnergyStorage storage = new CustomEnergyStorage(300000, 400, 0); private int oldEnergy; - public TileEntityShockSuppressor(){ + public TileEntityShockSuppressor() { super("shockSuppressor"); } @Override - public void onChunkUnload(){ + public void onChunkUnload() { super.onChunkUnload(); - if(!this.world.isRemote){ + if (!this.world.isRemote) { SUPPRESSORS.remove(this); } } @Override - public void invalidate(){ + public void invalidate() { super.invalidate(); - if(!this.world.isRemote){ + if (!this.world.isRemote) { SUPPRESSORS.remove(this); } } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ - if(!this.isInvalid() && !SUPPRESSORS.contains(this)){ + if (!this.world.isRemote) { + if (!this.isInvalid() && !SUPPRESSORS.contains(this)) { SUPPRESSORS.add(this); } - if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){ + if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { this.oldEnergy = this.storage.getEnergyStored(); } } } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); } @Override - public CustomEnergyStorage getEnergyStorage(){ + public CustomEnergyStorage getEnergyStorage() { return this.storage; } @Override - public boolean needsHoldShift(){ + public boolean needsHoldShift() { return false; } @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing){ + public IEnergyStorage getEnergyStorage(EnumFacing facing) { return this.storage; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java index ba1a04b66..d12a69b4e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java @@ -14,37 +14,37 @@ import de.ellpeck.actuallyadditions.mod.network.gui.IStringReactor; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; -public class TileEntitySmileyCloud extends TileEntityBase implements IStringReactor{ +public class TileEntitySmileyCloud extends TileEntityBase implements IStringReactor { public String name; private String nameBefore; - public TileEntitySmileyCloud(){ + public TileEntitySmileyCloud() { super("smileyCloud"); } @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { super.writeSyncableNBT(compound, type); - if(this.name != null && type != NBTType.SAVE_BLOCK){ + if (this.name != null && type != NBTType.SAVE_BLOCK) { compound.setString("Name", this.name); } } @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type) { super.readSyncableNBT(compound, type); - if(type != NBTType.SAVE_BLOCK){ + if (type != NBTType.SAVE_BLOCK) { this.name = compound.getString("Name"); } } @Override - public void updateEntity(){ + public void updateEntity() { super.updateEntity(); - if(!this.world.isRemote){ + if (!this.world.isRemote) { boolean nameChanged = this.name != null ? !this.name.equals(this.nameBefore) : this.nameBefore != null; - if(nameChanged && this.sendUpdateWithInterval()){ + if (nameChanged && this.sendUpdateWithInterval()) { this.nameBefore = this.name; this.markDirty(); } @@ -52,7 +52,7 @@ public class TileEntitySmileyCloud extends TileEntityBase implements IStringReac } @Override - public void onTextReceived(String text, int textID, EntityPlayer player){ + public void onTextReceived(String text, int textID, EntityPlayer player) { this.name = text; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/update/ThreadUpdateChecker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/update/ThreadUpdateChecker.java index 2f97e10e4..31c77b900 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/update/ThreadUpdateChecker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/update/ThreadUpdateChecker.java @@ -18,39 +18,38 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.util.Util; -public class ThreadUpdateChecker extends Thread{ +public class ThreadUpdateChecker extends Thread { - public ThreadUpdateChecker(){ - this.setName(ActuallyAdditions.NAME+" Update Checker"); + public ThreadUpdateChecker() { + this.setName(ActuallyAdditions.NAME + " Update Checker"); this.setDaemon(true); this.start(); } @Override - public void run(){ + public void run() { ActuallyAdditions.LOGGER.info("Starting Update Check..."); - try{ + try { URL newestURL = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/update/updateVersions.properties"); Properties updateProperties = new Properties(); updateProperties.load(new InputStreamReader(newestURL.openStream())); String currentMcVersion = Util.getMcVersion(); - if(ConfigBoolValues.UPDATE_CHECK_VERSION_SPECIFIC.isEnabled()){ + if (ConfigBoolValues.UPDATE_CHECK_VERSION_SPECIFIC.isEnabled()) { String newestVersionProp = updateProperties.getProperty(currentMcVersion); UpdateChecker.updateVersionInt = Integer.parseInt(newestVersionProp); - UpdateChecker.updateVersionString = currentMcVersion+"-r"+newestVersionProp; - } - else{ + UpdateChecker.updateVersionString = currentMcVersion + "-r" + newestVersionProp; + } else { int highest = 0; String highestString = ""; - for(String updateMC : updateProperties.stringPropertyNames()){ + for (String updateMC : updateProperties.stringPropertyNames()) { String updateVersion = updateProperties.getProperty(updateMC); int update = Integer.parseInt(updateVersion); - if(highest < update){ + if (highest < update) { highest = update; - highestString = updateMC+"-r"+updateVersion; + highestString = updateMC + "-r" + updateVersion; } } @@ -60,26 +59,24 @@ public class ThreadUpdateChecker extends Thread{ String clientVersionString = Util.getMajorModVersion(); int clientVersion = Integer.parseInt(clientVersionString.contains("_") ? clientVersionString.substring(0, clientVersionString.indexOf("_")) : clientVersionString); - if(UpdateChecker.updateVersionInt > clientVersion){ + if (UpdateChecker.updateVersionInt > clientVersion) { UpdateChecker.needsUpdateNotify = true; } ActuallyAdditions.LOGGER.info("Update Check done!"); - } - catch(Exception e){ + } catch (Exception e) { ActuallyAdditions.LOGGER.error("Update Check failed!", e); UpdateChecker.checkFailed = true; } - if(!UpdateChecker.checkFailed){ - if(UpdateChecker.needsUpdateNotify){ - ActuallyAdditions.LOGGER.info("There is an Update for "+ActuallyAdditions.NAME+" available!"); - ActuallyAdditions.LOGGER.info("Current Version: "+ActuallyAdditions.VERSION+", newest Version: "+UpdateChecker.updateVersionString+"!"); - ActuallyAdditions.LOGGER.info("View the Changelog at "+UpdateChecker.CHANGELOG_LINK); - ActuallyAdditions.LOGGER.info("Download at "+UpdateChecker.DOWNLOAD_LINK); - } - else{ - ActuallyAdditions.LOGGER.info(ActuallyAdditions.NAME+" is up to date!"); + if (!UpdateChecker.checkFailed) { + if (UpdateChecker.needsUpdateNotify) { + ActuallyAdditions.LOGGER.info("There is an Update for " + ActuallyAdditions.NAME + " available!"); + ActuallyAdditions.LOGGER.info("Current Version: " + ActuallyAdditions.VERSION + ", newest Version: " + UpdateChecker.updateVersionString + "!"); + ActuallyAdditions.LOGGER.info("View the Changelog at " + UpdateChecker.CHANGELOG_LINK); + ActuallyAdditions.LOGGER.info("Download at " + UpdateChecker.DOWNLOAD_LINK); + } else { + ActuallyAdditions.LOGGER.info(ActuallyAdditions.NAME + " is up to date!"); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java index 3a0faeaec..609f2edfc 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java @@ -23,7 +23,7 @@ import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class UpdateChecker{ +public class UpdateChecker { public static final String DOWNLOAD_LINK = "http://ellpeck.de/actadddownload"; public static final String CHANGELOG_LINK = "http://ellpeck.de/actaddchangelog"; @@ -33,8 +33,8 @@ public class UpdateChecker{ public static String updateVersionString; public static boolean threadFinished = false; - public UpdateChecker(){ - if(ConfigBoolValues.DO_UPDATE_CHECK.isEnabled() && !Util.isDevVersion()){ + public UpdateChecker() { + if (ConfigBoolValues.DO_UPDATE_CHECK.isEnabled() && !Util.isDevVersion()) { ActuallyAdditions.LOGGER.info("Initializing Update Checker..."); new ThreadUpdateChecker(); MinecraftForge.EVENT_BUS.register(this); @@ -43,18 +43,17 @@ public class UpdateChecker{ @SideOnly(Side.CLIENT) @SubscribeEvent(receiveCanceled = true) - public void onTick(TickEvent.ClientTickEvent event){ - if(Minecraft.getMinecraft().player != null){ + public void onTick(TickEvent.ClientTickEvent event) { + if (Minecraft.getMinecraft().player != null) { EntityPlayer player = Minecraft.getMinecraft().player; - if(UpdateChecker.checkFailed){ - player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localize("info."+ActuallyAdditions.MODID+".update.failed"))); + if (UpdateChecker.checkFailed) { + player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localize("info." + ActuallyAdditions.MODID + ".update.failed"))); + } else if (UpdateChecker.needsUpdateNotify) { + player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localize("info." + ActuallyAdditions.MODID + ".update.generic"))); + player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".update.versionCompare", ActuallyAdditions.VERSION, UpdateChecker.updateVersionString))); + player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".update.buttons", UpdateChecker.CHANGELOG_LINK, UpdateChecker.DOWNLOAD_LINK))); } - else if(UpdateChecker.needsUpdateNotify){ - player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localize("info."+ActuallyAdditions.MODID+".update.generic"))); - player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localizeFormatted("info."+ActuallyAdditions.MODID+".update.versionCompare", ActuallyAdditions.VERSION, UpdateChecker.updateVersionString))); - player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localizeFormatted("info."+ActuallyAdditions.MODID+".update.buttons", UpdateChecker.CHANGELOG_LINK, UpdateChecker.DOWNLOAD_LINK))); - } - if(threadFinished) MinecraftForge.EVENT_BUS.unregister(this); + if (threadFinished) MinecraftForge.EVENT_BUS.unregister(this); } } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java index 90d72a20b..66e23549b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java @@ -47,39 +47,39 @@ import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public final class AssetUtil{ +public final class AssetUtil { public static final int MAX_LIGHT_X = 0xF000F0; public static final int MAX_LIGHT_Y = 0xF000F0; public static final ResourceLocation GUI_INVENTORY_LOCATION = getGuiLocation("gui_inventory"); - public static ResourceLocation getGuiLocation(String file){ - return new ResourceLocation(ActuallyAdditions.MODID, "textures/gui/"+file+".png"); + public static ResourceLocation getGuiLocation(String file) { + return new ResourceLocation(ActuallyAdditions.MODID, "textures/gui/" + file + ".png"); } - public static ResourceLocation getBookletGuiLocation(String file){ - return getGuiLocation("booklet/"+file); + public static ResourceLocation getBookletGuiLocation(String file) { + return getGuiLocation("booklet/" + file); } @SideOnly(Side.CLIENT) - public static void displayNameString(FontRenderer font, int xSize, int yPositionOfMachineText, String text){ - font.drawString(text, xSize/2-font.getStringWidth(text)/2, yPositionOfMachineText, StringUtil.DECIMAL_COLOR_WHITE); + public static void displayNameString(FontRenderer font, int xSize, int yPositionOfMachineText, String text) { + font.drawString(text, xSize / 2 - font.getStringWidth(text) / 2, yPositionOfMachineText, StringUtil.DECIMAL_COLOR_WHITE); } @SideOnly(Side.CLIENT) - public static void displayNameString(FontRenderer font, int xSize, int yPositionOfMachineText, TileEntityBase tile){ + public static void displayNameString(FontRenderer font, int xSize, int yPositionOfMachineText, TileEntityBase tile) { displayNameString(font, xSize, yPositionOfMachineText, StringUtil.localize(tile.getNameForTranslation())); } @SideOnly(Side.CLIENT) - public static void renderBlockInWorld(Block block, int meta){ + public static void renderBlockInWorld(Block block, int meta) { renderItemInWorld(new ItemStack(block, 1, meta)); } @SideOnly(Side.CLIENT) - public static void renderItemInWorld(ItemStack stack){ - if(StackUtil.isValid(stack)){ + public static void renderItemInWorld(ItemStack stack) { + if (StackUtil.isValid(stack)) { GlStateManager.pushMatrix(); GlStateManager.disableLighting(); GlStateManager.pushAttrib(); @@ -93,7 +93,7 @@ public final class AssetUtil{ } @SideOnly(Side.CLIENT) - public static void renderStateInWorld(IBlockState state, IBlockAccess world, BlockPos pos, float brightness){ + public static void renderStateInWorld(IBlockState state, IBlockAccess world, BlockPos pos, float brightness) { Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state); GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F); @@ -107,8 +107,8 @@ public final class AssetUtil{ } @SideOnly(Side.CLIENT) - public static void renderItemWithoutScrewingWithColors(ItemStack stack){ - if(StackUtil.isValid(stack)){ + public static void renderItemWithoutScrewingWithColors(ItemStack stack) { + if (StackUtil.isValid(stack)) { Minecraft mc = Minecraft.getMinecraft(); RenderItem renderer = mc.getRenderItem(); TextureManager manager = mc.getTextureManager(); @@ -132,7 +132,7 @@ public final class AssetUtil{ } @SideOnly(Side.CLIENT) - public static void renderStackToGui(ItemStack stack, int x, int y, float scale){ + public static void renderStackToGui(ItemStack stack, int x, int y, float scale) { GlStateManager.pushMatrix(); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); @@ -155,15 +155,15 @@ public final class AssetUtil{ //Copied from Gui.class and changed @SideOnly(Side.CLIENT) - public static void drawHorizontalGradientRect(int left, int top, int right, int bottom, int startColor, int endColor, float zLevel){ - float f = (startColor >> 24 & 255)/255.0F; - float f1 = (startColor >> 16 & 255)/255.0F; - float f2 = (startColor >> 8 & 255)/255.0F; - float f3 = (startColor & 255)/255.0F; - float f4 = (endColor >> 24 & 255)/255.0F; - float f5 = (endColor >> 16 & 255)/255.0F; - float f6 = (endColor >> 8 & 255)/255.0F; - float f7 = (endColor & 255)/255.0F; + public static void drawHorizontalGradientRect(int left, int top, int right, int bottom, int startColor, int endColor, float zLevel) { + float f = (startColor >> 24 & 255) / 255.0F; + float f1 = (startColor >> 16 & 255) / 255.0F; + float f2 = (startColor >> 8 & 255) / 255.0F; + float f3 = (startColor & 255) / 255.0F; + float f4 = (endColor >> 24 & 255) / 255.0F; + float f5 = (endColor >> 16 & 255) / 255.0F; + float f6 = (endColor >> 8 & 255) / 255.0F; + float f7 = (endColor & 255) / 255.0F; GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); GlStateManager.disableAlpha(); @@ -184,10 +184,10 @@ public final class AssetUtil{ } @SideOnly(Side.CLIENT) - public static void renderNameTag(String tag, double x, double y, double z){ + public static void renderNameTag(String tag, double x, double y, double z) { FontRenderer fontrenderer = Minecraft.getMinecraft().fontRenderer; float f = 1.6F; - float f1 = 0.016666668F*f; + float f1 = 0.016666668F * f; GlStateManager.pushMatrix(); GlStateManager.translate(x, y, z); GL11.glNormal3f(0.0F, 1.0F, 0.0F); @@ -202,27 +202,27 @@ public final class AssetUtil{ Tessellator tessellator = Tessellator.getInstance(); BufferBuilder renderer = tessellator.getBuffer(); int i = 0; - int j = fontrenderer.getStringWidth(tag)/2; + int j = fontrenderer.getStringWidth(tag) / 2; GlStateManager.disableTexture2D(); renderer.begin(7, DefaultVertexFormats.POSITION_COLOR); - renderer.pos(-j-1, -1+i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); - renderer.pos(-j-1, 8+i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); - renderer.pos(j+1, 8+i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); - renderer.pos(j+1, -1+i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); + renderer.pos(-j - 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); + renderer.pos(-j - 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); + renderer.pos(j + 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); + renderer.pos(j + 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); tessellator.draw(); GlStateManager.enableTexture2D(); - fontrenderer.drawString(tag, -fontrenderer.getStringWidth(tag)/2, i, 553648127); + fontrenderer.drawString(tag, -fontrenderer.getStringWidth(tag) / 2, i, 553648127); GlStateManager.enableDepth(); GlStateManager.depthMask(true); - fontrenderer.drawString(tag, -fontrenderer.getStringWidth(tag)/2, i, -1); + fontrenderer.drawString(tag, -fontrenderer.getStringWidth(tag) / 2, i, -1); GlStateManager.enableLighting(); GlStateManager.disableBlend(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.popMatrix(); } - public static void spawnLaserWithTimeServer(World world, double startX, double startY, double startZ, double endX, double endY, double endZ, float[] color, int maxAge, double rotationTime, float size, float alpha){ - if(!world.isRemote){ + public static void spawnLaserWithTimeServer(World world, double startX, double startY, double startZ, double endX, double endY, double endZ, float[] color, int maxAge, double rotationTime, float size, float alpha) { + if (!world.isRemote) { NBTTagCompound data = new NBTTagCompound(); data.setDouble("StartX", startX); data.setDouble("StartY", startY); @@ -242,10 +242,10 @@ public final class AssetUtil{ } @SideOnly(Side.CLIENT) - public static void spawnLaserWithTimeClient(double startX, double startY, double startZ, double endX, double endY, double endZ, float[] color, int maxAge, double rotationTime, float size, float alpha){ + public static void spawnLaserWithTimeClient(double startX, double startY, double startZ, double endX, double endY, double endZ, float[] color, int maxAge, double rotationTime, float size, float alpha) { Minecraft mc = Minecraft.getMinecraft(); - if(mc.player.getDistance(startX, startY, startZ) <= 64 || mc.player.getDistance(endX, endY, endZ) <= 64){ + if (mc.player.getDistance(startX, startY, startZ) <= 64 || mc.player.getDistance(endX, endY, endZ) <= 64) { Particle fx = new ParticleBeam(mc.world, startX, startY, startZ, endX, endY, endZ, color, maxAge, rotationTime, size, alpha); mc.effectRenderer.addEffect(fx); } @@ -254,7 +254,7 @@ public final class AssetUtil{ //Thanks to feldim2425 for this. //I can't do rendering code. Ever. @SideOnly(Side.CLIENT) - public static void renderLaser(double firstX, double firstY, double firstZ, double secondX, double secondY, double secondZ, double rotationTime, float alpha, double beamWidth, float[] color){ + public static void renderLaser(double firstX, double firstY, double firstZ, double secondX, double secondY, double secondZ, double rotationTime, float alpha, double beamWidth, float[] color) { Tessellator tessy = Tessellator.getInstance(); BufferBuilder render = tessy.getBuffer(); World world = Minecraft.getMinecraft().world; @@ -267,8 +267,8 @@ public final class AssetUtil{ Vec3d vec2 = new Vec3d(secondX, secondY, secondZ); Vec3d combinedVec = vec2.subtract(vec1); - double rot = rotationTime > 0 ? 360D*(world.getTotalWorldTime()%rotationTime/rotationTime) : 0; - double pitch = Math.atan2(combinedVec.y, Math.sqrt(combinedVec.x*combinedVec.x+combinedVec.z*combinedVec.z)); + double rot = rotationTime > 0 ? 360D * (world.getTotalWorldTime() % rotationTime / rotationTime) : 0; + double pitch = Math.atan2(combinedVec.y, Math.sqrt(combinedVec.x * combinedVec.x + combinedVec.z * combinedVec.z)); double yaw = Math.atan2(-combinedVec.z, combinedVec.x); double length = combinedVec.length(); @@ -281,50 +281,50 @@ public final class AssetUtil{ int func = GL11.glGetInteger(GL11.GL_ALPHA_TEST_FUNC); float ref = GL11.glGetFloat(GL11.GL_ALPHA_TEST_REF); GlStateManager.alphaFunc(GL11.GL_ALWAYS, 0); - GlStateManager.translate(firstX-TileEntityRendererDispatcher.staticPlayerX, firstY-TileEntityRendererDispatcher.staticPlayerY, firstZ-TileEntityRendererDispatcher.staticPlayerZ); - GlStateManager.rotate((float)(180*yaw/Math.PI), 0, 1, 0); - GlStateManager.rotate((float)(180*pitch/Math.PI), 0, 0, 1); - GlStateManager.rotate((float)rot, 1, 0, 0); + GlStateManager.translate(firstX - TileEntityRendererDispatcher.staticPlayerX, firstY - TileEntityRendererDispatcher.staticPlayerY, firstZ - TileEntityRendererDispatcher.staticPlayerZ); + GlStateManager.rotate((float) (180 * yaw / Math.PI), 0, 1, 0); + GlStateManager.rotate((float) (180 * pitch / Math.PI), 0, 0, 1); + GlStateManager.rotate((float) rot, 1, 0, 0); /*if(r != r2 || g != g2 || b != b2){ render.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR); Minecraft.getMinecraft().renderEngine.bindTexture(ClientUtil.LIGHT_BEAM_GRADIENT); - + render.pos(length, -beamWidth, beamWidth).tex(0, 0).color(r, g, b, alpha).endVertex(); render.pos(length, beamWidth, beamWidth).tex(0, 1).color(r, g, b, alpha).endVertex(); render.pos(0, beamWidth, beamWidth).tex(1, 1).color(r, g, b, alpha).endVertex(); render.pos(0, -beamWidth, beamWidth).tex(1, 0).color(r, g, b, alpha).endVertex(); - + render.pos(length, -beamWidth, beamWidth).tex(1, 0).color(r2, g2, b2, alpha).endVertex(); render.pos(length, beamWidth, beamWidth).tex(1, 1).color(r2, g2, b2, alpha).endVertex(); render.pos(0, beamWidth, beamWidth).tex(0, 1).color(r2, g2, b2, alpha).endVertex(); render.pos(0, -beamWidth, beamWidth).tex(0, 0).color(r2, g2, b2, alpha).endVertex(); - + render.pos(length, beamWidth, -beamWidth).tex(0, 0).color(r, g, b, alpha).endVertex(); render.pos(length, -beamWidth, -beamWidth).tex(0, 1).color(r, g, b, alpha).endVertex(); render.pos(0, -beamWidth, -beamWidth).tex(1, 1).color(r, g, b, alpha).endVertex(); render.pos(0, beamWidth, -beamWidth).tex(1, 0).color(r, g, b, alpha).endVertex(); - + render.pos(length, beamWidth, -beamWidth).tex(1, 0).color(r2, g2, b2, alpha).endVertex(); render.pos(length, -beamWidth, -beamWidth).tex(1, 1).color(r2, g2, b2, alpha).endVertex(); render.pos(0, -beamWidth, -beamWidth).tex(0, 1).color(r2, g2, b2, alpha).endVertex(); render.pos(0, beamWidth, -beamWidth).tex(0, 0).color(r2, g2, b2, alpha).endVertex(); - + render.pos(length, beamWidth, beamWidth).tex(0, 0).color(r, g, b, alpha).endVertex(); render.pos(length, beamWidth, -beamWidth).tex(0, 1).color(r, g, b, alpha).endVertex(); render.pos(0, beamWidth, -beamWidth).tex(1, 1).color(r, g, b, alpha).endVertex(); render.pos(0, beamWidth, beamWidth).tex(1, 0).color(r, g, b, alpha).endVertex(); - + render.pos(length, beamWidth, beamWidth).tex(1, 0).color(r2, g2, b2, alpha).endVertex(); render.pos(length, beamWidth, -beamWidth).tex(1, 1).color(r2, g2, b2, alpha).endVertex(); render.pos(0, beamWidth, -beamWidth).tex(0, 1).color(r2, g2, b2, alpha).endVertex(); render.pos(0, beamWidth, beamWidth).tex(0, 0).color(r2, g2, b2, alpha).endVertex(); - + render.pos(length, -beamWidth, -beamWidth).tex(0, 0).color(r, g, b, alpha).endVertex(); render.pos(length, -beamWidth, beamWidth).tex(0, 1).color(r, g, b, alpha).endVertex(); render.pos(0, -beamWidth, beamWidth).tex(1, 1).color(r, g, b, alpha).endVertex(); render.pos(0, -beamWidth, -beamWidth).tex(1, 0).color(r, g, b, alpha).endVertex(); - + render.pos(length, -beamWidth, -beamWidth).tex(1, 0).color(r2, g2, b2, alpha).endVertex(); render.pos(length, -beamWidth, beamWidth).tex(1, 1).color(r2, g2, b2, alpha).endVertex(); render.pos(0, -beamWidth, beamWidth).tex(0, 1).color(r2, g2, b2, alpha).endVertex(); @@ -334,8 +334,8 @@ public final class AssetUtil{ else{*/ GlStateManager.disableTexture2D(); render.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR); - for(double i = 0; i < 4; i++){ - double width = beamWidth*(i/4.0); + for (double i = 0; i < 4; i++) { + double width = beamWidth * (i / 4.0); render.pos(length, width, width).tex(0, 0).lightmap(MAX_LIGHT_X, MAX_LIGHT_Y).color(r, g, b, alpha).endVertex(); render.pos(0, width, width).tex(0, 0).lightmap(MAX_LIGHT_X, MAX_LIGHT_Y).color(r, g, b, alpha).endVertex(); render.pos(0, -width, width).tex(0, 0).lightmap(MAX_LIGHT_X, MAX_LIGHT_Y).color(r, g, b, alpha).endVertex(); @@ -368,13 +368,9 @@ public final class AssetUtil{ GlStateManager.popMatrix(); } - public static float[] getWheelColor(float pos){ - if(pos < 85.0f){ - return new float[]{pos*3.0F, 255.0f-pos*3.0f, 0.0f}; - } - if(pos < 170.0f){ - return new float[]{255.0f-(pos -= 85.0f)*3.0f, 0.0f, pos*3.0f}; - } - return new float[]{0.0f, (pos -= 170.0f)*3.0f, 255.0f-pos*3.0f}; + public static float[] getWheelColor(float pos) { + if (pos < 85.0f) { return new float[] { pos * 3.0F, 255.0f - pos * 3.0f, 0.0f }; } + if (pos < 170.0f) { return new float[] { 255.0f - (pos -= 85.0f) * 3.0f, 0.0f, pos * 3.0f }; } + return new float[] { 0.0f, (pos -= 170.0f) * 3.0f, 255.0f - pos * 3.0f }; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AwfulUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AwfulUtil.java index f4b1ad7fe..e3958d31b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AwfulUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AwfulUtil.java @@ -10,7 +10,13 @@ package de.ellpeck.actuallyadditions.mod.util; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Random; + import com.google.common.collect.Lists; + import net.minecraft.item.ItemStack; import net.minecraft.util.math.MathHelper; import net.minecraft.world.storage.loot.LootContext; @@ -18,64 +24,55 @@ import net.minecraft.world.storage.loot.LootTable; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.items.IItemHandlerModifiable; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Random; - //This is stuff copied from somewhere in vanilla and changed so that it works properly //It's unpolished and vanilla-y, so don't look at it! O_O -public final class AwfulUtil{ +public final class AwfulUtil { - public static void fillInventory(LootTable table, IItemHandlerModifiable inventory, Random rand, LootContext context){ + public static void fillInventory(LootTable table, IItemHandlerModifiable inventory, Random rand, LootContext context) { List list = table.generateLootForPools(rand, context); List list1 = getEmptySlotsRandomized(inventory, rand); shuffleItems(list, list1.size(), rand); - for(ItemStack itemstack : list){ - if(itemstack.isEmpty()){ - inventory.setStackInSlot(list1.remove(list1.size()-1), ItemStack.EMPTY); - } - else{ - inventory.setStackInSlot(list1.remove(list1.size()-1), itemstack); + for (ItemStack itemstack : list) { + if (itemstack.isEmpty()) { + inventory.setStackInSlot(list1.remove(list1.size() - 1), ItemStack.EMPTY); + } else { + inventory.setStackInSlot(list1.remove(list1.size() - 1), itemstack); } } } - private static void shuffleItems(List stacks, int someInt, Random rand){ + private static void shuffleItems(List stacks, int someInt, Random rand) { List list = Lists.newArrayList(); Iterator iterator = stacks.iterator(); - while(iterator.hasNext()){ + while (iterator.hasNext()) { ItemStack itemstack = iterator.next(); - if(itemstack.isEmpty()){ + if (itemstack.isEmpty()) { iterator.remove(); - } - else if(itemstack.getCount() > 1){ + } else if (itemstack.getCount() > 1) { list.add(itemstack); iterator.remove(); } } - someInt = someInt-stacks.size(); + someInt = someInt - stacks.size(); - while(someInt > 0 && list.size() > 0){ - ItemStack itemstack2 = list.remove(MathHelper.getInt(rand, 0, list.size()-1)); - int i = MathHelper.getInt(rand, 1, itemstack2.getCount()/2); + while (someInt > 0 && list.size() > 0) { + ItemStack itemstack2 = list.remove(MathHelper.getInt(rand, 0, list.size() - 1)); + int i = MathHelper.getInt(rand, 1, itemstack2.getCount() / 2); ItemStack itemstack1 = itemstack2.splitStack(i); - if(itemstack2.getCount() > 1 && rand.nextBoolean()){ + if (itemstack2.getCount() > 1 && rand.nextBoolean()) { list.add(itemstack2); - } - else{ + } else { stacks.add(itemstack2); } - if(itemstack1.getCount() > 1 && rand.nextBoolean()){ + if (itemstack1.getCount() > 1 && rand.nextBoolean()) { list.add(itemstack1); - } - else{ + } else { stacks.add(itemstack1); } } @@ -84,11 +81,11 @@ public final class AwfulUtil{ Collections.shuffle(stacks, rand); } - private static List getEmptySlotsRandomized(IItemHandlerModifiable inventory, Random rand){ + private static List getEmptySlotsRandomized(IItemHandlerModifiable inventory, Random rand) { List list = Lists.newArrayList(); - for(int i = 0; i < inventory.getSlots(); ++i){ - if(inventory.getStackInSlot(i).isEmpty()){ + for (int i = 0; i < inventory.getSlots(); ++i) { + if (inventory.getStackInSlot(i).isEmpty()) { list.add(i); } } @@ -100,7 +97,7 @@ public final class AwfulUtil{ public static void callTheFuckinPolice(Object... stuff) { int i = 0; String error = "Actually Additions: Something is very wrong. This method was provided with "; - for(Object k : stuff) { + for (Object k : stuff) { error += "\n" + i++ + ": " + (k == null ? "null" : k.getClass().getSimpleName() + " <- CLASS | INSTANCE -> " + k.toString() + ", "); } error += "\n" + "The current side is: " + FMLCommonHandler.instance().getEffectiveSide(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/FluidStateMapper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/FluidStateMapper.java index 78c1dc937..9d1a79549 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/FluidStateMapper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/FluidStateMapper.java @@ -25,25 +25,24 @@ import net.minecraftforge.fml.relauncher.SideOnly; * (Excerpted from Tinkers' Construct with permission, thanks guys!) */ @SideOnly(Side.CLIENT) -public class FluidStateMapper extends StateMapperBase implements ItemMeshDefinition{ +public class FluidStateMapper extends StateMapperBase implements ItemMeshDefinition { public final Fluid fluid; public final ModelResourceLocation location; - public FluidStateMapper(Fluid fluid){ + public FluidStateMapper(Fluid fluid) { this.fluid = fluid; this.location = new ModelResourceLocation(new ResourceLocation(ActuallyAdditions.MODID, "fluids"), fluid.getName()); } @Override - protected ModelResourceLocation getModelResourceLocation(IBlockState state){ + protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return this.location; } - @Override - public ModelResourceLocation getModelLocation(ItemStack stack){ + public ModelResourceLocation getModelLocation(ItemStack stack) { return this.location; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingBlock.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingBlock.java index eb3dada13..40543780d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingBlock.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingBlock.java @@ -14,7 +14,7 @@ import net.minecraft.client.renderer.color.IBlockColor; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public interface IColorProvidingBlock{ +public interface IColorProvidingBlock { @SideOnly(Side.CLIENT) IBlockColor getBlockColor(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingItem.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingItem.java index 080f9d0de..33562842d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingItem.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingItem.java @@ -14,7 +14,7 @@ import net.minecraft.client.renderer.color.IItemColor; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public interface IColorProvidingItem{ +public interface IColorProvidingItem { @SideOnly(Side.CLIENT) IItemColor getItemColor(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java index a9bc93c7a..e4f877184 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java @@ -10,6 +10,9 @@ package de.ellpeck.actuallyadditions.mod.util; +import java.util.Arrays; +import java.util.List; + import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.RegistryHandler; import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase; @@ -26,17 +29,14 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.registry.ForgeRegistries; -import java.util.Arrays; -import java.util.List; +public final class ItemUtil { -public final class ItemUtil{ - - public static Item getItemFromName(String name){ + public static Item getItemFromName(String name) { return ForgeRegistries.ITEMS.getValue(new ResourceLocation(name)); } - public static void registerBlock(Block block, ItemBlockBase itemBlock, String name, boolean addTab){ - block.setTranslationKey(ActuallyAdditions.MODID+"."+name); + public static void registerBlock(Block block, ItemBlockBase itemBlock, String name, boolean addTab) { + block.setTranslationKey(ActuallyAdditions.MODID + "." + name); block.setRegistryName(ActuallyAdditions.MODID, name); RegistryHandler.BLOCKS_TO_REGISTER.add(block); @@ -48,13 +48,13 @@ public final class ItemUtil{ IMCHandler.doBlockIMC(block); - if(block instanceof IColorProvidingBlock){ + if (block instanceof IColorProvidingBlock) { ActuallyAdditions.PROXY.addColoredBlock(block); } } - public static void registerItem(Item item, String name, boolean addTab){ - item.setTranslationKey(ActuallyAdditions.MODID+"."+name); + public static void registerItem(Item item, String name, boolean addTab) { + item.setTranslationKey(ActuallyAdditions.MODID + "." + name); item.setRegistryName(ActuallyAdditions.MODID, name); RegistryHandler.ITEMS_TO_REGISTER.add(item); @@ -63,89 +63,85 @@ public final class ItemUtil{ IMCHandler.doItemIMC(item); - if(item instanceof IColorProvidingItem){ + if (item instanceof IColorProvidingItem) { ActuallyAdditions.PROXY.addColoredItem(item); } } - public static boolean contains(ItemStack[] array, ItemStack stack, boolean checkWildcard){ + public static boolean contains(ItemStack[] array, ItemStack stack, boolean checkWildcard) { return getPlaceAt(array, stack, checkWildcard) != -1; } - public static int getPlaceAt(ItemStack[] array, ItemStack stack, boolean checkWildcard){ + public static int getPlaceAt(ItemStack[] array, ItemStack stack, boolean checkWildcard) { return getPlaceAt(Arrays.asList(array), stack, checkWildcard); } - public static int getPlaceAt(List list, ItemStack stack, boolean checkWildcard){ - if(list != null && list.size() > 0){ - for(int i = 0; i < list.size(); i++){ - if(!StackUtil.isValid(stack) && !StackUtil.isValid(list.get(i)) || areItemsEqual(stack, list.get(i), checkWildcard)){ - return i; - } + public static int getPlaceAt(List list, ItemStack stack, boolean checkWildcard) { + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + if (!StackUtil.isValid(stack) && !StackUtil.isValid(list.get(i)) || areItemsEqual(stack, list.get(i), checkWildcard)) { return i; } } } return -1; } - public static boolean areItemsEqual(ItemStack stack1, ItemStack stack2, boolean checkWildcard){ + public static boolean areItemsEqual(ItemStack stack1, ItemStack stack2, boolean checkWildcard) { return StackUtil.isValid(stack1) && StackUtil.isValid(stack2) && (stack1.isItemEqual(stack2) || checkWildcard && stack1.getItem() == stack2.getItem() && (stack1.getItemDamage() == Util.WILDCARD || stack2.getItemDamage() == Util.WILDCARD)); } /** * Returns true if list contains stack or if both contain null */ - public static boolean contains(List list, ItemStack stack, boolean checkWildcard){ + public static boolean contains(List list, ItemStack stack, boolean checkWildcard) { return !(list == null || list.isEmpty()) && getPlaceAt(list, stack, checkWildcard) != -1; } - public static void addEnchantment(ItemStack stack, Enchantment e, int level){ - if(!hasEnchantment(stack, e)){ + public static void addEnchantment(ItemStack stack, Enchantment e, int level) { + if (!hasEnchantment(stack, e)) { stack.addEnchantment(e, level); } } - public static boolean hasEnchantment(ItemStack stack, Enchantment e){ + public static boolean hasEnchantment(ItemStack stack, Enchantment e) { NBTTagList ench = stack.getEnchantmentTagList(); - if(ench != null){ - for(int i = 0; i < ench.tagCount(); i++){ + if (ench != null) { + for (int i = 0; i < ench.tagCount(); i++) { short id = ench.getCompoundTagAt(i).getShort("id"); - if(id == Enchantment.getEnchantmentID(e)){ - return true; - } + if (id == Enchantment.getEnchantmentID(e)) { return true; } } } return false; } - public static void removeEnchantment(ItemStack stack, Enchantment e){ + public static void removeEnchantment(ItemStack stack, Enchantment e) { NBTTagList ench = stack.getEnchantmentTagList(); - if(ench != null){ - for(int i = 0; i < ench.tagCount(); i++){ + if (ench != null) { + for (int i = 0; i < ench.tagCount(); i++) { short id = ench.getCompoundTagAt(i).getShort("id"); - if(id == Enchantment.getEnchantmentID(e)){ + if (id == Enchantment.getEnchantmentID(e)) { ench.removeTag(i); } } - if(ench.isEmpty() && stack.hasTagCompound()){ + if (ench.isEmpty() && stack.hasTagCompound()) { stack.getTagCompound().removeTag("ench"); } } } - public static boolean canBeStacked(ItemStack stack1, ItemStack stack2){ + public static boolean canBeStacked(ItemStack stack1, ItemStack stack2) { return ItemStack.areItemsEqual(stack1, stack2) && ItemStack.areItemStackTagsEqual(stack1, stack2); } - public static boolean isEnabled(ItemStack stack){ + public static boolean isEnabled(ItemStack stack) { return stack.hasTagCompound() && stack.getTagCompound().getBoolean("IsEnabled"); } - public static void changeEnabled(EntityPlayer player, EnumHand hand){ + public static void changeEnabled(EntityPlayer player, EnumHand hand) { changeEnabled(player.getHeldItem(hand)); } - public static void changeEnabled(ItemStack stack){ - if(!stack.hasTagCompound()){ + public static void changeEnabled(ItemStack stack) { + if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/RecipeUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/RecipeUtil.java index 6be36dea9..be8d227db 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/RecipeUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/RecipeUtil.java @@ -10,6 +10,8 @@ package de.ellpeck.actuallyadditions.mod.util; +import java.util.List; + import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe; @@ -17,26 +19,24 @@ import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; import de.ellpeck.actuallyadditions.mod.util.crafting.RecipeHandler; import net.minecraft.item.crafting.IRecipe; -import java.util.List; +public final class RecipeUtil { -public final class RecipeUtil{ - - public static LensConversionRecipe lastReconstructorRecipe(){ + public static LensConversionRecipe lastReconstructorRecipe() { List list = ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES; - return list.get(list.size()-1); + return list.get(list.size() - 1); } - public static CrusherRecipe lastCrusherRecipe(){ + public static CrusherRecipe lastCrusherRecipe() { List list = ActuallyAdditionsAPI.CRUSHER_RECIPES; - return list.get(list.size()-1); + return list.get(list.size() - 1); } - public static IRecipe lastIRecipe(){ + public static IRecipe lastIRecipe() { return RecipeHandler.lastRecipe; } - public static EmpowererRecipe lastEmpowererRecipe(){ + public static EmpowererRecipe lastEmpowererRecipe() { List list = ActuallyAdditionsAPI.EMPOWERER_RECIPES; - return list.get(list.size()-1); + return list.get(list.size() - 1); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/RefHelp.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/RefHelp.java index 3147c61e3..f25841218 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/RefHelp.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/RefHelp.java @@ -16,7 +16,7 @@ import com.google.common.base.Preconditions; import net.minecraftforge.fml.relauncher.FMLLaunchHandler; public class RefHelp { - + public static class UnableToFindMethodException extends RuntimeException { private static final long serialVersionUID = 1L; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/StringUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/StringUtil.java index 503da14ce..0ab74e0e4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/StringUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/StringUtil.java @@ -22,18 +22,18 @@ import net.minecraft.util.text.translation.LanguageMap; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public final class StringUtil{ +public final class StringUtil { public static final int DECIMAL_COLOR_WHITE = 16777215; public static final int DECIMAL_COLOR_GRAY_TEXT = 4210752; - public static final String BUGGED_ITEM_NAME = ActuallyAdditions.MODID+".lolWutHowUDoDis"; + public static final String BUGGED_ITEM_NAME = ActuallyAdditions.MODID + ".lolWutHowUDoDis"; /** * Localizes a given String */ @SideOnly(Side.CLIENT) - public static String localize(String text){ + public static String localize(String text) { return I18n.format(text); } @@ -41,42 +41,42 @@ public final class StringUtil{ * Localizes a given formatted String with the given Replacements */ @SideOnly(Side.CLIENT) - public static String localizeFormatted(String text, Object... replace){ + public static String localizeFormatted(String text, Object... replace) { return I18n.format(text, replace); } - @SuppressWarnings("deprecation")//TODO: delete this shit and move ItemPotionRing's getItemStackDisplayName into getUnlocalizedName + @SuppressWarnings("deprecation") //TODO: delete this shit and move ItemPotionRing's getItemStackDisplayName into getUnlocalizedName public static String localizeIllegallyOnTheServerDontUseMePls(String langKey) { return net.minecraft.util.text.translation.I18n.translateToLocal(langKey); } @SideOnly(Side.CLIENT) - public static void drawSplitString(FontRenderer renderer, String strg, int x, int y, int width, int color, boolean shadow){ + public static void drawSplitString(FontRenderer renderer, String strg, int x, int y, int width, int color, boolean shadow) { List list = renderer.listFormattedStringToWidth(strg, width); - for(int i = 0; i < list.size(); i++){ + for (int i = 0; i < list.size(); i++) { String s1 = list.get(i); - renderer.drawString(s1, x, y+i*renderer.FONT_HEIGHT, color, shadow); + renderer.drawString(s1, x, y + i * renderer.FONT_HEIGHT, color, shadow); } } @SideOnly(Side.CLIENT) - public static void renderScaledAsciiString(FontRenderer font, String text, float x, float y, int color, boolean shadow, float scale){ + public static void renderScaledAsciiString(FontRenderer font, String text, float x, float y, int color, boolean shadow, float scale) { GlStateManager.pushMatrix(); GlStateManager.scale(scale, scale, scale); boolean oldUnicode = font.getUnicodeFlag(); font.setUnicodeFlag(false); - font.drawString(text, x/scale, y/scale, color, shadow); + font.drawString(text, x / scale, y / scale, color, shadow); font.setUnicodeFlag(oldUnicode); GlStateManager.popMatrix(); } @SideOnly(Side.CLIENT) - public static void renderSplitScaledAsciiString(FontRenderer font, String text, int x, int y, int color, boolean shadow, float scale, int length){ - List lines = font.listFormattedStringToWidth(text, (int)(length/scale)); - for(int i = 0; i < lines.size(); i++){ - renderScaledAsciiString(font, lines.get(i), x, y+i*(int)(font.FONT_HEIGHT*scale+3), color, shadow, scale); + public static void renderSplitScaledAsciiString(FontRenderer font, String text, int x, int y, int color, boolean shadow, float scale, int length) { + List lines = font.listFormattedStringToWidth(text, (int) (length / scale)); + for (int i = 0; i < lines.size(); i++) { + renderScaledAsciiString(font, lines.get(i), x, y + i * (int) (font.FONT_HEIGHT * scale + 3), color, shadow, scale); } } @@ -99,6 +99,6 @@ public final class StringUtil{ cancerino = new LanguageMap(); setupLangMap(); } - return cancerino.translateKey("item.actuallyadditions."+someUnlocAAItemName+".name"); + return cancerino.translateKey("item.actuallyadditions." + someUnlocAAItemName + ".name"); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CommonCapsUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CommonCapsUtil.java index dbc3e2310..5991614c6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CommonCapsUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CommonCapsUtil.java @@ -10,34 +10,33 @@ package de.ellpeck.actuallyadditions.mod.util.compat; +import org.cyclops.commoncapabilities.api.capability.itemhandler.DefaultSlotlessItemHandlerWrapper; +import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler; + import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer; import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer.SlotlessItemHandlerInfo; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.item.ItemStack; import net.minecraftforge.items.IItemHandler; -import org.cyclops.commoncapabilities.api.capability.itemhandler.DefaultSlotlessItemHandlerWrapper; -import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler; -public final class CommonCapsUtil{ +public final class CommonCapsUtil { - public static ISlotlessItemHandler createSlotlessItemViewerHandler(final TileEntityItemViewer tile, IItemHandler normalHandler){ - return new DefaultSlotlessItemHandlerWrapper(normalHandler){ + public static ISlotlessItemHandler createSlotlessItemViewerHandler(final TileEntityItemViewer tile, IItemHandler normalHandler) { + return new DefaultSlotlessItemHandlerWrapper(normalHandler) { @Override - public ItemStack insertItem(ItemStack stack, boolean simulate){ + public ItemStack insertItem(ItemStack stack, boolean simulate) { ItemStack remain = stack.copy(); - for(SlotlessItemHandlerInfo handler : tile.slotlessInfos){ - if(handler.isLoaded() && tile.isWhitelisted(handler, stack, false)){ - if(handler.handler instanceof ISlotlessItemHandler){ - remain = ((ISlotlessItemHandler)handler.handler).insertItem(stack, simulate); + for (SlotlessItemHandlerInfo handler : tile.slotlessInfos) { + if (handler.isLoaded() && tile.isWhitelisted(handler, stack, false)) { + if (handler.handler instanceof ISlotlessItemHandler) { + remain = ((ISlotlessItemHandler) handler.handler).insertItem(stack, simulate); - if(!ItemStack.areItemStacksEqual(remain, stack) && !simulate){ + if (!ItemStack.areItemStacksEqual(remain, stack) && !simulate) { tile.markDirty(); tile.doItemParticle(stack, handler.relayInQuestion.getPos(), tile.connectedRelay.getPos()); } - if(!StackUtil.isValid(remain)){ - return StackUtil.getEmpty(); - } + if (!StackUtil.isValid(remain)) { return StackUtil.getEmpty(); } } } } @@ -45,24 +44,23 @@ public final class CommonCapsUtil{ } @Override - public ItemStack extractItem(int amount, boolean simulate){ - for(SlotlessItemHandlerInfo handler : tile.slotlessInfos){ - if(handler.isLoaded()){ - if(handler.handler instanceof ISlotlessItemHandler){ - ISlotlessItemHandler slotless = (ISlotlessItemHandler)handler.handler; + public ItemStack extractItem(int amount, boolean simulate) { + for (SlotlessItemHandlerInfo handler : tile.slotlessInfos) { + if (handler.isLoaded()) { + if (handler.handler instanceof ISlotlessItemHandler) { + ISlotlessItemHandler slotless = (ISlotlessItemHandler) handler.handler; ItemStack would = slotless.extractItem(amount, true); - if(StackUtil.isValid(would)){ - if(tile.isWhitelisted(handler, would, true)){ + if (StackUtil.isValid(would)) { + if (tile.isWhitelisted(handler, would, true)) { ItemStack has; - if(simulate){ + if (simulate) { has = would; - } - else{ + } else { has = slotless.extractItem(amount, false); } - if(StackUtil.isValid(has) && !simulate){ + if (StackUtil.isValid(has) && !simulate) { tile.markDirty(); tile.doItemParticle(has, tile.connectedRelay.getPos(), handler.relayInQuestion.getPos()); } @@ -77,19 +75,18 @@ public final class CommonCapsUtil{ } @Override - public ItemStack extractItem(ItemStack matchStack, int matchFlags, boolean simulate){ - for(SlotlessItemHandlerInfo handler : tile.slotlessInfos){ - if(handler.isLoaded()){ - if(handler.handler instanceof ISlotlessItemHandler){ - ISlotlessItemHandler slotless = (ISlotlessItemHandler)handler.handler; + public ItemStack extractItem(ItemStack matchStack, int matchFlags, boolean simulate) { + for (SlotlessItemHandlerInfo handler : tile.slotlessInfos) { + if (handler.isLoaded()) { + if (handler.handler instanceof ISlotlessItemHandler) { + ISlotlessItemHandler slotless = (ISlotlessItemHandler) handler.handler; ItemStack would = slotless.extractItem(matchStack, matchFlags, true); - if(StackUtil.isValid(would)){ - if(tile.isWhitelisted(handler, would, true)){ - if(simulate){ + if (StackUtil.isValid(would)) { + if (tile.isWhitelisted(handler, would, true)) { + if (simulate) { return would; - } - else{ + } else { return slotless.extractItem(matchStack, matchFlags, false); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/IMCHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/IMCHandler.java index 77e4c2cb3..f5b9b6e18 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/IMCHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/IMCHandler.java @@ -10,32 +10,30 @@ package de.ellpeck.actuallyadditions.mod.util.compat; -import de.ellpeck.actuallyadditions.mod.blocks.*; +import org.apache.commons.lang3.ArrayUtils; + +import de.ellpeck.actuallyadditions.mod.blocks.BlockGiantChest; +import de.ellpeck.actuallyadditions.mod.blocks.BlockItemViewer; +import de.ellpeck.actuallyadditions.mod.blocks.BlockItemViewerHopping; +import de.ellpeck.actuallyadditions.mod.blocks.BlockLaserRelay; +import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom; +import de.ellpeck.actuallyadditions.mod.blocks.BlockTinyTorch; +import de.ellpeck.actuallyadditions.mod.blocks.BlockWildPlant; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraftforge.fml.common.event.FMLInterModComms; -import org.apache.commons.lang3.ArrayUtils; -public final class IMCHandler{ +public final class IMCHandler { - private static final Class[] NO_CARRYING = new Class[]{ - BlockGiantChest.class, - BlockWildPlant.class, - BlockPlant.class, - BlockPhantom.class, - BlockTinyTorch.class, - BlockItemViewer.class, - BlockItemViewerHopping.class, - BlockLaserRelay.class - }; + private static final Class[] NO_CARRYING = new Class[] { BlockGiantChest.class, BlockWildPlant.class, BlockPlant.class, BlockPhantom.class, BlockTinyTorch.class, BlockItemViewer.class, BlockItemViewerHopping.class, BlockLaserRelay.class }; - public static void doBlockIMC(Block block){ + public static void doBlockIMC(Block block) { boolean allow = !ArrayUtils.contains(NO_CARRYING, block.getClass()); - FMLInterModComms.sendMessage("charset", (allow ? "add" : "remove")+"Carry", block.getRegistryName()); + FMLInterModComms.sendMessage("charset", (allow ? "add" : "remove") + "Carry", block.getRegistryName()); } - public static void doItemIMC(Item item){ + public static void doItemIMC(Item item) { } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/SlotlessableItemHandlerWrapper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/SlotlessableItemHandlerWrapper.java index 4810036e7..04e64fa3c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/SlotlessableItemHandlerWrapper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/SlotlessableItemHandlerWrapper.java @@ -12,21 +12,21 @@ package de.ellpeck.actuallyadditions.mod.util.compat; import net.minecraftforge.items.IItemHandler; -public class SlotlessableItemHandlerWrapper{ +public class SlotlessableItemHandlerWrapper { private final IItemHandler normalHandler; private final Object slotlessHandler; - public SlotlessableItemHandlerWrapper(IItemHandler normalHandler, Object slotlessHandler){ + public SlotlessableItemHandlerWrapper(IItemHandler normalHandler, Object slotlessHandler) { this.normalHandler = normalHandler; this.slotlessHandler = slotlessHandler; } - public IItemHandler getNormalHandler(){ + public IItemHandler getNormalHandler() { return this.normalHandler; } - public Object getSlotlessHandler(){ + public Object getSlotlessHandler() { return this.slotlessHandler; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/BlankRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/BlankRecipe.java index 1190f1dd7..e8f3ea081 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/BlankRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/BlankRecipe.java @@ -6,8 +6,7 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.world.World; import net.minecraftforge.registries.IForgeRegistryEntry; - -public class BlankRecipe extends IForgeRegistryEntry.Impl implements IRecipe{ +public class BlankRecipe extends IForgeRegistryEntry.Impl implements IRecipe { @Override public boolean matches(InventoryCrafting inv, World worldIn) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/IRecipeGrouped.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/IRecipeGrouped.java index 96ee6d8c1..edd42a94c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/IRecipeGrouped.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/IRecipeGrouped.java @@ -10,7 +10,7 @@ package de.ellpeck.actuallyadditions.mod.util.crafting; -public interface IRecipeGrouped{ +public interface IRecipeGrouped { String getRecipeGroup(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/RecipeHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/RecipeHandler.java index 28b3a64be..a853282d7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/RecipeHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/RecipeHandler.java @@ -13,23 +13,23 @@ package de.ellpeck.actuallyadditions.mod.util.crafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; -public final class RecipeHandler{ +public final class RecipeHandler { public static IRecipe lastRecipe; - public static void addOreDictRecipe(ItemStack output, Object... inputs){ + public static void addOreDictRecipe(ItemStack output, Object... inputs) { addShapedRecipe(output, inputs); } - public static void addShapelessOreDictRecipe(ItemStack output, Object... inputs){ + public static void addShapelessOreDictRecipe(ItemStack output, Object... inputs) { addShapelessRecipe(output, inputs); } - public static void addShapelessRecipe(ItemStack output, Object... inputs){ + public static void addShapelessRecipe(ItemStack output, Object... inputs) { RecipeHelper.addOldShapeless(output, inputs); } - public static void addShapedRecipe(ItemStack output, Object... inputs){ + public static void addShapedRecipe(ItemStack output, Object... inputs) { RecipeHelper.addOldShaped(output, inputs); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/RecipeHelper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/RecipeHelper.java index 6e9187df9..3f3fab225 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/RecipeHelper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/RecipeHelper.java @@ -1,5 +1,7 @@ package de.ellpeck.actuallyadditions.mod.util.crafting; +import java.util.List; + import de.ellpeck.actuallyadditions.api.misc.IDisableableItem; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.RegistryHandler; @@ -16,8 +18,6 @@ import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.common.crafting.CraftingHelper.ShapedPrimer; import net.minecraftforge.oredict.OreIngredient; -import java.util.List; - //This class created by Shadows_of_Fire //MIT License public final class RecipeHelper {