diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java deleted file mode 100644 index 184dd51a3..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java +++ /dev/null @@ -1,332 +0,0 @@ -/* - * This file ("ActuallyAdditionsAPI.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api; - -import java.util.ArrayList; -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.IBookletEntry; -import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior; -import de.ellpeck.actuallyadditions.api.internal.IMethodHandler; -import de.ellpeck.actuallyadditions.api.laser.ILaserRelayConnectionHandler; -import de.ellpeck.actuallyadditions.api.lens.Lens; -import de.ellpeck.actuallyadditions.api.lens.LensConversion; -import de.ellpeck.actuallyadditions.api.recipe.BallOfFurReturn; -import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; -import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe; -import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; -import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe; -import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger; -import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; -import de.ellpeck.actuallyadditions.api.recipe.OilGenRecipe; -import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot; -import de.ellpeck.actuallyadditions.api.recipe.WeightedOre; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; - -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_VERSION = "34"; - - public static final List CRUSHER_RECIPES = new ArrayList<>(); - public static final List BALL_OF_FUR_RETURN_ITEMS = new ArrayList<>(); - public static final List TREASURE_CHEST_LOOT = new ArrayList<>(); - public static final List RECONSTRUCTOR_LENS_CONVERSION_RECIPES = new ArrayList<>(); - public static final List EMPOWERER_RECIPES = new ArrayList<>(); - public static final Map RECONSTRUCTOR_LENS_COLOR_CHANGERS = new HashMap<>(); - /** - * Farmer behaviors are sorted when first accessed, this will not be done until after loading, but do not add behaviors at runtime. - */ - public static final List FARMER_BEHAVIORS = new ArrayList<>(); - public static final List COFFEE_MACHINE_INGREDIENTS = new ArrayList<>(); - public static final List COMPOST_RECIPES = new ArrayList<>(); - public static final List OIL_GENERATOR_RECIPES = new ArrayList<>(); - public static final List BOOKLET_ENTRIES = new ArrayList<>(); - //This is added to automatically, you don't need to add anything to this list - public static final List ALL_CHAPTERS = new ArrayList<>(); - //This is added to automatically, you don't need to add anything to this list - public static final List BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA = new ArrayList<>(); - public static final List STONE_ORES = new ArrayList<>(); - public static final List NETHERRACK_ORES = new ArrayList<>(); - - /** - * Use this to handle things that aren't based in the API itself - * DO NOT CHANGE/OVERRIDE THIS!! - * This is getting initialized in Actually Additions' PreInit phase - */ - public static IMethodHandler methodHandler; - - /** - * Use this to add, remove or get Laser Relay Connections and Networks - * The network system is built in a way that doesn't need the individual - * positions to be Laser Relays, it relies only on BlockPos - * DO NOT CHANGE/OVERRIDE THIS!! - * This is getting initialized in Actually Additions' PreInit phase - */ - public static ILaserRelayConnectionHandler connectionHandler; - - //These are getting initialized in Actually Additions' PreInit phase - //DO NOT CHANGE/OVERRIDE THESE!! - public static IBookletEntry entryGettingStarted; - public static IBookletEntry entryReconstruction; - public static IBookletEntry entryLaserRelays; - public static IBookletEntry entryFunctionalNonRF; - public static IBookletEntry entryFunctionalRF; - public static IBookletEntry entryGeneratingRF; - public static IBookletEntry entryItemsNonRF; - public static IBookletEntry entryItemsRF; - public static IBookletEntry entryMisc; - public static IBookletEntry entryUpdatesAndInfos; - //This is added to automatically, you don't need to add anything to this entry - public static IBookletEntry entryAllAndSearch; - public static IBookletEntry entryTrials; - - //These are getting initialized in Actually Additions' PreInit phase - //DO NOT CHANGE/OVERRIDE THESE!! - public static LensConversion lensDefaultConversion; - public static Lens lensDetonation; - public static Lens lensDeath; - public static Lens lensEvenMoarDeath; - public static Lens lensColor; - public static Lens lensDisruption; - public static Lens lensDisenchanting; - public static Lens lensMining; - - /** - * Adds an ore with a specific weight to the list of ores that the lens of the miner will generate inside of stone. - * Higher weight means higher occurence. - * - * @param oreName The ore's name - * @param weight The ore's weight - */ - public static void addMiningLensStoneOre(String oreName, int weight) { - STONE_ORES.add(new WeightedOre(oreName, weight)); - } - - /** - * Adds an ore with a specific weight to the list of ores that the lens of the miner will generate inside of netherrack. - * Higher weight means higher occurence. - * - * @param oreName The ore's name - * @param weight The ore's weight - */ - public static void addMiningLensNetherOre(String oreName, int weight) { - NETHERRACK_ORES.add(new WeightedOre(oreName, weight)); - } - - /** - * Adds a Recipe to the Crusher Recipe Registry - * - * @param input The input as an ItemStack - * @param outputOne The first output as an ItemStack - * @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) { - CRUSHER_RECIPES.add(new CrusherRecipe(Ingredient.fromStacks(input), outputOne, outputTwo.isEmpty() ? ItemStack.EMPTY : outputTwo, outputTwoChance)); - } - - /** - * Adds a Recipe to the Crusher Recipe Registry - * - * @param input The input as an Ingredient - * @param outputOne The first output as an ItemStack - * @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) { - CRUSHER_RECIPES.add(new CrusherRecipe(input, outputOne, outputTwo.isEmpty() ? ItemStack.EMPTY : outputTwo, outputTwoChance)); - } - - /** - * Adds multiple Recipes to the Crusher Recipe Registry - * Use this if you want to add OreDictionary recipes easier - * - * @param inputs The inputs as an ItemStack List, stacksizes are ignored - * @param outputOnes The first outputs as an ItemStack List, stacksizes are ignored - * @param outputOneAmounts The amount of the first output, will be equal for all entries in the list - * @param outputTwos The second outputs as a List (can be null or empty if there should be none) - * @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) { - 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) { - return methodHandler.addCrusherRecipes(inputs, outputOne, outputOneAmount, outputTwo, outputTwoAmount, outputTwoChance); - } - - /** - * Adds a Recipe to the Oil generator - * - * @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) { - addOilGenRecipe(fluidName, genAmount, 100); - } - - /** - * Adds a Recipe to the Oil generator - * - * @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) { - OIL_GENERATOR_RECIPES.add(new OilGenRecipe(fluidName, genAmount, genTime)); - } - - /** - * Adds a new conversion recipe to the compost. - * - * @param input The itemstack to be input into the compost - * @param inputDisplay The block to display when there is input in the compost - * @param output The itemstack to be output from the compost once conversion finishes - * @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) { - COMPOST_RECIPES.add(new CompostRecipe(input, inputDisplay, output, outputDisplay)); - } - - /** - * Adds a new conversion recipe to the compost. - * - * @param input The ingredient to be input into the compost - * @param inputDisplay The state to display when there is input in the compost - * @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) { - COMPOST_RECIPES.add(new CompostRecipe(input, inputDisplay, output, outputDisplay)); - } - - /** - * Adds an item to the list of possible items to be returned when right-clicking a Ball Of Fur - * - * @param stack The ItemStack to be returned - * @param chance The chance (this is from WeightedRandom.Item) - */ - public static void addBallOfFurReturnItem(ItemStack stack, int chance) { - BALL_OF_FUR_RETURN_ITEMS.add(new BallOfFurReturn(stack, chance)); - } - - /** - * Adds an item to the list of possible items to be returned when opening a Treasure Chest - * - * @param stack The ItemStack to be returned, the stacksize is ignored - * @param chance The chance (this is from WeightedRandom.Item) - * @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) { - 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) { - 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) { - EMPOWERER_RECIPES.add(new EmpowererRecipe(input, output, modifier1, modifier2, modifier3, modifier4, energyPerStand, time, particleColor)); - } - - /** - * Adds a recipe to the Atomic Reconstructor conversion lenses - * StackSizes can only be 1 and greater ones will be ignored - * - * @param input The input as an ItemStack - * @param output The output as an ItemStack - * @param energyUse The amount of RF used per conversion - * @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! - */ - @Deprecated - 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) { - addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion); - } - - /** - * Adds a recipe to the Atomic Reconstructor conversion lenses - * StackSizes can only be 1 and greater ones will be ignored - * - * @param input The input as an ItemStack - * @param output The output as an ItemStack - * @param energyUse The amount of RF used per conversion - * @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) { - RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(new LensConversionRecipe(input, output, energyUse, type)); - } - - public static void addReconstructorLensConversionRecipe(Ingredient input, ItemStack output, int energyUse) { - addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion); - } - - /** - * Adds an item and the way it is modified to the Atomic Reconstructor's color lens. - * This also works for blocks, but they have to be in their item form. - * The way it is modified is an instance of IColorLensChanger. When modifying the item, - * its modifyItem() method will be called with a stack containing the item. - * - * @param item The item (or block's item) to add - * @param changer The change mechanism - */ - public static void addReconstructorLensColorChangeItem(Item item, IColorLensChanger changer) { - RECONSTRUCTOR_LENS_COLOR_CHANGERS.put(item, changer); - } - - /** - * Adds an ingredient to the Coffee Machine ingredient list - * - * @param ingredient The ingredient to add - */ - public static void addCoffeeMachineIngredient(CoffeeIngredient ingredient) { - COFFEE_MACHINE_INGREDIENTS.add(ingredient); - } - - /** - * Adds a booklet entry to the list of entries - * - * @param entry The entry to add - */ - public static void addBookletEntry(IBookletEntry entry) { - BOOKLET_ENTRIES.add(entry); - } - - /** - * Adds a new farmer behavior to the Farmer - * - * @param behavior The behavior to add - */ - 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 deleted file mode 100644 index 7e8ade57c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletChapter.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file ("IBookletChapter.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.booklet; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public interface IBookletChapter { - - IBookletPage[] getAllPages(); - - @SideOnly(Side.CLIENT) - String getLocalizedName(); - - @SideOnly(Side.CLIENT) - String getLocalizedNameWithFormatting(); - - IBookletEntry getEntry(); - - ItemStack getDisplayItemStack(); - - String getIdentifier(); - - int getPageIndex(IBookletPage page); - - int getSortingPriority(); -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletEntry.java b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletEntry.java deleted file mode 100644 index 43b7683c9..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletEntry.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file ("IBookletEntry.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.booklet; - -import java.util.List; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public interface IBookletEntry { - - List getAllChapters(); - - String getIdentifier(); - - @SideOnly(Side.CLIENT) - String getLocalizedName(); - - @SideOnly(Side.CLIENT) - String getLocalizedNameWithFormatting(); - - void addChapter(IBookletChapter chapter); - - @SideOnly(Side.CLIENT) - List getChaptersForDisplay(String searchBarText); - - int getSortingPriority(); - - @SideOnly(Side.CLIENT) - boolean visibleOnFrontPage(); -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletPage.java b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletPage.java deleted file mode 100644 index 9651ae51c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletPage.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file ("IBookletPage.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public interface IBookletPage { - - void getItemStacksForPage(List list); - - void getFluidStacksForPage(List list); - - IBookletChapter getChapter(); - - void setChapter(IBookletChapter chapter); - - @SideOnly(Side.CLIENT) - String getInfoText(); - - @SideOnly(Side.CLIENT) - void mouseClicked(GuiBookletBase gui, int mouseX, int mouseY, int mouseButton); - - @SideOnly(Side.CLIENT) - void mouseReleased(GuiBookletBase gui, int mouseX, int mouseY, int state); - - @SideOnly(Side.CLIENT) - void mouseClickMove(GuiBookletBase gui, int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick); - - @SideOnly(Side.CLIENT) - void actionPerformed(GuiBookletBase gui, GuiButton button); - - @SideOnly(Side.CLIENT) - void initGui(GuiBookletBase gui, int startX, int startY); - - @SideOnly(Side.CLIENT) - void updateScreen(GuiBookletBase gui, int startX, int startY, int pageTimer); - - @SideOnly(Side.CLIENT) - void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks); - - @SideOnly(Side.CLIENT) - void drawScreenPost(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks); - - boolean shouldBeOnLeftSide(); - - String getIdentifier(); - - String getWebLink(); - - IBookletPage addTextReplacement(String key, String value); - - IBookletPage addTextReplacement(String key, float value); - - IBookletPage addTextReplacement(String key, int value); - - int getSortingPriority(); -} 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 deleted file mode 100644 index 71c1af5ef..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/internal/GuiBookletBase.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file ("GuiBookletBase.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; - -public abstract class GuiBookletBase extends GuiScreen { - - public abstract void renderScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale); - - public abstract void renderSplitScaledAsciiString(String text, int x, int y, int color, boolean shadow, float scale, int length); - - public abstract List getButtonList(); - - public abstract int getGuiLeft(); - - public abstract int getGuiTop(); - - public abstract int getSizeX(); - - public abstract int getSizeY(); - - public abstract void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer); - - public abstract float getSmallFontSize(); - - public abstract float getMediumFontSize(); - - public abstract float getLargeFontSize(); -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/farmer/FarmerResult.java b/src/main/java/de/ellpeck/actuallyadditions/api/farmer/FarmerResult.java deleted file mode 100644 index 22cee0fef..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/farmer/FarmerResult.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file ("FarmerResult.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.farmer; - -/** - * Return values for IFarmerBehavior, each one has a different meaning in harvest and planting contexts. - * - */ -public enum FarmerResult { - - /** - * Indicates that your behavior failed to perform the action it attempted. - */ - FAIL, - - /** - * Indicates that your behavior succeeded doing the action it attempted. For harvesting, this also shrinks the current stack by one, and stops processing. - */ - SUCCESS, - - /** - * Indicates you want the farmer to halt all further actions this tick. This will exit the farmer behavior loop if returned. - */ - STOP_PROCESSING -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/farmer/IFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/api/farmer/IFarmerBehavior.java deleted file mode 100644 index c9a1ed5e4..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/farmer/IFarmerBehavior.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file ("IFarmerBehavior.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.farmer; - -import de.ellpeck.actuallyadditions.api.internal.IFarmer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public interface IFarmerBehavior { - - /** - * Try to plant a seed with this behavior - * If this method returns true, the seed ItemStack will be shrunk by one. - * This method will not be called if the block at the given position is not replaceable. - * - * @param seed The seed stack to plant - * @param world The world - * @param pos The position to plant the seed on - * @param farmer The Farmer doing this action. Can be used to query and extract energy and add items to the slots - * @return If planting was successful - */ - FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer); - - /** - * Try to harvest a plant with this behavior - * - * @param world The world - * @param pos The position of the plant - * @param farmer The Farmer doing this action. Can be used to query and extract energy and add items to the slots - * @return If harvesting was successful - */ - FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer); - - int getPriority(); - - default Integer getPrioInt() { - return getPriority(); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IAtomicReconstructor.java b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IAtomicReconstructor.java deleted file mode 100644 index 5fd2ad1a1..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IAtomicReconstructor.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * This file ("IAtomicReconstructor.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.internal; - -import de.ellpeck.actuallyadditions.api.lens.Lens; -import net.minecraft.util.EnumFacing; - -/** - * This is a helper interface for Lens' invoke() method. - *

- * This is not supposed to be implemented. - * Can be cast to TileEntity. - */ -public interface IAtomicReconstructor extends IEnergyTile { - - Lens getLens(); - - EnumFacing getOrientation(); -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IEnergyTile.java b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IEnergyTile.java deleted file mode 100644 index cffde8875..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IEnergyTile.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file ("IEnergyTile.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.internal; - -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -/** - * This is not supposed to be implemented. - * Can be cast to TileEntity. - */ -public interface IEnergyTile { - - BlockPos getPosition(); - - int getX(); - - int getY(); - - int getZ(); - - //TODO: Rename to getWorld - World getWorldObject(); - - void extractEnergy(int amount); - - int getEnergy(); -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IFarmer.java b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IFarmer.java deleted file mode 100644 index 07f8b51bb..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IFarmer.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file ("IFarmer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.internal; - -import java.util.List; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; - -/** - * This is a helper interface for IFarmerBehavior. - *

- * This is not supposed to be implemented. - * Can be cast to TileEntity. - */ -public interface IFarmer extends IEnergyTile { - - EnumFacing getOrientation(); - - boolean canAddToSeeds(List stacks); - - boolean canAddToOutput(List stacks); - - void addToSeeds(List stacks); - - void addToOutput(List stacks); -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java deleted file mode 100644 index b6dd6c2ad..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file ("IMethodHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.internal; - -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; -import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; - -/** - * This is the internal method handler. - * Use ActuallyAdditionsAPI.methodHandler for calling - * This is not supposed to be implemented. - */ -public interface IMethodHandler { - - boolean addEffectToStack(ItemStack stack, CoffeeIngredient ingredient); - - PotionEffect getSameEffectFromStack(ItemStack stack, PotionEffect effect); - - void addEffectProperties(ItemStack stack, PotionEffect effect, boolean addDur, boolean addAmp); - - void addEffectToStack(ItemStack stack, PotionEffect effect); - - PotionEffect[] getEffectsFromStack(ItemStack stack); - - 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 - boolean addCrusherRecipes(List inputs, ItemStack outputOne, int outputOneAmount, ItemStack outputTwo, int outputTwoAmount, int outputTwoChance); - - IBookletPage generateTextPage(int id); - - IBookletPage generatePicturePage(int id, ResourceLocation resLoc, int textStartY); - - IBookletPage generateCraftingPage(int id, IRecipe... recipes); - - IBookletPage generateFurnacePage(int id, ItemStack input, ItemStack result); - - IBookletChapter generateBookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages); - - IBookletPage generateTextPage(int id, int priority); - - IBookletPage generatePicturePage(int id, ResourceLocation resLoc, int textStartY, int priority); - - IBookletPage generateCraftingPage(int id, int priority, IRecipe... recipes); - - IBookletPage generateFurnacePage(int id, ItemStack input, ItemStack result, int priority); - - IBookletChapter generateBookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, int priority, IBookletPage... pages); - - IBookletChapter createTrial(String identifier, ItemStack displayStack, boolean textOnSecondPage); -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/laser/IConnectionPair.java b/src/main/java/de/ellpeck/actuallyadditions/api/laser/IConnectionPair.java deleted file mode 100644 index 6155cab35..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/laser/IConnectionPair.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * This file ("IConnectionPair.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.laser; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.BlockPos; - -public interface IConnectionPair { - - void writeToNBT(NBTTagCompound compound); - - void readFromNBT(NBTTagCompound compound); - - BlockPos[] getPositions(); - - boolean doesSuppressRender(); - - LaserType getType(); - - boolean contains(BlockPos pos); -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/laser/ILaserRelayConnectionHandler.java b/src/main/java/de/ellpeck/actuallyadditions/api/laser/ILaserRelayConnectionHandler.java deleted file mode 100644 index 700eed229..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/laser/ILaserRelayConnectionHandler.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file ("ILaserRelayConnectionHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.laser; - -import io.netty.util.internal.ConcurrentSet; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -/** - * This is the internal laser relay connection handler. - * Use ActuallyAdditionsAPI.connectionHandler for calling - * This is not supposed to be implemented. - *

- * 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 { - - ConcurrentSet getConnectionsFor(BlockPos relay, World world); - - void removeRelayFromNetwork(BlockPos relay, World world); - - Network getNetworkFor(BlockPos relay, World world); - - boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world); - - boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world, boolean suppressConnectionRender); - - boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world, boolean suppressConnectionRender, boolean removeIfConnected); - - void removeConnection(World world, BlockPos firstRelay, BlockPos secondRelay); - - LaserType getTypeFromLaser(TileEntity tile); - - LaserType getTypeFromLaser(BlockPos pos, 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 deleted file mode 100644 index 38c125f95..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/laser/LaserType.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * This file ("LaserType.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.laser; - -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 deleted file mode 100644 index 5bfabd862..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/laser/Network.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file ("Network.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.laser; - -import io.netty.util.internal.ConcurrentSet; - -public class Network { - - public final ConcurrentSet connections = new ConcurrentSet<>(); - public int changeAmount; - - @Override - 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; } - } - 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 deleted file mode 100644 index 5fbb28388..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/lens/ILensItem.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * This file ("ILensItem.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.lens; - -/** - * This is the base class for a Reconstructor Lens Item - */ -public interface ILensItem { - - /** - * Returns the lens type that belongs to this lens item - */ - Lens getLens(); -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java b/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java deleted file mode 100644 index b5ebb9c63..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file ("Lens.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.lens; - -import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; - -/** - * This is the base class for a Reconstructor Lens Type (NOT THE ITEM!) - */ -public abstract class Lens { - - /** - * Invokes the lens type's behavior on a block - * - * @param hitBlock The block that was hit - * @param tile The tile the lens was invoked from - * @return If the Reconstructor should stop continuing (return false if you want it to go through blocks) - */ - public abstract boolean invoke(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile); - - /** - * Returns the color in an array of 3 float values that are r, g, b - */ - public abstract float[] getColor(); - - /** - * Gets the maximum distance the beam goes with this lens - */ - public abstract int getDistance(); - - /** - * @return If the lens can be invoked at the current time - */ - 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 deleted file mode 100644 index 195af9e34..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/lens/LensConversion.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file ("LensConversion.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.util.math.BlockPos; - -/** - * This is the base class for a Reconstructor Lens Type that converts two items - * via the ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES list. - *

- * 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 { - - @Override - 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 }; - } - - @Override - public int getDistance() { - return 10; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/misc/IDisableableItem.java b/src/main/java/de/ellpeck/actuallyadditions/api/misc/IDisableableItem.java deleted file mode 100644 index 0dbbe0909..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/misc/IDisableableItem.java +++ /dev/null @@ -1,12 +0,0 @@ -package de.ellpeck.actuallyadditions.api.misc; - -public interface IDisableableItem { - - /** - * Represents an item that can be disabled in the configuration of the mod. - * If this returns true, assume the item is not registered with the game, but may still be instantiated. - * @return If the item has not been registered with the Forge Registry. - */ - public boolean isDisabled(); - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/misc/IDisplayStandItem.java b/src/main/java/de/ellpeck/actuallyadditions/api/misc/IDisplayStandItem.java deleted file mode 100644 index 21605c82b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/misc/IDisplayStandItem.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This file ("IDisplayStandItem.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.misc; - -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; - -public interface IDisplayStandItem { - - boolean update(ItemStack stack, TileEntity tile, int elapsedTicks); - - int getUsePerTick(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 deleted file mode 100644 index 6dfff7269..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/misc/IGoggles.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * This file ("IGoggles.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.misc; - -public interface IGoggles { - - boolean displaySpectralMobs(); - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/package-info.java b/src/main/java/de/ellpeck/actuallyadditions/api/package-info.java deleted file mode 100644 index 0b348ec8d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * This file ("package-info.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -@API(owner = ActuallyAdditionsAPI.MOD_ID, apiVersion = ActuallyAdditionsAPI.API_VERSION, provides = ActuallyAdditionsAPI.API_ID) -package de.ellpeck.actuallyadditions.api; - -import net.minecraftforge.fml.common.API; \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/BallOfFurReturn.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/BallOfFurReturn.java deleted file mode 100644 index ef77dc8ee..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/BallOfFurReturn.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This file ("BallOfFurReturn.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.recipe; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.WeightedRandom; - -public class BallOfFurReturn extends WeightedRandom.Item { - - public final ItemStack returnItem; - - public BallOfFurReturn(ItemStack returnItem, int chance) { - super(chance); - this.returnItem = returnItem; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CoffeeIngredient.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CoffeeIngredient.java deleted file mode 100644 index 4899a3ba6..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CoffeeIngredient.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file ("CoffeeIngredient.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.recipe; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.potion.PotionEffect; - -public class CoffeeIngredient { - - protected final Ingredient input; - protected final int maxAmplifier; - protected PotionEffect[] effects; - - @Deprecated - public CoffeeIngredient(ItemStack input, PotionEffect[] effects, int maxAmplifier) { - this(Ingredient.fromStacks(input), maxAmplifier, effects); - } - - public CoffeeIngredient(Ingredient input, int maxAmplifier, PotionEffect... effects) { - this.input = input; - this.effects = effects; - this.maxAmplifier = maxAmplifier; - } - - public boolean matches(ItemStack stack) { - return this.input.apply(stack); - } - - public Ingredient getInput() { - return this.input; - } - - public PotionEffect[] getEffects() { - return this.effects; - } - - public boolean effect(ItemStack stack) { - return ActuallyAdditionsAPI.methodHandler.addEffectToStack(stack, this); - } - - public String getExtraText() { - return ""; - } - - public int getMaxAmplifier() { - return this.maxAmplifier; - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/ColorLensChangerByDyeMeta.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/ColorLensChangerByDyeMeta.java deleted file mode 100644 index 1368c2ce8..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/ColorLensChangerByDyeMeta.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file ("ColorLensChangerByDyeMeta.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.recipe; - -import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; - -/** - * Changes an item's color by changing its metadata. - * Much like dye and wool, 0 is white and 15 is black and it will cycle around. - */ -public class ColorLensChangerByDyeMeta implements IColorLensChanger { - - @Override - public ItemStack modifyItem(ItemStack stack, IBlockState hitBlockState, BlockPos hitBlock, IAtomicReconstructor tile) { - ItemStack newStack = stack.copy(); - int meta = newStack.getItemDamage(); - newStack.setItemDamage((meta + 1) % 16); - return newStack; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java deleted file mode 100644 index 5522e7318..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file ("CompostRecipe.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.recipe; - -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; - -public class CompostRecipe { - - protected final Ingredient input; - protected final ItemStack output; - protected final IBlockState inputDisplay; - protected final IBlockState outputDisplay; - - @Deprecated - public CompostRecipe(ItemStack input, Block inputDisplay, ItemStack output, Block outputDisplay) { - this(Ingredient.fromStacks(input), inputDisplay.getDefaultState(), output, outputDisplay.getDefaultState()); - } - - public CompostRecipe(Ingredient input, IBlockState inputDisplay, ItemStack output, IBlockState outputDisplay) { - this.input = input; - this.output = output; - this.inputDisplay = inputDisplay; - this.outputDisplay = outputDisplay; - } - - public boolean matches(ItemStack stack) { - return this.input.apply(stack); - } - - public Ingredient getInput() { - return this.input; - } - - public ItemStack getOutput() { - return this.output; - } - - public IBlockState getInputDisplay() { - return this.inputDisplay; - } - - public IBlockState getOutputDisplay() { - return this.outputDisplay; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CrusherRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CrusherRecipe.java deleted file mode 100644 index 6aaa90529..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CrusherRecipe.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file ("CrusherRecipe.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.recipe; - -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; - -public class CrusherRecipe { - - protected Ingredient input; - protected ItemStack outputOne; - protected ItemStack outputTwo; - protected int outputChance; - - @Deprecated - public CrusherRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int outputChance) { - this(Ingredient.fromStacks(input), outputOne, outputTwo, outputChance); - } - - public CrusherRecipe(Ingredient input, ItemStack outputOne, ItemStack outputTwo, int outputChance) { - this.input = input; - this.outputOne = outputOne; - this.outputTwo = outputTwo; - this.outputChance = outputChance; - } - - public boolean matches(ItemStack stack) { - return this.input.apply(stack); - } - - public ItemStack getOutputOne() { - return this.outputOne; - } - - public ItemStack getOutputTwo() { - return this.outputTwo; - } - - public int getSecondChance() { - return this.outputChance; - } - - public Ingredient getInput() { - return this.input; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/EmpowererRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/EmpowererRecipe.java deleted file mode 100644 index 753c336fc..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/EmpowererRecipe.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * This file ("EmpowererRecipe.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.recipe; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; - -public class EmpowererRecipe { - - protected final Ingredient input; - protected final ItemStack output; - - protected final Ingredient modifier1; - protected final Ingredient modifier2; - protected final Ingredient modifier3; - protected final Ingredient modifier4; - - protected final int energyPerStand; - protected final float[] particleColor; - protected final int time; - - @Deprecated - public EmpowererRecipe(ItemStack input, ItemStack output, ItemStack modifier1, ItemStack modifier2, ItemStack modifier3, ItemStack modifier4, int energyPerStand, int time, float[] particleColor) { - this(Ingredient.fromStacks(input), output, Ingredient.fromStacks(modifier1), Ingredient.fromStacks(modifier2), Ingredient.fromStacks(modifier3), Ingredient.fromStacks(modifier4), energyPerStand, time, particleColor); - } - - public EmpowererRecipe(Ingredient input, ItemStack output, Ingredient modifier1, Ingredient modifier2, Ingredient modifier3, Ingredient modifier4, int energyPerStand, int time, float[] particleColor) { - this.input = input; - this.output = output; - this.modifier1 = modifier1; - this.modifier2 = modifier2; - this.modifier3 = modifier3; - this.modifier4 = modifier4; - this.energyPerStand = energyPerStand; - this.particleColor = particleColor; - this.time = time; - } - - public boolean matches(ItemStack base, ItemStack stand1, ItemStack stand2, ItemStack stand3, ItemStack stand4) { - if (!this.input.apply(base)) return false; - List matches = new ArrayList<>(); - ItemStack[] stacks = { stand1, stand2, stand3, stand4 }; - boolean[] unused = { true, true, true, true }; - for (ItemStack s : stacks) { - if (unused[0] && this.modifier1.apply(s)) { - matches.add(this.modifier1); - unused[0] = false; - } else if (unused[1] && this.modifier2.apply(s)) { - matches.add(this.modifier2); - unused[1] = false; - } else if (unused[2] && this.modifier3.apply(s)) { - matches.add(this.modifier3); - unused[2] = false; - } else if (unused[3] && this.modifier4.apply(s)) { - matches.add(this.modifier4); - unused[3] = false; - } - } - - return matches.size() == 4; - } - - public Ingredient getInput() { - return this.input; - } - - public ItemStack getOutput() { - return this.output; - } - - public Ingredient getStandOne() { - return this.modifier1; - } - - public Ingredient getStandTwo() { - return this.modifier2; - } - - public Ingredient getStandThree() { - return this.modifier3; - } - - public Ingredient getStandFour() { - return this.modifier4; - } - - public int getTime() { - return this.time; - } - - public int getEnergyPerStand() { - return this.energyPerStand; - } - - public float[] getParticleColors() { - return this.particleColor; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/IColorLensChanger.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/IColorLensChanger.java deleted file mode 100644 index 876ea10f3..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/IColorLensChanger.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file ("IColorLensChanger.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.recipe; - -import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; - -/** - * Used for the Atomic Reconstructor's Color Lens changing algorythm. - * When registering a new item to be changed, it needs an IColorLensChanger which - * is the method with which the item will be changed. - *

- * See ColorLensChangerByDyeMeta for reference. - */ -public interface IColorLensChanger { - - /** - * Modifies the given item. - * Will only be called with stacks containing items that are registered with - * this IColorLensChanger. - * - * @param stack the stack to modify - * @param hitBlockState The state of the block that was hit - * @param hitBlock the block that was hit (usually air, or the block that is also in the stack) - * @param tile the Reconstructor doing the color conversion - * @return the modified stack. Please make sure to return a modified COPY of the input stack. - */ - ItemStack modifyItem(ItemStack stack, IBlockState hitBlockState, BlockPos hitBlock, IAtomicReconstructor tile); - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/LensConversionRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/LensConversionRecipe.java deleted file mode 100644 index c8f9b7ee4..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/LensConversionRecipe.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file ("LensConversionRecipe.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.recipe; - -import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; -import de.ellpeck.actuallyadditions.api.lens.Lens; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.math.BlockPos; - -public class LensConversionRecipe { - - protected final Ingredient input; - protected final ItemStack output; - protected final int energy; - protected final Lens type; - - @Deprecated - public LensConversionRecipe(ItemStack input, ItemStack output, int energy, Lens type) { - this(Ingredient.fromStacks(input), output, energy, type); - } - - public LensConversionRecipe(Ingredient input, ItemStack output, int energy, Lens type) { - this.input = input; - this.output = output; - this.energy = energy; - this.type = type; - } - - public boolean matches(ItemStack input, Lens lens) { - return this.input.apply(input) && this.type == lens; - } - - public Ingredient getInput() { - return this.input; - } - - public ItemStack getOutput() { - return this.output; - } - - public int getEnergyUsed() { - return this.energy; - } - - public Lens getType() { - return this.type; - } - - public void transformHook(ItemStack stack, IBlockState state, BlockPos pos, IAtomicReconstructor tile) { - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/OilGenRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/OilGenRecipe.java deleted file mode 100644 index 51d4fc206..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/OilGenRecipe.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file ("OilGenRecipe.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.recipe; - -public class OilGenRecipe { - - public final String fluidName; - public final int genAmount; - public final int genTime; - - /** - * Oil generator recipe - * @param fluidName The fluid - * @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) { - 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 deleted file mode 100644 index 3560bf1b6..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/TreasureChestLoot.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * This file ("TreasureChestLoot.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.recipe; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.WeightedRandom; - -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) { - super(chance); - this.returnItem = returnItem; - this.minAmount = minAmount; - this.maxAmount = maxAmount; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/WeightedOre.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/WeightedOre.java deleted file mode 100644 index 9cd0a93dd..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/WeightedOre.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * This file ("WeightedOre.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.recipe; - -import net.minecraft.util.WeightedRandom; - -public class WeightedOre extends WeightedRandom.Item { - - public final String name; - - 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 deleted file mode 100644 index a56c0ee07..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/api/tile/IPhantomTile.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file ("IPhantomTile.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.api.tile; - -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 { - - /** - * @return If the Phantom Tile is currently bound to anything - */ - boolean hasBoundPosition(); - - /** - * @return If the Phantom Tile's bound position is in range - */ - boolean isBoundThingInRange(); - - /** - * @return The position this tile is bound to - */ - BlockPos getBoundPosition(); - - /** - * Sets the bound position - */ - void setBoundPosition(BlockPos pos); - - /** - * @return The ID of the GUI it opens, -1 if none - */ - int getGuiID(); - - /** - * @return The range the tile currently has - */ - int getRange(); -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java index 41f464005..fc581ec09 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java @@ -13,155 +13,25 @@ package de.ellpeck.actuallyadditions.mod; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.mod.booklet.InitBooklet; -import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler; -import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting; -import de.ellpeck.actuallyadditions.mod.data.WorldData; -import de.ellpeck.actuallyadditions.mod.entity.InitEntities; -import de.ellpeck.actuallyadditions.mod.event.CommonEvents; -import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; -import de.ellpeck.actuallyadditions.mod.gen.AAWorldGen; -import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; -import de.ellpeck.actuallyadditions.mod.items.ItemCoffee; -import de.ellpeck.actuallyadditions.mod.items.lens.LensMining; -import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler; -import de.ellpeck.actuallyadditions.mod.items.lens.Lenses; -import de.ellpeck.actuallyadditions.mod.material.InitArmorMaterials; -import de.ellpeck.actuallyadditions.mod.material.InitToolMaterials; -import de.ellpeck.actuallyadditions.mod.misc.BannerHelper; -import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot; -import de.ellpeck.actuallyadditions.mod.misc.apiimpl.LaserRelayConnectionHandler; -import de.ellpeck.actuallyadditions.mod.misc.apiimpl.MethodHandler; -import de.ellpeck.actuallyadditions.mod.network.PacketHandler; -import de.ellpeck.actuallyadditions.mod.proxy.IProxy; -import de.ellpeck.actuallyadditions.mod.recipe.EmpowererHandler; -import de.ellpeck.actuallyadditions.mod.recipe.HairyBallHandler; -import de.ellpeck.actuallyadditions.mod.recipe.TreasureChestHandler; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.update.UpdateChecker; -import de.ellpeck.actuallyadditions.mod.util.compat.CompatUtil; -import net.minecraft.launchwrapper.Launch; -import net.minecraft.server.MinecraftServer; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.Mod.Instance; -import net.minecraftforge.fml.common.SidedProxy; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.event.FMLServerStartedEvent; -import net.minecraftforge.fml.common.event.FMLServerStoppedEvent; -import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -@Mod(modid = ActuallyAdditions.MODID, name = ActuallyAdditions.NAME, version = ActuallyAdditions.VERSION, guiFactory = ActuallyAdditions.GUIFACTORY, dependencies = ActuallyAdditions.DEPS) +@Mod(ActuallyAdditions.MODID) public class ActuallyAdditions { - public static final String MODID = ActuallyAdditionsAPI.MOD_ID; - public static final String NAME = "Actually Additions"; - public static final String VERSION = "@VERSION@"; - public static final String GUIFACTORY = "de.ellpeck.actuallyadditions.mod.config.GuiFactory"; - public static final String DEPS = "required:forge@[14.23.5.2836,);before:craftingtweaks;after:fastbench@[1.3.2,)"; - public static final boolean DEOBF = (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment"); + public static final String MODID = "actuallyadditions"; + public static final Logger LOGGER = LogManager.getLogger(MODID); - @Instance - public static ActuallyAdditions INSTANCE; + public ActuallyAdditions() { + FMLJavaModLoadingContext ctx = FMLJavaModLoadingContext.get(); + ctx.getModEventBus().register(this); + } - @SidedProxy(clientSide = "de.ellpeck.actuallyadditions.mod.proxy.ClientProxy", serverSide = "de.ellpeck.actuallyadditions.mod.proxy.ServerProxy") - public static IProxy PROXY; + @SubscribeEvent + public void setup(FMLCommonSetupEvent e) { - public static final Logger LOGGER = LogManager.getLogger(NAME); + } - static { - FluidRegistry.enableUniversalBucket(); - } - - public static boolean commonCapsLoaded; - - @EventHandler - public void preInit(FMLPreInitializationEvent event) { - ActuallyAdditions.LOGGER.info("Starting PreInitialization Phase..."); - - ActuallyAdditionsAPI.methodHandler = new MethodHandler(); - ActuallyAdditionsAPI.connectionHandler = new LaserRelayConnectionHandler(); - Lenses.init(); - InitBooklet.preInit(); - CompatUtil.registerCraftingTweaks(); - commonCapsLoaded = Loader.isModLoaded("commoncapabilities"); - - MinecraftForge.EVENT_BUS.register(new RegistryHandler()); - - new ConfigurationHandler(event.getSuggestedConfigurationFile()); - PacketHandler.init(); - InitToolMaterials.init(); - InitArmorMaterials.init(); - InitFluids.init(); - new UpdateChecker(); - PROXY.preInit(event); - - ActuallyAdditions.LOGGER.info("PreInitialization Finished."); - } - - @EventHandler - public void init(FMLInitializationEvent event) { - ActuallyAdditions.LOGGER.info("Starting Initialization Phase..."); - - BannerHelper.init(); - //InitAchievements.init(); - GuiHandler.init(); - AAWorldGen gen = new AAWorldGen(); - GameRegistry.registerWorldGenerator(gen, 10000); - MinecraftForge.TERRAIN_GEN_BUS.register(gen); - TileEntityBase.init(); - MinecraftForge.EVENT_BUS.register(new CommonEvents()); - MinecraftForge.EVENT_BUS.register(new DungeonLoot()); - InitEntities.init(); - - PROXY.init(event); - - RegistryHandler.BLOCKS_TO_REGISTER.clear(); - - ActuallyAdditions.LOGGER.info("Initialization Finished."); - } - - @EventHandler - public void postInit(FMLPostInitializationEvent event) { - ActuallyAdditions.LOGGER.info("Starting PostInitialization Phase..."); - - ItemCoffee.initIngredients(); - CrusherCrafting.init(); - HairyBallHandler.init(); - TreasureChestHandler.init(); - LensRecipeHandler.init(); - EmpowererHandler.init(); - LensMining.init(); - - InitBooklet.postInit(); - PROXY.postInit(event); - - ConfigurationHandler.redefineConfigs(); - - ActuallyAdditions.LOGGER.info("PostInitialization Finished."); - } - - @EventHandler - public void serverStarted(FMLServerStartedEvent event) { - MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); - if (server != null) { - World world = server.getEntityWorld(); - if (world != null && !world.isRemote) { - WorldData.get(world, true).markDirty(); - } - } - } - - @EventHandler - public void serverStopped(FMLServerStoppedEvent event) { - WorldData.clear(); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditionsClient.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditionsClient.java new file mode 100644 index 000000000..85bf5d8af --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditionsClient.java @@ -0,0 +1,17 @@ +package de.ellpeck.actuallyadditions.mod; + +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; +import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; + +@EventBusSubscriber(value = Dist.CLIENT, modid = ActuallyAdditions.MODID, bus = Bus.MOD) +public class ActuallyAdditionsClient { + + @SubscribeEvent + public static void setup(FMLClientSetupEvent e) { + + } + +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ClientRegistryHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ClientRegistryHandler.java deleted file mode 100644 index 15401d56a..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/ClientRegistryHandler.java +++ /dev/null @@ -1,63 +0,0 @@ -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; -import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; -import de.ellpeck.actuallyadditions.mod.util.FluidStateMapper; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.block.model.ModelBakery; -import net.minecraft.client.renderer.block.model.ModelResourceLocation; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.event.ModelBakeEvent; -import net.minecraftforge.client.event.ModelRegistryEvent; -import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -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) { - Block block = fluid.getBlock(); - Item item = Item.getItemFromBlock(block); - FluidStateMapper mapper = new FluidStateMapper(fluid); - ModelBakery.registerItemVariants(item); - ModelLoader.setCustomMeshDefinition(item, mapper); - ModelLoader.setCustomStateMapper(block, mapper); - } - - @SubscribeEvent - 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()) { - ModelLoader.setCustomModelResourceLocation(entry.getKey().getItem(), entry.getKey().getItemDamage(), entry.getValue()); - } - - registerCustomFluidBlockRenderer(InitFluids.fluidCanolaOil); - registerCustomFluidBlockRenderer(InitFluids.fluidRefinedCanolaOil); - registerCustomFluidBlockRenderer(InitFluids.fluidCrystalOil); - registerCustomFluidBlockRenderer(InitFluids.fluidEmpoweredOil); - } - - @SubscribeEvent - public void onModelBake(ModelBakeEvent e) { - ModelResourceLocation mrl = new ModelResourceLocation(new ResourceLocation(ActuallyAdditions.MODID, "block_compost"), "normal"); - CompostModel.compostBase = e.getModelRegistry().getObject(mrl); - e.getModelRegistry().putObject(mrl, new ActualCompostModel()); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/RegistryHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/RegistryHandler.java deleted file mode 100644 index 0f4ed0d25..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/RegistryHandler.java +++ /dev/null @@ -1,78 +0,0 @@ -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; -import de.ellpeck.actuallyadditions.mod.gen.village.InitVillager; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.misc.SoundHandler; -import de.ellpeck.actuallyadditions.mod.ore.InitOreDict; -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.SoundEvent; -import net.minecraftforge.event.RegistryEvent.Register; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession; - -//Class to wrap around the trainwreck that is the new registry system -public class RegistryHandler { - - public static final List BLOCKS_TO_REGISTER = new ArrayList<>(); - public static final List ITEMS_TO_REGISTER = new ArrayList<>(); - public static final List SOUNDS_TO_REGISTER = new ArrayList<>(); - public static final List RECIPES_TO_REGISTER = new ArrayList<>(); - - @SubscribeEvent - public void onBlockRegistry(Register event) { - InitBlocks.init(); - - for (Block block : BLOCKS_TO_REGISTER) { - event.getRegistry().register(block); - } - } - - @SubscribeEvent - public void onItemRegistry(Register event) { - InitItems.init(); - - for (Item item : ITEMS_TO_REGISTER) { - event.getRegistry().register(item); - } - ITEMS_TO_REGISTER.clear(); - - //Hack to make this register before recipes :> - InitOreDict.init(); - } - - @SubscribeEvent - 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); - } - - @SubscribeEvent - public void onCraftingRegistry(Register event) { - InitCrafting.init(); - - for (IRecipe recipe : RECIPES_TO_REGISTER) { - event.getRegistry().register(recipe); - } - RECIPES_TO_REGISTER.clear(); - } - - @SubscribeEvent - public void onSoundRegistry(Register event) { - SoundHandler.init(); - - for (SoundEvent sound : SOUNDS_TO_REGISTER) { - event.getRegistry().register(sound); - } - SOUNDS_TO_REGISTER.clear(); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/achievement/InitAchievements.java b/src/main/java/de/ellpeck/actuallyadditions/mod/achievement/InitAchievements.java deleted file mode 100644 index 7e111c016..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/achievement/InitAchievements.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file ("InitAchievements.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -//TODO Achievements -> Advancements? -/* -package de.ellpeck.actuallyadditions.mod.achievement; -import de.ellpeck.actuallyadditions.mod.util.ModUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.stats.Achievement; -import net.minecraftforge.common.AchievementPage; - -import java.util.ArrayList; - -public final class InitAchievements{ - - public static final ArrayList ACHIEVEMENT_LIST = new ArrayList(); - public static int pageNumber; - public static AchievementPage theAchievementPage; - - public static void init(){ - ModUtil.LOGGER.info("Initializing Achievements..."); - - for(int i = 0; i < TheAchievements.values().length; i++){ - ACHIEVEMENT_LIST.add(TheAchievements.values()[i].chieve); - } - - theAchievementPage = new AchievementPage(StringUtil.localize("achievement.page."+ModUtil.MOD_ID), ACHIEVEMENT_LIST.toArray(new Achievement[ACHIEVEMENT_LIST.size()])); - pageNumber = AchievementPage.getAchievementPages().size(); - AchievementPage.registerAchievementPage(theAchievementPage); - } - - public enum Type{ - CRAFTING, - SMELTING, - PICK_UP, - MISC - } - -} - */ \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/achievement/TheAchievements.java b/src/main/java/de/ellpeck/actuallyadditions/mod/achievement/TheAchievements.java deleted file mode 100644 index 8e1f7c58d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/achievement/TheAchievements.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * This file ("TheAchievements.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -//TODO Fix achievements -/* -package de.ellpeck.actuallyadditions.mod.achievement; - -import de.ellpeck.actuallyadditions.mod.achievement.InitAchievements.Type; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; -import de.ellpeck.actuallyadditions.mod.util.ModUtil; -import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.stats.Achievement; -import net.minecraft.stats.StatisticsManager; -import net.minecraft.util.JsonSerializableSet; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -public enum TheAchievements{ - - OPEN_BOOKLET("openBooklet", 0, 0, new ItemStack(InitItems.itemBooklet), null, Type.MISC), - NAME_SMILEY_CLOUD("nameSmileyCloud", 4, 3, new ItemStack(InitBlocks.blockSmileyCloud), null, Type.MISC, true, 0), - OPEN_TREASURE_CHEST("openTreasureChest", 1, -3, new ItemStack(InitBlocks.blockTreasureChest), OPEN_BOOKLET, Type.MISC), - CRAFT_COAL_GEN("craftCoalGen", -2, 0, new ItemStack(InitBlocks.blockCoalGenerator), OPEN_BOOKLET), - CRAFT_LEAF_GEN("craftLeafGen", -3, -2, new ItemStack(InitBlocks.blockLeafGenerator), CRAFT_COAL_GEN), - CRAFT_RECONSTRUCTOR("craftReconstructor", -5, 0, new ItemStack(InitBlocks.blockAtomicReconstructor), CRAFT_COAL_GEN), - MAKE_FIRST_CRYSTAL("makeCrystal", -4, 2, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), CRAFT_RECONSTRUCTOR, Type.PICK_UP, new ItemStack(InitItems.itemCrystal, 1, Util.WILDCARD), new ItemStack(InitBlocks.blockCrystal, 1, Util.WILDCARD)), - CRAFT_EMPOWERER("craftEmpowerer", -4, 4, new ItemStack(InitBlocks.blockEmpowerer), MAKE_FIRST_CRYSTAL), - CRAFT_PHANTOMFACE("craftPhantomface", 2, 0, new ItemStack(InitBlocks.blockPhantomface), OPEN_BOOKLET), - CRAFT_LIQUIFACE("craftLiquiface", 2, 2, new ItemStack(InitBlocks.blockPhantomLiquiface), CRAFT_PHANTOMFACE), - CRAFT_ENERGYFACE("craftEnergyface", 4, -1, new ItemStack(InitBlocks.blockPhantomEnergyface), CRAFT_PHANTOMFACE), - CRAFT_LASER_RELAY("craftLaserRelay", -7, -2, new ItemStack(InitBlocks.blockLaserRelay), CRAFT_RECONSTRUCTOR), - CRAFT_LASER_RELAY_ITEM("craftLaserRelayItem", -9, -2, new ItemStack(InitBlocks.blockLaserRelayItem), CRAFT_LASER_RELAY, Type.PICK_UP), - CRAFT_ITEM_INTERFACE("craftItemInterface", -11, -3, new ItemStack(InitBlocks.blockItemViewer), CRAFT_LASER_RELAY_ITEM), - CRAFT_LASER_RELAY_ADVANCED("craftLaserRelayAdvanced", -7, -4, new ItemStack(InitBlocks.blockLaserRelayAdvanced), CRAFT_LASER_RELAY), - CRAFT_LASER_RELAY_EXTREME("craftLaserRelayExtreme", -9, -4, new ItemStack(InitBlocks.blockLaserRelayExtreme), CRAFT_LASER_RELAY_ADVANCED), - CRAFT_CRUSHER("craftCrusher", -8, 0, new ItemStack(InitBlocks.blockGrinder), CRAFT_RECONSTRUCTOR), - CRAFT_DOUBLE_CRUSHER("craftDoubleCrusher", -10, 1, new ItemStack(InitBlocks.blockGrinderDouble), CRAFT_CRUSHER), - PICK_UP_COFFEE("pickUpCoffee", -2, 2, new ItemStack(InitItems.itemCoffeeBean), CRAFT_COAL_GEN, Type.PICK_UP), - CRAFT_COFFEE_MACHINE("craftCoffeeMachine", -1, 3, new ItemStack(InitBlocks.blockCoffeeMachine), PICK_UP_COFFEE), - CRAFT_FIREWORK_BOX("craftFireworkBox", -4, -5, new ItemStack(InitBlocks.blockFireworkBox), null, Type.CRAFTING, true, 0), - GET_UNPROBED("getUnProbed", -7, 3, new ItemStack(InitItems.itemPlayerProbe), null, Type.MISC, true, 0), - - GET_CRYSTALS_MILESTONE("getCrystalsMilestone", 6, -3, new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.DIAMOND.ordinal()), null, Type.PICK_UP, true, 200, new ItemStack(InitItems.itemCrystal, 1, Util.WILDCARD), new ItemStack(InitBlocks.blockCrystal, 1, Util.WILDCARD)), - OPEN_BOOKLET_MILESTONE("openBookletMilestone", 6, -1, new ItemStack(InitItems.itemBooklet), null, Type.MISC, true, 50), - COMPLETE_TRIALS("completeTrials", 6, 1, new ItemStack(Items.GOLD_INGOT), null, Type.MISC, true, 0); - - public final Achievement chieve; - public final Type type; - public final int progressToReach; - public List itemsToBeGotten; - - TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore, ItemStack... specialItemsToBeGotten){ - this(name, x, y, displayStack, hasToHaveBefore, Type.CRAFTING, false, 0, specialItemsToBeGotten); - } - - TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore, Type type, boolean special, int progressToReach, ItemStack... specialItemsToBeGotten){ - this.type = type; - this.progressToReach = progressToReach; - - this.chieve = new Achievement("achievement."+ModUtil.MOD_ID+"."+name, ModUtil.MOD_ID+"."+name, x, y, displayStack, hasToHaveBefore == null ? null : hasToHaveBefore.chieve); - if(hasToHaveBefore == null){ - this.chieve.initIndependentStat(); - } - if(special){ - this.chieve.setSpecial(); - } - if(progressToReach > 0){ - this.chieve.setSerializableClazz(JsonSerializableSet.class); - } - this.chieve.registerStat(); - - if(specialItemsToBeGotten == null || specialItemsToBeGotten.length <= 0){ - this.itemsToBeGotten = Collections.singletonList(displayStack); - } - else{ - this.itemsToBeGotten = Arrays.asList(specialItemsToBeGotten); - } - } - - TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore, Type type, ItemStack... specialItemsToBeGotten){ - this(name, x, y, displayStack, hasToHaveBefore, type, false, 0, specialItemsToBeGotten); - } - - public void get(EntityPlayer player){ - this.get(player, 1); - } - - public void get(EntityPlayer player, int amount){ - if(this.progressToReach > 0){ - this.updateStatus(player, amount); - } - else{ - player.addStat(this.chieve); - } - } - - private void updateStatus(EntityPlayer player, int amount){ - if(player instanceof EntityPlayerMP){ - - StatisticsManager manager = ((EntityPlayerMP)player).getStatFile(); - if(manager != null && !manager.hasAchievementUnlocked(this.chieve) && manager.canUnlockAchievement(this.chieve)){ - - JsonSerializableSet data = manager.getProgress(this.chieve); - if(data == null){ - data = manager.setProgress(this.chieve, new JsonSerializableSet()); - } - - int gottenSoFar = 0; - for(String strg : data){ - try{ - int i = Integer.parseInt(strg); - gottenSoFar += i; - data.remove(strg); - } - catch(Exception e){ - data.remove(strg); - } - } - - gottenSoFar += amount; - if(gottenSoFar >= this.progressToReach){ - player.addStat(this.chieve); - } - else{ - data.add(Integer.toString(gottenSoFar)); - } - } - } - } -} - */ \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/block/AABlocks.java b/src/main/java/de/ellpeck/actuallyadditions/mod/block/AABlocks.java new file mode 100644 index 000000000..9e86a2651 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/block/AABlocks.java @@ -0,0 +1,26 @@ +package de.ellpeck.actuallyadditions.mod.block; + +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraftforge.event.RegistryEvent.Register; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; +import net.minecraftforge.registries.ObjectHolder; + +@EventBusSubscriber(modid = ActuallyAdditions.MODID, bus = Bus.MOD) +@ObjectHolder(ActuallyAdditions.MODID) +public class AABlocks { + + @SubscribeEvent + public static void register(Register e) { + + } + + @SubscribeEvent + public static void registerItemBlocks(Register e) { + + } + +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java deleted file mode 100644 index df91f13ad..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * This file ("BlockAtomicReconstructor.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.block.Block; -import net.minecraft.block.BlockDirectional; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -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) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(10F); - this.setResistance(80F); - this.setSoundType(SoundType.STONE); - } - - @Override - 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) { - 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)) { - Item item = heldItem.getItem(); - 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) { - reconstructor.counter++; - reconstructor.markDirty(); - } - } else { - ItemStack slot = reconstructor.inv.getStackInSlot(0); - if (StackUtil.isValid(slot)) { - player.setHeldItem(hand, slot.copy()); - reconstructor.inv.setStackInSlot(0, StackUtil.getEmpty()); - } - } - } - } - return true; - } - - @Override - 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) { - TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos()); - 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 { - strg = slot.getItem().getItemStackDisplayName(slot); - - 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); - } - } - - @Override - protected ItemBlockBase getItemBlock() { - return new TheItemBlock(this); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; - } - - @Override - 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); - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BlockDirectional.FACING).getIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockDirectional.FACING); - } - - @Override - 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) { - return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING))); - } - - public static class TheItemBlock extends ItemBlockBase { - - private long lastSysTime; - private int toPick1; - private int toPick2; - - public TheItemBlock(Block block) { - super(block); - this.setHasSubtypes(false); - this.setMaxDamage(0); - } - - @Override - public String getTranslationKey(ItemStack stack) { - return this.getTranslationKey(); - } - - @Override - public int getMetadata(int damage) { - return damage; - } - - @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag advanced) { - long sysTime = System.currentTimeMillis(); - - 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; - } - } - - 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) { - return true; - } - - @Override - public int getComparatorInputOverride(IBlockState blockState, World world, BlockPos pos) { - TileEntity t = world.getTileEntity(pos); - int i = 0; - if (t instanceof TileEntityAtomicReconstructor) { - i = ((TileEntityAtomicReconstructor) t).getEnergy(); - } - return MathHelper.clamp(i / 20000, 0, 15); - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBatteryBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBatteryBox.java deleted file mode 100644 index acaf5134d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBatteryBox.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file ("BlockBatteryBox.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.items.ItemBattery; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBatteryBox; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -public class BlockBatteryBox extends BlockContainerBase { - - public BlockBatteryBox(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { - return BlockSlabs.AABB_BOTTOM_HALF; - } - - @Override - 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) { - TileEntity tile = world.getTileEntity(pos); - 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))) { - box.inv.setStackInSlot(0, stack.copy()); - player.setHeldItem(hand, StackUtil.getEmpty()); - return true; - } - } else { - ItemStack inSlot = box.inv.getStackInSlot(0); - if (StackUtil.isValid(inSlot)) { - player.setHeldItem(hand, inSlot.copy()); - box.inv.setStackInSlot(0, StackUtil.getEmpty()); - return true; - } - } - } - return false; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - 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 deleted file mode 100644 index 5a8779601..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBioReactor.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file ("BlockBioReactor.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBioReactor; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class BlockBioReactor extends BlockContainerBase { - - public BlockBioReactor(String name) { - super(Material.ROCK, name); - - this.setHarvestLevel("pickaxe", 0); - this.setHardness(2.0F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - 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) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.BIO_REACTOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - } - return true; - } - - @Override - 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 deleted file mode 100644 index c64dd7f0b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBlackLotus.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This file ("BlockBlackLotus.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBushBase; - -public class BlockBlackLotus extends BlockBushBase { - - 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 deleted file mode 100644 index 3b9e33e1c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBreaker.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This file ("BlockBreaker.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlacer; -import net.minecraft.block.BlockDirectional; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class BlockBreaker extends BlockContainerBase { - - private final boolean isPlacer; - - public BlockBreaker(boolean isPlacer, String name) { - super(Material.ROCK, name); - this.isPlacer = isPlacer; - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - 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) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.BREAKER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - return true; - } - return true; - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.UNCOMMON; - } - - @Override - 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); - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BlockDirectional.FACING).getIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockDirectional.FACING); - } - - @Override - 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) { - 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 deleted file mode 100644 index 87c6d5848..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCanolaPress.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file ("BlockCanolaPress.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class BlockCanolaPress extends BlockContainerBase { - - public BlockCanolaPress(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - 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)) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.CANOLA_PRESS.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - } - return true; - } - return true; - } - - @Override - 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 deleted file mode 100644 index 1936246a3..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * This file ("BlockCoalGenerator.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator; -import net.minecraft.block.BlockHorizontal; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -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.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; - -public class BlockCoalGenerator extends BlockContainerBase { - - public BlockCoalGenerator(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - this.setTickRandomly(true); - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - 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) { - 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); - } - } - } - } - - @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) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.COAL_GENERATOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - return true; - } - return true; - } - - @Override - 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) { - return EnumRarity.RARE; - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockHorizontal.FACING); - } - - @Override - 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) { - 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 deleted file mode 100644 index c6248a39e..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoffeeMachine.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * This file ("BlockCoffeeMachine.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine; -import net.minecraft.block.BlockHorizontal; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -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.EnumFacing; -import net.minecraft.util.EnumHand; -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.util.math.MathHelper; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -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); - - public BlockCoffeeMachine(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { - return AABB; - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - 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)) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.COFFEE_MACHINE.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - } - return true; - } - return true; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileEntityCoffeeMachine(); - } - - @Override - 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; - - if (rotation == 0) { - world.setBlockState(pos, this.getStateFromMeta(0), 2); - } - if (rotation == 1) { - world.setBlockState(pos, this.getStateFromMeta(3), 2); - } - if (rotation == 2) { - world.setBlockState(pos, this.getStateFromMeta(1), 2); - } - if (rotation == 3) { - world.setBlockState(pos, this.getStateFromMeta(2), 2); - } - - super.onBlockPlacedBy(world, pos, state, player, stack); - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockHorizontal.FACING); - } - - @Override - 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) { - 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 deleted file mode 100644 index 069ff7d28..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockColoredLamp.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * This file ("BlockColoredLamp.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import java.util.Random; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; -import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase; -import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.oredict.OreDictionary; - -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) { - super(Material.REDSTONE_LIGHT, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(0.5F); - this.setResistance(3.0F); - this.isOn = isOn; - } - - @Override - public Item getItemDropped(IBlockState state, Random rand, int par3) { - return Item.getItemFromBlock(InitBlocks.blockColoredLamp); - } - - @Override - 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) { - ItemStack stack = player.getHeldItem(hand); - //Turning On - 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)) { - //Changing Colors - int[] oreIDs = OreDictionary.getOreIDs(stack); - 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) { - world.setBlockState(pos, this.getStateFromMeta(color.ordinal()), 2); - if (!player.capabilities.isCreativeMode) { - player.inventory.decrStackSize(player.inventory.currentItem, 1); - } - } - return true; - } - } - } - } - } - return false; - } - - @Override - @SideOnly(Side.CLIENT) - 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) { - return this.isOn ? 15 : 0; - } - - @Override - 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); - } - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(TYPE, TheColoredLampColors.values()[meta]); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(TYPE).ordinal(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, TYPE); - } - - public static class TheItemBlock extends ItemBlockBase { - - 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") + ")" : ""); - else return super.getItemStackDisplayName(stack); - } - - @Override - 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/BlockCompost.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCompost.java deleted file mode 100644 index 2094afb8e..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCompost.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * This file ("BlockCompost.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import java.util.List; - -import org.apache.commons.lang3.tuple.Pair; - -import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe; -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.IProperty; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.entity.Entity; -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.BlockRenderLayer; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.property.ExtendedBlockState; -import net.minecraftforge.common.property.IExtendedBlockState; -import net.minecraftforge.common.property.IUnlistedProperty; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class BlockCompost extends BlockContainerBase implements IHudDisplay { - - protected static final AxisAlignedBB AABB_LEGS = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.3125D, 1.0D); - protected static final AxisAlignedBB AABB_WALL_NORTH = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.125D); - protected static final AxisAlignedBB AABB_WALL_SOUTH = new AxisAlignedBB(0.0D, 0.0D, 0.875D, 1.0D, 1.0D, 1.0D); - protected static final AxisAlignedBB AABB_WALL_EAST = new AxisAlignedBB(0.875D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); - protected static final AxisAlignedBB AABB_WALL_WEST = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.125D, 1.0D, 1.0D); - private static final AxisAlignedBB AABB = new AxisAlignedBB(0.0625, 0, 0.0625, 1 - 0.0625, 11 * 0.0625, 1 - 0.0625); - - public BlockCompost(String name) { - super(Material.WOOD, name); - this.setHarvestLevel("axe", 0); - this.setHardness(0.5F); - this.setResistance(5.0F); - this.setSoundType(SoundType.WOOD); - } - - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { - return AABB; - } - - @Override - @Deprecated - public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, Entity entityIn, boolean someBool) { - addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_LEGS); - addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_WEST); - addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_NORTH); - addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_EAST); - addCollisionBoxToList(pos, entityBox, collidingBoxes, AABB_WALL_SOUTH); - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - public boolean isFullCube(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) { - ItemStack stackPlayer = player.getHeldItem(hand); - if (!world.isRemote) { - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityCompost) { - TileEntityCompost compost = (TileEntityCompost) tile; - ItemStack slot = compost.inv.getStackInSlot(0); - CompostRecipe recipeIn = TileEntityCompost.getRecipeForInput(slot); - if (!StackUtil.isValid(slot) || recipeIn != null) { - if (StackUtil.isValid(stackPlayer)) { - CompostRecipe recipeHand = TileEntityCompost.getRecipeForInput(stackPlayer); - if (recipeHand != null && (recipeIn == null || recipeIn == recipeHand)) { - int maxAdd = stackPlayer.getCount(); - - if (!StackUtil.isValid(slot)) { - ItemStack stackToAdd = stackPlayer.copy(); - stackToAdd.setCount(maxAdd); - compost.inv.setStackInSlot(0, stackToAdd); - player.inventory.decrStackSize(player.inventory.currentItem, maxAdd); - return true; - } else { - ItemStack stackIn = slot.copy(); - if (stackIn.getCount() < slot.getMaxStackSize()) { - int sizeAdded = Math.min(maxAdd, slot.getMaxStackSize() - stackIn.getCount()); - stackIn.grow(sizeAdded); - compost.inv.setStackInSlot(0, stackIn); - player.inventory.decrStackSize(player.inventory.currentItem, sizeAdded); - return true; - } - } - } - } - } else { - if (!StackUtil.isValid(stackPlayer)) { - player.setHeldItem(hand, slot.copy()); - compost.inv.setStackInSlot(0, StackUtil.getEmpty()); - return true; - } else if (ItemUtil.canBeStacked(stackPlayer, slot)) { - int addedStackSize = Math.min(slot.getCount(), stackPlayer.getMaxStackSize() - stackPlayer.getCount()); - ItemStack stackToAdd = stackPlayer.copy(); - stackToAdd.grow(addedStackSize); - player.setHeldItem(hand, stackToAdd); - compost.inv.getStackInSlot(0).shrink(addedStackSize); - return true; - - } - } - tile.markDirty(); - world.notifyBlockUpdate(pos, this.getDefaultState(), this.getDefaultState(), 3); - } - } else { - return true; - } - return false; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileEntityCompost(); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.UNCOMMON; - } - - @Override - @SideOnly(Side.CLIENT) - public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution) { - TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos()); - if (tile instanceof TileEntityCompost) { - ItemStack slot = ((TileEntityCompost) tile).inv.getStackInSlot(0); - String strg; - if (!StackUtil.isValid(slot)) { - strg = "Empty"; - } else { - strg = slot.getDisplayName(); - - AssetUtil.renderStackToGui(slot, resolution.getScaledWidth() / 2 + 15, resolution.getScaledHeight() / 2 - 29, 1F); - } - minecraft.fontRenderer.drawStringWithShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + strg, resolution.getScaledWidth() / 2 + 35, resolution.getScaledHeight() / 2 - 25, StringUtil.DECIMAL_COLOR_WHITE); - } - } - - @Override - protected BlockStateContainer createBlockState() { - return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[] { COMPOST_PROP }); - } - - @Override - public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntity te = world.getTileEntity(pos); - if (te instanceof TileEntityCompost && state instanceof IExtendedBlockState) { - TileEntityCompost compost = (TileEntityCompost) te; - return ((IExtendedBlockState) state).withProperty(COMPOST_PROP, Pair.of(compost.getCurrentDisplay(), compost.getHeight())); - } - return state; - } - - public BlockRenderLayer getBlockLayer() { - return BlockRenderLayer.CUTOUT; - } - - public static CompostProperty COMPOST_PROP = new CompostProperty(); - - @SuppressWarnings("rawtypes") - private static class CompostProperty implements IUnlistedProperty { - - @Override - public String getName() { - return "compost"; - } - - @Override - public boolean isValid(Pair value) { - return true; - } - - @Override - public Class getType() { - return Pair.class; - } - - @Override - public String valueToString(Pair value) { - return ""; - } - - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystal.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystal.java deleted file mode 100644 index 63db25a41..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystal.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * This file ("BlockCrystal.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; -import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraftforge.common.IRarity; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class BlockCrystal extends BlockBase { - - public static final TheCrystals[] ALL_CRYSTALS = TheCrystals.values(); - private static final PropertyEnum TYPE = PropertyEnum.create("type", TheCrystals.class); - - private final boolean isEmpowered; - - public BlockCrystal(String name, boolean isEmpowered) { - super(Material.ROCK, name); - this.isEmpowered = isEmpowered; - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setHarvestLevel("pickaxe", 1); - } - - @Override - public int damageDropped(IBlockState state) { - return this.getMetaFromState(state); - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(CreativeTabs tab, NonNullList list) { - for (int j = 0; j < ALL_CRYSTALS.length; j++) { - list.add(new ItemStack(this, 1, j)); - } - } - - @Override - protected ItemBlockBase getItemBlock() { - return new TheItemBlock(this); - } - - @Override - public void registerRendering() { - for (int i = 0; i < ALL_CRYSTALS.length; i++) { - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), TYPE.getName() + "=" + ALL_CRYSTALS[i].name); - } - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(TYPE, TheCrystals.values()[meta]); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(TYPE).ordinal(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, TYPE); - } - - @Override - public IRarity getRarity(ItemStack stack) { - return stack.getItemDamage() >= ALL_CRYSTALS.length ? EnumRarity.COMMON : ALL_CRYSTALS[stack.getItemDamage()].rarity; - } - - public static class TheItemBlock extends ItemBlockBase { - - public TheItemBlock(Block block) { - super(block); - this.setHasSubtypes(true); - this.setMaxDamage(0); - } - - @Override - public String getTranslationKey(ItemStack stack) { - return stack.getItemDamage() >= ALL_CRYSTALS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey() + "_" + ALL_CRYSTALS[stack.getItemDamage()].name; - } - - @Override - public boolean hasEffect(ItemStack stack) { - return this.block instanceof BlockCrystal && ((BlockCrystal) this.block).isEmpowered; - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystalCluster.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystalCluster.java deleted file mode 100644 index 7579e7717..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystalCluster.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * This file ("BlockCrystalCluster.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; -import de.ellpeck.actuallyadditions.mod.util.IColorProvidingBlock; -import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; -import net.minecraft.block.BlockDirectional; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.color.IBlockColor; -import net.minecraft.client.renderer.color.IItemColor; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockRenderLayer; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class BlockCrystalCluster extends BlockBase implements IColorProvidingBlock, IColorProvidingItem { - - private final TheCrystals crystal; - - public BlockCrystalCluster(String name, TheCrystals crystal) { - super(Material.GLASS, name); - this.crystal = crystal; - - this.setHardness(0.25F); - this.setResistance(1.0F); - this.setSoundType(SoundType.GLASS); - this.setLightOpacity(1); - this.setLightLevel(0.7F); - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - 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) { - return this.getStateFromMeta(side.ordinal()); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BlockDirectional.FACING).getIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockDirectional.FACING); - } - - @Override - 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) { - return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING))); - } - - @Override - @SideOnly(Side.CLIENT) - public IBlockColor getBlockColor() { - return (state, world, pos, tintIndex) -> BlockCrystalCluster.this.crystal.clusterColor; - } - - @Override - public BlockRenderLayer getRenderLayer() { - return BlockRenderLayer.TRANSLUCENT; - } - - @Override - @SideOnly(Side.CLIENT) - public IItemColor getItemColor() { - return (stack, tintIndex) -> BlockCrystalCluster.this.crystal.clusterColor; - } - - @Override - public Item getItemDropped(IBlockState state, Random rand, int fortune) { - return InitItems.itemCrystalShard; - } - - @Override - 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) { - return new ItemStack(this); - } - - @Override - public int quantityDropped(Random random) { - return random.nextInt(5) + 2; - } - - @Override - 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 deleted file mode 100644 index 81f3ca8a4..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDirectionalBreaker.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file ("BlockDirectionalBreaker.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityDirectionalBreaker; -import net.minecraft.block.BlockDirectional; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class BlockDirectionalBreaker extends BlockContainerBase { - - public BlockDirectionalBreaker(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - 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) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DIRECTIONAL_BREAKER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - return true; - } - return true; - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; - } - - @Override - 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); - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BlockDirectional.FACING).getIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockDirectional.FACING); - } - - @Override - 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) { - 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 deleted file mode 100644 index 4b4eaa83a..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * This file ("BlockDisplayStand.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityDisplayStand; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockFaceShape; -import net.minecraft.block.state.IBlockState; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -public class BlockDisplayStand extends BlockContainerBase { - - public BlockDisplayStand(String name) { - super(Material.ROCK, name); - - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - public TileEntity createNewTileEntity(World worldIn, int meta) { - return new TileEntityDisplayStand(); - } - - @Override - 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) { - ItemStack heldItem = player.getHeldItem(hand); - if (!world.isRemote) { - TileEntityDisplayStand stand = (TileEntityDisplayStand) world.getTileEntity(pos); - if (stand != null) { - ItemStack display = stand.inv.getStackInSlot(0); - if (StackUtil.isValid(heldItem)) { - if (!StackUtil.isValid(display)) { - ItemStack toPut = heldItem.copy(); - toPut.setCount(1); - stand.inv.setStackInSlot(0, toPut); - 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()); - if (maxTransfer > 0) { - heldItem.grow(maxTransfer); - ItemStack newDisplay = display.copy(); - newDisplay.shrink(maxTransfer); - stand.inv.setStackInSlot(0, newDisplay); - return true; - } - } - } else { - if (StackUtil.isValid(display)) { - player.setHeldItem(hand, display.copy()); - stand.inv.setStackInSlot(0, StackUtil.getEmpty()); - return true; - } - } - } - return false; - } else { - return true; - } - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) { - if (face == EnumFacing.DOWN) return BlockFaceShape.SOLID; - return BlockFaceShape.UNDEFINED; - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java deleted file mode 100644 index f03a4f159..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file ("BlockDropper.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper; -import net.minecraft.block.BlockDirectional; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class BlockDropper extends BlockContainerBase { - - public BlockDropper(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - 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) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DROPPER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - return true; - } - return true; - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; - } - - @Override - 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); - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BlockDirectional.FACING).getIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockDirectional.FACING); - } - - @Override - 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) { - 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 deleted file mode 100644 index 4d4c8dba2..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEmpowerer.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file ("BlockEmpowerer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityEmpowerer; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -public class BlockEmpowerer extends BlockContainerBase { - - public BlockEmpowerer(String name) { - super(Material.ROCK, name); - - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - public TileEntity createNewTileEntity(World worldIn, int meta) { - return new TileEntityEmpowerer(); - } - - @Override - 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) { - ItemStack heldItem = player.getHeldItem(hand); - 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)) { - ItemStack toPut = heldItem.copy(); - toPut.setCount(1); - empowerer.inv.setStackInSlot(0, toPut); - 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) { - player.setHeldItem(hand, StackUtil.grow(heldItem, maxTransfer)); - ItemStack newStackThere = stackThere.copy(); - newStackThere = StackUtil.shrink(newStackThere, maxTransfer); - empowerer.inv.setStackInSlot(0, newStackThere); - return true; - } - } - } else { - if (StackUtil.isValid(stackThere)) { - player.setHeldItem(hand, stackThere.copy()); - empowerer.inv.setStackInSlot(0, StackUtil.getEmpty()); - return true; - } - } - } - return false; - } else { - return true; - } - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - 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 deleted file mode 100644 index 13464a703..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEnergizer.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file ("BlockEnergizer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class BlockEnergizer extends BlockContainerBase { - - private final boolean isEnergizer; - - public BlockEnergizer(boolean isEnergizer, String name) { - super(Material.ROCK, name); - this.isEnergizer = isEnergizer; - this.setHarvestLevel("pickaxe", 0); - this.setHardness(2.0F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - 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) { - 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) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.ENERVATOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - } - return true; - } - return true; - } - - @Override - 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 deleted file mode 100644 index 991d50970..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This file ("BlockFarmer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFarmer; -import net.minecraft.block.BlockHorizontal; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class BlockFarmer extends BlockContainerBase { - - public BlockFarmer(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - 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) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FARMER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - return true; - } - return true; - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; - } - - @Override - 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) { - return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockHorizontal.FACING); - } - - @Override - 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) { - 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 deleted file mode 100644 index 525bdd781..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file ("BlockFeeder.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFeeder; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class BlockFeeder extends BlockContainerBase { - - public BlockFeeder(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(0.5F); - this.setResistance(6.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - 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) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FEEDER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - return true; - } - return true; - } - - @Override - 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 deleted file mode 100644 index 925f3cd4e..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file ("BlockFermentingBarrel.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFermentingBarrel; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class BlockFermentingBarrel extends BlockContainerBase { - - public BlockFermentingBarrel(String name) { - super(Material.WOOD, name); - this.setHarvestLevel("axe", 0); - this.setHardness(0.5F); - this.setResistance(5.0F); - this.setSoundType(SoundType.WOOD); - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - 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)) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FERMENTING_BARREL.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - } - return true; - } - return true; - } - - @Override - 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 deleted file mode 100644 index 9c01f5ced..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file ("BlockFireworkBox.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFireworkBox; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class BlockFireworkBox extends BlockContainerBase { - - public BlockFireworkBox(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @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; - } 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()); - } - } - return true; - } - - @Override - public TileEntity createNewTileEntity(World world, int par2) { - return new TileEntityFireworkBox(); - } - - @Override - 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 deleted file mode 100644 index a7ee0d164..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFishingNet.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file ("BlockFishingNet.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFishingNet; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -public class BlockFishingNet extends BlockContainerBase { - - private static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 1, 0.0625, 1); - - public BlockFishingNet(String name) { - super(Material.WOOD, name); - this.setHarvestLevel("axe", 0); - this.setHardness(0.5F); - this.setResistance(3.0F); - this.setSoundType(SoundType.WOOD); - } - - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { - return AABB; - } - - @Override - public TileEntity createNewTileEntity(World world, int par2) { - return new TileEntityFishingNet(); - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - 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 deleted file mode 100644 index 45e343c0c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This file ("BlockFluidCollector.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidCollector; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidPlacer; -import net.minecraft.block.BlockDirectional; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class BlockFluidCollector extends BlockContainerBase { - - private final boolean isPlacer; - - public BlockFluidCollector(boolean isPlacer, String name) { - super(Material.ROCK, name); - this.isPlacer = isPlacer; - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - 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)) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FLUID_COLLECTOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - } - return true; - } - return true; - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; - } - - @Override - 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); - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BlockDirectional.FACING).getIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockDirectional.FACING); - } - - @Override - 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) { - 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 deleted file mode 100644 index fcf5f7749..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceDouble.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * This file ("BlockFurnaceDouble.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceDouble; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.block.Block; -import net.minecraft.block.BlockHorizontal; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.PropertyBool; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.EntityLivingBase; -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.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; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class BlockFurnaceDouble extends BlockContainerBase { - - public static final PropertyBool IS_ON = PropertyBool.create("on"); - - public BlockFurnaceDouble(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - this.setTickRandomly(true); - } - - @Override - 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); - } - } - } - - @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) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FURNACE_DOUBLE.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - return true; - } - return true; - } - - @Override - public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { - return state.getValue(IS_ON) ? 12 : 0; - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.UNCOMMON; - } - - @Override - 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) { - boolean isOn = meta >= 4; - 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) { - int meta = state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); - return state.getValue(IS_ON) ? meta + 4 : meta; - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockHorizontal.FACING, IS_ON); - } - - @Override - 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) { - return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING))); - } - - @Override - protected ItemBlockBase getItemBlock() { - return new TheItemBlock(this); - } - - public static class TheItemBlock extends ItemBlockBase { - - 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")); - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceSolar.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceSolar.java deleted file mode 100644 index 1a2be9d5c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceSolar.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file ("BlockFurnaceSolar.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceSolar; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -public class BlockFurnaceSolar extends BlockContainerBase { - - private static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 1, 6 * 0.0625, 1); - - public BlockFurnaceSolar(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { - return AABB; - } - - @Override - public TileEntity createNewTileEntity(World world, int par2) { - return new TileEntityFurnaceSolar(); - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - 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 deleted file mode 100644 index a7c1a01c3..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGeneric.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file ("BlockGeneric.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; - -public class BlockGeneric extends BlockBase { - - 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) { - super(material, name); - this.setHarvestLevel(harvestTool, harvestLevel); - this.setHardness(hardness); - this.setResistance(resistance); - this.setSoundType(sound); - } - - @Override - 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 deleted file mode 100644 index 76b8205c7..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * This file ("BlockGiantChest.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import java.util.List; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase; -import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestLarge; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestMedium; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.block.Block; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.items.IItemHandlerModifiable; - -public class BlockGiantChest extends BlockContainerBase { - - public final int type; - - public BlockGiantChest(String name, int type) { - super(Material.WOOD, name); - this.type = type; - - this.setHarvestLevel("axe", 0); - this.setHardness(0.5F); - this.setResistance(15.0F); - this.setSoundType(SoundType.WOOD); - - } - - @Override - public TileEntity createNewTileEntity(World world, int par2) { - switch (this.type) { - case 1: - return new TileEntityGiantChestMedium(); - case 2: - return new TileEntityGiantChestLarge(); - default: - return new TileEntityGiantChest(); - } - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - 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) { - chest.fillWithLoot(player); - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.GIANT_CHEST.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - return true; - } - return true; - } - - @Override - 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) { - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityGiantChest) { - NBTTagList list = stack.getTagCompound().getTagList("Items", 10); - IItemHandlerModifiable inv = ((TileEntityGiantChest) tile).inv; - - for (int i = 0; i < list.tagCount(); i++) { - NBTTagCompound compound = list.getCompoundTagAt(i); - if (compound != null && compound.hasKey("id")) { - inv.setStackInSlot(i, new ItemStack(list.getCompoundTagAt(i))); - } - } - } - } - - super.onBlockPlacedBy(world, pos, state, entity, stack); - } - - @Override - 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; - int place = ItemUtil.getPlaceAt(slots.getItems(), new ItemStack(InitItems.itemCrateKeeper), false); - if (place >= 0) { - NBTTagList list = new NBTTagList(); - for (int i = 0; i < slots.getSlots(); i++) { - //Destroy the keeper - if (i != place) { - NBTTagCompound compound = new NBTTagCompound(); - if (StackUtil.isValid(slots.getStackInSlot(i))) { - slots.getStackInSlot(i).writeToNBT(compound); - } - list.appendTag(compound); - } - } - - if (list.tagCount() > 0) { - ItemStack stackInQuestion = drops.get(0); - if (StackUtil.isValid(stackInQuestion)) { - if (stackInQuestion.getTagCompound() == null) { - stackInQuestion.setTagCompound(new NBTTagCompound()); - } - stackInQuestion.getTagCompound().setTag("Items", list); - } - } - } - } - } - - @Override - public boolean shouldDropInventory(World world, BlockPos pos) { - TileEntity tile = world.getTileEntity(pos); - return !(tile instanceof TileEntityGiantChest) || !ItemUtil.contains(((TileEntityGiantChest) tile).inv.getItems(), new ItemStack(InitItems.itemCrateKeeper), false); - } - - @Override - protected ItemBlockBase getItemBlock() { - return new TheItemBlock(this); - } - - public static class TheItemBlock extends ItemBlockBase { - - 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")); - } - } - - @Override - public NBTTagCompound getNBTShareTag(ItemStack stack) { - return null; - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGreenhouseGlass.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGreenhouseGlass.java deleted file mode 100644 index c1b6abfa4..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGreenhouseGlass.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * This file ("BlockGreenhouseGlass.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import java.util.Random; - -import org.apache.commons.lang3.tuple.Triple; - -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; -import net.minecraft.block.Block; -import net.minecraft.block.IGrowable; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockRenderLayer; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class BlockGreenhouseGlass extends BlockBase { - - public BlockGreenhouseGlass(String name) { - super(Material.GLASS, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(0.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.GLASS); - this.setTickRandomly(true); - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - public int getLightOpacity(IBlockState state) { - return 0; - } - - @Override - @Deprecated - @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { - IBlockState otherState = world.getBlockState(pos.offset(side)); - Block block = otherState.getBlock(); - - return state != otherState || block != this && super.shouldSideBeRendered(state, world, pos, side); - - } - - @Override - public BlockRenderLayer getRenderLayer() { - return BlockRenderLayer.CUTOUT; - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; - } - - @Override - public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { - if (world.isRemote) return; - if (world.canBlockSeeSky(pos) && world.isDaytime()) { - Triple trip = firstBlock(world, pos); - boolean once = false; - if (trip != null) for (int i = 0; i < 3; i++) { - IBlockState growState = i == 0 ? trip.getMiddle() : world.getBlockState(trip.getLeft()); - if (growState.getBlock() == trip.getRight() && trip.getRight().canGrow(world, trip.getLeft(), growState, false)) { - trip.getRight().grow(world, rand, trip.getLeft(), growState); - once = true; - } - } - if (once) world.playEvent(2005, trip.getMiddle().isOpaqueCube() ? trip.getLeft().up() : trip.getLeft(), 0); - } - } - - public Triple firstBlock(World world, BlockPos glassPos) { - BlockPos.MutableBlockPos mut = new BlockPos.MutableBlockPos(glassPos); - while (true) { - mut.setPos(mut.getX(), mut.getY() - 1, mut.getZ()); - if (mut.getY() < 0) return null; - IBlockState state = world.getBlockState(mut); - if (state.isOpaqueCube() || state.getBlock() instanceof IGrowable || state.getBlock() == this) { - if (state.getBlock() instanceof IGrowable) return Triple.of(mut.toImmutable(), state, (IGrowable) state.getBlock()); - else 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 deleted file mode 100644 index 86877e50c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGrinder.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * This file ("BlockGrinder.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinder; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinderDouble; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.EnumParticleTypes; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class BlockGrinder extends BlockContainerBase { - - private final boolean isDouble; - - public BlockGrinder(boolean isDouble, String name) { - super(Material.ROCK, name); - this.isDouble = isDouble; - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - this.setTickRandomly(true); - } - - @Override - 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); - } - 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) { - player.openGui(ActuallyAdditions.INSTANCE, this.isDouble ? GuiHandler.GuiTypes.GRINDER_DOUBLE.ordinal() : GuiHandler.GuiTypes.GRINDER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - return true; - } - return true; - } - - @Override - public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { - return this.getMetaFromState(state) == 1 ? 12 : 0; - } - - @Override - public int damageDropped(IBlockState state) { - return 0; - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; - } - - @Override - public IBlockState getStateFromMeta(int meta) { - boolean isOn = meta == 1; - return this.getDefaultState().withProperty(BlockFurnaceDouble.IS_ON, isOn); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BlockFurnaceDouble.IS_ON) ? 1 : 0; - } - - @Override - 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 deleted file mode 100644 index 8f61f1494..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockHeatCollector.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file ("BlockHeatCollector.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityHeatCollector; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -public class BlockHeatCollector extends BlockContainerBase { - - public BlockHeatCollector(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(2.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - public TileEntity createNewTileEntity(World world, int par2) { - return new TileEntityHeatCollector(); - } - - @Override - 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 deleted file mode 100644 index 835db5e1f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockInputter.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * This file ("BlockInputter.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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.blocks.base.ItemBlockBase; -import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityInputter; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityInputterAdvanced; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.block.Block; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class BlockInputter extends BlockContainerBase { - - public static final int NAME_FLAVOR_AMOUNTS = 15; - - public final boolean isAdvanced; - - public BlockInputter(boolean isAdvanced, String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - this.setTickRandomly(true); - this.isAdvanced = isAdvanced; - } - - @Override - 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) { - player.openGui(ActuallyAdditions.INSTANCE, this.isAdvanced ? GuiHandler.GuiTypes.INPUTTER_ADVANCED.ordinal() : GuiHandler.GuiTypes.INPUTTER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - return true; - } - return true; - } - - @Override - protected ItemBlockBase getItemBlock() { - return new TheItemBlock(this); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; - } - - public static class TheItemBlock extends ItemBlockBase { - - private final Random rand = new Random(); - private long lastSysTime; - private int toPick; - - public TheItemBlock(Block block) { - super(block); - this.setHasSubtypes(false); - this.setMaxDamage(0); - } - - @Override - public String getTranslationKey(ItemStack stack) { - return this.getTranslationKey(); - } - - @Override - public int getMetadata(int damage) { - return damage; - } - - @Override - public String getItemStackDisplayName(ItemStack stack) { - if (Util.isClient()) { - long sysTime = System.currentTimeMillis(); - - if (this.lastSysTime + 5000 < sysTime) { - this.lastSysTime = sysTime; - 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); - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemRepairer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemRepairer.java deleted file mode 100644 index 23201504f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemRepairer.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file ("BlockItemRepairer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemRepairer; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -public class BlockItemRepairer extends BlockContainerBase { - - public BlockItemRepairer(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(20.0F); - this.setResistance(15.0F); - this.setSoundType(SoundType.STONE); - this.setTickRandomly(true); - } - - @Override - 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) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.REPAIRER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - return true; - } - return true; - } - - @Override - public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { - return this.getMetaFromState(state) == 1 ? 12 : 0; - } - - @Override - 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 deleted file mode 100644 index a983c8b4b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemViewer.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file ("BlockItemViewer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -public class BlockItemViewer extends BlockContainerBase { - - public BlockItemViewer(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - public TileEntity createNewTileEntity(World worldIn, int meta) { - return new TileEntityItemViewer(); - } - - @Override - 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 deleted file mode 100644 index fbd86a2f1..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemViewerHopping.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * This file ("BlockItemViewerHopping.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockRenderLayer; -import net.minecraft.util.EnumFacing; -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; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -//Most of this is just copied from BlockHopper, no credit taken. Or clue what it is. -public class BlockItemViewerHopping extends BlockItemViewer { - - public static final PropertyDirection FACING = PropertyDirection.create("facing", facing -> facing != EnumFacing.UP); - - private static final AxisAlignedBB BASE_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.625D, 1.0D); - private static final AxisAlignedBB SOUTH_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.125D); - private static final AxisAlignedBB NORTH_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.875D, 1.0D, 1.0D, 1.0D); - 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) { - super(name); - } - - @Override - 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) { - addCollisionBoxToList(pos, entityBox, collidingBoxes, BASE_AABB); - addCollisionBoxToList(pos, entityBox, collidingBoxes, EAST_AABB); - addCollisionBoxToList(pos, entityBox, collidingBoxes, WEST_AABB); - addCollisionBoxToList(pos, entityBox, collidingBoxes, SOUTH_AABB); - addCollisionBoxToList(pos, entityBox, collidingBoxes, NORTH_AABB); - } - - @Override - 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) { - 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) { - return true; - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { - return true; - } - - @Override - public BlockRenderLayer getRenderLayer() { - return BlockRenderLayer.CUTOUT_MIPPED; - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(FACING, EnumFacing.byIndex(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(FACING).getIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, FACING); - } - - @Override - public IBlockState withRotation(IBlockState state, Rotation rot) { - return state.withProperty(FACING, rot.rotate(state.getValue(FACING))); - } - - @Override - 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 deleted file mode 100644 index 188b736c9..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLampPowerer.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * This file ("BlockLampPowerer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.block.Block; -import net.minecraft.block.BlockDirectional; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class BlockLampPowerer extends BlockBase { - - public BlockLampPowerer(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - 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) { - this.updateLamp(world, pos); - } - - @Override - 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) { - 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) { - IBlockState state = world.getBlockState(pos); - Block block = state.getBlock(); - if (block instanceof BlockColoredLamp) { - boolean isOn = ((BlockColoredLamp) block).isOn; - if (powered) { - if (!isOn) { - world.setBlockState(pos, InitBlocks.blockColoredLampOn.getDefaultState().withProperty(BlockColoredLamp.TYPE, state.getValue(BlockColoredLamp.TYPE)), 2); - } - } else { - if (isOn) { - world.setBlockState(pos, InitBlocks.blockColoredLamp.getDefaultState().withProperty(BlockColoredLamp.TYPE, state.getValue(BlockColoredLamp.TYPE)), 2); - } - } - - this.updateSurrounding(world, pos, powered, updatedAlready); - } - } - - 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)) { - updatedAlready.add(pos); - this.updateLampsAtPos(world, offset, powered, updatedAlready); - } - } - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BlockDirectional.FACING).getIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockDirectional.FACING); - } - - @Override - 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) { - 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 deleted file mode 100644 index 847de97a2..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * This file ("BlockLaserRelay.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.laser.Network; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.config.ConfigValues; -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.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; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockFaceShape; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.entity.EntityLivingBase; -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.EnumFacing; -import net.minecraft.util.EnumHand; -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.util.math.RayTraceResult; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.fml.common.eventhandler.Event; -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 { - - //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 final Type type; - - public BlockLaserRelay(String name, Type type) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - - this.type = type; - - if (this.type.ordinal() == 0) { - MinecraftForge.EVENT_BUS.register(this); - } - } - - @SubscribeEvent - 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) { - IBlockState state = event.getWorld().getBlockState(pos); - if (state != null && state.getBlock() instanceof BlockLaserRelay) { - if (player.isSneaking()) { - event.setUseBlock(Event.Result.ALLOW); - } - } - } - } - - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { - switch (this.getMetaFromState(state)) { - case 1: - return AABB_UP; - case 2: - return AABB_NORTH; - case 3: - return AABB_SOUTH; - case 4: - return AABB_WEST; - case 5: - return AABB_EAST; - default: - return AABB_DOWN; - } - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - 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) { - return this.getStateFromMeta(side.ordinal()); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(BlockDirectional.FACING, EnumFacing.byIndex(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BlockDirectional.FACING).getIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockDirectional.FACING); - } - - @Override - 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) { - 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) { - ItemStack stack = player.getHeldItem(hand); - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityLaserRelay) { - TileEntityLaserRelay relay = (TileEntityLaserRelay) tile; - - if (StackUtil.isValid(stack)) { - if (stack.getItem() instanceof ItemLaserWrench) { - return false; - } else if (stack.getItem() == ConfigValues.itemCompassConfigurator) { - if (!world.isRemote) { - relay.onCompassAction(player); - - Network network = relay.getNetwork(); - if (network != null) { - network.changeAmount++; - } - - relay.markDirty(); - relay.sendUpdate(); - } - - return true; - } else if (stack.getItem() instanceof ItemLaserRelayUpgrade) { - ItemStack inRelay = relay.inv.getStackInSlot(0); - if (!StackUtil.isValid(inRelay)) { - if (!world.isRemote) { - if (!player.isCreative()) { - player.setHeldItem(hand, StackUtil.shrink(stack, 1)); - } - - ItemStack set = stack.copy(); - set.setCount(1); - relay.inv.setStackInSlot(0, set); - } - return true; - } - - } - } - - if (player.isSneaking()) { - ItemStack inRelay = relay.inv.getStackInSlot(0).copy(); - if (StackUtil.isValid(inRelay)) { - if (!world.isRemote) { - relay.inv.setStackInSlot(0, StackUtil.getEmpty()); - - if (!player.inventory.addItemStackToInventory(inRelay)) { - player.entityDropItem(inRelay, 0); - } - } - return true; - } - } - - 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; - } - } - return false; - } - - @Override - public TileEntity createNewTileEntity(World world, int i) { - switch (this.type) { - case ITEM: - return new TileEntityLaserRelayItem(); - case ITEM_WHITELIST: - return new TileEntityLaserRelayItemWhitelist(); - case ENERGY_ADVANCED: - return new TileEntityLaserRelayEnergyAdvanced(); - case ENERGY_EXTREME: - return new TileEntityLaserRelayEnergyExtreme(); - case FLUIDS: - return new TileEntityLaserRelayFluids(); - default: - return new TileEntityLaserRelayEnergy(); - } - } - - @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) { - boolean wearing = ItemEngineerGoggles.isWearing(player); - if (wearing || StackUtil.isValid(stack)) { - boolean compass = stack.getItem() == ConfigValues.itemCompassConfigurator; - if (wearing || compass || stack.getItem() instanceof ItemLaserWrench) { - TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos()); - 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); - - String expl; - 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")); - } - - StringUtil.drawSplitString(minecraft.fontRenderer, expl, resolution.getScaledWidth() / 2 + 5, resolution.getScaledHeight() / 2 + 15, Integer.MAX_VALUE, StringUtil.DECIMAL_COLOR_WHITE, true); - } - } - } - } - } - - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state) { - super.breakBlock(world, pos, state); - - ActuallyAdditionsAPI.connectionHandler.removeRelayFromNetwork(pos, world); - } - - @Override - public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) { - return BlockFaceShape.UNDEFINED; - } - - public enum Type { - ENERGY_BASIC, - ENERGY_ADVANCED, - ENERGY_EXTREME, - FLUIDS, - ITEM, - ITEM_WHITELIST - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLavaFactoryController.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLavaFactoryController.java deleted file mode 100644 index 9f845eddf..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLavaFactoryController.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file ("BlockLavaFactoryController.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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.tile.TileEntityLavaFactoryController; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -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.math.RayTraceResult; -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 BlockLavaFactoryController(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(4.5F); - this.setResistance(20.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - public TileEntity createNewTileEntity(World world, int par2) { - return new TileEntityLavaFactoryController(); - } - - @Override - 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) { - 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); - } - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLeafGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLeafGenerator.java deleted file mode 100644 index 45fd23b00..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLeafGenerator.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file ("BlockLeafGenerator.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLeafGenerator; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -public class BlockLeafGenerator extends BlockContainerBase { - - public BlockLeafGenerator(String name) { - super(Material.IRON, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(5.0F); - this.setResistance(10.0F); - this.setSoundType(SoundType.METAL); - } - - @Override - public TileEntity createNewTileEntity(World world, int par2) { - return new TileEntityLeafGenerator(); - } - - @Override - 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 deleted file mode 100644 index eeddbd8e3..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMiner.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file ("BlockMiner.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityMiner; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -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 BlockMiner(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(8F); - this.setResistance(30F); - this.setSoundType(SoundType.STONE); - } - - @Override - 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) { - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityMiner) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.MINER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - } - return true; - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; - } - - @Override - 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) { - 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); - } - } -} \ 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 deleted file mode 100644 index 6d5173b11..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMisc.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This file ("BlockMisc.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; -import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase; -import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; - -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) { - super(Material.ROCK, name); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setHarvestLevel("pickaxe", 1); - } - - @Override - 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++) { - list.add(new ItemStack(this, 1, j)); - } - } - - @Override - 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); - } - } - - @Override - 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) { - return this.getDefaultState().withProperty(TYPE, TheMiscBlocks.values()[meta]); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(TYPE).ordinal(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, TYPE); - } - - public static class TheItemBlock extends ItemBlockBase { - - 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; - } - - @Override - public int getItemBurnTime(ItemStack stack) { - 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 deleted file mode 100644 index 627c78098..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockOilGenerator.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * This file ("BlockOilGenerator.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator; -import net.minecraft.block.BlockHorizontal; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -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.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; - -public class BlockOilGenerator extends BlockContainerBase { - - public BlockOilGenerator(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - this.setTickRandomly(true); - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - 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) { - 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); - } - } - } - } - - @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)) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.OIL_GENERATOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - } - return true; - } - return true; - } - - @Override - 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) { - return EnumRarity.RARE; - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockHorizontal.FACING); - } - - @Override - 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) { - 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 deleted file mode 100644 index ac75396c7..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * This file ("BlockPhantom.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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.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; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.Vec3d; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.IBlockAccess; -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 final Type type; - - public BlockPhantom(Type type, String name) { - super(Material.ROCK, name); - this.type = type; - this.setHarvestLevel("pickaxe", 0); - this.setHardness(4.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - 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) { - TileEntity tile = world.getTileEntity(pos); - 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) { - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityPhantomRedstoneface) { return ((TileEntityPhantomRedstoneface) tile).providesStrong[side.ordinal()]; } - } - return 0; - } - - @Override - 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) { - case PLACER: - return new TileEntityPhantomPlacer(); - case BREAKER: - return new TileEntityPhantomBreaker(); - case LIQUIFACE: - return new TileEntityPhantomLiquiface(); - case ENERGYFACE: - return new TileEntityPhantomEnergyface(); - case REDSTONEFACE: - return new TileEntityPhantomRedstoneface(); - default: - return new TileEntityPhantomItemface(); - } - } - - @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) { - 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()); - } - } - return true; - } - - @Override - 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) { - 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()) { - 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); - - 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 { - 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 { - FACE, - PLACER, - BREAKER, - LIQUIFACE, - ENERGYFACE, - REDSTONEFACE - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantomBooster.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantomBooster.java deleted file mode 100644 index e025e96b6..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantomBooster.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file ("BlockPhantomBooster.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomBooster; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -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); - - public BlockPhantomBooster(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { - return AABB; - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; - } - - @Override - 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 deleted file mode 100644 index a39029e2c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPlayerInterface.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file ("BlockPlayerInterface.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.entity.EntityLivingBase; -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.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.text.TextFormatting; -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 BlockPlayerInterface(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(4.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - public TileEntity createNewTileEntity(World world, int par2) { - return new TileEntityPlayerInterface(); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; - } - - @Override - 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) { - face.connectedPlayer = player.getUniqueID(); - face.playerName = player.getName(); - face.markDirty(); - face.sendUpdate(); - } - } - - super.onBlockPlacedBy(world, pos, state, player, stack); - } - - @Override - @SideOnly(Side.CLIENT) - 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; - 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); - } - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java deleted file mode 100644 index b2731cc15..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file ("BlockRangedCollector.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityRangedCollector; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class BlockRangedCollector extends BlockContainerBase { - - public BlockRangedCollector(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - 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) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.RANGED_COLLECTOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - return true; - } - return true; - } - - @Override - 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 deleted file mode 100644 index d316d4c9f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockShockSuppressor.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * This file ("BlockShockSuppressor.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.block.material.Material; -import net.minecraft.entity.Entity; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.world.ExplosionEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -public class BlockShockSuppressor extends BlockContainerBase { - - public BlockShockSuppressor(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(20.0F); - this.setResistance(2000.0F); - this.setSoundType(SoundType.STONE); - - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onExplosion(ExplosionEvent.Detonate event) { - World world = event.getWorld(); - if (!world.isRemote) { - List affectedBlocks = event.getAffectedBlocks(); - List affectedEntities = event.getAffectedEntities(); - - int rangeSq = TileEntityShockSuppressor.RANGE * TileEntityShockSuppressor.RANGE; - int use = TileEntityShockSuppressor.USE_PER; - - 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) { - posesToRemove.add(pos); - } - } - for (Entity entity : affectedEntities) { - if (entity.getPositionVector().squareDistanceTo(supPos.getX(), supPos.getY(), supPos.getZ()) <= rangeSq) { - entitiesToRemove.add(entity); - } - } - - Collections.shuffle(entitiesToRemove); - Collections.shuffle(posesToRemove); - - for (BlockPos pos : posesToRemove) { - if (suppressor.storage.getEnergyStored() >= use) { - suppressor.storage.extractEnergyInternal(use, false); - affectedBlocks.remove(pos); - } else { - break; - } - } - for (Entity entity : entitiesToRemove) { - if (suppressor.storage.getEnergyStored() >= use) { - suppressor.storage.extractEnergyInternal(use, false); - affectedEntities.remove(entity); - } else { - break; - } - } - } - } - } - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; - } - - @Override - 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 deleted file mode 100644 index cae57665b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSlabs.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * This file ("BlockSlabs.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; -import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.Block; -import net.minecraft.block.BlockSlab; -import net.minecraft.block.SoundType; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -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) { - this(name, fullBlock.getDefaultState()); - } - - public BlockSlabs(String name, IBlockState fullBlockState) { - super(fullBlockState.getMaterial(), name); - this.setHardness(1.5F); - this.setResistance(10.0F); - this.fullBlockState = fullBlockState; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - 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); } - return this.getStateFromMeta(meta); - } - - @Override - 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() { - return new TheItemBlock(this); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.COMMON; - } - - @Override - 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) { - return state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM ? 0 : 1; - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockSlab.HALF); - } - - public static class TheItemBlock extends ItemBlockBase { - - 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) { - ItemStack stack = player.getHeldItem(hand); - 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) { - 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)) { - 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); - player.setHeldItem(hand, StackUtil.shrink(stack, 1)); - } - - return EnumActionResult.SUCCESS; - } - } - - return this.tryPlace(player, stack, hand, world, pos.offset(facing)) ? EnumActionResult.SUCCESS : super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ); - } else { - return EnumActionResult.FAIL; - } - } - - @Override - @SideOnly(Side.CLIENT) - 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; } - } - - 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) { - IBlockState iblockstate = world.getBlockState(pos); - - 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)) { - 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); - - player.setHeldItem(hand, StackUtil.shrink(stack, 1)); - } - - return true; - } - - return false; - } - - @Override - 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 deleted file mode 100644 index fceb06cf8..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSmileyCloud.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * This file ("BlockSmileyCloud.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud; -import net.minecraft.block.BlockHorizontal; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -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.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; - -public class BlockSmileyCloud extends BlockContainerBase { - - public BlockSmileyCloud(String name) { - super(Material.CLOTH, name); - this.setHardness(0.5F); - this.setResistance(5.0F); - this.setSoundType(SoundType.CLOTH); - this.setTickRandomly(true); - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - 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); - } - } - } - - @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) { - TileEntity tile = world.getTileEntity(pos); - 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); - } - } - return true; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileEntitySmileyCloud(); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; - } - - @Override - 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) { - return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockHorizontal.FACING); - } - - @Override - 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) { - 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 deleted file mode 100644 index 8e073169b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTinyTorch.java +++ /dev/null @@ -1,273 +0,0 @@ -/* - * This file ("BlockTinyTorch.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -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.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; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -//Copied from BlockTorch. -//I have no idea what all of this means. -public class BlockTinyTorch extends BlockBase { - - //Thanks to xdjackiexd for these. - //Man, I hate numbers. - private static final AxisAlignedBB STANDING_AABB = new AxisAlignedBB(0.4375D, 0.0D, 0.4375D, 0.5625D, 0.3125D, 0.5625D); - private static final AxisAlignedBB TORCH_NORTH_AABB = new AxisAlignedBB(0.4375D, 0.25D, 0.8125D, 0.5625D, 0.5625D, 1.0D); - private static final AxisAlignedBB TORCH_SOUTH_AABB = new AxisAlignedBB(0.4375D, 0.25D, 0.0D, 0.5625D, 0.5625D, 0.1875D); - 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) { - super(Material.CIRCUITS, name); - this.setDefaultState(this.blockState.getBaseState().withProperty(BlockTorch.FACING, EnumFacing.UP)); - this.setTickRandomly(true); - - this.setHardness(0.0F); - this.setLightLevel(0.8F); - this.setSoundType(SoundType.WOOD); - } - - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { - switch (state.getValue(BlockTorch.FACING)) { - case EAST: - return TORCH_EAST_AABB; - case WEST: - return TORCH_WEST_AABB; - case SOUTH: - return TORCH_SOUTH_AABB; - case NORTH: - return TORCH_NORTH_AABB; - default: - return STANDING_AABB; - } - } - - @Nullable - @Override - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) { - return NULL_AABB; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - public boolean isNormalCube(IBlockState state) { - return false; - } - - @Override - public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing facing) { - return BlockFaceShape.UNDEFINED; - } - - 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; } - } - - return false; - } - - 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)) { - 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); } - } - - return this.getDefaultState(); - } - } - - @Override - 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) { - this.onNeighborChangeInternal(worldIn, pos, state); - } - - protected boolean onNeighborChangeInternal(World worldIn, BlockPos pos, IBlockState state) { - if (!this.checkForDrop(worldIn, pos, state)) { - return true; - } 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)) { - flag = true; - } else if (axis.isVertical() && !this.canPlaceOn(worldIn, pos.offset(enumfacing1))) { - flag = true; - } - - if (flag) { - this.dropBlockAsItem(worldIn, pos, state, 0); - worldIn.setBlockToAir(pos); - return true; - } else { - return false; - } - } - } - - 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) { - this.dropBlockAsItem(worldIn, pos, state, 0); - worldIn.setBlockToAir(pos); - } - - return false; - } - } - - @Override - @SideOnly(Side.CLIENT) - 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; - - 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, d1, d2, 0.0D, 0.0D, 0.0D); - worldIn.spawnParticle(EnumParticleTypes.FLAME, d0, d1, d2, 0.0D, 0.0D, 0.0D); - } - } - } - - @Override - public IBlockState getStateFromMeta(int meta) { - IBlockState iblockstate = this.getDefaultState(); - - switch (meta) { - case 1: - iblockstate = iblockstate.withProperty(BlockTorch.FACING, EnumFacing.EAST); - break; - case 2: - iblockstate = iblockstate.withProperty(BlockTorch.FACING, EnumFacing.WEST); - break; - case 3: - iblockstate = iblockstate.withProperty(BlockTorch.FACING, EnumFacing.SOUTH); - break; - case 4: - iblockstate = iblockstate.withProperty(BlockTorch.FACING, EnumFacing.NORTH); - break; - case 5: - default: - iblockstate = iblockstate.withProperty(BlockTorch.FACING, EnumFacing.UP); - } - - return iblockstate; - } - - @Override - public BlockRenderLayer getRenderLayer() { - return BlockRenderLayer.CUTOUT; - } - - @Override - public int getMetaFromState(IBlockState state) { - int i = 0; - - switch (state.getValue(BlockTorch.FACING)) { - case EAST: - i = i | 1; - break; - case WEST: - i = i | 2; - break; - case SOUTH: - i = i | 3; - break; - case NORTH: - i = i | 4; - break; - case DOWN: - case UP: - default: - i = i | 5; - } - - return i; - } - - @Override - 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) { - return state.withRotation(mirrorIn.toRotation(state.getValue(BlockTorch.FACING))); - } - - @Override - 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 deleted file mode 100644 index c215183f9..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTreasureChest.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * This file ("BlockTreasureChest.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import java.util.Random; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot; -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; -import net.minecraft.block.BlockHorizontal; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.init.SoundEvents; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -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.SoundCategory; -import net.minecraft.util.WeightedRandom; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class BlockTreasureChest extends BlockBase { - - public BlockTreasureChest(String name) { - super(Material.WOOD, name); - this.setHarvestLevel("axe", 0); - this.setHardness(300.0F); - this.setResistance(50.0F); - this.setSoundType(SoundType.WOOD); - this.setTickRandomly(true); - } - - @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) { - 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); - } - } - } - - @Override - 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); - this.dropItems(world, pos); - world.setBlockToAir(pos); - - //TheAchievements.OPEN_TREASURE_CHEST.get(player); - } - return true; - } - - @Override - 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) { - return false; - } - - 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 factor = 0.05F; - 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) { - return EnumRarity.EPIC; - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockHorizontal.FACING); - } - - @Override - 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) { - 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 deleted file mode 100644 index 9d1b1af2a..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWallAA.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * This file ("BlockWallAA.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; -import net.minecraft.block.Block; -import net.minecraft.block.BlockFenceGate; -import net.minecraft.block.BlockWall; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -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) }; - - @SuppressWarnings("deprecation") - public BlockWallAA(String name, Block blocc) { - super(blocc.getDefaultState().getMaterial(), name); - this.setHardness(1.5F); - this.setResistance(10F); - this.setSoundType(blocc.getSoundType()); - 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) { - int i = 0; - - if (state.getValue(BlockWall.NORTH)) { - i |= 1 << EnumFacing.NORTH.getHorizontalIndex(); - } - - if (state.getValue(BlockWall.EAST)) { - i |= 1 << EnumFacing.EAST.getHorizontalIndex(); - } - - if (state.getValue(BlockWall.SOUTH)) { - i |= 1 << EnumFacing.SOUTH.getHorizontalIndex(); - } - - if (state.getValue(BlockWall.WEST)) { - i |= 1 << EnumFacing.WEST.getHorizontalIndex(); - } - - return i; - } - - @Override - 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()); - boolean flag3 = this.canConnectTo(worldIn, pos.west()); - boolean flag4 = flag && !flag1 && flag2 && !flag3 || !flag && flag1 && !flag2 && flag3; - return state.withProperty(BlockWall.UP, !flag4 || !worldIn.isAirBlock(pos.up())).withProperty(BlockWall.NORTH, flag).withProperty(BlockWall.EAST, flag1).withProperty(BlockWall.SOUTH, flag2).withProperty(BlockWall.WEST, flag3); - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - 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) { - return side != EnumFacing.DOWN || super.shouldSideBeRendered(blockState, blockAccess, pos, side); - } - - @Override - 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) { - blockState = this.getActualState(blockState, worldIn, pos); - return CLIP_AABB_BY_INDEX[yesThisIsCopyPastedFromBlockWallAndIHaveNoIdeaWhatThisMethodDoes(blockState)]; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(CreativeTabs tab, NonNullList list) { - list.add(new ItemStack(this, 1, 0)); - } - - 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) { - return this.getDefaultState(); - } - - @Override - public int getMetaFromState(IBlockState state) { - return 0; - } - - @Override - 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 deleted file mode 100644 index 05acfc1dd..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWildPlant.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * This file ("BlockWildPlant.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase; -import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheWildPlants; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.block.Block; -import net.minecraft.block.BlockCrops; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -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) { - super(name); - this.setSoundType(SoundType.PLANT); - } - - @Override - 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) { - 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++) { - list.add(new ItemStack(this, 1, j)); - } - } - - @Override - 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) { - return false; - } - - @Override - protected ItemBlockBase getItemBlock() { - return new TheItemBlock(this); - } - - @Override - 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()); - } - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(TYPE, TheWildPlants.values()[meta]); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(TYPE).ordinal(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, TYPE); - } - - @Override - 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 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(); - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java deleted file mode 100644 index a92040a78..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This file ("BlockXPSolidifier.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityXPSolidifier; -import net.minecraft.block.BlockHorizontal; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -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.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class BlockXPSolidifier extends BlockContainerBase { - - public BlockXPSolidifier(String name) { - super(Material.ROCK, name); - this.setHarvestLevel("pickaxe", 0); - this.setHardness(2.5F); - this.setResistance(10.0F); - this.setSoundType(SoundType.STONE); - } - - @Override - 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) { - player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.XP_SOLIDIFIER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); - } - return true; - } - return true; - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; - } - - @Override - 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) { - return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BlockHorizontal.FACING); - } - - @Override - 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) { - 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 deleted file mode 100644 index f6c9e50c1..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/IHudDisplay.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file ("IHudDisplay.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.RayTraceResult; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -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 deleted file mode 100644 index f2d793a71..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/InitBlocks.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * This file ("InitBlocks.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.BlockLaserRelay.Type; -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant; -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockStair; -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 static Block blockCompost; - public static Block blockMisc; - public static Block blockWildPlant; - public static Block blockFeeder; - public static Block blockGiantChest; - public static Block blockGiantChestMedium; - public static Block blockGiantChestLarge; - public static Block blockGrinder; - public static Block blockGrinderDouble; - public static Block blockFurnaceDouble; - public static Block blockInputter; - public static Block blockInputterAdvanced; - public static Block blockFishingNet; - public static Block blockFurnaceSolar; - public static Block blockHeatCollector; - public static Block blockItemRepairer; - public static Block blockGreenhouseGlass; - public static Block blockBreaker; - public static Block blockPlacer; - public static Block blockDropper; - public static Block blockRice; - public static Block blockCanola; - public static Block blockFlax; - public static Block blockCoffee; - public static Block blockCanolaPress; - public static Block blockFermentingBarrel; - public static Block blockCoalGenerator; - public static Block blockOilGenerator; - public static Block blockPhantomface; - public static Block blockPhantomPlacer; - public static Block blockPhantomBreaker; - public static Block blockPhantomLiquiface; - public static Block blockPhantomEnergyface; - public static Block blockPhantomRedstoneface; - public static Block blockPlayerInterface; - public static Block blockFluidPlacer; - public static Block blockFluidCollector; - public static Block blockLavaFactoryController; - public static Block blockCoffeeMachine; - public static Block blockPhantomBooster; - public static Block blockEnergizer; - public static Block blockEnervator; - public static Block blockTestifiBucksGreenWall; - public static Block blockTestifiBucksWhiteWall; - public static Block blockTestifiBucksGreenStairs; - public static Block blockTestifiBucksWhiteStairs; - public static Block blockTestifiBucksGreenSlab; - public static Block blockTestifiBucksWhiteSlab; - public static Block blockTestifiBucksGreenFence; - public static Block blockTestifiBucksWhiteFence; - public static Block blockColoredLamp; - public static Block blockColoredLampOn; - public static Block blockLampPowerer; - public static Block blockTreasureChest; - public static Block blockXPSolidifier; - public static Block blockSmileyCloud; - public static Block blockLeafGenerator; - public static Block blockDirectionalBreaker; - public static Block blockRangedCollector; - public static Block blockLaserRelay; - public static Block blockLaserRelayAdvanced; - public static Block blockLaserRelayExtreme; - public static Block blockLaserRelayFluids; - public static Block blockLaserRelayItem; - public static Block blockLaserRelayItemWhitelist; - public static Block blockItemViewer; - public static Block blockItemViewerHopping; - public static Block blockBlackLotus; - public static Block blockCrystal; - public static Block blockCrystalEmpowered; - public static Block blockAtomicReconstructor; - public static Block blockMiner; - public static Block blockFireworkBox; - public static Block blockQuartzWall; - public static Block blockQuartzStair; - public static Block blockQuartzSlab; - public static Block blockChiseledQuartzWall; - public static Block blockChiseledQuartzStair; - public static Block blockChiseledQuartzSlab; - public static Block blockPillarQuartzWall; - public static Block blockPillarQuartzStair; - public static Block blockPillarQuartzSlab; - public static Block blockDisplayStand; - public static Block blockShockSuppressor; - public static Block blockEmpowerer; - public static Block blockBioReactor; - public static Block blockTinyTorch; - public static Block blockFarmer; - public static Block blockBatteryBox; - public static Block blockCrystalClusterRedstone; - public static Block blockCrystalClusterLapis; - public static Block blockCrystalClusterDiamond; - public static Block blockCrystalClusterCoal; - public static Block blockCrystalClusterEmerald; - public static Block blockCrystalClusterIron; - - public static void init() { - ActuallyAdditions.LOGGER.info("Initializing Blocks..."); - - blockCrystalClusterRedstone = new BlockCrystalCluster("block_crystal_cluster_redstone", TheCrystals.REDSTONE); - blockCrystalClusterLapis = new BlockCrystalCluster("block_crystal_cluster_lapis", TheCrystals.LAPIS); - blockCrystalClusterDiamond = new BlockCrystalCluster("block_crystal_cluster_diamond", TheCrystals.DIAMOND); - blockCrystalClusterCoal = new BlockCrystalCluster("block_crystal_cluster_coal", TheCrystals.COAL); - blockCrystalClusterEmerald = new BlockCrystalCluster("block_crystal_cluster_emerald", TheCrystals.EMERALD); - blockCrystalClusterIron = new BlockCrystalCluster("block_crystal_cluster_iron", TheCrystals.IRON); - blockBatteryBox = new BlockBatteryBox("block_battery_box"); - blockItemViewerHopping = new BlockItemViewerHopping("block_item_viewer_hopping"); - blockFarmer = new BlockFarmer("block_farmer"); - blockBioReactor = new BlockBioReactor("block_bio_reactor"); - blockEmpowerer = new BlockEmpowerer("block_empowerer"); - blockTinyTorch = new BlockTinyTorch("block_tiny_torch"); - blockShockSuppressor = new BlockShockSuppressor("block_shock_suppressor"); - blockDisplayStand = new BlockDisplayStand("block_display_stand"); - blockPlayerInterface = new BlockPlayerInterface("block_player_interface"); - blockItemViewer = new BlockItemViewer("block_item_viewer"); - blockFireworkBox = new BlockFireworkBox("block_firework_box"); - blockMiner = new BlockMiner("block_miner"); - blockAtomicReconstructor = new BlockAtomicReconstructor("block_atomic_reconstructor"); - blockCrystal = new BlockCrystal("block_crystal", false); - blockCrystalEmpowered = new BlockCrystal("block_crystal_empowered", true); - blockBlackLotus = new BlockBlackLotus("block_black_lotus"); - blockLaserRelay = new BlockLaserRelay("block_laser_relay", Type.ENERGY_BASIC); - blockLaserRelayAdvanced = new BlockLaserRelay("block_laser_relay_advanced", Type.ENERGY_ADVANCED); - blockLaserRelayExtreme = new BlockLaserRelay("block_laser_relay_extreme", Type.ENERGY_EXTREME); - blockLaserRelayFluids = new BlockLaserRelay("block_laser_relay_fluids", Type.FLUIDS); - blockLaserRelayItem = new BlockLaserRelay("block_laser_relay_item", Type.ITEM); - blockLaserRelayItemWhitelist = new BlockLaserRelay("block_laser_relay_item_whitelist", Type.ITEM_WHITELIST); - blockRangedCollector = new BlockRangedCollector("block_ranged_collector"); - blockDirectionalBreaker = new BlockDirectionalBreaker("block_directional_breaker"); - blockLeafGenerator = new BlockLeafGenerator("block_leaf_generator"); - blockSmileyCloud = new BlockSmileyCloud("block_smiley_cloud"); - blockXPSolidifier = new BlockXPSolidifier("block_xp_solidifier"); - blockTestifiBucksGreenWall = new BlockGeneric("block_testifi_bucks_green_wall"); - blockTestifiBucksWhiteWall = new BlockGeneric("block_testifi_bucks_white_wall"); - blockTestifiBucksGreenStairs = new BlockStair(blockTestifiBucksGreenWall, "block_testifi_bucks_green_stairs"); - blockTestifiBucksWhiteStairs = new BlockStair(blockTestifiBucksWhiteWall, "block_testifi_bucks_white_stairs"); - blockTestifiBucksGreenSlab = new BlockSlabs("block_testifi_bucks_green_slab", blockTestifiBucksGreenWall); - blockTestifiBucksWhiteSlab = new BlockSlabs("block_testifi_bucks_white_slab", blockTestifiBucksWhiteWall); - blockTestifiBucksGreenFence = new BlockWallAA("block_testifi_bucks_green_fence", blockTestifiBucksGreenWall); - blockTestifiBucksWhiteFence = new BlockWallAA("block_testifi_bucks_white_fence", blockTestifiBucksWhiteWall); - blockColoredLamp = new BlockColoredLamp(false, "block_colored_lamp"); - blockColoredLampOn = new BlockColoredLamp(true, "block_colored_lamp_on"); - blockLampPowerer = new BlockLampPowerer("block_lamp_powerer"); - blockTreasureChest = new BlockTreasureChest("block_treasure_chest"); - blockEnergizer = new BlockEnergizer(true, "block_energizer"); - blockEnervator = new BlockEnergizer(false, "block_enervator"); - blockLavaFactoryController = new BlockLavaFactoryController("block_lava_factory_controller"); - blockCanolaPress = new BlockCanolaPress("block_canola_press"); - blockPhantomface = new BlockPhantom(BlockPhantom.Type.FACE, "block_phantomface"); - blockPhantomPlacer = new BlockPhantom(BlockPhantom.Type.PLACER, "block_phantom_placer"); - blockPhantomLiquiface = new BlockPhantom(BlockPhantom.Type.LIQUIFACE, "block_phantom_liquiface"); - blockPhantomEnergyface = new BlockPhantom(BlockPhantom.Type.ENERGYFACE, "block_phantom_energyface"); - blockPhantomRedstoneface = new BlockPhantom(BlockPhantom.Type.REDSTONEFACE, "block_phantom_redstoneface"); - blockPhantomBreaker = new BlockPhantom(BlockPhantom.Type.BREAKER, "block_phantom_breaker"); - blockCoalGenerator = new BlockCoalGenerator("block_coal_generator"); - blockOilGenerator = new BlockOilGenerator("block_oil_generator"); - blockFermentingBarrel = new BlockFermentingBarrel("block_fermenting_barrel"); - blockRice = new BlockPlant("block_rice", 1, 2); - blockCanola = new BlockPlant("block_canola", 2, 3); - blockFlax = new BlockPlant("block_flax", 2, 4); - blockCoffee = new BlockPlant("block_coffee", 2, 2); - blockCompost = new BlockCompost("block_compost"); - blockMisc = new BlockMisc("block_misc"); - blockFeeder = new BlockFeeder("block_feeder"); - blockGiantChest = new BlockGiantChest("block_giant_chest", 0); - blockGiantChestMedium = new BlockGiantChest("block_giant_chest_medium", 1); - blockGiantChestLarge = new BlockGiantChest("block_giant_chest_large", 2); - blockGrinder = new BlockGrinder(false, "block_grinder"); - blockGrinderDouble = new BlockGrinder(true, "block_grinder_double"); - blockFurnaceDouble = new BlockFurnaceDouble("block_furnace_double"); - blockInputter = new BlockInputter(false, "block_inputter"); - blockInputterAdvanced = new BlockInputter(true, "block_inputter_advanced"); - blockFishingNet = new BlockFishingNet("block_fishing_net"); - blockFurnaceSolar = new BlockFurnaceSolar("block_furnace_solar"); - blockHeatCollector = new BlockHeatCollector("block_heat_collector"); - blockItemRepairer = new BlockItemRepairer("block_item_repairer"); - blockGreenhouseGlass = new BlockGreenhouseGlass("block_greenhouse_glass"); - blockBreaker = new BlockBreaker(false, "block_breaker"); - blockPlacer = new BlockBreaker(true, "block_placer"); - blockDropper = new BlockDropper("block_dropper"); - blockFluidPlacer = new BlockFluidCollector(true, "block_fluid_placer"); - blockFluidCollector = new BlockFluidCollector(false, "block_fluid_collector"); - blockCoffeeMachine = new BlockCoffeeMachine("block_coffee_machine"); - blockPhantomBooster = new BlockPhantomBooster("block_phantom_booster"); - blockWildPlant = new BlockWildPlant("block_wild"); - blockQuartzWall = new BlockWallAA("block_quartz_wall", blockMisc); - blockChiseledQuartzWall = new BlockWallAA("block_chiseled_quartz_wall", blockMisc); - blockPillarQuartzWall = new BlockWallAA("block_pillar_quartz_wall", blockMisc); - blockQuartzStair = new BlockStair(blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ), "block_quartz_stair"); - blockChiseledQuartzStair = new BlockStair(blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ_CHISELED), "block_chiseled_quartz_stair"); - blockPillarQuartzStair = new BlockStair(blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ_PILLAR), "block_pillar_quartz_stair"); - blockQuartzSlab = new BlockSlabs("block_quartz_slab", blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ)); - blockChiseledQuartzSlab = new BlockSlabs("block_chiseled_quartz_slab", blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ_CHISELED)); - blockPillarQuartzSlab = new BlockSlabs("block_pillar_quartz_slab", blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ_PILLAR)); - } -} \ No newline at end of file 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 deleted file mode 100644 index 188487c12..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockBase.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file ("BlockBase.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.IRarity; - -public class BlockBase extends Block implements ItemBlockBase.ICustomRarity, IHasModel { - - private final String name; - - public BlockBase(Material material, String name) { - super(material); - this.name = name; - - this.register(); - } - - private void register() { - ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative()); - } - - protected String getBaseName() { - return this.name; - } - - protected ItemBlockBase getItemBlock() { - return new ItemBlockBase(this); - } - - public boolean shouldAddCreative() { - return true; - } - - @Override - public void registerRendering() { - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); - } - - @Override - 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 deleted file mode 100644 index 76baf232e..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockBushBase.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file ("BlockBushBase.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.block.BlockBush; -import net.minecraft.block.SoundType; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; - -public class BlockBushBase extends BlockBush implements ItemBlockBase.ICustomRarity, IHasModel { - - private final String name; - - public BlockBushBase(String name) { - this.name = name; - this.setSoundType(SoundType.PLANT); - - this.register(); - } - - private void register() { - ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative()); - } - - protected String getBaseName() { - return this.name; - } - - protected ItemBlockBase getItemBlock() { - return new ItemBlockBase(this); - } - - public boolean shouldAddCreative() { - return true; - } - - @Override - public void registerRendering() { - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); - } - - @Override - 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 deleted file mode 100644 index 61e6680ad..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * This file ("BlockContainerBase.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagInt; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumBlockRenderType; -import net.minecraft.util.EnumHand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.Style; -import net.minecraft.util.text.TextComponentTranslation; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.fluids.FluidTank; -import net.minecraftforge.fluids.FluidUtil; - -public abstract class BlockContainerBase extends BlockContainer implements ItemBlockBase.ICustomRarity, IHasModel { - - private final String name; - - public BlockContainerBase(Material material, String name) { - super(material); - this.name = name; - - this.register(); - } - - private void register() { - ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative()); - } - - protected String getBaseName() { - return this.name; - } - - protected ItemBlockBase getItemBlock() { - return new ItemBlockBase(this); - } - - public boolean shouldAddCreative() { - return true; - } - - @Override - public void registerRendering() { - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.COMMON; - } - - 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++) { - this.dropSlotFromInventory(i, tile, world, position); - } - } - } - } - } - - 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()); - float factor = 0.05F; - 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) { - ItemStack stack = player.getHeldItemMainhand(); - 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()) { - base.isPulseMode = !base.isPulseMode; - base.markDirty(); - base.sendUpdate(); - } - return true; - } - } - return false; - } - - @Override - 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()) { - base.activateOnPulse(); - } - } - } - } - - 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()) { - base.saveDataOnChangeOrWorldStart(); - } - } - } - - @Override - 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) { - super.onNeighborChange(world, pos, neighbor); - if (world instanceof World) { - this.neighborsChangedCustom((World) world, pos); - } - } - - public void updateRedstoneState(World world, BlockPos pos) { - if (!world.isRemote) { - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityBase) { - TileEntityBase base = (TileEntityBase) tile; - boolean powered = world.getRedstonePowerFromNeighbors(pos) > 0; - boolean wasPowered = base.isRedstonePowered; - if (powered && !wasPowered) { - if (base.respondsToPulses()) { - world.scheduleUpdate(pos, this, this.tickRate(world)); - } - base.setRedstonePowered(true); - } else if (!powered && wasPowered) { - base.setRedstonePowered(false); - } - } - } - } - - 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) { - this.updateRedstoneState(world, pos); - } - - @Override - 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; - NBTTagCompound compound = stack.getTagCompound().getCompoundTag("Data"); - if (compound != null) { - base.readSyncableNBT(compound, TileEntityBase.NBTType.SAVE_BLOCK); - } - } - } - } - - @Override - 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))); - } - } - } - - @Override - public boolean hasComparatorInputOverride(IBlockState state) { - return true; - } - - @Override - public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) { - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityBase) { return ((TileEntityBase) tile).getComparatorStrength(); } - return 0; - } - - @Override - 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) { - 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()) { - 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) { - keysToRemove.add(key); - } - } - } - 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()) { - stack.setTagCompound(new NBTTagCompound()); - stack.getTagCompound().setTag("Data", data); - } - - drops.add(stack); - } - } else { - super.getDrops(drops, world, pos, state, fortune); - } - } - - @Override - public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) { - return willHarvest || super.removedByPlayer(state, world, pos, player, false); - } - - @Override - public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack) { - super.harvestBlock(worldIn, player, pos, state, te, stack); - worldIn.setBlockToAir(pos); - } - - @Override - public EnumBlockRenderType getRenderType(IBlockState state) { - return EnumBlockRenderType.MODEL; - } - - @Override - 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) { - 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 deleted file mode 100644 index bb60986d5..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockFluidFlowing.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file ("BlockFluidFlowing.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.fluids.BlockFluidClassic; -import net.minecraftforge.fluids.Fluid; - -public class BlockFluidFlowing extends BlockFluidClassic implements ItemBlockBase.ICustomRarity { - - private final String name; - - public BlockFluidFlowing(Fluid fluid, Material material, String unlocalizedName) { - super(fluid, material); - this.name = unlocalizedName; - this.displacements.put(this, false); - - this.register(); - } - - private void register() { - ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative()); - } - - protected String getBaseName() { - return this.name; - } - - protected ItemBlockBase getItemBlock() { - return new ItemBlockBase(this); - } - - public boolean shouldAddCreative() { - return false; - } - - @Override - 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) { - return !world.getBlockState(pos).getMaterial().isLiquid() && super.displaceIfPossible(world, pos); - } - - @Override - 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 deleted file mode 100644 index d87bac936..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockPlant.java +++ /dev/null @@ -1,139 +0,0 @@ -/* -* This file ("BlockPlant.java") is part of the Actually Additions mod for Minecraft. -* It is created and owned by Ellpeck and distributed -* under the Actually Additions License to be found at -* http://ellpeck.de/actaddlicense -* View the source code at https://github.com/Ellpeck/ActuallyAdditions -* -* © 2015-2017 Ellpeck -*/ - -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; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.BlockCrops; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.EnumPlantType; -import net.minecraftforge.items.ItemHandlerHelper; - -public class BlockPlant extends BlockCrops implements ItemBlockBase.ICustomRarity, IHasModel { - - private final String name; - private final int minDropAmount; - private final int addDropAmount; - public Item seedItem; - private Item returnItem; - private int returnMeta; - - 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) { - this.seedItem = seedItem; - this.returnItem = returnItem; - this.returnMeta = returnMeta; - } - - private void register() { - ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative()); - } - - protected String getBaseName() { - return this.name; - } - - protected ItemBlockBase getItemBlock() { - return new ItemBlockBase(this); - } - - public boolean shouldAddCreative() { - return false; - } - - @Override - public void registerRendering() { - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; - } - - @Override - public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) { - return EnumPlantType.Crop; - } - - @Override - 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) { - - 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) { - drop.shrink(1); - deductedSeedSize = true; - } - if (StackUtil.isValid(drop)) { - ItemHandlerHelper.giveItemToPlayer(player, drop); - } - } - } - - world.setBlockState(pos, this.getStateFromMeta(0)); - } - return true; - } - return false; - } - - @Override - 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); - } - - @Override - public Item getCrop() { - return this.returnItem; - } - - @Override - 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 deleted file mode 100644 index a6e551508..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockStair.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file ("BlockStair.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.block.Block; -import net.minecraft.block.BlockStairs; -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 { - - private final String name; - - public BlockStair(Block block, String name) { - this(block.getDefaultState(), name); - } - - public BlockStair(IBlockState state, String name) { - super(state); - this.name = name; - this.setLightOpacity(0); - - this.register(); - } - - private void register() { - ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative()); - } - - protected String getBaseName() { - return this.name; - } - - protected ItemBlockBase getItemBlock() { - return new ItemBlockBase(this); - } - - public boolean shouldAddCreative() { - return true; - } - - @Override - public void registerRendering() { - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.COMMON; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/ItemBlockBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/ItemBlockBase.java deleted file mode 100644 index 61a5adb59..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/ItemBlockBase.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file ("ItemBlockBase.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks.base; - -import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.block.Block; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.IRarity; - -public class ItemBlockBase extends ItemBlock { - - public ItemBlockBase(Block block) { - super(block); - this.setHasSubtypes(false); - this.setMaxDamage(0); - } - - @Override - public String getTranslationKey(ItemStack stack) { - return this.getTranslationKey(); - } - - @Override - public int getMetadata(int damage) { - return damage; - } - - @Override - public IRarity getForgeRarity(ItemStack stack) { - if (this.block instanceof ICustomRarity) { - return ((ICustomRarity) this.block).getRarity(stack); - } else { - return Util.FALLBACK_RARITY; - } - } - - public interface ICustomRarity { - - IRarity getRarity(ItemStack stack); - - } -} \ No newline at end of file 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 deleted file mode 100644 index f5b770254..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/metalists/TheColoredLampColors.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file ("TheColoredLampColors.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks.metalists; - -import net.minecraft.util.IStringSerializable; - -public enum TheColoredLampColors implements IStringSerializable { - - WHITE("White", "white"), - ORANGE("Orange", "orange"), - MAGENTA("Magenta", "magenta"), - LIGHT_BLUE("LightBlue", "light_blue"), - YELLOW("Yellow", "yellow"), - LIME("Lime", "lime"), - PINK("Pink", "pink"), - GRAY("Gray", "gray"), - LIGHT_GRAY("LightGray", "light_gray"), - CYAN("Cyan", "cyan"), - PURPLE("Purple", "purple"), - BLUE("Blue", "blue"), - BROWN("Brown", "brown"), - GREEN("Green", "green"), - RED("Red", "red"), - BLACK("Black", "black"); - - public final String regName; - public final String oreName; - - TheColoredLampColors(String oreName, String regName) { - this.oreName = oreName; - this.regName = regName; - } - - 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++) { - String aName = values()[i].oreName; - if (aName != null) { - if (aName.equalsIgnoreCase(actualName)) { return values()[i]; } - } - } - } - return null; - } - - @Override - 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 deleted file mode 100644 index a2fa35316..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/metalists/TheMiscBlocks.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file ("TheMiscBlocks.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks.metalists; - -import net.minecraft.item.EnumRarity; -import net.minecraft.util.IStringSerializable; - -public enum TheMiscBlocks implements IStringSerializable { - - QUARTZ_PILLAR("black_quartz_pillar", EnumRarity.RARE), - QUARTZ_CHISELED("black_quartz_chiseled", EnumRarity.RARE), - QUARTZ("black_quartz", EnumRarity.RARE), - ORE_QUARTZ("ore_black_quartz", EnumRarity.EPIC), - WOOD_CASING("wood_casing", EnumRarity.COMMON), - CHARCOAL_BLOCK("charcoal", EnumRarity.COMMON), - ENDERPEARL_BLOCK("enderpearl", EnumRarity.RARE), - LAVA_FACTORY_CASE("lava_factory_case", EnumRarity.UNCOMMON), - ENDER_CASING("ender_casing", EnumRarity.EPIC), - IRON_CASING("iron_casing", EnumRarity.RARE); - - public final String name; - public final EnumRarity rarity; - - TheMiscBlocks(String name, EnumRarity rarity) { - this.name = name; - this.rarity = rarity; - } - - @Override - public String getName() { - return this.name; - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/metalists/TheWildPlants.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/metalists/TheWildPlants.java deleted file mode 100644 index 808b7af20..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/metalists/TheWildPlants.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file ("TheWildPlants.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks.metalists; - -import com.google.common.base.Preconditions; - -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import net.minecraft.block.Block; -import net.minecraft.item.EnumRarity; -import net.minecraft.util.IStringSerializable; - -public enum TheWildPlants implements IStringSerializable { - - CANOLA("canola", EnumRarity.RARE, InitBlocks.blockCanola), - FLAX("flax", EnumRarity.RARE, InitBlocks.blockFlax), - RICE("rice", EnumRarity.RARE, InitBlocks.blockRice), - COFFEE("coffee", EnumRarity.RARE, InitBlocks.blockCoffee); - - final String name; - final EnumRarity rarity; - final Block normal; - - TheWildPlants(String name, EnumRarity rarity, Block normal) { - this.name = name; - this.rarity = rarity; - this.normal = Preconditions.checkNotNull(normal, "TheWildPlants was loaded before block init!"); - } - - @Override - public String getName() { - return this.name; - } - - public EnumRarity getRarity() { - return this.rarity; - } - - public Block getNormalVersion() { - return this.normal; - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/ActualCompostModel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/ActualCompostModel.java deleted file mode 100644 index 0efcca4e5..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/ActualCompostModel.java +++ /dev/null @@ -1,63 +0,0 @@ -package de.ellpeck.actuallyadditions.mod.blocks.render; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang3.tuple.Pair; - -import de.ellpeck.actuallyadditions.mod.blocks.BlockCompost; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.IBakedModel; -import net.minecraft.client.renderer.block.model.ItemOverrideList; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.common.property.IExtendedBlockState; - -public class ActualCompostModel implements IBakedModel { - - public static final Map, IBakedModel> MODELS = new HashMap<>(); - - @SuppressWarnings("unchecked") - @Override - public List getQuads(IBlockState state, EnumFacing side, long rand) { - if (state instanceof IExtendedBlockState) { - Pair data = ((IExtendedBlockState) state).getValue(BlockCompost.COMPOST_PROP); - if (data == null || data.getRight() <= 0) return CompostModel.compostBase.getQuads(state, side, rand); - IBakedModel model = MODELS.get(data); - if (model == null) { - model = new CompostModel(data.getLeft(), data.getRight()); - MODELS.put(data, model); - } - return model.getQuads(state, side, rand); - } - return CompostModel.compostBase.getQuads(state, side, rand); - } - - @Override - public boolean isAmbientOcclusion() { - return CompostModel.compostBase.isAmbientOcclusion(); - } - - @Override - public boolean isGui3d() { - return false; - } - - @Override - public boolean isBuiltInRenderer() { - return false; - } - - @Override - public TextureAtlasSprite getParticleTexture() { - return CompostModel.compostBase.getParticleTexture(); - } - - @Override - public ItemOverrideList getOverrides() { - return ItemOverrideList.NONE; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/CompostModel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/CompostModel.java deleted file mode 100644 index 196650f9d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/CompostModel.java +++ /dev/null @@ -1,94 +0,0 @@ -package de.ellpeck.actuallyadditions.mod.blocks.render; - -import java.util.EnumMap; -import java.util.List; - -import javax.annotation.Nullable; -import javax.vecmath.Vector3f; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.IBakedModel; -import net.minecraft.client.renderer.block.model.ItemOverrideList; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.common.model.TRSRTransformation; - -public class CompostModel implements IBakedModel { - public static IBakedModel compostBase; - private final IBakedModel display; - private final ImmutableList general; - private final ImmutableMap> faces; - - public CompostModel(IBlockState flowerState, float height) { - this.display = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(flowerState); - - TRSRTransformation transform = TRSRTransformation.blockCenterToCorner(new TRSRTransformation(new Vector3f(0, -.218F, 0), null, new Vector3f(0.75F, height / 1.81F, 0.75F), null)); - - ImmutableList.Builder builder; - EnumMap> faces = new EnumMap<>(EnumFacing.class); - - for (EnumFacing face : EnumFacing.values()) { - builder = ImmutableList.builder(); - if (!this.display.isBuiltInRenderer()) { - for (BakedQuad quad : this.display.getQuads(flowerState, face, 0)) { - Transformer transformer = new Transformer(transform, quad.getFormat()); - quad.pipe(transformer); - builder.add(transformer.build()); - } - builder.addAll(compostBase.getQuads(null, face, 0)); - } - faces.put(face, builder.build()); - } - - if (!this.display.isBuiltInRenderer()) { - builder = ImmutableList.builder(); - for (BakedQuad quad : this.display.getQuads(flowerState, null, 0)) { - Transformer transformer = new Transformer(transform, quad.getFormat()); - quad.pipe(transformer); - builder.add(transformer.build()); - } - builder.addAll(compostBase.getQuads(null, null, 0)); - this.general = builder.build(); - } else this.general = ImmutableList.of(); - - this.faces = Maps.immutableEnumMap(faces); - } - - @Override - public List getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) { - if (side == null) return this.general; - return this.faces.get(side); - } - - @Override - public boolean isAmbientOcclusion() { - return compostBase.isAmbientOcclusion() && this.display.isAmbientOcclusion(); - } - - @Override - public boolean isGui3d() { - return false; - } - - @Override - public boolean isBuiltInRenderer() { - return false; - } - - @Override - public TextureAtlasSprite getParticleTexture() { - return compostBase.getParticleTexture(); - } - - @Override - public ItemOverrideList getOverrides() { - return ItemOverrideList.NONE; - } - -} 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 deleted file mode 100644 index 115b8ab14..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/IHasModel.java +++ /dev/null @@ -1,7 +0,0 @@ -package de.ellpeck.actuallyadditions.mod.blocks.render; - -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 deleted file mode 100644 index 081dac388..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderBatteryBox.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file ("RenderBatteryBox.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraftforge.energy.CapabilityEnergy; -import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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; } - - ItemStack stack = tile.inv.getStackInSlot(0); - if (StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery) { - GlStateManager.pushMatrix(); - GlStateManager.translate((float) x + 0.5F, (float) y + 1F, (float) z + 0.5F); - - GlStateManager.pushMatrix(); - - GlStateManager.scale(0.0075F, 0.0075F, 0.0075F); - GlStateManager.rotate(180F, 1F, 0F, 0F); - GlStateManager.translate(0F, 0F, -50F); - - if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) { - IEnergyStorage cap = stack.getCapability(CapabilityEnergy.ENERGY, null); - NumberFormat format = NumberFormat.getInstance(); - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - - String s = format.format(cap.getEnergyStored()) + "/" + format.format(cap.getMaxEnergyStored()); - float lengthS = -font.getStringWidth(s) / 2F; - String s2 = "Crystal Flux"; - float lengthS2 = -font.getStringWidth(s2) / 2F; - - for (int i = 0; i < 4; i++) { - font.drawString(s, lengthS, 10F, 0xFFFFFF, false); - font.drawString(s2, lengthS2, 20F, 0xFFFFFF, false); - - GlStateManager.translate(-50F, 0F, 50F); - GlStateManager.rotate(90F, 0F, 1F, 0F); - } - } - - GlStateManager.popMatrix(); - - 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 { - AssetUtil.renderItemInWorld(stack); - } catch (Exception e) { - ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in a battery box! The item is " + stack.getItem().getRegistryName() + "!", e); - } - - GlStateManager.popMatrix(); - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderDisplayStand.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderDisplayStand.java deleted file mode 100644 index b6bdf77e2..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderDisplayStand.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file ("RenderDisplayStand.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks.render; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityDisplayStand; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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; } - - ItemStack stack = tile.inv.getStackInSlot(0); - if (StackUtil.isValid(stack)) { - GlStateManager.pushMatrix(); - 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); - - float scale = stack.getItem() instanceof ItemBlock ? 0.85F : 0.65F; - GlStateManager.scale(scale, scale, scale); - 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); - } - - 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 deleted file mode 100644 index 65a6398de..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderEmpowerer.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file ("RenderEmpowerer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks.render; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityEmpowerer; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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; } - - ItemStack stack = tile.inv.getStackInSlot(0); - if (StackUtil.isValid(stack)) { - GlStateManager.pushMatrix(); - 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); - - float scale = stack.getItem() instanceof ItemBlock ? 0.85F : 0.65F; - GlStateManager.scale(scale, scale, scale); - try { - AssetUtil.renderItemInWorld(stack); - } 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); - } - - GlStateManager.popMatrix(); - } - - int index = tile.recipeForRenderIndex; - 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++) { - 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()); - } - } - } - } -} 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 deleted file mode 100644 index f38ed1c35..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderLaserRelay.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This file ("RenderLaserRelay.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.config.ConfigValues; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.ItemEngineerGoggles; -import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import io.netty.util.internal.ConcurrentSet; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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 }; - - @Override - 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; - - EntityPlayer player = Minecraft.getMinecraft().player; - boolean hasGoggles = ItemEngineerGoggles.isWearing(player); - - ItemStack upgrade = relay.inv.getStackInSlot(0); - if (StackUtil.isValid(upgrade)) { - if (upgrade.getItem() == InitItems.itemLaserUpgradeInvisibility) { - hasInvis = true; - } - - ItemStack hand = player.getHeldItemMainhand(); - if (hasGoggles || StackUtil.isValid(hand) && (hand.getItem() == ConfigValues.itemCompassConfigurator || hand.getItem() instanceof ItemLaserWrench) || "themattabase".equals(player.getName())) { - GlStateManager.pushMatrix(); - - float yTrans = tile.getBlockMetadata() == 0 ? 0.2F : 0.8F; - GlStateManager.translate((float) x + 0.5F, (float) y + yTrans, (float) z + 0.5F); - GlStateManager.scale(0.2F, 0.2F, 0.2F); - - double boop = Minecraft.getSystemTime() / 800D; - GlStateManager.rotate((float) (boop * 40D % 360), 0, 1, 0); - - AssetUtil.renderItemInWorld(upgrade); - - GlStateManager.popMatrix(); - } - } - - ConcurrentSet 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])) { - 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); - boolean otherInvis = StackUtil.isValid(secondUpgrade) && secondUpgrade.getItem() == InitItems.itemLaserUpgradeInvisibility; - - 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); - } - } - } - } - } - } - } - - @Override - public boolean isGlobalRenderer(TileEntityLaserRelay tile) { - return true; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderReconstructorLens.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderReconstructorLens.java deleted file mode 100644 index 3e6f4ecb9..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderReconstructorLens.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file ("RenderReconstructorLens.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.blocks.render; - -import de.ellpeck.actuallyadditions.api.lens.ILensItem; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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; - - ItemStack stack = tile.inv.getStackInSlot(0); - - 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.rotate(180F, 0.0F, 0.0F, 1.0F); - - IBlockState state = tile.getWorld().getBlockState(tile.getPos()); - int meta = state.getBlock().getMetaFromState(state); - 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); - GlStateManager.rotate(90F, 1F, 0F, 0F); - } - if (meta == 2) { - GlStateManager.translate(0F, -1F, 0F); - GlStateManager.translate(0F, 0F, -0.5F); - } - if (meta == 3) { - GlStateManager.translate(0F, -1F, 0F); - GlStateManager.translate(0F, 0F, 0.5F + 0.5F / 16F); - } - if (meta == 4) { - GlStateManager.translate(0F, -1F, 0F); - GlStateManager.translate(0.5F + 0.5F / 16F, 0F, 0F); - GlStateManager.rotate(90F, 0F, 1F, 0F); - } - if (meta == 5) { - GlStateManager.translate(0F, -1F, 0F); - GlStateManager.translate(-0.5F, 0F, 0F); - GlStateManager.rotate(90F, 0F, 1F, 0F); - } - - GlStateManager.scale(0.5F, 0.5F, 0.5F); - AssetUtil.renderItemInWorld(stack); - - GlStateManager.popMatrix(); - } - } -} 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 deleted file mode 100644 index 50c3d251b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderSmileyCloud.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * This file ("RenderSmileyCloud.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.misc.special.RenderSpecial; -import de.ellpeck.actuallyadditions.mod.misc.special.SpecialRenderInit; -import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.block.BlockHorizontal; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - - GlStateManager.pushMatrix(); - 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()) { - 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(); - - 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; - } - } - } - } - - String nameLower = theCloud.name.toLowerCase(Locale.ROOT); - if (SpecialRenderInit.SPECIAL_LIST.containsKey(nameLower)) { - RenderSpecial render = SpecialRenderInit.SPECIAL_LIST.get(nameLower); - if (render != null) { - GlStateManager.pushMatrix(); - GlStateManager.translate(0F, renderedEaster ? 0.05F : 0.25F, 0F); - GlStateManager.rotate(180F, 1.0F, 0.0F, 1.0F); - GlStateManager.scale(0.75F, 0.75F, 0.75F); - render.render(); - GlStateManager.popMatrix(); - } - } - } - GlStateManager.popMatrix(); - - Minecraft mc = Minecraft.getMinecraft(); - if (theCloud.name != null && !theCloud.name.isEmpty() && !mc.gameSettings.hideGUI) { - if (mc.player.getDistanceSq(theCloud.getPos()) <= 36) { - AssetUtil.renderNameTag(theCloud.name, x + 0.5F, y + 1.5F, z + 0.5F); - } - } - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/Transformer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/Transformer.java deleted file mode 100644 index db8669466..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/Transformer.java +++ /dev/null @@ -1,54 +0,0 @@ -package de.ellpeck.actuallyadditions.mod.blocks.render; - -import javax.vecmath.Matrix3f; -import javax.vecmath.Matrix4f; -import javax.vecmath.Vector3f; -import javax.vecmath.Vector4f; - -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.client.renderer.vertex.VertexFormatElement; -import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad; -import net.minecraftforge.client.model.pipeline.VertexTransformer; -import net.minecraftforge.common.model.TRSRTransformation; - -public class Transformer extends VertexTransformer { - - protected final Matrix4f transformation; - protected final Matrix3f normalTransformation; - - public Transformer(TRSRTransformation transformation, VertexFormat format) { - super(new UnpackedBakedQuad.Builder(format)); - // position transform - this.transformation = transformation.getMatrix(); - // normal transform - this.normalTransformation = new Matrix3f(); - this.transformation.getRotationScale(this.normalTransformation); - this.normalTransformation.invert(); - this.normalTransformation.transpose(); - } - - @Override - public void put(int element, float... data) { - VertexFormatElement.EnumUsage usage = this.parent.getVertexFormat().getElement(element).getUsage(); - - // transform normals and position - if (usage == VertexFormatElement.EnumUsage.POSITION && data.length >= 3) { - Vector4f vec = new Vector4f(data); - vec.setW(1.0f); - this.transformation.transform(vec); - data = new float[4]; - vec.get(data); - } else if (usage == VertexFormatElement.EnumUsage.NORMAL && data.length >= 3) { - Vector3f vec = new Vector3f(data); - this.normalTransformation.transform(vec); - vec.normalize(); - data = new float[4]; - vec.get(data); - } - super.put(element, data); - } - - public UnpackedBakedQuad build() { - return ((UnpackedBakedQuad.Builder) this.parent).build(); - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java deleted file mode 100644 index 0e2cbc0ac..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java +++ /dev/null @@ -1,334 +0,0 @@ -/* - * This file ("InitBooklet.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.booklet; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; -import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; -import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; -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.booklet.chapter.BookletChapter; -import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapterCoffee; -import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapterCrusher; -import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapterTrials; -import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntry; -import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryAllItems; -import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryTrials; -import de.ellpeck.actuallyadditions.mod.booklet.page.BookletPage; -import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrafting; -import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrusherRecipe; -import de.ellpeck.actuallyadditions.mod.booklet.page.PageEmpowerer; -import de.ellpeck.actuallyadditions.mod.booklet.page.PageFurnace; -import de.ellpeck.actuallyadditions.mod.booklet.page.PageLinkButton; -import de.ellpeck.actuallyadditions.mod.booklet.page.PagePicture; -import de.ellpeck.actuallyadditions.mod.booklet.page.PageReconstructor; -import de.ellpeck.actuallyadditions.mod.booklet.page.PageTextOnly; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; -import de.ellpeck.actuallyadditions.mod.crafting.BlockCrafting; -import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting; -import de.ellpeck.actuallyadditions.mod.crafting.FoodCrafting; -import de.ellpeck.actuallyadditions.mod.crafting.ItemCrafting; -import de.ellpeck.actuallyadditions.mod.crafting.MiscCrafting; -import de.ellpeck.actuallyadditions.mod.crafting.ToolCrafting; -import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; -import de.ellpeck.actuallyadditions.mod.gen.AAWorldGen; -import de.ellpeck.actuallyadditions.mod.gen.WorldGenLushCaves; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.ItemWingsOfTheBats; -import de.ellpeck.actuallyadditions.mod.items.lens.LensDisenchanting; -import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.recipe.EmpowererHandler; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityDirectionalBreaker; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFireworkBox; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceDouble; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceSolar; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinder; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityHeatCollector; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemRepairer; -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.TileEntityLavaFactoryController; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLeafGenerator; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityMiner; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomPlacer; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomface; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityRangedCollector; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityShockSuppressor; -import de.ellpeck.actuallyadditions.mod.update.UpdateChecker; -import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.Ingredient; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidUtil; - -public final class InitBooklet { - - public static BookletChapter[] chaptersIntroduction = new BookletChapter[11]; - - public static void preInit() { - ActuallyAdditionsAPI.entryAllAndSearch = new BookletEntryAllItems("allAndSearch").setImportant(); - ActuallyAdditionsAPI.entryTrials = new BookletEntryTrials("trials"); - - ActuallyAdditionsAPI.entryGettingStarted = new BookletEntry("gettingStarted").setImportant(); - ActuallyAdditionsAPI.entryReconstruction = new BookletEntry("reconstruction"); - ActuallyAdditionsAPI.entryLaserRelays = new BookletEntry("laserRelays").setSpecial(); - ActuallyAdditionsAPI.entryFunctionalNonRF = new BookletEntry("functionalNoRF"); - ActuallyAdditionsAPI.entryFunctionalRF = new BookletEntry("functionalRF"); - ActuallyAdditionsAPI.entryGeneratingRF = new BookletEntry("generatingRF"); - ActuallyAdditionsAPI.entryItemsNonRF = new BookletEntry("itemsNoRF"); - ActuallyAdditionsAPI.entryItemsRF = new BookletEntry("itemsRF"); - ActuallyAdditionsAPI.entryMisc = new BookletEntry("misc"); - ActuallyAdditionsAPI.entryUpdatesAndInfos = new BookletEntry("updatesAndInfos").setSpecial(); - } - - public static void postInit() { - initChapters(); - - int chapCount = 0; - int pageCount = 0; - int infoCount = 0; - for (IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES) { - for (IBookletChapter chapter : entry.getAllChapters()) { - if (!ActuallyAdditionsAPI.ALL_CHAPTERS.contains(chapter)) { - ActuallyAdditionsAPI.ALL_CHAPTERS.add(chapter); - chapCount++; - - for (IBookletPage page : chapter.getAllPages()) { - pageCount++; - - List items = new ArrayList<>(); - page.getItemStacksForPage(items); - 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)) { - ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA.add(page); - infoCount++; - } - } - } - } - } - } - - Collections.sort(ActuallyAdditionsAPI.BOOKLET_ENTRIES, (entry1, entry2) -> { - Integer prio1 = entry1.getSortingPriority(); - Integer prio2 = entry2.getSortingPriority(); - return prio2.compareTo(prio1); - }); - Collections.sort(ActuallyAdditionsAPI.ALL_CHAPTERS, (chapter1, chapter2) -> { - Integer prio1 = chapter1.getSortingPriority(); - Integer prio2 = chapter2.getSortingPriority(); - return prio2.compareTo(prio1); - }); - Collections.sort(ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA, (page1, page2) -> { - Integer prio1 = page1.getSortingPriority(); - Integer prio2 = page2.getSortingPriority(); - 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!"); - } - - 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()); - } - 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()); - } - 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(); - - //Miscellaneous - new BookletChapter("worms", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemWorm), new PageTextOnly(1).addItemsToPage(new ItemStack(InitItems.itemWorm)), new PagePicture(2, "page_worms", 145)).setImportant(); - new BookletChapter("lushCaves", ActuallyAdditionsAPI.entryMisc, new ItemStack(Blocks.STONE), new PageTextOnly(1), new PagePicture(2, "page_lush_caves", 0).setNoText()); - new BookletChapter("crystalClusters", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockCrystalClusterEmerald), new PageTextOnly(1).addItemsToPage(WorldGenLushCaves.CRYSTAL_CLUSTERS), new PageCrafting(2, MiscCrafting.RECIPES_CRYSTAL_SHARDS).setNoText(), new PageCrafting(3, MiscCrafting.RECIPES_CRYSTAL_SHARDS_BACK).setNoText()).setSpecial(); - new BookletChapter("banners", ActuallyAdditionsAPI.entryMisc, new ItemStack(Items.BANNER, 1, 15), new PageTextOnly(1)); - new BookletChapter("miscDecorStuffsAndThings", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockTestifiBucksGreenWall), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeWhiteWall).setNoText(), new PageReconstructor(3, LensRecipeHandler.recipeGreenWall).setNoText()); - chaptersIntroduction[3] = new BookletChapter("quartz", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), new PageTextOnly(1).addItemsToPage(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal())).addTextReplacement("", AAWorldGen.QUARTZ_MIN).addTextReplacement("", AAWorldGen.QUARTZ_MAX), new PageTextOnly(2).addItemsToPage(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())), new PageCrafting(3, BlockCrafting.recipeQuartzBlock).setNoText(), new PageCrafting(4, BlockCrafting.recipeQuartzPillar).setNoText(), new PageCrafting(5, BlockCrafting.recipeQuartzChiseled).setNoText()); - 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()); - } - 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)); - new BookletChapter("spawnerShard", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.SPAWNER_SHARD.ordinal()), new PageTextOnly(1).addItemsToPage(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.SPAWNER_SHARD.ordinal()))); - new BookletChapter("treasureChest", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockTreasureChest), new PagePicture(1, "page_treasure_chest", 150).addItemsToPage(new ItemStack(InitBlocks.blockTreasureChest)), new PageTextOnly(2)).setSpecial(); - new BookletChapter("hairBalls", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemHairyBall), new PagePicture(1, "page_fur_balls", 110).addItemsToPage(new ItemStack(InitItems.itemHairyBall)), new PageTextOnly(2)).setSpecial(); - new BookletChapter("blackLotus", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockBlackLotus), new PageTextOnly(1).addItemsToPage(new ItemStack(InitBlocks.blockBlackLotus)), new PageCrafting(2, ItemCrafting.recipeBlackDye)); - new BookletChapter("waterBowl", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemWaterBowl), new PageTextOnly(1).addItemsToPage(new ItemStack(InitItems.itemWaterBowl))); - new BookletChapter("tinyTorch", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockTinyTorch), new PageCrafting(1, BlockCrafting.recipesTinyTorch).setWildcard()).setSpecial(); - - //Reconstruction - chaptersIntroduction[7] = new BookletChapter("reconstructorLenses", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), new PageTextOnly(1)).setImportant(); - new BookletChapter("additionalRecipes", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(Items.LEATHER), new PageReconstructor(1, LensRecipeHandler.recipeSoulSand).setNoText(), new PageReconstructor(2, LensRecipeHandler.recipeLeather).setNoText(), new PageReconstructor(3, LensRecipeHandler.recipeNetherWart).setNoText(), new PageReconstructor(4, LensRecipeHandler.recipePrismarine).setNoText()).setSpecial(); - new BookletChapter("bookSplitting", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(Items.ENCHANTED_BOOK), new PageTextOnly(1), new PageReconstructor(2, new LensConversionRecipe(Ingredient.fromItem(Items.ENCHANTED_BOOK), new ItemStack(Items.ENCHANTED_BOOK), 0, ActuallyAdditionsAPI.lensDefaultConversion)).setNoText()); - new BookletChapter("lensColor", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemColorLens), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeColorLens).setNoText()); - new BookletChapter("lensDeath", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemDamageLens), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeDamageLens).setNoText()); - new BookletChapter("lensMoreDeath", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemMoreDamageLens), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeLensMoreDeath).setNoText()); - new BookletChapter("lensDetonation", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemExplosionLens), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeExplosionLens).setNoText()); - new BookletChapter("lensDisenchanting", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemDisenchantingLens), new PageTextOnly(1).addTextReplacement("", LensDisenchanting.ENERGY_USE), new PageCrafting(2, ItemCrafting.recipeDisenchantingLens).setNoText()).setSpecial(); - new BookletChapter("lensMining", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemMiningLens), new PageTextOnly(1).addTextReplacement("", ConfigIntValues.MINING_LENS_USE.getValue()), new PageCrafting(2, ItemCrafting.recipeMiningLens).setNoText()).setImportant(); - - //Laser Relays - chaptersIntroduction[8] = new BookletChapter("laserIntro", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitItems.itemLaserWrench), new PageTextOnly(1), new PageTextOnly(2).addTextReplacement("", TileEntityLaserRelay.MAX_DISTANCE), new PageCrafting(3, ItemCrafting.recipeLaserWrench)).setImportant(); - new BookletChapter("laserRelays", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitBlocks.blockLaserRelay), new PageTextOnly(1), new PageTextOnly(2).addTextReplacement("", TileEntityLaserRelayEnergy.CAP).addTextReplacement("", TileEntityLaserRelayEnergyAdvanced.CAP).addTextReplacement("", TileEntityLaserRelayEnergyExtreme.CAP), new PagePicture(3, "page_laser_relay", 0).setNoText(), new PageCrafting(4, BlockCrafting.recipeLaserRelay).setWildcard().setNoText(), new PageCrafting(5, BlockCrafting.recipeLaserRelayAdvanced).setWildcard().setNoText(), new PageCrafting(6, BlockCrafting.recipeLaserRelayExtreme).setWildcard().setNoText()); - new BookletChapter("fluidLaser", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitBlocks.blockLaserRelayFluids), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeFluidLaser).setWildcard().setNoText()); - new BookletChapter("itemRelays", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitBlocks.blockLaserRelayItem), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeItemLaser).setWildcard().setNoText()).setSpecial(); - new BookletChapter("itemInterfaces", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitBlocks.blockItemViewer), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, BlockCrafting.recipeItemInterface).setNoText()); - new BookletChapter("itemRelaysAdvanced", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitBlocks.blockLaserRelayItemWhitelist), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeLaserRelayItemWhitelist).setWildcard()); - new BookletChapter("itemInterfacesHopping", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitBlocks.blockItemViewerHopping), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeItemInterfaceHopping).setWildcard().setNoText()); - new BookletChapter("laserUpgradeInvisibility", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitItems.itemLaserUpgradeInvisibility), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeLaserUpgradeInvisibility).setNoText()).setImportant(); - new BookletChapter("laserUpgradeRange", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitItems.itemLaserUpgradeRange), new PageTextOnly(1).addTextReplacement("", TileEntityLaserRelay.MAX_DISTANCE).addTextReplacement("", TileEntityLaserRelay.MAX_DISTANCE_RANGED), new PageCrafting(2, ItemCrafting.recipeLaserUpgradeRange).setNoText()).setImportant(); - - //No RF Using Blocks - new BookletChapter("breaker", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockBreaker), new PageCrafting(1, BlockCrafting.recipeBreaker).setWildcard(), new PageCrafting(2, BlockCrafting.recipePlacer).setWildcard(), new PageCrafting(3, BlockCrafting.recipeLiquidPlacer).setWildcard(), new PageCrafting(4, BlockCrafting.recipeLiquidCollector).setWildcard()); - new BookletChapter("dropper", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockDropper), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeDropper).setNoText()); - new BookletChapter("phantomfaces", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockPhantomLiquiface), new PageTextOnly(1).addTextReplacement("", TileEntityPhantomface.RANGE), new PageTextOnly(2), new PageCrafting(3, BlockCrafting.recipePhantomface), new PageCrafting(4, BlockCrafting.recipeLiquiface), new PageCrafting(5, BlockCrafting.recipeEnergyface), new PageCrafting(6, ItemCrafting.recipePhantomConnector).setNoText(), new PageCrafting(7, BlockCrafting.recipePhantomBooster)).setImportant(); - new BookletChapter("phantomRedstoneface", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockPhantomRedstoneface), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipePhantomRedstoneface).setNoText()); - new BookletChapter("phantomBreaker", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockPhantomBreaker), new PageTextOnly(1).addTextReplacement("", TileEntityPhantomPlacer.RANGE), new PageCrafting(2, BlockCrafting.recipePhantomPlacer).setNoText(), new PageCrafting(3, BlockCrafting.recipePhantomBreaker).setNoText()); - new BookletChapter("esd", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockInputterAdvanced), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeESD).setNoText(), new PageCrafting(3, BlockCrafting.recipeAdvancedESD).setNoText()).setSpecial(); - new BookletChapter("xpSolidifier", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockXPSolidifier), new PageTextOnly(1).addItemsToPage(new ItemStack(InitItems.itemSolidifiedExperience)), new PageCrafting(2, BlockCrafting.recipeSolidifier).setNoText()).setImportant(); - new BookletChapter("greenhouseGlass", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockGreenhouseGlass), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeGlass)); - new BookletChapter("fishingNet", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockFishingNet), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeFisher).setNoText()); - new BookletChapter("feeder", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockFeeder), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeFeeder).setNoText()); - new BookletChapter("compost", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockCompost), new PageTextOnly(1).addItemsToPage(new ItemStack(InitItems.itemFertilizer)), new PageCrafting(2, BlockCrafting.recipeCompost).setNoText(), new PageTextOnly(3).addItemsToPage(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.MASHED_FOOD.ordinal()))); - new BookletChapter("crate", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockGiantChest), new PageCrafting(1, BlockCrafting.recipeCrate), new PageCrafting(2, BlockCrafting.recipeCrateMedium).setNoText(), new PageCrafting(3, BlockCrafting.recipeCrateLarge).setNoText(), new PageCrafting(4, ItemCrafting.recipeCrateKeeper), new PageCrafting(5, ItemCrafting.recipeChestToCrateUpgrade), new PageCrafting(6, ItemCrafting.recipeSmallToMediumCrateUpgrade), new PageCrafting(7, ItemCrafting.recipeMediumToLargeCrateUpgrade)); - new BookletChapter("rangedCollector", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockRangedCollector), new PageTextOnly(1).addTextReplacement("", TileEntityRangedCollector.RANGE), new PageCrafting(2, BlockCrafting.recipeRangedCollector).setNoText()); - - //RF Using Blocks - new BookletChapter("fireworkBox", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockFireworkBox), new PageTextOnly(1).addTextReplacement("", TileEntityFireworkBox.USE_PER_SHOT), new PageCrafting(2, BlockCrafting.recipeFireworkBox)).setSpecial(); - new BookletChapter("batteryBox", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockBatteryBox), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeBatteryBox).setNoText()).setSpecial(); - new BookletChapter("farmer", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockFarmer), new PageTextOnly(1), new PagePicture(2, "page_farmer_crops", 95).addItemsToPage(new ItemStack(Items.WHEAT_SEEDS)).addItemsToPage(new ItemStack(InitItems.itemCanolaSeed)), new PagePicture(3, "page_farmer_cactus", 105).addItemsToPage(new ItemStack(Blocks.CACTUS)), new PagePicture(4, "page_farmer_wart", 95).addItemsToPage(new ItemStack(Items.NETHER_WART)), new PagePicture(5, "page_farmer_reeds", 105).addItemsToPage(new ItemStack(Items.REEDS)), new PagePicture(6, "page_farmer_melons", 105).addItemsToPage(new ItemStack(Items.MELON), new ItemStack(Blocks.PUMPKIN), new ItemStack(Blocks.MELON_BLOCK)), new PagePicture(7, "page_farmer_enderlilly", 105), new PagePicture(8, "page_farmer_redorchid", 105), new PageCrafting(4, BlockCrafting.recipeFarmer).setWildcard().setNoText()).setImportant(); - new BookletChapter("miner", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockMiner), new PageTextOnly(1).addTextReplacement("", TileEntityMiner.ENERGY_USE_PER_BLOCK).addTextReplacement("", TileEntityMiner.DEFAULT_RANGE), new PageCrafting(2, BlockCrafting.recipeMiner)).setSpecial(); - new BookletChapterCoffee("coffeeMachine", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockCoffeeMachine), new PageTextOnly(1).addItemsToPage(new ItemStack(InitItems.itemCoffeeBean)).addTextReplacement("", TileEntityCoffeeMachine.ENERGY_USED).addTextReplacement("", TileEntityCoffeeMachine.CACHE_USE).addTextReplacement("", TileEntityCoffeeMachine.WATER_USE), new PageTextOnly(2).addItemsToPage(new ItemStack(InitItems.itemCoffee)), new PagePicture(3, "page_coffee_machine", 115), new PageCrafting(4, BlockCrafting.recipeCoffeeMachine).setWildcard().setNoText(), new PageCrafting(5, ItemCrafting.recipeCup).setNoText()).setImportant(); - - List list = new ArrayList<>(); - 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()); - - 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)); - new BookletChapter("lavaFactory", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockLavaFactoryController), new PageTextOnly(1).addTextReplacement("", TileEntityLavaFactoryController.ENERGY_USE), new PagePicture(2, "page_lava_factory", 0).setNoText(), new PageCrafting(3, BlockCrafting.recipeLavaFactory).setNoText(), new PageCrafting(4, BlockCrafting.recipeCasing).setNoText()); - new BookletChapter("energizer", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockEnergizer), new PageCrafting(1, BlockCrafting.recipeEnergizer), new PageCrafting(2, BlockCrafting.recipeEnervator)); - new BookletChapter("repairer", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockItemRepairer), new PageCrafting(1, BlockCrafting.recipeRepairer).addTextReplacement("", TileEntityItemRepairer.ENERGY_USE)); - new BookletChapter("longRangeBreaker", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockDirectionalBreaker), new PageTextOnly(1).addTextReplacement("", TileEntityDirectionalBreaker.ENERGY_USE).addTextReplacement("", TileEntityDirectionalBreaker.RANGE), new PageCrafting(2, BlockCrafting.recipeDirectionalBreaker).setWildcard()); - new BookletChapter("playerInterface", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockPlayerInterface), new PageTextOnly(1).addTextReplacement("", TileEntityPlayerInterface.DEFAULT_RANGE), new PageCrafting(2, BlockCrafting.recipePlayerInterface).setNoText()).setSpecial(); - new BookletChapter("displayStand", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockDisplayStand), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, BlockCrafting.recipeDisplayStand).setNoText()).setSpecial(); - new BookletChapter("shockSuppressor", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockShockSuppressor), new PageTextOnly(1).addTextReplacement("", TileEntityShockSuppressor.RANGE).addTextReplacement("", TileEntityShockSuppressor.USE_PER), new PageCrafting(2, BlockCrafting.recipeShockSuppressor)); - - //RF Generating Blocks - new BookletChapter("solarPanel", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockFurnaceSolar), new PageTextOnly(1).addTextReplacement("", TileEntityFurnaceSolar.PRODUCE), new PageCrafting(2, BlockCrafting.recipeSolar).setNoText()); - new BookletChapter("heatCollector", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockHeatCollector), new PageTextOnly(1).addTextReplacement("", TileEntityHeatCollector.ENERGY_PRODUCE).addTextReplacement("", TileEntityHeatCollector.BLOCKS_NEEDED), new PageCrafting(2, BlockCrafting.recipeHeatCollector).setNoText()); - new BookletChapter("canola", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockFermentingBarrel), new PageTextOnly(1).addItemsToPage(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CANOLA.ordinal())).addItemsToPage(new ItemStack(InitItems.itemCanolaSeed)).addFluidToPage(InitFluids.fluidCanolaOil), new PageTextOnly(2).addFluidToPage(InitFluids.fluidRefinedCanolaOil).addFluidToPage(InitFluids.fluidCrystalOil).addFluidToPage(InitFluids.fluidEmpoweredOil), new PageCrafting(3, BlockCrafting.recipeCanolaPress).setNoText(), new PageCrafting(4, BlockCrafting.recipeFermentingBarrel), new PageCrafting(5, BlockCrafting.recipeOilGen), new PageReconstructor(6, LensRecipeHandler.recipeCrystallizedCanolaSeed).setNoText(), new PageEmpowerer(7, EmpowererHandler.recipeEmpoweredCanolaSeed).setNoText()); - new BookletChapter("leafGen", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockLeafGenerator), new PageTextOnly(1).addTextReplacement("", TileEntityLeafGenerator.ENERGY_PRODUCED).addTextReplacement("", TileEntityLeafGenerator.RANGE), new PageCrafting(2, BlockCrafting.recipeLeafGen)).setImportant(); - new BookletChapter("bioReactor", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockBioReactor), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeBioReactor).setNoText()).setSpecial(); - - //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("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()); - } - 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()); - } - 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()); - new BookletChapter("itemFilter", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitItems.itemFilter), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeFilter).setNoText()).setImportant(); - - //RF Using Items - new BookletChapter("drill", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemDrill, 1, TheColoredLampColors.LIGHT_BLUE.ordinal()), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, ItemCrafting.recipeDrill).setNoText(), new PageCrafting(4, ItemCrafting.RECIPES_DRILL_COLORING), new PageCrafting(4, ItemCrafting.recipeDrillCore).setNoText(), new PageCrafting(5, ItemCrafting.recipeDrillSpeedI).setNoText(), new PageCrafting(6, ItemCrafting.recipeDrillSpeedII).setNoText(), new PageCrafting(7, ItemCrafting.recipeDrillSpeedIII).setNoText(), new PageCrafting(8, ItemCrafting.recipeDrillFortuneI).setNoText(), new PageCrafting(9, ItemCrafting.recipeDrillFortuneII).setNoText(), new PageCrafting(10, ItemCrafting.recipeDrillSilk).setNoText(), new PageCrafting(11, ItemCrafting.recipeDrillThree).setNoText(), new PageCrafting(12, ItemCrafting.recipeDrillFive).setNoText(), new PageCrafting(13, ItemCrafting.recipeDrillPlacing).setNoText()).setSpecial(); - new BookletChapter("fillingWand", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemFillingWand), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeFillingWand).setNoText()).setSpecial(); - new BookletChapter("staff", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemTeleStaff), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeStaff).setNoText()).setImportant(); - new BookletChapter("magnetRing", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemMagnetRing), new PageCrafting(1, ItemCrafting.recipeMagnetRing)); - new BookletChapter("growthRing", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemGrowthRing), new PageCrafting(1, ItemCrafting.recipeGrowthRing)); - new BookletChapter("waterRemovalRing", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemWaterRemovalRing), new PageCrafting(1, ItemCrafting.recipeWaterRing)); - new BookletChapter("batteries", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemBatteryTriple), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeBattery).setNoText(), new PageCrafting(3, ItemCrafting.recipeBatteryDouble).setNoText(), new PageCrafting(4, ItemCrafting.recipeBatteryTriple).setNoText(), new PageCrafting(5, ItemCrafting.recipeBatteryQuadruple).setNoText(), new PageCrafting(6, ItemCrafting.recipeBatteryQuintuple).setNoText()); - - //Updates and infos - new BookletChapter("changelog", ActuallyAdditionsAPI.entryUpdatesAndInfos, new ItemStack(Items.CLOCK), new PageLinkButton(1, UpdateChecker.CHANGELOG_LINK)); - new BookletChapter("curse", ActuallyAdditionsAPI.entryUpdatesAndInfos, new ItemStack(Items.FLINT_AND_STEEL), new PageLinkButton(1, "http://ellpeck.de/actadd")); - new BookletChapter("patreon", ActuallyAdditionsAPI.entryUpdatesAndInfos, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), new PageLinkButton(1, "http://patreon.com/Ellpeck"), new PagePicture(2, "page_patreon", 153)).setImportant(); - new BookletChapter("website", ActuallyAdditionsAPI.entryUpdatesAndInfos, new ItemStack(InitItems.itemBooklet), new PageLinkButton(1, "http://ellpeck.de")); - - //Trials - chaptersIntroduction[10] = new BookletChapter("trialsIntro", ActuallyAdditionsAPI.entryTrials, new ItemStack(Items.GOLD_INGOT), new PageTextOnly(1), new PageTextOnly(2)).setSpecial(); - new BookletChapterTrials("crystalProduction", new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), false); - new BookletChapterTrials("leatherProduction", new ItemStack(Items.LEATHER), false); - new BookletChapterTrials("crystalOil", FluidUtil.getFilledBucket(new FluidStack(InitFluids.fluidCrystalOil, Fluid.BUCKET_VOLUME)), false); - new BookletChapterTrials("autoDisenchanter", new ItemStack(InitItems.itemDisenchantingLens), false); - new BookletChapterTrials("empoweredOil", FluidUtil.getFilledBucket(new FluidStack(InitFluids.fluidEmpoweredOil, Fluid.BUCKET_VOLUME)), false); - new BookletChapterTrials("mobFarm", new ItemStack(Items.ROTTEN_FLESH), false); - new BookletChapterTrials("empowererAutomation", new ItemStack(InitBlocks.blockEmpowerer), false); - } -} 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 deleted file mode 100644 index a58cb643b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/BookmarkButton.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * This file ("BookmarkButton.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet; -import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiPage; -import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.client.config.GuiUtils; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class BookmarkButton extends GuiButton { - - private final GuiBooklet booklet; - public IBookletPage assignedPage; - - 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()) { - this.assignedPage = null; - } 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]; - } - } - } - - @Override - 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; - int k = this.getHoverState(this.hovered); - if (k == 0) { - k = 1; - } - - GlStateManager.enableBlend(); - 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.mouseDragged(minecraft, x, y); - - if (this.assignedPage != null) { - ItemStack display = this.assignedPage.getChapter().getDisplayItemStack(); - if (StackUtil.isValid(display)) { - GlStateManager.pushMatrix(); - AssetUtil.renderStackToGui(display, this.x + 2, this.y + 1, 0.725F); - GlStateManager.popMatrix(); - } - } - } - } - - public void drawHover(int mouseX, int mouseY) { - if (this.isMouseOver()) { - List list = new ArrayList<>(); - - 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")); - - 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")); - } - } - - Minecraft mc = Minecraft.getMinecraft(); - GuiUtils.drawHoveringText(list, mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRenderer); - } - } -} 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 deleted file mode 100644 index d3595ccf5..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/EntryButton.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file ("EntryButton.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.booklet.button; - -import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(id, x, y, width, height, text); - this.gui = gui; - StackUtil.isValid(stackToRender); - this.stackToRender = stackToRender; - } - - @Override - 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; - 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)) { - GlStateManager.pushMatrix(); - AssetUtil.renderStackToGui(this.stackToRender, this.x - 4, this.y, 0.725F); - GlStateManager.popMatrix(); - textOffsetX = 10; - } - - float scale = this.gui.getMediumFontSize(); - - 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); - GlStateManager.popMatrix(); - } - - 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 deleted file mode 100644 index 08b1e6400..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/button/TrialsButton.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file ("TrialsButton.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.booklet.button; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet; -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 { - - 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); - this.isTrials = gui.areTrialsOpened(); - this.enabled = !this.isTrials; - } - - @Override - 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); - } - } - } - - @Override - protected int getHoverState(boolean mouseOver) { - if (mouseOver || this.isTrials) { - return 2; - } else if (!this.enabled) { - return 0; - } 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 deleted file mode 100644 index 23ce0eb15..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapter.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * This file ("BookletChapter.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.booklet.chapter; - -import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; -import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; -import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.misc.IDisableableItem; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class BookletChapter implements IBookletChapter { - - public final IBookletPage[] pages; - public final IBookletEntry entry; - public final ItemStack displayStack; - private final String identifier; - private final int priority; - public TextFormatting color; - - 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) { - this.pages = pages; - this.identifier = identifier; - this.entry = entry; - this.displayStack = displayStack; - 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) { - page.setChapter(this); - } - } - - @Override - public IBookletPage[] getAllPages() { - return this.pages; - } - - @Override - @SideOnly(Side.CLIENT) - 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(); - } - - @Override - public IBookletEntry getEntry() { - return this.entry; - } - - @Override - public ItemStack getDisplayItemStack() { - return this.displayStack; - } - - @Override - 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; } - } - return -1; - } - - @Override - public int getSortingPriority() { - return this.priority; - } - - public BookletChapter setImportant() { - this.color = TextFormatting.DARK_GREEN; - return this; - } - - 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 deleted file mode 100644 index ef051c904..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCoffee.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file ("BookletChapterCoffee.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; -import de.ellpeck.actuallyadditions.mod.booklet.page.BookletPage; -import de.ellpeck.actuallyadditions.mod.booklet.page.PageCoffeeMachine; -import de.ellpeck.actuallyadditions.mod.items.ItemCoffee; -import net.minecraft.item.ItemStack; - -public class BookletChapterCoffee extends BookletChapter { - - public BookletChapterCoffee(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages) { - super(identifier, entry, displayStack, getPages(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)) { - page.setNoText(); - } - allPages.add(page); - } - - return allPages.toArray(new IBookletPage[allPages.size()]); - } -} 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 deleted file mode 100644 index 8096cfac7..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterCrusher.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file ("BookletChapterCrusher.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrusherRecipe; -import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting; -import net.minecraft.item.ItemStack; - -public class BookletChapterCrusher extends BookletChapter { - - public BookletChapterCrusher(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages) { - super(identifier, entry, displayStack, getPages(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()); - } - - 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 deleted file mode 100644 index 6a6db75c2..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/chapter/BookletChapterTrials.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file ("BookletChapterTrials.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.booklet.chapter; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.booklet.page.PageTrials; -import de.ellpeck.actuallyadditions.mod.data.PlayerData; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class BookletChapterTrials extends BookletChapter { - - 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"); - } - - @Override - @SideOnly(Side.CLIENT) - 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(); - } -} 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 deleted file mode 100644 index a24e1261e..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntry.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * This file ("BookletEntry.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -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) { - this(identifier, 0); - } - - public BookletEntry(String identifier, int prio) { - this.identifier = identifier; - this.priority = prio; - ActuallyAdditionsAPI.addBookletEntry(this); - - this.color = TextFormatting.RESET; - } - - @SideOnly(Side.CLIENT) - 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)) { - 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; } - } - } - } - } - - List fluids = new ArrayList<>(); - page.getFluidStacksForPage(fluids); - 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; } - } - } - } - - return false; - } - - @Override - public List getAllChapters() { - return this.chapters; - } - - @Override - public String getIdentifier() { - return this.identifier; - } - - @Override - @SideOnly(Side.CLIENT) - 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(); - } - - @Override - public void addChapter(IBookletChapter chapter) { - this.chapters.add(chapter); - } - - @Override - @SideOnly(Side.CLIENT) - 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)) { - fittingChapters.add(chapter); - } else { - for (IBookletPage page : chapter.getAllPages()) { - if (fitsFilter(page, search)) { - fittingChapters.add(chapter); - break; - } - } - } - } - - return fittingChapters; - } else { - return this.getAllChapters(); - } - } - - @Override - public int getSortingPriority() { - return this.priority; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean visibleOnFrontPage() { - return true; - } - - public BookletEntry setImportant() { - this.color = TextFormatting.DARK_GREEN; - return this; - } - - 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 deleted file mode 100644 index 9db755d92..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntryAllItems.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file ("BookletEntryAllItems.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.booklet.entry; - -import java.util.List; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; - -public class BookletEntryAllItems extends BookletEntry { - - public BookletEntryAllItems(String identifier) { - super(identifier, -Integer.MAX_VALUE); - } - - @Override - public void addChapter(IBookletChapter chapter) { - - } - - @Override - 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 deleted file mode 100644 index dd3fc7ec8..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/entry/BookletEntryTrials.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * This file ("BookletEntryTrials.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.booklet.entry; - -public class BookletEntryTrials extends BookletEntry { - - public BookletEntryTrials(String identifier) { - super(identifier, -Integer.MAX_VALUE); - } - - @Override - 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 deleted file mode 100644 index bdfc6ee57..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiBooklet.java +++ /dev/null @@ -1,375 +0,0 @@ -/* - * This file ("GuiBooklet.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.booklet.button.BookmarkButton; -import de.ellpeck.actuallyadditions.mod.booklet.button.TrialsButton; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; -import de.ellpeck.actuallyadditions.mod.data.PlayerData; -import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave; -import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton; -import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.GuiTextField; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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"); - public static final ResourceLocation RES_LOC_GADGETS = AssetUtil.getBookletGuiLocation("gui_booklet_gadgets"); - protected final BookmarkButton[] bookmarkButtons = new BookmarkButton[12]; - public GuiScreen previousScreen; - public GuiBookletBase parentPage; - public GuiTextField searchField; - protected int xSize; - protected int ySize; - protected int guiLeft; - protected int guiTop; - private GuiButton buttonLeft; - private GuiButton buttonRight; - private GuiButton buttonBack; - - private GuiButton buttonTrials; - - private float smallFontSize; - private float mediumFontSize; - private float largeFontSize; - - public GuiBooklet(GuiScreen previousScreen, GuiBookletBase parentPage) { - this.previousScreen = previousScreen; - this.parentPage = parentPage; - - this.xSize = 281; - this.ySize = 180; - } - - 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) { - return defaultValue; - } - } else { - return conf / 100F; - } - } - - @Override - public void initGui() { - super.initGui(); - - 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); - 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); - 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); - 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); - this.searchField.setMaxStringLength(50); - this.searchField.setEnableBackgroundDrawing(false); - } - - 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); - this.buttonList.add(this.bookmarkButtons[i]); - - if (data.bookmarks[i] != null) { - this.bookmarkButtons[i].assignedPage = data.bookmarks[i]; - } - } - } - - this.buttonTrials = new TrialsButton(this); - this.buttonList.add(this.buttonTrials); - } - - @Override - 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; - 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) { - data.bookmarks[i] = this.bookmarkButtons[i].assignedPage; - change = true; - } - } - - if (change) { - PacketHandlerHelper.sendPlayerDataToServer(true, 0); - } - } - - @Override - 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) { - 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()) { - this.mc.getTextureManager().bindTexture(RES_LOC_GADGETS); - 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); - } - - this.searchField.drawTextBox(); - - this.fontRenderer.setUnicodeFlag(unicodeBefore); - } - } - - 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 { - super.mouseClicked(mouseX, mouseY, mouseButton); - - if (this.hasSearchBar()) { - this.searchField.mouseClicked(mouseX, mouseY, mouseButton); - } - - if (mouseButton == 1 && this.hasBackButton()) { - this.onBackButtonPressed(); - } - } - - @Override - public void handleMouseInput() throws IOException { - int wheel = Mouse.getEventDWheel(); - if (wheel != 0) { - if (wheel < 0) { - if (this.hasPageRightButton()) { - this.onPageRightButtonPressed(); - } - } else if (wheel > 0) { - if (this.hasPageLeftButton()) { - this.onPageLeftButtonPressed(); - } - } - } - super.handleMouseInput(); - } - - @Override - public void updateScreen() { - super.updateScreen(); - - if (this.hasSearchBar()) { - this.searchField.updateCursorCounter(); - } - } - - @Override - public boolean doesGuiPauseGame() { - return false; - } - - public boolean hasPageLeftButton() { - return false; - } - - public void onPageLeftButtonPressed() { - - } - - public boolean hasPageRightButton() { - return false; - } - - public void onPageRightButtonPressed() { - - } - - public boolean areTrialsOpened() { - return false; - } - - public boolean hasBackButton() { - return false; - } - - public void onBackButtonPressed() { - this.mc.displayGuiScreen(new GuiMainPage(this.previousScreen)); - } - - public boolean hasSearchBar() { - return true; - } - - public boolean hasBookmarkButtons() { - return true; - } - - @Override - public float getSmallFontSize() { - return this.smallFontSize; - } - - @Override - public float getMediumFontSize() { - return this.mediumFontSize; - } - - @Override - public float getLargeFontSize() { - return this.largeFontSize; - } - - 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) { - this.onPageLeftButtonPressed(); - } else if (this.hasPageRightButton() && button == this.buttonRight) { - this.onPageRightButtonPressed(); - } else if (this.hasBackButton() && button == this.buttonBack) { - this.onBackButtonPressed(); - } - if (button == this.buttonTrials) { - this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, this, ActuallyAdditionsAPI.entryTrials, 0, "", false)); - } else if (this.hasBookmarkButtons() && button instanceof BookmarkButton) { - int index = ArrayUtils.indexOf(this.bookmarkButtons, button); - if (index >= 0) { - this.bookmarkButtons[index].onPressed(); - } - } 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())) { - this.mc.displayGuiScreen(this.previousScreen); - } else if (this.hasSearchBar() & this.searchField.isFocused()) { - String lastText = this.searchField.getText(); - - this.searchField.textboxKeyTyped(typedChar, key); - - if (!lastText.equals(this.searchField.getText())) { - this.onSearchBarChanged(this.searchField.getText()); - } - } else { - super.keyTyped(typedChar, key); - } - } - - @Override - 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) { - StringUtil.renderSplitScaledAsciiString(this.fontRenderer, text, x, y, color, shadow, scale, length); - } - - @Override - public List getButtonList() { - return this.buttonList; - } - - @Override - public int getGuiLeft() { - return this.guiLeft; - } - - @Override - public int getGuiTop() { - return this.guiTop; - } - - @Override - public int getSizeX() { - return this.xSize; - } - - @Override - 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 deleted file mode 100644 index 95f8c058c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * This file ("GuiEntry.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; -import de.ellpeck.actuallyadditions.mod.booklet.button.EntryButton; -import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryTrials; -import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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; - private final int pageAmount; - private final IBookletEntry entry; - private final List chapters; - private final String searchText; - private final 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; - this.searchText = search; - 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 { - this.pageAmount = 1; - } - } - - 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) { - int index = entry.getChaptersForDisplay(search).indexOf(chapterForPageCalc); - return index / (BUTTONS_PER_PAGE * 2); - } - - @Override - 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); - - 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() { - super.initGui(); - - if (this.hasSearchBar() && this.searchText != null) { - this.searchField.setText(this.searchText); - 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 { - return; - } - } - } - } - - @Override - 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) { - IBookletChapter chapter = this.chapters.get(actualId); - if (chapter != null) { - IBookletPage[] pages = chapter.getAllPages(); - if (pages != null && pages.length > 0) { - this.mc.displayGuiScreen(BookletUtils.createPageGui(this.previousScreen, this, pages[0])); - } - } - } - } else { - super.actionPerformed(button); - } - } - - @Override - public void addOrModifyItemRenderer(ItemStack renderedStack, int x, int y, float scale, boolean shouldTryTransfer) { - - } - - @Override - 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())); - } - - @Override - 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())); - } - - @Override - public boolean hasBackButton() { - return true; - } - - @Override - public void onBackButtonPressed() { - if (!isShiftKeyDown()) { - this.mc.displayGuiScreen(this.parentPage); - } else { - super.onBackButtonPressed(); - } - } - - @Override - 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 deleted file mode 100644 index e6f687e88..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiMainPage.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * This file ("GuiMainPage.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.booklet.InitBooklet; -import de.ellpeck.actuallyadditions.mod.booklet.button.EntryButton; -import de.ellpeck.actuallyadditions.mod.config.GuiConfiguration; -import de.ellpeck.actuallyadditions.mod.data.PlayerData; -import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave; -import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton; -import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -//TODO Fix achievement button -@SideOnly(Side.CLIENT) -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 TexturedButton achievementButton; - private TexturedButton configButton; - - private GuiButton tutorialButton; - private boolean showTutorial; - - private String bookletName; - private String bookletEdition; - - private List quote; - private String quoteGuy; - - public GuiMainPage(GuiScreen previousScreen) { - super(previousScreen, null); - } - - private static List getDisplayedEntries() { - List displayed = new ArrayList<>(); - - for (IBookletEntry entry : ActuallyAdditionsAPI.BOOKLET_ENTRIES) { - if (entry.visibleOnFrontPage()) { - displayed.add(entry); - } - } - - return displayed; - } - - @Override - public void initGui() { - super.initGui(); - - int flavor = 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; - - String usedQuote = QUOTES[this.mc.world.rand.nextInt(QUOTES.length)]; - String[] quoteSplit = usedQuote.split("@"); - 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")) { - this.bookletEdition = "Pants Edition"; - } else if (playerName.equalsIgnoreCase("TwoOfEight") || playerName.equalsIgnoreCase("BootyToast")) { - this.bookletEdition = "Illustrator's Edition"; - } else if (playerName.equalsIgnoreCase("KittyVanCat")) { - this.bookletEdition = "Cat's Edition"; - } else if (playerName.equalsIgnoreCase("canitzp")) { - this.bookletEdition = "P's Edition"; - } else if (playerName.equalsIgnoreCase("direwolf20")) { - this.bookletEdition = "Edition 20"; - } else if (playerName.equalsIgnoreCase("dannydjdk") || playerName.equalsIgnoreCase("andrew_period")) { - this.bookletEdition = "Derp's Edition"; - } else if (playerName.equalsIgnoreCase("mezz")) { - this.bookletEdition = "Just Enough Editions"; - } else if (playerName.equalsIgnoreCase("amadornes")) { - this.bookletEdition = "Beard's Edition"; - } else if (playerName.equalsIgnoreCase("raoul")) { - this.bookletEdition = "Giraffe's Edition"; - } 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; - } - 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")) { - this.bookletEdition = "Naughty Edition"; - } else if (playerName.equalsIgnoreCase("themattabase")) { - this.bookletEdition = "Withered Edition"; - } else if (playerName.equalsIgnoreCase("robsonld04")) { - this.bookletEdition = "Modpack Edition"; - } else if (playerName.equalsIgnoreCase("snowshock35")) { - this.bookletEdition = "Edition 35"; - } else if (playerName.equalsIgnoreCase("asiekierka")) { - this.bookletEdition = "‽ Edition"; - } else if (playerName.equalsIgnoreCase("elucent")) { - this.bookletEdition = ""; - } else { - if (Util.isDevVersion()) { - this.bookletEdition = "Dev's Edition"; - } 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); - 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)); - //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) { - this.showTutorial = true; - - 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++) { - List displayed = getDisplayedEntries(); - 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 { - return; - } - } - } - - @Override - protected void actionPerformed(GuiButton button) throws IOException { - if (button instanceof EntryButton) { - List displayed = getDisplayedEntries(); - if (displayed.size() > button.id) { - IBookletEntry entry = displayed.get(button.id); - if (entry != null) { - this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, this, entry, 0, "", false)); - } - } - } - /*else if(button == this.achievementButton){ - GuiScreen achievements = new GuiAAAchievements(this, this.mc.player.getStatFileWriter()); - this.mc.displayGuiScreen(achievements); - }*/ - 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++) { - this.bookmarkButtons[i].assignedPage = InitBooklet.chaptersIntroduction[i].getAllPages()[0]; - } - } - this.showTutorial = false; - this.tutorialButton.visible = false; - - this.configButton.visible = true; - //this.achievementButton.visible = true; - - PlayerSave data = PlayerData.getDataFromPlayer(this.mc.player); - data.didBookTutorial = true; - PacketHandlerHelper.sendPlayerDataToServer(false, 1); - } - } else { - super.actionPerformed(button); - } - } - - @Override - 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); - - 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) { - 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()); - } - 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) { - - } -} 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 deleted file mode 100644 index 6d04a301f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiPage.java +++ /dev/null @@ -1,284 +0,0 @@ -/* - * This file ("GuiPage.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; -import de.ellpeck.actuallyadditions.mod.booklet.page.ItemDisplay; -import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class GuiPage extends GuiBooklet { - - public final IBookletPage[] pages = new IBookletPage[2]; - private final List itemDisplays = new ArrayList<>(); - private int pageTimer; - - private GuiButton buttonViewOnline; - - public GuiPage(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletPage page1, IBookletPage page2) { - super(previousScreen, parentPage); - - this.pages[0] = page1; - this.pages[1] = page2; - } - - @Override - public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { - super.mouseClicked(mouseX, mouseY, mouseButton); - - for (ItemDisplay display : this.itemDisplays) { - display.onMousePress(mouseButton, mouseX, mouseY); - } - - for (IBookletPage page : this.pages) { - if (page != null) { - page.mouseClicked(this, mouseX, mouseY, mouseButton); - } - } - } - - @Override - public void mouseReleased(int mouseX, int mouseY, int state) { - super.mouseReleased(mouseX, mouseY, state); - - 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) { - super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); - - 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) { - List links = this.getWebLinks(); - if (Desktop.isDesktopSupported()) { - for (String link : links) { - try { - Desktop.getDesktop().browse(new URI(link)); - } catch (Exception e) { - ActuallyAdditions.LOGGER.error("Couldn't open website from Booklet page!", e); - } - } - } - } else { - super.actionPerformed(button); - - for (IBookletPage page : this.pages) { - if (page != null) { - page.actionPerformed(this, button); - } - } - } - } - - @Override - 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"))); - this.buttonList.add(this.buttonViewOnline); - } - - 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); - } - } - } - - private List getWebLinks() { - List links = new ArrayList<>(); - - for (IBookletPage page : this.pages) { - if (page != null) { - String link = page.getWebLink(); - if (link != null && !links.contains(link)) { - links.add(link); - } - } - } - - return links; - } - - @Override - public void updateScreen() { - super.updateScreen(); - - 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); - } - } - - this.pageTimer++; - } - - @Override - public void drawScreenPre(int mouseX, int mouseY, float partialTicks) { - super.drawScreenPre(mouseX, mouseY, partialTicks); - - 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); - } - - for (int i = 0; i < this.pages.length; i++) { - IBookletPage page = this.pages[i]; - 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()); - - GlStateManager.color(1F, 1F, 1F); - page.drawScreenPre(this, this.guiLeft + 6 + i * 142, this.guiTop + 7, mouseX, mouseY, partialTicks); - } - } - for (ItemDisplay display : this.itemDisplays) { - display.drawPre(); - } - } - - @Override - public void drawScreenPost(int mouseX, int mouseY, float partialTicks) { - super.drawScreenPost(mouseX, mouseY, partialTicks); - - for (int i = 0; i < this.pages.length; i++) { - IBookletPage page = this.pages[i]; - if (page != null) { - GlStateManager.color(1F, 1F, 1F); - page.drawScreenPost(this, this.guiLeft + 6 + i * 142, this.guiTop + 7, mouseX, mouseY, partialTicks); - } - } - 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) { - display.stack = renderedStack; - return; - } - } - - this.itemDisplays.add(new ItemDisplay(this, x, y, scale, renderedStack, shouldTryTransfer)); - } - - @Override - public boolean hasPageLeftButton() { - IBookletPage page = this.pages[0]; - if (page != null) { - IBookletChapter chapter = page.getChapter(); - if (chapter != null) { return chapter.getPageIndex(page) > 0; } - } - return false; - } - - @Override - public void onPageLeftButtonPressed() { - IBookletPage page = this.pages[0]; - if (page != null) { - IBookletChapter chapter = page.getChapter(); - if (chapter != null) { - IBookletPage[] pages = chapter.getAllPages(); - - int pageNumToOpen = chapter.getPageIndex(page) - 1; - if (pageNumToOpen >= 0 && pageNumToOpen < pages.length) { - this.mc.displayGuiScreen(BookletUtils.createPageGui(this.previousScreen, this.parentPage, pages[pageNumToOpen])); - } - } - } - } - - @Override - public boolean hasPageRightButton() { - IBookletPage page = this.pages[1]; - if (page != null) { - IBookletChapter chapter = page.getChapter(); - if (chapter != null) { - int pageIndex = chapter.getPageIndex(page); - int pageAmount = chapter.getAllPages().length; - return pageIndex + 1 < pageAmount; - } - } - return false; - } - - @Override - public void onPageRightButtonPressed() { - IBookletPage page = this.pages[1]; - if (page != null) { - IBookletChapter chapter = page.getChapter(); - if (chapter != null) { - IBookletPage[] pages = chapter.getAllPages(); - - int pageNumToOpen = chapter.getPageIndex(page) + 1; - if (pageNumToOpen >= 0 && pageNumToOpen < pages.length) { - this.mc.displayGuiScreen(BookletUtils.createPageGui(this.previousScreen, this.parentPage, pages[pageNumToOpen])); - } - } - } - } - - @Override - public boolean hasBackButton() { - return true; - } - - @Override - public void onBackButtonPressed() { - if (!isShiftKeyDown()) { - this.mc.displayGuiScreen(this.parentPage); - } 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 deleted file mode 100644 index 4f63ddfd8..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/BookletUtils.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This file ("BookletUtils.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.booklet.misc; - -import java.util.List; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; -import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; -import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiEntry; -import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiMainPage; -import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiPage; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public final class BookletUtils { - - 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; } - } - } - } - return null; - } - - @SideOnly(Side.CLIENT) - public static GuiPage createBookletGuiFromPage(GuiScreen previousScreen, IBookletPage page) { - GuiMainPage mainPage = new GuiMainPage(previousScreen); - - IBookletChapter chapter = page.getChapter(); - GuiEntry entry = new GuiEntry(previousScreen, mainPage, chapter.getEntry(), chapter, "", false); - - return createPageGui(previousScreen, entry, page); - } - - @SideOnly(Side.CLIENT) - public static GuiPage createPageGui(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletPage page) { - IBookletChapter chapter = page.getChapter(); - - IBookletPage[] allPages = chapter.getAllPages(); - int pageIndex = chapter.getPageIndex(page); - IBookletPage page1; - IBookletPage page2; - - if (page.shouldBeOnLeftSide()) { - page1 = page; - 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; } - } - } - } - return null; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/GuiAAAchievements.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/GuiAAAchievements.java deleted file mode 100644 index 85ccae067..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/GuiAAAchievements.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file ("GuiAAAchievements.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -//TODO Achievement GUI? -/* -package de.ellpeck.actuallyadditions.mod.booklet.misc; - -import de.ellpeck.actuallyadditions.mod.achievement.InitAchievements; -import de.ellpeck.actuallyadditions.mod.util.ModUtil; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.achievement.GuiAchievements; -import net.minecraft.stats.StatisticsManager; -import net.minecraftforge.fml.relauncher.ReflectionHelper; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.lwjgl.input.Keyboard; - -import java.io.IOException; - -/** - * (Partially excerpted from Botania by Vazkii with permission, thanks!) - * -@SideOnly(Side.CLIENT) -public class GuiAAAchievements extends GuiAchievements{ - - public GuiAAAchievements(GuiScreen screen, StatisticsManager statistics){ - super(screen, statistics); - try{ - ReflectionHelper.setPrivateValue(GuiAchievements.class, this, InitAchievements.pageNumber, 20); - } - catch(Exception e){ - ModUtil.LOGGER.error("Something went wrong trying to open the Achievements GUI!", e); - } - } - - @Override - public void initGui(){ - super.initGui(); - - try{ - this.buttonList.remove(1); - } - catch(Exception e){ - ModUtil.LOGGER.error("Something went wrong trying to initialize the Achievements GUI!", e); - } - } - - @Override - protected void keyTyped(char typedChar, int key) throws IOException{ - if(key == Keyboard.KEY_ESCAPE || key == this.mc.gameSettings.keyBindInventory.getKeyCode()){ - this.mc.displayGuiScreen(this.parentScreen); - } - else{ - super.keyTyped(typedChar, key); - } - } -} - */ \ No newline at end of file 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 deleted file mode 100644 index 79a663369..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPage.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * This file ("BookletPage.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.block.Block; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class BookletPage implements IBookletPage { - - protected final HashMap textReplacements = new HashMap<>(); - protected final int localizationKey; - private final int priority; - private final List itemsForPage = new ArrayList<>(); - private final List fluidsForPage = new ArrayList<>(); - protected IBookletChapter chapter; - protected boolean hasNoText; - - public BookletPage(int localizationKey) { - this(localizationKey, 0); - } - - public BookletPage(int localizationKey, int priority) { - this.localizationKey = localizationKey; - this.priority = priority; - } - - @Override - public void getItemStacksForPage(List list) { - list.addAll(this.itemsForPage); - } - - @Override - public void getFluidStacksForPage(List list) { - list.addAll(this.fluidsForPage); - } - - @Override - public IBookletChapter getChapter() { - return this.chapter; - } - - @Override - public void setChapter(IBookletChapter chapter) { - this.chapter = chapter; - } - - @Override - @SideOnly(Side.CLIENT) - 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("", "\n"); - 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()) { - 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; - } - - @Override - @SideOnly(Side.CLIENT) - 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) { - - } - - @Override - @SideOnly(Side.CLIENT) - public void mouseClickMove(GuiBookletBase gui, int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { - - } - - @Override - @SideOnly(Side.CLIENT) - public void actionPerformed(GuiBookletBase gui, GuiButton button) { - - } - - @Override - @SideOnly(Side.CLIENT) - public void initGui(GuiBookletBase gui, int startX, int startY) { - - } - - @Override - @SideOnly(Side.CLIENT) - 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) { - - } - - @Override - @SideOnly(Side.CLIENT) - 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; - } - - @Override - public String getIdentifier() { - return this.chapter.getIdentifier() + "." + this.chapter.getPageIndex(this); - } - - @Override - public String getWebLink() { - return "http://ellpeck.de/actaddmanual#" + this.chapter.getIdentifier(); - } - - public BookletPage setNoText() { - this.hasNoText = true; - return this; - } - - public BookletPage addFluidToPage(Fluid fluid) { - this.fluidsForPage.add(new FluidStack(fluid, 1)); - return this; - } - - public BookletPage addItemsToPage(Block... blocks) { - for (Block block : blocks) { - this.addItemsToPage(new ItemStack(block)); - } - return this; - } - - public BookletPage addItemsToPage(ItemStack... stacks) { - Collections.addAll(this.itemsForPage, stacks); - return this; - } - - @Override - public BookletPage addTextReplacement(String key, String value) { - this.textReplacements.put(key, value); - return this; - } - - @Override - public BookletPage addTextReplacement(String key, float value) { - return this.addTextReplacement(key, Float.toString(value)); - } - - @Override - public BookletPage addTextReplacement(String key, int value) { - return this.addTextReplacement(key, Integer.toString(value)); - } - - @Override - 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 deleted file mode 100644 index e43f9a044..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/ItemDisplay.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file ("ItemDisplay.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiPage; -import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.util.ITooltipFlag.TooltipFlags; -import net.minecraft.init.SoundEvents; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.client.config.GuiUtils; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class ItemDisplay { - - public final int x; - public final int y; - public final float scale; - private final GuiPage gui; - private final IBookletPage page; - public ItemStack stack; - - public ItemDisplay(GuiPage gui, int x, int y, float scale, ItemStack stack, boolean shouldTryTransfer) { - this.gui = gui; - this.x = x; - this.y = y; - this.scale = scale; - this.stack = stack; - this.page = shouldTryTransfer ? BookletUtils.findFirstPageForStack(stack) : null; - } - - @SideOnly(Side.CLIENT) - 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)) { - 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)); - } - } - - 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); - - mc.fontRenderer.setUnicodeFlag(flagBefore); - } - } - - 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); - this.gui.mc.displayGuiScreen(gui); - } - } - } - - 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 deleted file mode 100644 index b4e120eef..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCoffeeMachine.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This file ("PageCoffeeMachine.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.client.config.GuiUtils; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class PageCoffeeMachine extends BookletPage { - - private final CoffeeIngredient ingredient; - private final ItemStack outcome; - private int counter = 0; - private int rotate = 0; - private final ItemStack[] stacks; - - public PageCoffeeMachine(int localizationKey, CoffeeIngredient ingredient) { - super(localizationKey); - this.ingredient = ingredient; - this.stacks = ingredient.getInput().getMatchingStacks(); - - this.outcome = new ItemStack(InitItems.itemCoffee); - ActuallyAdditionsAPI.methodHandler.addEffectToStack(this.outcome, this.ingredient); - } - - @Override - @SideOnly(Side.CLIENT) - 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); - - 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); - - 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) { - 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(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) { - 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 deleted file mode 100644 index 0df0910f1..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrafting.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * This file ("PageCrafting.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.booklet.page; - -import java.util.Arrays; -import java.util.List; - -import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet; -import de.ellpeck.actuallyadditions.mod.util.RefHelp; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import de.ellpeck.actuallyadditions.mod.util.Util; -import de.ellpeck.actuallyadditions.mod.util.crafting.BlankRecipe; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.ShapedRecipes; -import net.minecraft.item.crafting.ShapelessRecipes; -import net.minecraftforge.fml.client.config.GuiUtils; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.oredict.ShapedOreRecipe; -import net.minecraftforge.oredict.ShapelessOreRecipe; - -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) { - super(localizationKey, priority); - this.recipes = recipes; - } - - public PageCrafting(int localizationKey, List recipes) { - this(localizationKey, 0, recipes); - } - - public PageCrafting(int localizationKey, IRecipe... recipes) { - this(localizationKey, 0, recipes); - } - - public PageCrafting(int localizationKey, int priority, IRecipe... recipes) { - this(localizationKey, priority, Arrays.asList(recipes)); - } - - 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) { - 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); - - if (recipeTypeLocKey != null) gui.renderScaledAsciiString("(" + StringUtil.localize(this.recipeTypeLocKey) + ")", startX + 6, startY + 65, 0, false, gui.getMediumFontSize()); - - PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 80); - } - - @Override - @SideOnly(Side.CLIENT) - public void updateScreen(GuiBookletBase gui, int startX, int startY, int pageTimer) { - super.updateScreen(gui, startX, startY, pageTimer); - - if (pageTimer % 20 == 0) { - this.findRecipe(gui, startX, startY); - } - } - - private void findRecipe(GuiBookletBase gui, int startX, int startY) { - if (!this.recipes.isEmpty()) { - IRecipe recipe = this.recipes.get(this.recipeAt); - if (recipe != null) { - this.setupRecipe(gui, recipe, startX, startY); - } - - this.recipeAt++; - if (this.recipeAt >= this.recipes.size()) { - this.recipeAt = 0; - } - } - } - - @Override - 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) { - super.getItemStacksForPage(list); - - if (!this.recipes.isEmpty()) { - for (IRecipe recipe : this.recipes) { - if (recipe != null) { - ItemStack output = recipe.getRecipeOutput(); - if (StackUtil.isValid(output)) { - ItemStack copy = output.copy(); - if (this.isWildcard) { - copy.setItemDamage(Util.WILDCARD); - } - list.add(copy); - } - } - } - } - } - - 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); - return; - } 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++) { - ings[i] = shapeless.recipeItems.get(i); - } - 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) { - 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++) { - 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++) { - ings[i] = shapeless.getIngredients().get(i); - } - 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) { - ItemStack[] stacks = ing.getMatchingStacks(); - if (stacks != null && stacks.length > 0) { - ItemStack stack = stacks[0]; - if (StackUtil.isValid(stack)) { - ItemStack copy = stack.copy(); - copy.setCount(1); - if (copy.getItemDamage() == Util.WILDCARD) { - copy.setItemDamage(0); - } - - gui.addOrModifyItemRenderer(copy, startX + 6 + x * 18, startY + 7 + y * 18, 1F, true); - } - } - } - } - } - - 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 deleted file mode 100644 index 44153a1cc..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageCrusherRecipe.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file ("PageCrusherRecipe.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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.CrusherRecipe; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.client.config.GuiUtils; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -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) { - super(localizationKey); - this.recipe = recipe; - this.stacks = recipe.getInput().getMatchingStacks(); - } - - @Override - @SideOnly(Side.CLIENT) - 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); - - gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".crusherRecipe") + ")", startX + 36, startY + 85, 0, false, gui.getMediumFontSize()); - - 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); - } - - @Override - @SideOnly(Side.CLIENT) - 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 (StackUtil.isValid(this.recipe.getOutputTwo())) { - gui.addOrModifyItemRenderer(this.recipe.getOutputTwo(), startX + 38 + 30, startY + 6 + 53, 1F, false); - } - } - } - - @Override - public void getItemStacksForPage(List list) { - super.getItemStacksForPage(list); - - if (this.recipe != null) { - list.add(this.recipe.getOutputOne()); - - 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 deleted file mode 100644 index b0ad58294..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageEmpowerer.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This file ("PageEmpowerer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.client.config.GuiUtils; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class PageEmpowerer extends BookletPage { - - private final EmpowererRecipe recipe; - private int counter = 0; - private int rotate = 0; - ItemStack[] inputs; - ItemStack[] stand1; - ItemStack[] stand2; - ItemStack[] stand3; - ItemStack[] stand4; - - public PageEmpowerer(int localizationKey, EmpowererRecipe recipe) { - super(localizationKey); - this.recipe = recipe; - if (recipe != null) { - this.inputs = recipe.getInput().getMatchingStacks(); - this.stand1 = recipe.getStandOne().getMatchingStacks(); - this.stand2 = recipe.getStandTwo().getMatchingStacks(); - this.stand3 = recipe.getStandThree().getMatchingStacks(); - this.stand4 = recipe.getStandFour().getMatchingStacks(); - } - } - - @Override - @SideOnly(Side.CLIENT) - 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); - - 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); - } - - @Override - @SideOnly(Side.CLIENT) - 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); - - 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) { - 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.inputs[this.rotate % this.inputs.length], startX + 5 + 26, startY + 10 + 26, 1F, true); - } - } - - @Override - public void getItemStacksForPage(List list) { - super.getItemStacksForPage(list); - - if (this.recipe != null) { - list.add(this.recipe.getOutput()); - } - } - - @Override - 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 deleted file mode 100644 index 862905caa..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageFurnace.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This file ("PageFurnace.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.FurnaceRecipes; -import net.minecraftforge.fml.client.config.GuiUtils; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class PageFurnace extends BookletPage { - - private final ItemStack input; - private final ItemStack output; - - public PageFurnace(int localizationKey, ItemStack output) { - this(localizationKey, output, 0); - } - - 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()) { - ItemStack stack = entry.getValue(); - if (StackUtil.isValid(stack)) { - if (stack.isItemEqual(output)) { return entry.getKey(); } - } - } - return ItemStack.EMPTY; - } - - @Override - @SideOnly(Side.CLIENT) - 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); - - gui.renderScaledAsciiString("(" + StringUtil.localize("booklet." + ActuallyAdditions.MODID + ".furnaceRecipe") + ")", startX + 32, startY + 42, 0, false, gui.getMediumFontSize()); - - PageTextOnly.renderTextToPage(gui, this, startX + 6, startY + 57); - } - - @Override - @SideOnly(Side.CLIENT) - 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); - } - - @Override - 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 deleted file mode 100644 index 7b5ab3d8c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageLinkButton.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This file ("PageLinkButton.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.client.gui.GuiButton; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class PageLinkButton extends BookletPage { - - public static int nextButtonId = 23782; - private final int buttonId; - - private final String link; - - public PageLinkButton(int localizationKey, String link) { - super(localizationKey); - this.link = link; - - this.buttonId = nextButtonId; - nextButtonId++; - } - - @Override - @SideOnly(Side.CLIENT) - 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))); - } - - @Override - @SideOnly(Side.CLIENT) - 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); - } - - @Override - @SideOnly(Side.CLIENT) - 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) { - ActuallyAdditions.LOGGER.error("Couldn't open website from Link Button page!", e); - } - } - } 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 deleted file mode 100644 index c4c1e16f9..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PagePicture.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file ("PagePicture.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.booklet.page; - -import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.client.config.GuiUtils; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class PagePicture extends BookletPage { - - private final ResourceLocation resLoc; - private final int yTextOffset; - - 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) { - super(localizationKey); - this.yTextOffset = yTextOffset; - this.resLoc = resLoc; - } - - 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) { - super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); - - gui.mc.getTextureManager().bindTexture(this.resLoc); - - GlStateManager.pushMatrix(); - GlStateManager.enableBlend(); - GlStateManager.disableAlpha(); - 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); - } -} 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 deleted file mode 100644 index 46770d7b0..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageReconstructor.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * This file ("PageReconstructor.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.client.config.GuiUtils; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class PageReconstructor extends BookletPage { - - private final LensConversionRecipe recipe; - private boolean isWildcard; - private int counter = 0; - private int rotate = 0; - private ItemStack[] stacks; - - public PageReconstructor(int localizationKey, LensConversionRecipe recipe) { - super(localizationKey); - this.recipe = recipe; - 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) { - 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); - - 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); - } - } - - @Override - @SideOnly(Side.CLIENT) - 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); - } - } - - @Override - public void getItemStacksForPage(List list) { - super.getItemStacksForPage(list); - - if (this.recipe != null) { - ItemStack copy = this.recipe.getOutput().copy(); - if (this.isWildcard) { - copy.setItemDamage(Util.WILDCARD); - } - list.add(copy); - } - } - - public BookletPage setWildcard() { - this.isWildcard = true; - return this; - } - - @Override - 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 deleted file mode 100644 index 226a98354..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTextOnly.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file ("PageTextOnly.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.booklet.page; - -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 PageTextOnly(int localizationKey, int priority) { - super(localizationKey, priority); - } - - public PageTextOnly(int localizationKey) { - super(localizationKey); - } - - @SideOnly(Side.CLIENT) - public static void renderTextToPage(GuiBookletBase gui, BookletPage page, int x, int y) { - String text = page.getInfoText(); - 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) { - super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); - 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 deleted file mode 100644 index 4ea7c338b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageTrials.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * This file ("PageTrials.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.booklet.page; - -import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.data.PlayerData; -import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave; -import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class PageTrials extends BookletPage { - - private final int buttonId; - @SideOnly(Side.CLIENT) - private GuiButton button; - - public PageTrials(int localizationKey, boolean button, boolean text) { - super(localizationKey); - - if (!text) { - this.setNoText(); - } - - if (button) { - this.buttonId = PageLinkButton.nextButtonId; - PageLinkButton.nextButtonId++; - } else { - this.buttonId = -1; - } - } - - @Override - @SideOnly(Side.CLIENT) - 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, ""); - gui.getButtonList().add(this.button); - this.updateButton(); - } - } - - @Override - @SideOnly(Side.CLIENT) - 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); - } - - @Override - @SideOnly(Side.CLIENT) - 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) { - EntityPlayer player = Minecraft.getMinecraft().player; - PlayerSave data = PlayerData.getDataFromPlayer(player); - String id = this.chapter.getIdentifier(); - - boolean completed = data.completedTrials.contains(id); - if (completed) { - data.completedTrials.remove(id); - } else { - data.completedTrials.add(id); - } - this.updateButton(); - - PacketHandlerHelper.sendPlayerDataToServer(false, 2); - } else { - super.actionPerformed(gui, button); - } - } - - @SideOnly(Side.CLIENT) - 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"); - } - - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigCategories.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigCategories.java deleted file mode 100644 index 9662114fd..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigCategories.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file ("ConfigCategories.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.config; - -import java.util.Locale; - -public enum ConfigCategories { - - TOOL_VALUES("Tool Values", "Values for Tools"), - MACHINE_VALUES("Machine Values", "Values for Machines"), - MOB_DROPS("Mob Drops", "Everything regarding Item drops from mobs"), - WORLD_GEN("World Gen", "Everything regarding World Generation"), - OTHER("Other", "Everything else"); - - public final String name; - public final 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 deleted file mode 100644 index ca7da86e9..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigValues.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file ("ConfigValues.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.config; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntListValues; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.config.Configuration; - -public final class ConfigValues { - - public static Item itemRedstoneTorchConfigurator; - public static Item itemCompassConfigurator; - - 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()) { - currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getBoolean(); - } - - for (ConfigIntListValues currConf : ConfigIntListValues.values()) { - currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getIntList(); - } - - for (ConfigStringListValues currConf : ConfigStringListValues.values()) { - currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getStringList(); - } - - parseConfiguratorConfig(); - } - - private static void parseConfiguratorConfig() { - itemRedstoneTorchConfigurator = null; - itemCompassConfigurator = null; - - String[] conf = ConfigStringListValues.CONFIGURE_ITEMS.getValue(); - 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) { - ActuallyAdditions.LOGGER.error("Parsing the Configuration Items config failed, reverting back to the default settings!"); - - itemRedstoneTorchConfigurator = Item.getItemFromBlock(Blocks.REDSTONE_TORCH); - itemCompassConfigurator = Items.COMPASS; - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigurationHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigurationHandler.java deleted file mode 100644 index b850f6704..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/ConfigurationHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file ("ConfigurationHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; - -public class ConfigurationHandler { - - public static Configuration config; - - public ConfigurationHandler(File configFile) { - ActuallyAdditions.LOGGER.info("Grabbing Configurations..."); - - MinecraftForge.EVENT_BUS.register(this); - - config = new Configuration(configFile); - config.load(); - - redefineConfigs(); - } - - public static void redefineConfigs() { - ConfigValues.defineConfigValues(config); - - if (config.hasChanged()) { - config.save(); - } - } - - @SubscribeEvent - public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) { - if (event.getModID().equalsIgnoreCase(ActuallyAdditions.MODID)) { - redefineConfigs(); - } - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiConfiguration.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiConfiguration.java deleted file mode 100644 index 2d1dfea2f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file ("GuiConfiguration.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; - -public class GuiConfiguration extends GuiConfig { - - public GuiConfiguration(GuiScreen parentScreen) { - super(parentScreen, getConfigElements(), ActuallyAdditions.MODID, false, false, GuiConfig.getAbridgedConfigPath(ConfigurationHandler.config.toString())); - } - - private static List getConfigElements() { - List list = new ArrayList<>(); - 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))); - } - return list; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiFactory.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiFactory.java deleted file mode 100644 index 627e6a1bb..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file ("GuiFactory.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; - -public class GuiFactory implements IModGuiFactory { - - @Override - public void initialize(Minecraft minecraftInstance) { - - } - - @Override - public boolean hasConfigGui() { - return true; - } - - @Override - public GuiScreen createConfigGui(GuiScreen parentScreen) { - return new GuiConfiguration(parentScreen); - } - - @Override - 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 deleted file mode 100644 index fadf239e9..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigBoolValues.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * This file ("ConfigBoolValues.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.config.values; - -import de.ellpeck.actuallyadditions.mod.config.ConfigCategories; - -public enum ConfigBoolValues { - - 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?"), - - 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_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."), - - DO_RICE_GEN("Rice Gen", ConfigCategories.WORLD_GEN, true, "Should Rice generate in the World?"), - DO_CANOLA_GEN("Canola Gen", ConfigCategories.WORLD_GEN, true, "Should Canola generate in the World?"), - 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_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."), - - 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"), - - 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?"), - 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"), - - 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."), - MINING_LENS_ADAPTED_USE( - "Mining Lens Math", - ConfigCategories.MACHINE_VALUES, - true, - "If true, the mining lens uses some weird math to calculate energy costs."); - - public final String name; - public final String category; - public final boolean defaultValue; - public final String desc; - - public boolean currentValue; - - 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() { - 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 deleted file mode 100644 index 8283bbaf3..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntListValues.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file ("ConfigIntListValues.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.config.values; - -import de.ellpeck.actuallyadditions.mod.config.ConfigCategories; - -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."); - - public final String name; - public final String category; - public final int[] defaultValue; - public final String desc; - - public int[] currentValue; - - 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() { - return this.currentValue; - } - -} \ No newline at end of file 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 deleted file mode 100644 index 0803b7025..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigIntValues.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * This file ("ConfigIntValues.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.config.values; - -import de.ellpeck.actuallyadditions.mod.config.ConfigCategories; - -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."), - - 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."), - - 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."), - MINING_LENS_USE( - "Mining Lens Energy", - ConfigCategories.MACHINE_VALUES, - 60000, - 1, - Integer.MAX_VALUE, - "The energy use of the Atomic Reconstructor's Mining Lens."); - - public final String name; - public final String category; - public final int defaultValue; - public final int min; - public final int max; - public final String desc; - - public int currentValue; - - ConfigIntValues(String name, ConfigCategories category, int defaultValue, int min, int max, String desc) { - this.name = name; - this.category = category.name; - this.defaultValue = defaultValue; - this.min = min; - this.max = max; - this.desc = desc; - } - - 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 deleted file mode 100644 index bfcb883cd..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/values/ConfigStringListValues.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * This file ("ConfigStringListValues.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.config.values; - -import de.ellpeck.actuallyadditions.mod.config.ConfigCategories; - -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"), - REPAIR_BLACKLIST( - "Repair Blacklist", - ConfigCategories.OTHER, - new String[0], - "The items that aren't allowed to be put in the Repairer. Use REGISTRY NAMES, and if metadata is needed, add it like so: somemod:some_block@3"); - - public final String name; - public final String category; - public final String[] defaultValue; - public final String desc; - - public String[] currentValue; - - 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() { - return this.currentValue; - } - -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/BlockCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/BlockCrafting.java deleted file mode 100644 index e6a576e75..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/BlockCrafting.java +++ /dev/null @@ -1,424 +0,0 @@ -/* - * This file ("BlockCrafting.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.crafting; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.BlockColoredLamp; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -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.TheCrystals; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.util.RecipeUtil; -import de.ellpeck.actuallyadditions.mod.util.Util; -import de.ellpeck.actuallyadditions.mod.util.crafting.RecipeHandler; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.ResourceLocation; - -public final class BlockCrafting { - - public static final IRecipe[] RECIPES_LAMPS = new IRecipe[BlockColoredLamp.ALL_LAMP_TYPES.length]; - public static IRecipe recipeSmileyCloud; - public static IRecipe recipePhantomface; - public static IRecipe recipeLiquiface; - public static IRecipe recipeEnergyface; - public static IRecipe recipePhantomBreaker; - public static IRecipe recipePhantomPlacer; - public static IRecipe recipeBreaker; - public static IRecipe recipePlacer; - public static IRecipe recipeLiquidPlacer; - public static IRecipe recipeLiquidCollector; - public static IRecipe recipeCase; - public static IRecipe recipeIronCase; - public static IRecipe recipeEnderCase; - public static IRecipe recipeEnderPearlBlock; - public static IRecipe recipeESD; - public static IRecipe recipeAdvancedESD; - public static IRecipe recipePhantomBooster; - public static IRecipe recipeCoffeeMachine; - public static IRecipe recipeCrusher; - public static IRecipe recipeDoubleCrusher; - public static IRecipe recipeFurnace; - public static IRecipe recipeSolidifier; - public static IRecipe recipeCasing; - public static IRecipe recipeGlass; - public static IRecipe recipeLavaFactory; - public static IRecipe recipeEnergizer; - public static IRecipe recipeEnervator; - public static IRecipe recipeSolar; - public static IRecipe recipeHeatCollector; - public static IRecipe recipeCoalGen; - public static IRecipe recipeOilGen; - public static IRecipe recipeRepairer; - public static IRecipe recipeFisher; - public static IRecipe recipeQuartzBlock; - public static IRecipe recipeQuartzChiseled; - public static IRecipe recipeQuartzPillar; - public static IRecipe recipeBlockChar; - public static IRecipe recipeFeeder; - public static IRecipe recipeCompost; - public static IRecipe recipeCrate; - public static IRecipe recipeCrateMedium; - public static IRecipe recipeCrateLarge; - public static IRecipe recipeFermentingBarrel; - public static IRecipe recipeCanolaPress; - public static IRecipe recipePowerer; - public static IRecipe recipeLeafGen; - public static IRecipe recipeDirectionalBreaker; - public static IRecipe recipeDropper; - public static IRecipe recipeRangedCollector; - public static IRecipe recipeLaserRelay; - public static IRecipe recipeLaserRelayAdvanced; - public static IRecipe recipeLaserRelayExtreme; - public static IRecipe recipeAtomicReconstructor; - public static IRecipe recipeMiner; - public static IRecipe recipeFireworkBox; - public static IRecipe recipePhantomRedstoneface; - public static IRecipe recipeLaserRelayItemWhitelist; - public static IRecipe recipeItemInterface; - public static IRecipe recipeItemInterfaceHopping; - public static IRecipe recipePlayerInterface; - public static IRecipe recipeDisplayStand; - public static IRecipe recipeShockSuppressor; - public static IRecipe recipeEmpowerer; - public static IRecipe[] recipesTinyTorch = new IRecipe[2]; - public static IRecipe recipeBioReactor; - public static IRecipe recipeFarmer; - public static IRecipe recipeBatteryBox; - - private static class FireworkIngredient extends Ingredient { - - ItemStack firework = new ItemStack(Items.FIREWORKS); - ItemStack[] fireworks = new ItemStack[] { this.firework }; - - @Override - public ItemStack[] getMatchingStacks() { - return this.fireworks; - } - - @Override - public boolean apply(ItemStack stack) { - return stack.getItem() == Items.FIREWORKS; - } - } - - public static void init() { - - Block[] removeNBTBlocks = new Block[] { InitBlocks.blockOilGenerator, InitBlocks.blockFluidPlacer, InitBlocks.blockFluidCollector, InitBlocks.blockCanolaPress, InitBlocks.blockFermentingBarrel }; - - 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())); - 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)); - 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)); - 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"); - 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"); - 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())); - 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())); - 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)); - 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)); - 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())); - - //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())); - - //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())); - - //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)); - - //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)); - - //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())); - 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())); - 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())); - 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())); - 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()), "gemQuartzBlack", 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"); - recipeItemInterface = RecipeUtil.lastIRecipe(); - - //Hopping Item Interface - 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())); - 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)); - 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)); - 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())); - 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())); - 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)); - recipeBlockChar = RecipeUtil.lastIRecipe(); - 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"); - recipeCase = RecipeUtil.lastIRecipe(); - - //Iron Casing - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.IRON_CASING.ordinal()), "WSW", "SQS", "WSW", 'Q', "gemQuartzBlack", '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())); - 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())); - 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())); - 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())); - 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())); - 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); - 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())); - 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())); - 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())); - 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())); - 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())); - recipePlayerInterface = RecipeUtil.lastIRecipe(); - - //Phantom Placer - 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); - 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); - 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); - recipePhantomRedstoneface = RecipeUtil.lastIRecipe(); - - //Phantom Liquiface - 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); - recipeLiquidPlacer = RecipeUtil.lastIRecipe(); - - //Liquid Breaker - 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())); - 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)); - 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)); - 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())); - recipeLeafGen = RecipeUtil.lastIRecipe(); - - //Enderpearl Block - 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())); - - //Quartz Block - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ.ordinal()), "QQ", "QQ", 'Q', "gemQuartzBlack"); - 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); - 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())); - 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)); - 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)); - recipeHeatCollector = RecipeUtil.lastIRecipe(); - - //Quartz Pillar - RecipeHandler.addOreDictRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ_PILLAR.ordinal()), "Q", "Q", 'Q', "gemQuartzBlack"); - 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())); - 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())); - recipeESD = RecipeUtil.lastIRecipe(); - - RecipeHandler.addShapelessOreDictRecipe(new ItemStack(InitBlocks.blockInputterAdvanced), InitBlocks.blockInputter, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), "gemQuartzBlack", 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)); - 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())); - 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())); - 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())); - 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"); - 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"); - 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"); - 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"); - 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())); - 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())); - 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())); - 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', "gemQuartzBlack"); - 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)); - recipePowerer = RecipeUtil.lastIRecipe(); - - } - -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrusherCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrusherCrafting.java deleted file mode 100644 index 7eadac814..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/CrusherCrafting.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * This file ("CrusherCrafting.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.crafting; - -import java.util.ArrayList; -import java.util.List; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheDusts; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods; -import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry; -import de.ellpeck.actuallyadditions.mod.util.RecipeUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraftforge.oredict.OreDictionary; -import net.minecraftforge.oredict.OreIngredient; - -public final class CrusherCrafting { - - public static final ArrayList MISC_RECIPES = new ArrayList<>(); - public static CrusherRecipe recipeIronHorseArmor; - public static CrusherRecipe recipeGoldHorseArmor; - public static CrusherRecipe recipeDiamondHorseArmor; - - public static void init() { - ActuallyAdditions.LOGGER.info("Initializing Crusher Recipes..."); - - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.BONE), new ItemStack(Items.DYE, 6, 15), StackUtil.getEmpty(), 0); - MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.REEDS), new ItemStack(Items.SUGAR, 3), StackUtil.getEmpty(), 0); - MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.BLAZE_ROD), new ItemStack(Items.BLAZE_POWDER, 4), StackUtil.getEmpty(), 0); - MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.YELLOW_FLOWER), new ItemStack(Items.DYE, 3, 11), StackUtil.getEmpty(), 0); - MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 0), new ItemStack(Items.DYE, 3, 1), StackUtil.getEmpty(), 0); - MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 1), new ItemStack(Items.DYE, 3, 12), StackUtil.getEmpty(), 0); - MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 2), new ItemStack(Items.DYE, 3, 13), StackUtil.getEmpty(), 0); - MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 3), new ItemStack(Items.DYE, 3, 7), StackUtil.getEmpty(), 0); - MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 4), new ItemStack(Items.DYE, 3, 1), StackUtil.getEmpty(), 0); - MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 5), new ItemStack(Items.DYE, 3, 14), StackUtil.getEmpty(), 0); - MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 6), new ItemStack(Items.DYE, 3, 7), StackUtil.getEmpty(), 0); - MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 7), new ItemStack(Items.DYE, 3, 9), StackUtil.getEmpty(), 0); - MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.RED_FLOWER, 1, 8), new ItemStack(Items.DYE, 3, 7), StackUtil.getEmpty(), 0); - MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.DOUBLE_PLANT, 1, 0), new ItemStack(Items.DYE, 4, 11), StackUtil.getEmpty(), 0); - MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.DOUBLE_PLANT, 1, 1), new ItemStack(Items.DYE, 4, 13), StackUtil.getEmpty(), 0); - MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.DOUBLE_PLANT, 1, 4), new ItemStack(Items.DYE, 4, 1), StackUtil.getEmpty(), 0); - MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - 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); - 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); - - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal()), new ItemStack(Items.SUGAR, 2), StackUtil.getEmpty(), 0); - MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe()); - - 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); - - ItemStack temp = getStack("dustIron"); - if (!temp.isEmpty()) { - temp.setCount(6); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.IRON_HORSE_ARMOR), temp, StackUtil.getEmpty(), 0); - recipeIronHorseArmor = RecipeUtil.lastCrusherRecipe(); - } - - temp = getStack("dustGold"); - if (!temp.isEmpty()) { - temp.setCount(6); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.GOLDEN_HORSE_ARMOR), temp, StackUtil.getEmpty(), 0); - recipeGoldHorseArmor = RecipeUtil.lastCrusherRecipe(); - } - - temp = getStack("dustDiamond"); - if (!temp.isEmpty()) { - temp.setCount(6); - ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.DIAMOND_HORSE_ARMOR), temp, StackUtil.getEmpty(), 0); - recipeDiamondHorseArmor = RecipeUtil.lastCrusherRecipe(); - } - - CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("oreNether", 6)); - CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("orePoor", 4, "nugget")); - CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("denseore", 8)); - CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("gem", 1)); - CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("ingot", 1)); - CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("ore", 2, "gem")); //Search for gems first so removeDuplicates doesn't clear gem recipes. - CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("ore", 2)); - - CrusherRecipeRegistry.registerFinally(); - } - - private static ItemStack getStack(String ore) { - List stacks = OreDictionary.getOres(ore); - if (stacks.isEmpty()) return StackUtil.getEmpty(); - return stacks.get(0).copy(); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/FoodCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/FoodCrafting.java deleted file mode 100644 index 03fc7168f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/FoodCrafting.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * This file ("FoodCrafting.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.crafting; - -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.util.RecipeUtil; -import de.ellpeck.actuallyadditions.mod.util.Util; -import de.ellpeck.actuallyadditions.mod.util.crafting.RecipeHandler; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.Ingredient; -import net.minecraftforge.fml.common.registry.GameRegistry; - -public final class FoodCrafting { - - public static IRecipe recipePizza; - public static IRecipe recipeHamburger; - public static IRecipe recipeBigCookie; - public static IRecipe recipeSubSandwich; - public static IRecipe recipeFrenchFry; - public static IRecipe recipeFrenchFries; - public static IRecipe recipeFishNChips; - public static IRecipe recipeCheese; - public static IRecipe recipePumpkinStew; - public static IRecipe recipeCarrotJuice; - public static IRecipe recipeSpaghetti; - public static IRecipe recipeNoodle; - public static IRecipe recipeChocolate; - public static IRecipe recipeChocolateCake; - public static IRecipe recipeToast; - public static IRecipe recipeChocolateToast; - public static IRecipe recipeBacon; - - 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); - - //Bacon - 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); - - //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())); - 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)); - 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)); - 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); - recipeSubSandwich = RecipeUtil.lastIRecipe(); - - //French Fry - 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())); - 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())); - 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 - 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)); - recipePumpkinStew = RecipeUtil.lastIRecipe(); - - //Carrot Juice - 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)); - recipeSpaghetti = RecipeUtil.lastIRecipe(); - - //Noodle - 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)); - 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)); - recipeChocolateCake = RecipeUtil.lastIRecipe(); - - //Toast - RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemFoods, 2, TheFoods.TOAST.ordinal()), new ItemStack(Items.BREAD)); - recipeToast = RecipeUtil.lastIRecipe(); - - //Chocolate Toast - RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.CHOCOLATE_TOAST.ordinal()), new ItemStack(InitItems.itemFoods, 1, TheFoods.TOAST.ordinal()), new ItemStack(InitItems.itemFoods, 1, TheFoods.CHOCOLATE.ordinal())); - recipeChocolateToast = RecipeUtil.lastIRecipe(); - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java deleted file mode 100644 index 788057b21..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file ("InitCrafting.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.crafting; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntListValues; -import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.CactusFarmerBehavior; -import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.DefaultFarmerBehavior; -import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.MelonPumpkinFarmerBehavior; -import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.NetherWartFarmerBehavior; -import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.ReedFarmerBehavior; -import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.exu.EnderlillyFarmerBehavior; -import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.exu.RedOrchidFarmerBehavior; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.ResourceLocation; - -public final class InitCrafting { - - public static void init() { - ActuallyAdditions.LOGGER.info("Initializing Crafting Recipes..."); - - ItemCrafting.init(); - BlockCrafting.init(); - MiscCrafting.init(); - FoodCrafting.init(); - ToolCrafting.init(); - - ActuallyAdditionsAPI.addCompostRecipe(Ingredient.fromStacks(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.MASHED_FOOD.ordinal())), Blocks.LEAVES.getDefaultState(), new ItemStack(InitItems.itemFertilizer), Blocks.DIRT.getDefaultState()); - ActuallyAdditionsAPI.addCompostRecipe(Ingredient.fromItems(InitItems.itemCanolaSeed), Blocks.DIRT.getDefaultState(), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BIOMASS.ordinal()), Blocks.SOUL_SAND.getDefaultState()); - - int[] power = ConfigIntListValues.OIL_POWER.getValue(); - int[] time = ConfigIntListValues.OIL_TIME.getValue(); - ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidCanolaOil.getName(), power[0], time[0]); - ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidRefinedCanolaOil.getName(), power[1], time[1]); - ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidCrystalOil.getName(), power[2], time[2]); - ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidEmpoweredOil.getName(), power[3], time[3]); - - ActuallyAdditionsAPI.addFarmerBehavior(new DefaultFarmerBehavior()); - ActuallyAdditionsAPI.addFarmerBehavior(new CactusFarmerBehavior()); - ActuallyAdditionsAPI.addFarmerBehavior(new NetherWartFarmerBehavior()); - ActuallyAdditionsAPI.addFarmerBehavior(new ReedFarmerBehavior()); - ActuallyAdditionsAPI.addFarmerBehavior(new MelonPumpkinFarmerBehavior()); - ActuallyAdditionsAPI.addFarmerBehavior(new EnderlillyFarmerBehavior()); - ActuallyAdditionsAPI.addFarmerBehavior(new RedOrchidFarmerBehavior()); - - new RecipePotionRingCharging(new ResourceLocation(ActuallyAdditions.MODID, "potion_ring_charging")); - new RecipeBioMash(new ResourceLocation(ActuallyAdditions.MODID, "bio_mash")); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ItemCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ItemCrafting.java deleted file mode 100644 index 762fcaf8f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ItemCrafting.java +++ /dev/null @@ -1,386 +0,0 @@ -/* - * This file ("ItemCrafting.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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.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; -import net.minecraft.enchantment.EnchantmentData; -import net.minecraft.init.Blocks; -import net.minecraft.init.Enchantments; -import net.minecraft.init.Items; -import net.minecraft.init.PotionTypes; -import net.minecraft.item.ItemEnchantedBook; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.potion.PotionUtils; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.registry.GameRegistry; -import net.minecraftforge.oredict.OreDictionary; - -public final class ItemCrafting { - - public static final ArrayList RECIPES_POTION_RINGS = new ArrayList<>(); - public static final ArrayList RECIPES_DRILL_COLORING = new ArrayList<>(); - public static IRecipe recipePhantomConnector; - public static IRecipe recipeCoil; - public static IRecipe recipeCoilAdvanced; - public static IRecipe recipeBook; - public static IRecipe recipeTinyCoal; - public static IRecipe recipeTinyChar; - public static IRecipe recipeDrill; - public static IRecipe recipeDrillSpeedI; - public static IRecipe recipeDrillSpeedII; - public static IRecipe recipeDrillSpeedIII; - public static IRecipe recipeDrillFortuneI; - public static IRecipe recipeDrillFortuneII; - public static IRecipe recipeDrillSilk; - public static IRecipe recipeDrillPlacing; - public static IRecipe recipeDrillThree; - public static IRecipe recipeDrillFive; - public static IRecipe recipeBattery; - public static IRecipe recipeBatteryDouble; - public static IRecipe recipeBatteryTriple; - public static IRecipe recipeBatteryQuadruple; - public static IRecipe recipeBatteryQuintuple; - public static IRecipe recipeStaff; - public static IRecipe recipeGrowthRing; - public static IRecipe recipeMagnetRing; - public static IRecipe recipeWaterRing; - public static IRecipe recipeWings; - public static IRecipe recipeCup; - public static IRecipe recipeKnifeHandle; - public static IRecipe recipeKnifeBlade; - public static IRecipe recipeKnife; - public static IRecipe recipeRing; - public static IRecipe recipeDough; - public static IRecipe recipeRiceDough; - public static IRecipe recipeLeafBlower; - public static IRecipe recipeLeafBlowerAdvanced; - public static IRecipe recipeChestToCrateUpgrade; - public static IRecipe recipeSmallToMediumCrateUpgrade; - public static IRecipe recipeMediumToLargeCrateUpgrade; - public static IRecipe recipeLaserWrench; - public static IRecipe recipeDrillCore; - public static IRecipe recipeBlackDye; - public static IRecipe recipeLens; - public static IRecipe recipeCrateKeeper; - public static IRecipe recipeEnderStar; - public static IRecipe recipeSpawnerChanger; - public static IRecipe recipeFilter; - public static IRecipe recipePlayerProbe; - public static IRecipe recipeDisenchantingLens; - public static IRecipe recipeMiningLens; - public static IRecipe recipeBag; - public static IRecipe recipeVoidBag; - public static IRecipe recipeLensMoreDeath; - public static IRecipe recipeFillingWand; - public static IRecipe recipeLaserUpgradeInvisibility; - public static IRecipe recipeLaserUpgradeRange; - public static IRecipe recipeGoggles; - public static IRecipe recipeGogglesAdvanced; - - 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)); - 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"); - 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())); - 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())); - 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)); - 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())); - 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())); - recipeVoidBag = RecipeUtil.lastIRecipe(); - - //Lens - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), "GGG", "GBG", "GGG", 'G', "blockGlass", 'B', "gemQuartzBlack"); - recipeLens = RecipeUtil.lastIRecipe(); - - //Black Dye - 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)); - recipeBook = RecipeUtil.lastIRecipe(); - - //Clearing NBT Storage - RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemLaserWrench), new ItemStack(InitItems.itemLaserWrench)); - RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemPhantomConnector), new ItemStack(InitItems.itemPhantomConnector)); - 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"); - recipeChestToCrateUpgrade = RecipeUtil.lastIRecipe(); - - 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"); - 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())); - 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', "gemQuartzBlack", '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); - recipeLensMoreDeath = RecipeUtil.lastIRecipe(); - - //Filter - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemFilter), "III", "IQI", "III", 'I', new ItemStack(Blocks.IRON_BARS), 'Q', "gemQuartzBlack"); - recipeFilter = RecipeUtil.lastIRecipe(); - - //Crate Keeper - RecipeHandler.addOreDictRecipe(new ItemStack(InitItems.itemCrateKeeper), "WIW", "IQI", "WIW", 'I', "ingotIron", 'W', "plankWood", 'Q', "gemQuartzBlack"); - 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())); - 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())); - 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)); - - //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())); - 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())); - 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); - 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())); - 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)); - 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())); - 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); - 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())); - 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())); - 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())); - 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())); - 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())); - 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())); - 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())); - 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())); - 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())); - 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())); - 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())); - 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())); - 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())); - 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())); - 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())); - 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())); - 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()) : "gemQuartzBlack", '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"); - 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); - } - - //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"); - 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())); - recipeLeafBlowerAdvanced = RecipeUtil.lastIRecipe(); - - //Phantom Connector - 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)); - recipePlayerProbe = RecipeUtil.lastIRecipe(); - - //Quartz - 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())); - recipeKnife = RecipeUtil.lastIRecipe(); - - //Crafter on a Stick - 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)); - recipeTinyCoal = RecipeUtil.lastIRecipe(); - 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())); - } - - //Rice Seeds - 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())); - - //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); - - } - - 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()); - addRingRecipeWithStack(ThePotionRings.HASTE.craftingItem, ThePotionRings.HASTE.ordinal()); - addRingRecipeWithStack(ThePotionRings.STRENGTH.craftingItem, ThePotionRings.STRENGTH.ordinal()); - addRingRecipeWithStack(ThePotionRings.JUMP_BOOST.craftingItem, ThePotionRings.JUMP_BOOST.ordinal()); - addRingRecipeWithStack(ThePotionRings.REGEN.craftingItem, ThePotionRings.REGEN.ordinal()); - addRingRecipeWithStack(ThePotionRings.RESISTANCE.craftingItem, ThePotionRings.RESISTANCE.ordinal()); - addRingRecipeWithStack(ThePotionRings.FIRE_RESISTANCE.craftingItem, ThePotionRings.FIRE_RESISTANCE.ordinal()); - addRingRecipeWithStack(ThePotionRings.WATER_BREATHING.craftingItem, ThePotionRings.WATER_BREATHING.ordinal()); - addRingRecipeWithStack(ThePotionRings.INVISIBILITY.craftingItem, ThePotionRings.INVISIBILITY.ordinal()); - addRingRecipeWithStack(ThePotionRings.NIGHT_VISION.craftingItem, ThePotionRings.NIGHT_VISION.ordinal()); - } - - public static void addRingRecipeWithStack(ItemStack mainStack, int meta) { - ItemStack potion = new ItemStack(Items.POTIONITEM); - PotionUtils.addPotionToItemStack(potion, PotionTypes.AWKWARD); - - RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemPotionRing, 1, meta), mainStack, mainStack, mainStack, mainStack, new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.DIAMOND.ordinal()), new ItemStack(Items.NETHER_WART), potion, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RING.ordinal())); - RECIPES_POTION_RINGS.add(RecipeUtil.lastIRecipe()); - - RecipeHandler.addShapelessRecipe(new ItemStack(InitItems.itemPotionRingAdvanced, 1, meta), new ItemStack(InitItems.itemPotionRing, 1, meta), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.ENDER_STAR.ordinal())); - RECIPES_POTION_RINGS.add(RecipeUtil.lastIRecipe()); - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/MiscCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/MiscCrafting.java deleted file mode 100644 index c267f790d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/MiscCrafting.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This file ("MiscCrafting.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.crafting; - -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.util.RecipeUtil; -import de.ellpeck.actuallyadditions.mod.util.crafting.RecipeHandler; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraftforge.fml.common.registry.GameRegistry; - -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]; - - public static final IRecipe[] RECIPES_CRYSTALS = new IRecipe[TheCrystals.values().length]; - public static final IRecipe[] RECIPES_CRYSTAL_BLOCKS = new IRecipe[TheCrystals.values().length]; - - 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() { - - //Bio Coal - 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)); - 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)); - 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)); - 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"); - 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())); - 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)); - - //Knife Handle - 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)); - 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), "gemQuartzBlack", new ItemStack(Items.PRISMARINE_SHARD)); - ItemCrafting.recipeEnderStar = RecipeUtil.lastIRecipe(); - - //Spawner Shard -> ingot - GameRegistry.addSmelting(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.SPAWNER_SHARD.ordinal()), new ItemStack(Items.IRON_INGOT, 2), 5F); - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeBioMash.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeBioMash.java deleted file mode 100644 index 90a5c51ff..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeBioMash.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file ("RecipeBioMash.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.crafting; - -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.ItemKnife; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.crafting.RecipeHelper; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.registries.IForgeRegistryEntry; - -public class RecipeBioMash extends IForgeRegistryEntry.Impl implements IRecipe { - - public RecipeBioMash(ResourceLocation location) { - RecipeHelper.addRecipe(location.getPath(), this); - } - - @Override - public boolean matches(InventoryCrafting inv, World world) { - boolean foundFood = false; - boolean hasKnife = false; - - for (int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if (StackUtil.isValid(stack)) { - if (stack.getItem() instanceof ItemKnife) { - if (hasKnife) { - return false; - } else { - hasKnife = true; - } - } else if (stack.getItem() instanceof ItemFood) { - foundFood = true; - } else { - return false; - } - } - } - - return foundFood && hasKnife; - } - - @Override - public ItemStack getCraftingResult(InventoryCrafting inv) { - int amount = 0; - - 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(); - float heal = food.getHealAmount(stack); - float sat = food.getSaturationModifier(stack); - - amount += MathHelper.ceil(heal * sat); - } - } - } - - if (amount > 0 && amount <= 64) { - return new ItemStack(InitItems.itemMisc, amount, TheMiscItems.MASHED_FOOD.ordinal()); - } else { - return StackUtil.getEmpty(); - } - } - - @Override - public boolean canFit(int width, int height) { - return width * height > 5; - } - - @Override - public ItemStack getRecipeOutput() { - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index 58300bf8e..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShaped.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file ("RecipeKeepDataShaped.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.crafting; - -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.crafting.RecipeHelper; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.oredict.ShapedOreRecipe; - -public class RecipeKeepDataShaped extends ShapedOreRecipe { - - private final ItemStack nbtCopyStack; - - public RecipeKeepDataShaped(ResourceLocation group, ItemStack result, ItemStack nbtCopyStack, Object... recipe) { - super(group, result, recipe); - this.nbtCopyStack = nbtCopyStack; - - RecipeHelper.addRecipe(group.getPath(), this); - } - - @Override - public ItemStack getCraftingResult(InventoryCrafting inventory) { - ItemStack stack = super.getCraftingResult(inventory); - if (StackUtil.isValid(stack)) { - for (int i = 0; i < inventory.getSizeInventory(); i++) { - ItemStack input = inventory.getStackInSlot(i); - if (ItemUtil.areItemsEqual(this.nbtCopyStack, input, true)) { - stack.setTagCompound(input.getTagCompound()); - break; - } - } - } - return stack; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShapeless.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShapeless.java deleted file mode 100644 index fd85a8b56..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipeKeepDataShapeless.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file ("RecipeKeepDataShapeless.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.crafting; - -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.crafting.RecipeHelper; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.oredict.ShapelessOreRecipe; - -public class RecipeKeepDataShapeless extends ShapelessOreRecipe { - - private final ItemStack nbtCopyStack; - - public RecipeKeepDataShapeless(ResourceLocation group, ItemStack result, ItemStack nbtCopyStack, Object... recipe) { - super(group, result, recipe); - this.nbtCopyStack = nbtCopyStack; - - RecipeHelper.addRecipe(group.getPath(), this); - } - - @Override - public ItemStack getCraftingResult(InventoryCrafting inventory) { - ItemStack stack = super.getCraftingResult(inventory); - if (StackUtil.isValid(stack)) { - for (int i = 0; i < inventory.getSizeInventory(); i++) { - ItemStack input = inventory.getStackInSlot(i); - if (ItemUtil.areItemsEqual(this.nbtCopyStack, input, true)) { - stack.setTagCompound(input.getTagCompound()); - break; - } - } - } - return stack; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipePotionRingCharging.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipePotionRingCharging.java deleted file mode 100644 index 856eaba76..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/RecipePotionRingCharging.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This file ("RecipePotionRingCharging.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.crafting; - -import de.ellpeck.actuallyadditions.mod.items.ItemPotionRing; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.crafting.RecipeHelper; -import net.minecraft.init.Items; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.registries.IForgeRegistryEntry; - -public class RecipePotionRingCharging extends IForgeRegistryEntry.Impl implements IRecipe { - - public RecipePotionRingCharging(ResourceLocation location) { - RecipeHelper.addRecipe(location.getPath(), this); - } - - @Override - public boolean matches(InventoryCrafting inv, World worldIn) { - boolean hasRing = false; - - for (int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if (StackUtil.isValid(stack)) { - if (stack.getItem() instanceof ItemPotionRing) { - if (!hasRing) { - hasRing = true; - } else { - return false; - } - } else if (stack.getItem() != Items.BLAZE_POWDER) { return false; } - } - } - - return hasRing; - } - - @Override - public ItemStack getCraftingResult(InventoryCrafting inv) { - ItemStack inputRing = StackUtil.getEmpty(); - int totalBlaze = 0; - - for (int i = 0; i < inv.getSizeInventory(); i++) { - ItemStack stack = inv.getStackInSlot(i); - if (StackUtil.isValid(stack)) { - if (stack.getItem() instanceof ItemPotionRing) { - inputRing = stack; - } else if (stack.getItem() == Items.BLAZE_POWDER) { - totalBlaze += 20; - } - } - } - - if (StackUtil.isValid(inputRing) && totalBlaze > 0) { - ItemStack copy = inputRing.copy(); - - int total = ItemPotionRing.getStoredBlaze(copy) + totalBlaze; - if (total <= ItemPotionRing.MAX_BLAZE) { - ItemPotionRing.setStoredBlaze(copy, total); - return copy; - } - } - - return StackUtil.getEmpty(); - } - - @Override - public boolean canFit(int width, int height) { - return width * height > 3; - } - - @Override - public ItemStack getRecipeOutput() { - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index 2093c6531..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/ToolCrafting.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This file ("ToolCrafting.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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.util.RecipeUtil; -import de.ellpeck.actuallyadditions.mod.util.crafting.RecipeHandler; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; - -public final class ToolCrafting { - - public static final ArrayList RECIPES_PAXELS = new ArrayList<>(); - - 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("gemQuartzBlack", InitItems.itemPickaxeQuartz, InitItems.itemSwordQuartz, InitItems.itemAxeQuartz, InitItems.itemShovelQuartz, InitItems.itemHoeQuartz, InitItems.itemHelmQuartz, InitItems.itemChestQuartz, InitItems.itemPantsQuartz, InitItems.itemBootsQuartz); - addToolAndArmorRecipes(new ItemStack(Blocks.OBSIDIAN), InitItems.itemPickaxeObsidian, InitItems.itemSwordObsidian, InitItems.itemAxeObsidian, InitItems.itemShovelObsidian, InitItems.itemHoeObsidian, InitItems.itemHelmObsidian, InitItems.itemChestObsidian, InitItems.itemPantsObsidian, InitItems.itemBootsObsidian); - - addToolAndArmorRecipes(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), InitItems.itemPickaxeCrystalRed, InitItems.itemSwordCrystalRed, InitItems.itemAxeCrystalRed, InitItems.itemShovelCrystalRed, InitItems.itemHoeCrystalRed, InitItems.itemHelmCrystalRed, InitItems.itemChestCrystalRed, InitItems.itemPantsCrystalRed, InitItems.itemBootsCrystalRed); - addToolAndArmorRecipes(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), InitItems.itemPickaxeCrystalGreen, InitItems.itemSwordCrystalGreen, InitItems.itemAxeCrystalGreen, InitItems.itemShovelCrystalGreen, InitItems.itemHoeCrystalGreen, InitItems.itemHelmCrystalGreen, InitItems.itemChestCrystalGreen, InitItems.itemPantsCrystalGreen, InitItems.itemBootsCrystalGreen); - addToolAndArmorRecipes(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), InitItems.itemPickaxeCrystalWhite, InitItems.itemSwordCrystalWhite, InitItems.itemAxeCrystalWhite, InitItems.itemShovelCrystalWhite, InitItems.itemHoeCrystalWhite, InitItems.itemHelmCrystalWhite, InitItems.itemChestCrystalWhite, InitItems.itemPantsCrystalWhite, InitItems.itemBootsCrystalWhite); - addToolAndArmorRecipes(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), InitItems.itemPickaxeCrystalLightBlue, InitItems.itemSwordCrystalLightBlue, InitItems.itemAxeCrystalLightBlue, InitItems.itemShovelCrystalLightBlue, InitItems.itemHoeCrystalLightBlue, InitItems.itemHelmCrystalLightBlue, InitItems.itemChestCrystalLightBlue, InitItems.itemPantsCrystalLightBlue, InitItems.itemBootsCrystalLightBlue); - addToolAndArmorRecipes(new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), InitItems.itemPickaxeCrystalBlue, InitItems.itemSwordCrystalBlue, InitItems.itemAxeCrystalBlue, InitItems.itemShovelCrystalBlue, InitItems.itemHoeCrystalBlue, InitItems.itemHelmCrystalBlue, InitItems.itemChestCrystalBlue, InitItems.itemPantsCrystalBlue, InitItems.itemBootsCrystalBlue); - 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)); - 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)); - 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)); - 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)); - 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)); - 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)); - 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)); - 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)); - 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)); - 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)); - 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)); - 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)); - 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)); - 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)); - RECIPES_PAXELS.add(RecipeUtil.lastIRecipe()); - } - - public static void addToolAndArmorRecipes(Object 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)); - - //Sword - 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)); - - //Shovel - 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)); - - //Helm - RecipeHandler.addShapedRecipe(new ItemStack(helm), "OOO", "O O", 'O', base); - - //Chest - RecipeHandler.addShapedRecipe(new ItemStack(chest), "O O", "OOO", "OOO", 'O', base); - - //Legs - RecipeHandler.addShapedRecipe(new ItemStack(pants), "OOO", "O O", "O O", 'O', base); - - //Boots - 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 deleted file mode 100644 index 324dcec70..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/creative/CreativeTab.java +++ /dev/null @@ -1,363 +0,0 @@ -/* - * This file ("CreativeTab.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.creative; - -import de.ellpeck.actuallyadditions.api.misc.IDisableableItem; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import net.minecraft.block.Block; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidUtil; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class CreativeTab extends CreativeTabs { - - public static final CreativeTab INSTANCE = new CreativeTab(); - private NonNullList list; - - public CreativeTab() { - super(ActuallyAdditions.MODID); - this.setBackgroundImageName(ActuallyAdditions.MODID + ".png"); - } - - @Override - public boolean hasSearchBar() { - return true; - } - - @Override - public int getSearchbarWidth() { - return 70; - } - - @Override - public ItemStack createIcon() { - return new ItemStack(InitItems.itemBooklet); - } - - @Override - @SideOnly(Side.CLIENT) - public void displayAllRelevantItems(NonNullList list) { - this.list = list; - - this.add(InitItems.itemBooklet); - this.add(InitBlocks.blockSmileyCloud); - this.add(InitBlocks.blockTinyTorch); - - this.add(InitBlocks.blockFireworkBox); - this.add(InitBlocks.blockLaserRelay); - this.add(InitBlocks.blockLaserRelayAdvanced); - this.add(InitBlocks.blockLaserRelayExtreme); - this.add(InitBlocks.blockLaserRelayFluids); - this.add(InitBlocks.blockLaserRelayItem); - this.add(InitBlocks.blockLaserRelayItemWhitelist); - this.add(InitBlocks.blockItemViewer); - this.add(InitBlocks.blockItemViewerHopping); - this.add(InitBlocks.blockAtomicReconstructor); - this.add(InitBlocks.blockEmpowerer); - this.add(InitBlocks.blockPhantomface); - this.add(InitBlocks.blockPhantomEnergyface); - this.add(InitBlocks.blockPhantomLiquiface); - this.add(InitBlocks.blockPhantomRedstoneface); - this.add(InitBlocks.blockPhantomPlacer); - this.add(InitBlocks.blockPhantomBreaker); - this.add(InitBlocks.blockPlayerInterface); - this.add(InitBlocks.blockInputter); - this.add(InitBlocks.blockInputterAdvanced); - this.add(InitBlocks.blockPhantomBooster); - this.add(InitBlocks.blockCoffeeMachine); - this.add(InitBlocks.blockXPSolidifier); - this.add(InitBlocks.blockDisplayStand); - - this.add(InitBlocks.blockFarmer); - this.add(InitBlocks.blockShockSuppressor); - this.add(InitBlocks.blockMiner); - this.add(InitBlocks.blockGreenhouseGlass); - this.add(InitBlocks.blockGrinder); - this.add(InitBlocks.blockGrinderDouble); - this.add(InitBlocks.blockFurnaceDouble); - this.add(InitBlocks.blockLavaFactoryController); - - this.add(InitBlocks.blockEnergizer); - this.add(InitBlocks.blockEnervator); - - this.add(InitBlocks.blockFurnaceSolar); - this.add(InitBlocks.blockHeatCollector); - this.add(InitBlocks.blockCoalGenerator); - this.add(InitBlocks.blockOilGenerator); - this.add(InitBlocks.blockLeafGenerator); - this.add(InitBlocks.blockBioReactor); - - this.add(InitBlocks.blockItemRepairer); - this.add(InitBlocks.blockFishingNet); - this.add(InitBlocks.blockBreaker); - this.add(InitBlocks.blockDirectionalBreaker); - this.add(InitBlocks.blockRangedCollector); - this.add(InitBlocks.blockPlacer); - this.add(InitBlocks.blockDropper); - this.add(InitBlocks.blockFluidPlacer); - this.add(InitBlocks.blockFluidCollector); - this.add(InitBlocks.blockBatteryBox); - - this.add(InitBlocks.blockMisc); - this.add(InitBlocks.blockFeeder); - this.add(InitBlocks.blockCompost); - this.add(InitBlocks.blockGiantChest); - this.add(InitBlocks.blockGiantChestMedium); - this.add(InitBlocks.blockGiantChestLarge); - this.add(InitBlocks.blockCanolaPress); - this.add(InitBlocks.blockFermentingBarrel); - - this.add(InitBlocks.blockTestifiBucksGreenWall); - this.add(InitBlocks.blockTestifiBucksWhiteWall); - this.add(InitBlocks.blockTestifiBucksGreenStairs); - this.add(InitBlocks.blockTestifiBucksWhiteStairs); - this.add(InitBlocks.blockTestifiBucksGreenSlab); - this.add(InitBlocks.blockTestifiBucksWhiteSlab); - this.add(InitBlocks.blockTestifiBucksGreenFence); - this.add(InitBlocks.blockTestifiBucksWhiteFence); - - this.add(InitBlocks.blockQuartzWall); - this.add(InitBlocks.blockQuartzStair); - this.add(InitBlocks.blockQuartzSlab); - this.add(InitBlocks.blockChiseledQuartzWall); - this.add(InitBlocks.blockChiseledQuartzStair); - this.add(InitBlocks.blockChiseledQuartzSlab); - this.add(InitBlocks.blockPillarQuartzWall); - this.add(InitBlocks.blockPillarQuartzStair); - this.add(InitBlocks.blockPillarQuartzSlab); - - this.add(InitBlocks.blockColoredLamp); - this.add(InitBlocks.blockColoredLampOn); - this.add(InitBlocks.blockLampPowerer); - this.add(InitBlocks.blockTreasureChest); - - this.add(InitBlocks.blockBlackLotus); - - this.add(InitItems.itemBag); - this.add(InitItems.itemVoidBag); - - this.add(InitItems.itemWorm); - this.add(InitItems.itemPlayerProbe); - this.add(InitItems.itemColorLens); - this.add(InitItems.itemExplosionLens); - this.add(InitItems.itemDamageLens); - this.add(InitItems.itemMoreDamageLens); - this.add(InitItems.itemDisenchantingLens); - this.add(InitItems.itemMiningLens); - this.add(InitItems.itemLaserWrench); - this.add(InitItems.itemLaserUpgradeInvisibility); - this.add(InitItems.itemLaserUpgradeRange); - this.add(InitItems.itemEngineerGoggles); - this.add(InitItems.itemEngineerGogglesAdvanced); - this.add(InitItems.itemCrateKeeper); - this.add(InitItems.itemChestToCrateUpgrade); - this.add(InitItems.itemSmallToMediumCrateUpgrade); - this.add(InitItems.itemMediumToLargeCrateUpgrade); - this.add(InitItems.itemSpawnerChanger); - this.add(InitItems.itemWaterBowl); - - this.add(InitItems.itemDrill); - this.add(InitItems.itemDrillUpgradeSpeed); - this.add(InitItems.itemDrillUpgradeSpeedII); - this.add(InitItems.itemDrillUpgradeSpeedIII); - this.add(InitItems.itemDrillUpgradeSilkTouch); - this.add(InitItems.itemDrillUpgradeFortune); - this.add(InitItems.itemDrillUpgradeFortuneII); - this.add(InitItems.itemDrillUpgradeThreeByThree); - this.add(InitItems.itemDrillUpgradeFiveByFive); - this.add(InitItems.itemDrillUpgradeBlockPlacing); - this.add(InitItems.itemBattery); - this.add(InitItems.itemBatteryDouble); - this.add(InitItems.itemBatteryTriple); - this.add(InitItems.itemBatteryQuadruple); - this.add(InitItems.itemBatteryQuintuple); - this.add(InitItems.itemTeleStaff); - this.add(InitItems.itemFillingWand); - - this.add(InitItems.itemGrowthRing); - this.add(InitItems.itemMagnetRing); - this.add(InitItems.itemWaterRemovalRing); - - this.list.add(FluidUtil.getFilledBucket(new FluidStack(InitFluids.fluidCanolaOil, Fluid.BUCKET_VOLUME))); - this.list.add(FluidUtil.getFilledBucket(new FluidStack(InitFluids.fluidRefinedCanolaOil, Fluid.BUCKET_VOLUME))); - this.list.add(FluidUtil.getFilledBucket(new FluidStack(InitFluids.fluidCrystalOil, Fluid.BUCKET_VOLUME))); - this.list.add(FluidUtil.getFilledBucket(new FluidStack(InitFluids.fluidEmpoweredOil, Fluid.BUCKET_VOLUME))); - - this.add(InitItems.itemPhantomConnector); - this.add(InitItems.itemFilter); - this.add(InitItems.itemWingsOfTheBats); - - this.add(InitItems.itemCoffeeSeed); - this.add(InitItems.itemCoffeeBean); - this.add(InitItems.itemRiceSeed); - this.add(InitItems.itemCanolaSeed); - this.add(InitItems.itemFlaxSeed); - this.add(InitItems.itemHairyBall); - this.add(InitItems.itemMisc); - this.add(InitItems.itemResonantRice); - this.add(InitItems.itemFertilizer); - - this.add(InitItems.itemCoffee); - this.add(InitItems.itemFoods); - this.add(InitItems.itemKnife); - this.add(InitItems.itemCrafterOnAStick); - this.add(InitItems.itemDust); - this.add(InitItems.itemSolidifiedExperience); - this.add(InitItems.itemLeafBlower); - this.add(InitItems.itemLeafBlowerAdvanced); - - this.add(InitItems.woodenPaxel); - this.add(InitItems.stonePaxel); - this.add(InitItems.ironPaxel); - this.add(InitItems.goldPaxel); - this.add(InitItems.diamondPaxel); - this.add(InitItems.emeraldPaxel); - this.add(InitItems.obsidianPaxel); - this.add(InitItems.quartzPaxel); - this.add(InitItems.itemPaxelCrystalRed); - this.add(InitItems.itemPaxelCrystalBlue); - this.add(InitItems.itemPaxelCrystalLightBlue); - this.add(InitItems.itemPaxelCrystalBlack); - this.add(InitItems.itemPaxelCrystalGreen); - this.add(InitItems.itemPaxelCrystalWhite); - - this.add(InitBlocks.blockCrystalClusterRedstone); - this.add(InitBlocks.blockCrystalClusterLapis); - this.add(InitBlocks.blockCrystalClusterDiamond); - this.add(InitBlocks.blockCrystalClusterCoal); - this.add(InitBlocks.blockCrystalClusterEmerald); - this.add(InitBlocks.blockCrystalClusterIron); - this.add(InitBlocks.blockCrystal); - this.add(InitBlocks.blockCrystalEmpowered); - this.add(InitItems.itemCrystal); - this.add(InitItems.itemCrystalEmpowered); - this.add(InitItems.itemCrystalShard); - - this.add(InitItems.itemJams); - - this.add(InitItems.itemPotionRing); - this.add(InitItems.itemPotionRingAdvanced); - - this.add(InitItems.itemPickaxeQuartz); - this.add(InitItems.itemSwordQuartz); - this.add(InitItems.itemAxeQuartz); - this.add(InitItems.itemShovelQuartz); - this.add(InitItems.itemHoeQuartz); - - this.add(InitItems.itemHelmQuartz); - this.add(InitItems.itemChestQuartz); - this.add(InitItems.itemPantsQuartz); - this.add(InitItems.itemBootsQuartz); - - this.add(InitItems.itemPickaxeEmerald); - this.add(InitItems.itemSwordEmerald); - this.add(InitItems.itemAxeEmerald); - this.add(InitItems.itemShovelEmerald); - this.add(InitItems.itemHoeEmerald); - - this.add(InitItems.itemHelmEmerald); - this.add(InitItems.itemChestEmerald); - this.add(InitItems.itemPantsEmerald); - this.add(InitItems.itemBootsEmerald); - - this.add(InitItems.itemPickaxeObsidian); - this.add(InitItems.itemSwordObsidian); - this.add(InitItems.itemAxeObsidian); - this.add(InitItems.itemShovelObsidian); - this.add(InitItems.itemHoeObsidian); - - this.add(InitItems.itemHelmObsidian); - this.add(InitItems.itemChestObsidian); - this.add(InitItems.itemPantsObsidian); - this.add(InitItems.itemBootsObsidian); - - this.add(InitItems.itemPickaxeCrystalRed); - this.add(InitItems.itemAxeCrystalRed); - this.add(InitItems.itemShovelCrystalRed); - this.add(InitItems.itemSwordCrystalRed); - this.add(InitItems.itemHoeCrystalRed); - this.add(InitItems.itemHelmCrystalRed); - this.add(InitItems.itemChestCrystalRed); - this.add(InitItems.itemPantsCrystalRed); - this.add(InitItems.itemBootsCrystalRed); - - this.add(InitItems.itemPickaxeCrystalBlue); - this.add(InitItems.itemAxeCrystalBlue); - this.add(InitItems.itemShovelCrystalBlue); - this.add(InitItems.itemSwordCrystalBlue); - this.add(InitItems.itemHoeCrystalBlue); - this.add(InitItems.itemHelmCrystalBlue); - this.add(InitItems.itemChestCrystalBlue); - this.add(InitItems.itemPantsCrystalBlue); - this.add(InitItems.itemBootsCrystalBlue); - - this.add(InitItems.itemPickaxeCrystalLightBlue); - this.add(InitItems.itemAxeCrystalLightBlue); - this.add(InitItems.itemShovelCrystalLightBlue); - this.add(InitItems.itemSwordCrystalLightBlue); - this.add(InitItems.itemHoeCrystalLightBlue); - this.add(InitItems.itemHelmCrystalLightBlue); - this.add(InitItems.itemChestCrystalLightBlue); - this.add(InitItems.itemPantsCrystalLightBlue); - this.add(InitItems.itemBootsCrystalLightBlue); - - this.add(InitItems.itemPickaxeCrystalBlack); - this.add(InitItems.itemAxeCrystalBlack); - this.add(InitItems.itemShovelCrystalBlack); - this.add(InitItems.itemSwordCrystalBlack); - this.add(InitItems.itemHoeCrystalBlack); - this.add(InitItems.itemHelmCrystalBlack); - this.add(InitItems.itemChestCrystalBlack); - this.add(InitItems.itemPantsCrystalBlack); - this.add(InitItems.itemBootsCrystalBlack); - - this.add(InitItems.itemPickaxeCrystalGreen); - this.add(InitItems.itemAxeCrystalGreen); - this.add(InitItems.itemShovelCrystalGreen); - this.add(InitItems.itemSwordCrystalGreen); - this.add(InitItems.itemHoeCrystalGreen); - this.add(InitItems.itemHelmCrystalGreen); - this.add(InitItems.itemChestCrystalGreen); - this.add(InitItems.itemPantsCrystalGreen); - this.add(InitItems.itemBootsCrystalGreen); - - this.add(InitItems.itemPickaxeCrystalWhite); - this.add(InitItems.itemAxeCrystalWhite); - this.add(InitItems.itemShovelCrystalWhite); - this.add(InitItems.itemSwordCrystalWhite); - this.add(InitItems.itemHoeCrystalWhite); - this.add(InitItems.itemHelmCrystalWhite); - this.add(InitItems.itemChestCrystalWhite); - this.add(InitItems.itemPantsCrystalWhite); - this.add(InitItems.itemBootsCrystalWhite); - } - - 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) { - 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 deleted file mode 100644 index 9163566a8..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/data/PlayerData.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * This file ("PlayerData.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public final class PlayerData { - - public static PlayerSave getDataFromPlayer(EntityPlayer player) { - WorldData worldData = WorldData.get(player.getEntityWorld()); - ConcurrentHashMap data = worldData.playerSaveData; - UUID id = player.getUniqueID(); - - if (data.containsKey(id)) { - PlayerSave save = data.get(id); - if (save != null && save.id != null && save.id.equals(id)) { return save; } - } - - //Add Data if none is existant - PlayerSave save = new PlayerSave(id); - data.put(id, save); - worldData.markDirty(); - return save; - } - - public static class PlayerSave { - - public UUID id; - - public boolean bookGottenAlready; - public boolean didBookTutorial; - public boolean hasBatWings; - public boolean shouldDisableBatWings; - public int batWingsFlyTime; - - public IBookletPage[] bookmarks = new IBookletPage[12]; - public List completedTrials = new ArrayList<>(); - - @SideOnly(Side.CLIENT) - public GuiBooklet lastOpenBooklet; - - public PlayerSave(UUID id) { - this.id = id; - } - - public void readFromNBT(NBTTagCompound compound, boolean savingToFile) { - this.bookGottenAlready = compound.getBoolean("BookGotten"); - this.didBookTutorial = compound.getBoolean("DidTutorial"); - - this.hasBatWings = compound.getBoolean("HasBatWings"); - this.batWingsFlyTime = compound.getInteger("BatWingsFlyTime"); - - NBTTagList bookmarks = compound.getTagList("Bookmarks", 8); - this.loadBookmarks(bookmarks); - - NBTTagList trials = compound.getTagList("Trials", 8); - this.loadTrials(trials); - - if (!savingToFile) { - this.shouldDisableBatWings = compound.getBoolean("ShouldDisableWings"); - } - } - - public void writeToNBT(NBTTagCompound compound, boolean savingToFile) { - compound.setBoolean("BookGotten", this.bookGottenAlready); - compound.setBoolean("DidTutorial", this.didBookTutorial); - - compound.setBoolean("HasBatWings", this.hasBatWings); - compound.setInteger("BatWingsFlyTime", this.batWingsFlyTime); - - compound.setTag("Bookmarks", this.saveBookmarks()); - compound.setTag("Trials", this.saveTrials()); - - if (!savingToFile) { - compound.setBoolean("ShouldDisableWings", this.shouldDisableBatWings); - } - } - - public NBTTagList saveBookmarks() { - NBTTagList bookmarks = new NBTTagList(); - 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++) { - String strg = bookmarks.getStringTagAt(i); - if (strg != null && !strg.isEmpty()) { - IBookletPage page = BookletUtils.getBookletPageById(strg); - this.bookmarks[i] = page; - } else { - this.bookmarks[i] = null; - } - } - } - - public NBTTagList saveTrials() { - NBTTagList trials = new NBTTagList(); - for (String trial : this.completedTrials) { - trials.appendTag(new NBTTagString(trial)); - } - return trials; - } - - public void loadTrials(NBTTagList trials) { - this.completedTrials.clear(); - - for (int i = 0; i < trials.tagCount(); i++) { - String strg = trials.getStringTagAt(i); - if (strg != null && !strg.isEmpty()) { - this.completedTrials.add(strg); - } - } - } - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/data/WorldData.java b/src/main/java/de/ellpeck/actuallyadditions/mod/data/WorldData.java deleted file mode 100644 index a9544df07..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/data/WorldData.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * This file ("WorldData.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.data; - -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; - -import de.ellpeck.actuallyadditions.api.laser.Network; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave; -import de.ellpeck.actuallyadditions.mod.misc.apiimpl.LaserRelayConnectionHandler; -import io.netty.util.internal.ConcurrentSet; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.world.World; -import net.minecraft.world.storage.WorldSavedData; - -public class WorldData extends WorldSavedData { - - public static final String DATA_TAG = ActuallyAdditions.MODID + "data"; - private static WorldData data; - public final ConcurrentSet laserRelayNetworks = new ConcurrentSet<>(); - public final ConcurrentHashMap playerSaveData = new ConcurrentHashMap<>(); - - public WorldData(String name) { - super(name); - } - - public static WorldData get(World world, boolean forceLoad) { - WorldData w = getInternal(world, forceLoad); - if (w == null) ActuallyAdditions.LOGGER.error("An impossible bug has occured."); - return w == null ? new WorldData(DATA_TAG) : w; - } - - private static WorldData getInternal(World world, boolean forceLoad) { - if (forceLoad || data == null) { - if (!world.isRemote) { - WorldSavedData savedData = world.loadData(WorldData.class, DATA_TAG); - - if (savedData == null) { - ActuallyAdditions.LOGGER.info("No WorldData found, creating..."); - - WorldData newData = new WorldData(DATA_TAG); - world.setData(DATA_TAG, newData); - data = newData; - } else { - data = (WorldData) savedData; - ActuallyAdditions.LOGGER.info("Successfully loaded WorldData!"); - } - } else { - data = new WorldData(DATA_TAG); - ActuallyAdditions.LOGGER.info("Created temporary WorldData to cache data on the client!"); - } - } - return data; - } - - public static void clear() { - if (data != null) { - data = null; - ActuallyAdditions.LOGGER.info("Unloaded WorldData!"); - } - } - - public static WorldData get(World world) { - return get(world, false); - } - - @Override - public void readFromNBT(NBTTagCompound compound) { - this.laserRelayNetworks.clear(); - NBTTagList networkList = compound.getTagList("Networks", 10); - for (int i = 0; i < networkList.tagCount(); i++) { - Network network = LaserRelayConnectionHandler.readNetworkFromNBT(networkList.getCompoundTagAt(i)); - this.laserRelayNetworks.add(network); - } - - this.playerSaveData.clear(); - NBTTagList playerList = compound.getTagList("PlayerData", 10); - for (int i = 0; i < playerList.tagCount(); i++) { - NBTTagCompound player = playerList.getCompoundTagAt(i); - - UUID id = player.getUniqueId("UUID"); - NBTTagCompound data = player.getCompoundTag("Data"); - - PlayerSave save = new PlayerSave(id); - save.readFromNBT(data, true); - this.playerSaveData.put(id, save); - } - } - - @Override - public NBTTagCompound writeToNBT(NBTTagCompound compound) { - //Laser World Data - NBTTagList networkList = new NBTTagList(); - for (Network network : this.laserRelayNetworks) { - networkList.appendTag(LaserRelayConnectionHandler.writeNetworkToNBT(network)); - } - compound.setTag("Networks", networkList); - - //Player Data - NBTTagList playerList = new NBTTagList(); - for (PlayerSave save : this.playerSaveData.values()) { - NBTTagCompound player = new NBTTagCompound(); - player.setUniqueId("UUID", save.id); - - NBTTagCompound data = new NBTTagCompound(); - save.writeToNBT(data, true); - player.setTag("Data", data); - - playerList.appendTag(player); - } - compound.setTag("PlayerData", playerList); - - return compound; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java deleted file mode 100644 index 6e6e80e54..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * This file ("EntityWorm.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.entity; - -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; -import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.DefaultFarmerBehavior; -import net.minecraft.block.Block; -import net.minecraft.block.BlockBush; -import net.minecraft.block.BlockDirt; -import net.minecraft.block.BlockFarmland; -import net.minecraft.block.BlockGrass; -import net.minecraft.block.IGrowable; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.Entity; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.common.IPlantable; - -public class EntityWorm extends Entity { - - public int timer; - - public EntityWorm(World world) { - super(world); - this.setEntityBoundingBox(null); - } - - 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) { - 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 { - return false; - } - } - - @Override - protected void entityInit() { - - } - - @Override - protected void readEntityFromNBT(NBTTagCompound compound) { - this.timer = compound.getInteger("Timer"); - } - - @Override - protected void writeEntityToNBT(NBTTagCompound compound) { - compound.setInteger("Timer", this.timer); - } - - @Override - public void onUpdate() { - this.onEntityUpdate(); - } - - @Override - 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); - IBlockState state = this.world.getBlockState(pos); - Block block = state.getBlock(); - boolean isMiddlePose = x == 0 && z == 0; - - 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) 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.rand.nextFloat() >= 0.95F) { - BlockPos plant = pos.up(); - 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)) { - plantBlock.updateTick(this.world, plant, plantState, this.world.rand); - - IBlockState newState = this.world.getBlockState(plant); - if (newState != plantState) { - this.world.playEvent(2005, plant, 0); - } - } - } - } - } else if (isMiddlePose) { - this.setDead(); - } - } - } - } - - int dieTime = ConfigIntValues.WORMS_DIE_TIME.getValue(); - 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 deleted file mode 100644 index 643cf3402..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/InitEntities.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file ("InitEntities.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.entity; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.client.registry.RenderingRegistry; -import net.minecraftforge.fml.common.registry.EntityRegistry; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public final class InitEntities { - - 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); - } - - @SideOnly(Side.CLIENT) - 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 deleted file mode 100644 index 761e11775..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/RenderWorm.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file ("RenderWorm.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.entity; - -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class RenderWorm extends Render { - - private static ItemStack stack = ItemStack.EMPTY; - - public static void fixItemStack() { - stack = new ItemStack(InitItems.itemWorm); - } - - protected RenderWorm(RenderManager renderManager) { - super(renderManager); - } - - @Override - 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) { - 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(0, 0, 0.4); - - stack.setStackDisplayName(entity.getName()); - AssetUtil.renderItemInWorld(stack); - - GlStateManager.popMatrix(); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java b/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java deleted file mode 100644 index 50c8864ab..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * This file ("ClientEvents.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.event; - -import java.util.Locale; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay; -import de.ellpeck.actuallyadditions.mod.config.ConfigValues; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; -import de.ellpeck.actuallyadditions.mod.data.WorldData; -import de.ellpeck.actuallyadditions.mod.inventory.gui.EnergyDisplay; -import de.ellpeck.actuallyadditions.mod.items.ItemWingsOfTheBats; -import de.ellpeck.actuallyadditions.mod.tile.IEnergyDisplay; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemSword; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.client.event.RenderGameOverlayEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.oredict.OreDictionary; - -@SideOnly(Side.CLIENT) -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 EnergyDisplay energyDisplay; - - public ClientEvents() { - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onClientTick(ClientTickEvent event) { - if (event.phase == Phase.END) { - Minecraft mc = Minecraft.getMinecraft(); - - if (mc.world == null) { - WorldData.clear(); - } - } - } - - @SubscribeEvent - public void onTooltipEvent(ItemTooltipEvent event) { - ItemStack stack = event.getItemStack(); - if (StackUtil.isValid(stack)) { - //Be da bland - 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 (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") + ":"); - - //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)); - } - } 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())); - - //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); - } - - //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 : "")); - - //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); - } - - //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()) { - 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 { - 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") + "]"); - } - } - - //Disabling Info - 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")); - } - } - } - } - } - - @SubscribeEvent - 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 (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 (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"); - } 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); - } - } - - 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); - - GlStateManager.pushMatrix(); - GlStateManager.color(1F, 1F, 1F, 1F); - energyDisplay.draw(); - GlStateManager.popMatrix(); - } - } - } - } - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java b/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java deleted file mode 100644 index 04fec3e6b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * This file ("CommonEvents.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.event; - -import java.util.Locale; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; -import de.ellpeck.actuallyadditions.mod.data.PlayerData; -import de.ellpeck.actuallyadditions.mod.data.WorldData; -import de.ellpeck.actuallyadditions.mod.inventory.ContainerBag; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.ItemBag; -import de.ellpeck.actuallyadditions.mod.items.ItemDrill; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; -import de.ellpeck.actuallyadditions.mod.tile.FilterSettings; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.monster.EntitySpider; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraftforge.event.entity.living.LivingDropsEvent; -import net.minecraftforge.event.entity.player.EntityItemPickupEvent; -import net.minecraftforge.event.world.BlockEvent; -import net.minecraftforge.fml.common.eventhandler.Event; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.PlayerEvent; - -public class CommonEvents { - - @SubscribeEvent - public void onBlockBreakEvent(BlockEvent.HarvestDropsEvent event) { - IBlockState state = event.getState(); - 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; } - - EntityPlayer player = event.getEntityPlayer(); - EntityItem item = event.getItem(); - 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) { - - ItemStack invStack = player.inventory.getStackInSlot(i); - if (StackUtil.isValid(invStack) && invStack.getItem() instanceof ItemBag && invStack.hasTagCompound()) { - if (invStack.getTagCompound().getBoolean("AutoInsert")) { - boolean changed = false; - - 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) { - stack.setCount(0); - changed = true; - } 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) { - inv.setStackInSlot(j, StackUtil.grow(bagStack, maxTransfer)); - stack.shrink(maxTransfer); - changed = true; - } - } - } else { - inv.setStackInSlot(j, stack.copy()); - stack.setCount(0); - changed = true; - } - - if (!StackUtil.isValid(stack)) { - break; - } - } - } - } - - if (changed) { - if (!isVoid) { - ItemDrill.writeSlotsToNBT(inv, invStack); - } - event.setResult(Event.Result.ALLOW); - } - } - } - } - - if (!StackUtil.isValid(stack)) { - break; - } - } - } - - item.setItem(stack); - } - } - - //TODO Checking Achievements? - /*public static void checkAchievements(ItemStack gotten, EntityPlayer player, InitAchievements.Type type){ - if(gotten != null && player != null){ - for(TheAchievements ach : TheAchievements.values()){ - if(ach.type == type){ - if(ItemUtil.contains(ach.itemsToBeGotten, gotten, true)){ - ach.get(player); - } - } - } - } - }*/ - - @SubscribeEvent - 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))); - } - } - } - } - - @SubscribeEvent - 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() + "."); - } - } - - @SubscribeEvent - 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) { - - String name = event.crafting.getItem().getRegistryName().toString(); - if (name != null && name.toLowerCase(Locale.ROOT).contains(ActuallyAdditions.MODID)) { - PlayerData.PlayerSave save = PlayerData.getDataFromPlayer(event.player); - if (save != null && !save.bookGottenAlready) { - save.bookGottenAlready = true; - WorldData.get(event.player.getEntityWorld()).markDirty(); - - EntityItem entityItem = new EntityItem(event.player.world, event.player.posX, event.player.posY, event.player.posZ, new ItemStack(InitItems.itemBooklet)); - entityItem.setPickupDelay(0); - event.player.world.spawnEntity(entityItem); - } - } - } - } - } - - @SubscribeEvent - public void onSmeltedEvent(PlayerEvent.ItemSmeltedEvent event) { - //checkAchievements(event.smelting, event.player, InitAchievements.Type.SMELTING); - } - - @SubscribeEvent - 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 deleted file mode 100644 index 46d56d317..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/FluidAA.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * This file ("FluidAA.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.fluids; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.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")); - } - - @Override - 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 deleted file mode 100644 index b672c5748..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/InitFluids.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file ("InitFluids.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.item.EnumRarity; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; - -public final class InitFluids { - - public static Fluid fluidCanolaOil; - public static Fluid fluidRefinedCanolaOil; - public static Fluid fluidCrystalOil; - public static Fluid fluidEmpoweredOil; - - public static Block blockCanolaOil; - public static Block blockRefinedCanolaOil; - public static Block blockCrystalOil; - public static Block blockEmpoweredOil; - - 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); - fluidEmpoweredOil = registerFluid("empoweredoil", "block_empowered_oil", EnumRarity.EPIC); - - blockCanolaOil = registerFluidBlock(fluidCanolaOil, Material.WATER, "block_canola_oil"); - blockRefinedCanolaOil = registerFluidBlock(fluidRefinedCanolaOil, Material.WATER, "block_refined_canola_oil"); - blockCrystalOil = registerFluidBlock(fluidCrystalOil, Material.WATER, "block_crystal_oil"); - blockEmpoweredOil = registerFluidBlock(fluidEmpoweredOil, Material.WATER, "block_empowered_oil"); - } - - 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); - - return FluidRegistry.getFluid(fluid.getName()); - } - - 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/AAWorldGen.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/AAWorldGen.java deleted file mode 100644 index 3db235c7d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/AAWorldGen.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * This file ("OreGen.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.gen; - -import java.util.ArrayList; -import java.util.Random; - -import org.apache.commons.lang3.ArrayUtils; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.BlockMisc; -import de.ellpeck.actuallyadditions.mod.blocks.BlockWildPlant; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks; -import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheWildPlants; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntListValues; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import net.minecraft.block.Block; -import net.minecraft.block.BlockHorizontal; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.block.state.pattern.BlockMatcher; -import net.minecraft.init.Blocks; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraft.world.WorldType; -import net.minecraft.world.biome.BiomeOcean; -import net.minecraft.world.chunk.IChunkProvider; -import net.minecraft.world.gen.IChunkGenerator; -import net.minecraft.world.gen.feature.WorldGenMinable; -import net.minecraft.world.gen.structure.StructureBoundingBox; -import net.minecraftforge.event.terraingen.DecorateBiomeEvent; -import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType; -import net.minecraftforge.fml.common.IWorldGenerator; -import net.minecraftforge.fml.common.eventhandler.Event; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -public class AAWorldGen implements IWorldGenerator { - - public static final int QUARTZ_MIN = 0; - public static final int QUARTZ_MAX = 45; - - private final WorldGenLushCaves caveGen = new WorldGenLushCaves(); - - public AAWorldGen() { - ActuallyAdditions.LOGGER.info("Registering World Generator..."); - } - - @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { - int dimension = world.provider.getDimension(); - if (dimension != -1 && dimension != 1) { - if (world.getWorldType() != WorldType.FLAT && canGen(world.provider.getDimension())) { - this.generateDefault(world, random, chunkX, chunkZ); - } - } - } - - private boolean canGen(int dimension) { - boolean inList = ArrayUtils.contains(ConfigIntListValues.ORE_GEN_DIMENSION_BLACKLIST.getValue(), dimension); - return (inList && ConfigBoolValues.ORE_GEN_DIM_WHITELIST.isEnabled()) || (!inList && !ConfigBoolValues.ORE_GEN_DIM_WHITELIST.isEnabled()); - } - - private void generateDefault(World world, Random random, int x, int z) { - if (ConfigBoolValues.GENERATE_QUARTZ.isEnabled()) { - this.addOreSpawn(InitBlocks.blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.ORE_QUARTZ), Blocks.STONE, world, random, x * 16, z * 16, MathHelper.getInt(random, 5, 8), 10, QUARTZ_MIN, QUARTZ_MAX); - } - - if (ConfigBoolValues.GEN_LUSH_CAVES.isEnabled()) { - - int randConst = 0x969ce69d;//so that it won't generate the same numbers as other mod that does the same thing - Random chunkRand = new Random(randConst ^ world.getSeed() ^ (x * 29 + z * 31)); - - StructureBoundingBox box = new StructureBoundingBox(x * 16 + 8, 0, z * 16 + 8, x * 16 + 8 + 15, 255, z * 16 + 8 + 15); - if (chunkRand.nextInt(ConfigIntValues.LUSH_CAVE_CHANCE.getValue()) <= 0) { - BlockPos randPos = world.getTopSolidOrLiquidBlock(new BlockPos(x * 16 + MathHelper.getInt(random, 6, 10), 0, z * 16 + MathHelper.getInt(random, 6, 10))); - BlockPos pos = randPos.down(MathHelper.getInt(chunkRand, 15, randPos.getY() - 15)); - - this.caveGen.generate(world, chunkRand, pos, box); - } - } - } - - public void addOreSpawn(IBlockState state, Block blockIn, World world, Random random, int blockXPos, int blockZPos, int maxVeinSize, int chancesToSpawn, int minY, int maxY) { - for (int i = 0; i < chancesToSpawn; i++) { - int posX = blockXPos + random.nextInt(16); - int posY = minY + random.nextInt(maxY - minY); - int posZ = blockZPos + random.nextInt(16); - new WorldGenMinable(state, maxVeinSize, BlockMatcher.forBlock(blockIn)).generate(world, random, new BlockPos(posX, posY, posZ)); - } - } - - @SubscribeEvent - public void onWorldDecoration(DecorateBiomeEvent.Decorate event) { - if ((event.getResult() == Event.Result.ALLOW || event.getResult() == Event.Result.DEFAULT)) { - if (event.getType() == EventType.FLOWERS) { - if (!ArrayUtils.contains(ConfigIntListValues.PLANT_DIMENSION_BLACKLIST.getValue(), event.getWorld().provider.getDimension())) { - this.generateRice(event); - IBlockState plantDefault = InitBlocks.blockWildPlant.getDefaultState(); - this.genPlantNormally(plantDefault.withProperty(BlockWildPlant.TYPE, TheWildPlants.CANOLA), ConfigIntValues.CANOLA_AMOUNT.getValue(), ConfigBoolValues.DO_CANOLA_GEN.isEnabled(), Material.GRASS, event); - this.genPlantNormally(plantDefault.withProperty(BlockWildPlant.TYPE, TheWildPlants.FLAX), ConfigIntValues.FLAX_AMOUNT.getValue(), ConfigBoolValues.DO_FLAX_GEN.isEnabled(), Material.GRASS, event); - this.genPlantNormally(plantDefault.withProperty(BlockWildPlant.TYPE, TheWildPlants.COFFEE), ConfigIntValues.COFFEE_AMOUNT.getValue(), ConfigBoolValues.DO_COFFEE_GEN.isEnabled(), Material.GRASS, event); - this.genPlantNormally(InitBlocks.blockBlackLotus.getDefaultState(), ConfigIntValues.BLACK_LOTUS_AMOUNT.getValue(), ConfigBoolValues.DO_LOTUS_GEN.isEnabled(), Material.GRASS, event); - } - } - - if (event.getType() == EventType.LILYPAD) { - //Generate Treasure Chests - if (ConfigBoolValues.DO_TREASURE_CHEST_GEN.isEnabled()) { - if (event.getRand().nextInt(40) == 0) { - BlockPos randomPos = event.getChunkPos().getBlock(event.getRand().nextInt(16) + 8, 0, event.getRand().nextInt(16) + 8); - randomPos = event.getWorld().getTopSolidOrLiquidBlock(randomPos); - - if (event.getWorld().getBiome(randomPos) instanceof BiomeOcean) { - if (randomPos.getY() >= 25 && randomPos.getY() <= 45) { - if (event.getWorld().getBlockState(randomPos).getMaterial() == Material.WATER) { - if (event.getWorld().getBlockState(randomPos.down()).getMaterial().isSolid()) { - event.getWorld().setBlockState(randomPos, InitBlocks.blockTreasureChest.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.byHorizontalIndex(event.getRand().nextInt(4))), 2); - } - } - } - } - } - } - } - } - } - - private void generateRice(DecorateBiomeEvent event) { - if (ConfigBoolValues.DO_RICE_GEN.isEnabled()) { - for (int i = 0; i < ConfigIntValues.RICE_AMOUNT.getValue(); i++) { - if (event.getRand().nextInt(3) == 0) { - BlockPos randomPos = event.getChunkPos().getBlock(event.getRand().nextInt(16) + 8, 0, event.getRand().nextInt(16) + 8); - randomPos = event.getWorld().getTopSolidOrLiquidBlock(randomPos); - if (event.getWorld().getBlockState(randomPos).getMaterial() == Material.WATER) { - ArrayList blocksAroundBottom = WorldUtil.getMaterialsAround(event.getWorld(), randomPos); - BlockPos posToGenAt = randomPos.up(); - ArrayList blocksAroundTop = WorldUtil.getMaterialsAround(event.getWorld(), posToGenAt); - if (blocksAroundBottom.contains(Material.GRASS) || blocksAroundBottom.contains(Material.GROUND) || blocksAroundBottom.contains(Material.ROCK) || blocksAroundBottom.contains(Material.SAND)) { - if (!blocksAroundTop.contains(Material.WATER) && event.getWorld().getBlockState(posToGenAt).getMaterial() == Material.AIR) { - event.getWorld().setBlockState(posToGenAt, InitBlocks.blockWildPlant.getDefaultState().withProperty(BlockWildPlant.TYPE, TheWildPlants.RICE), 2); - } - } - } - } - } - } - } - - private void genPlantNormally(IBlockState plant, int amount, boolean doIt, Material blockBelow, DecorateBiomeEvent event) { - if (doIt) { - for (int i = 0; i < amount; i++) { - if (event.getRand().nextInt(100) == 0) { - BlockPos randomPos = event.getChunkPos().getBlock(event.getRand().nextInt(16) + 8, 0, event.getRand().nextInt(16) + 8); - randomPos = event.getWorld().getTopSolidOrLiquidBlock(randomPos); - - if (event.getWorld().getBlockState(randomPos.down()).getMaterial() == blockBelow) { - if (plant.getBlock().canPlaceBlockAt(event.getWorld(), randomPos) && event.getWorld().isAirBlock(randomPos)) { - event.getWorld().setBlockState(randomPos, plant, 2); - } - } - } - } - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/WorldGenLushCaves.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/WorldGenLushCaves.java deleted file mode 100644 index 0304811cf..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/WorldGenLushCaves.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * This file ("WorldGenLushCaves.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest; -import net.minecraft.block.Block; -import net.minecraft.block.BlockDirectional; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraft.world.gen.feature.WorldGenAbstractTree; -import net.minecraft.world.gen.feature.WorldGenBigTree; -import net.minecraft.world.gen.feature.WorldGenShrub; -import net.minecraft.world.gen.feature.WorldGenTrees; -import net.minecraft.world.gen.structure.StructureBoundingBox; -import net.minecraft.world.storage.loot.ILootContainer; - -public class WorldGenLushCaves { - - 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) { - 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; - 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++) { - //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.genTreesAndTallGrass(world, center, 11, spheres * 2, rand, chunkRegion); - } - - 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++) { - BlockPos pos = center.add(x, y, z); - 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) { - EnumFacing[] values = EnumFacing.values(); - EnumFacing side = values[rand.nextInt(values.length)]; - BlockPos posSide = pos.offset(side); - - 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())) { - Block block = CRYSTAL_CLUSTERS[rand.nextInt(CRYSTAL_CLUSTERS.length)]; - world.setBlockState(pos, block.getDefaultState().withProperty(BlockDirectional.FACING, side.getOpposite()), 2); - } - } - } - } - } - } - } - } - - if (!possiblePoses.isEmpty()) { - boolean crateGenDone = false; - - for (int i = 0; i <= amount; i++) { - Collections.shuffle(possiblePoses); - BlockPos pos = possiblePoses.get(0); - if (rand.nextBoolean()) { - boolean genCrate = false; - - WorldGenAbstractTree trees; - if (rand.nextBoolean()) { - if (rand.nextBoolean()) { - trees = new WorldGenBigTree(false); - } else { - trees = new WorldGenShrub(Blocks.LOG.getDefaultState(), Blocks.LEAVES.getDefaultState()); - genCrate = true; - } - } else { - trees = new WorldGenTrees(false); - } - trees.generate(world, rand, pos.up()); - - 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)) { - world.setBlockState(cratePos, InitBlocks.blockGiantChest.getDefaultState(), 2); - - TileEntity tile = world.getTileEntity(cratePos); - if (tile instanceof TileEntityGiantChest) { - ((TileEntityGiantChest) tile).lootTable = DungeonLoot.LUSH_CAVES; - } - } - - crateGenDone = true; - } - } 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) { - 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)) { - world.setBlockToAir(pos); - } - } - } - } - } - - 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)) { - IBlockState state = world.getBlockState(pos); - BlockPos posUp = pos.up(); - - if (!this.checkIndestructable(world, posUp)) { - IBlockState stateUp = world.getBlockState(posUp); - if (!state.getBlock().isAir(state, world, pos) && stateUp.getBlock().isAir(stateUp, world, posUp)) { - world.setBlockState(pos, Blocks.GRASS.getDefaultState(), 2); - } - } - } - } - } - } - } - - 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; } - - IBlockState state = world.getBlockState(pos); - 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; } - } - return true; - } -} \ No newline at end of file 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 deleted file mode 100644 index 391b16f4d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/BasicTradeList.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file ("BasicTradeList.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.gen.village; - -import java.util.Random; - -import net.minecraft.entity.IMerchant; -import net.minecraft.entity.passive.EntityVillager.ITradeList; -import net.minecraft.entity.passive.EntityVillager.PriceInfo; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.village.MerchantRecipe; -import net.minecraft.village.MerchantRecipeList; - -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) { - this.input = input; - this.inputAmount = inputAmount; - this.output = output; - this.outputAmount = 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) { - this(input, inputAmount, new ItemStack(Items.EMERALD), emeraldOutput); - } - - @Override - 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(); - out.setCount(this.outputAmount.getPrice(random)); - recipeList.add(new MerchantRecipe(in, out)); - } -} 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 deleted file mode 100644 index d971d04c5..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/InitVillager.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file ("InitVillager.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.gen.village; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; -import de.ellpeck.actuallyadditions.mod.gen.village.component.VillageComponentCustomCropField; -import de.ellpeck.actuallyadditions.mod.gen.village.component.VillageComponentEngineerHouse; -import de.ellpeck.actuallyadditions.mod.gen.village.component.VillageComponentJamHouse; -import de.ellpeck.actuallyadditions.mod.gen.village.component.handler.VillageCustomCropFieldHandler; -import de.ellpeck.actuallyadditions.mod.gen.village.component.handler.VillageEngineerHouseHandler; -import de.ellpeck.actuallyadditions.mod.gen.village.component.handler.VillageJamHouseHandler; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheJams; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import net.minecraft.entity.passive.EntityVillager.PriceInfo; -import net.minecraft.item.ItemStack; -import net.minecraft.world.gen.structure.MapGenStructureIO; -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 static VillagerProfession jamProfession; - public static VillagerProfession engineerProfession; - - public static void init() { - ActuallyAdditions.LOGGER.info("Initializing Village Addons..."); - - if (ConfigBoolValues.JAM_VILLAGER_EXISTS.isEnabled()) { - initJamVillagePart(); - } - if (ConfigBoolValues.CROP_FIELD_EXISTS.isEnabled()) { - initCustomCropFieldPart(); - } - if (ConfigBoolValues.ENGINEER_VILLAGER_EXISTS.isEnabled()) { - initEngineerVillagePart(); - } - } - - private static void initEngineerVillagePart() { - VillagerRegistry.instance().registerVillageCreationHandler(new VillageEngineerHouseHandler()); - 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"); - - 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))); - } - - 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))); - - VillagerRegistry.instance().registerVillageCreationHandler(new VillageJamHouseHandler()); - MapGenStructureIO.registerStructureComponent(VillageComponentJamHouse.class, ActuallyAdditions.MODID + ":jamHouseStructure"); - } - - private static void initCustomCropFieldPart() { - VillagerRegistry.instance().registerVillageCreationHandler(new VillageCustomCropFieldHandler()); - 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 deleted file mode 100644 index 7b5d38de2..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentCustomCropField.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * This file ("VillageComponentCustomCropField.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraft.world.gen.structure.StructureBoundingBox; -import net.minecraft.world.gen.structure.StructureComponent; -import net.minecraft.world.gen.structure.StructureVillagePieces; - -public class VillageComponentCustomCropField extends StructureVillagePieces.House1 { - - private static final int X_SIZE = 13; - private static final int Y_SIZE = 4; - private static final int Z_SIZE = 9; - - private int averageGroundLevel = -1; - - public VillageComponentCustomCropField() { - - } - - 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) { - 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) { - 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); - } - - 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++) { - this.clearCurrentPositionBlocksUpwards(world, i, Y_SIZE, j, sbb); - this.replaceAirAndLiquidDownwards(world, Blocks.DIRT.getDefaultState(), i, -1, j, sbb); - } - } - - return true; - } - - 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) { - 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); - this.fillWithBlocks(world, sbb, 10, 0, 1, 11, 0, 7, Blocks.FARMLAND); - this.fillWithBlocks(world, sbb, 0, 0, 0, 0, 0, 8, Blocks.LOG); - this.fillWithBlocks(world, sbb, 6, 0, 0, 6, 0, 8, Blocks.LOG); - this.fillWithBlocks(world, sbb, 12, 0, 0, 12, 0, 8, Blocks.LOG); - this.fillWithBlocks(world, sbb, 1, 0, 0, 11, 0, 0, Blocks.LOG); - this.fillWithBlocks(world, sbb, 1, 0, 8, 11, 0, 8, Blocks.LOG); - 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) { - 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); - this.setBlockState(world, this.getRandomCropType(rand), 5, 1, i, sbb); - this.setBlockState(world, this.getRandomCropType(rand), 7, 1, i, sbb); - this.setBlockState(world, this.getRandomCropType(rand), 8, 1, i, sbb); - this.setBlockState(world, this.getRandomCropType(rand), 10, 1, i, sbb); - this.setBlockState(world, this.getRandomCropType(rand), 11, 1, i, sbb); - } - } - - private IBlockState getRandomCropType(Random rand) { - int randomMeta = MathHelper.getInt(rand, 1, 7); - switch (rand.nextInt(4)) { - case 0: - return InitBlocks.blockFlax.getDefaultState().withProperty(BlockCrops.AGE, randomMeta); - case 1: - return InitBlocks.blockCoffee.getDefaultState().withProperty(BlockCrops.AGE, randomMeta); - case 2: - return InitBlocks.blockRice.getDefaultState().withProperty(BlockCrops.AGE, randomMeta); - default: - return InitBlocks.blockCanola.getDefaultState().withProperty(BlockCrops.AGE, randomMeta); - } - } -} 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 deleted file mode 100644 index 3dd219af9..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentEngineerHouse.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * This file ("VillageComponentEngineerHouse.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.blocks.BlockColoredLamp; -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.fluids.InitFluids; -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.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; -import net.minecraft.item.ItemStack; -import net.minecraft.server.MinecraftServer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.Mirror; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.gen.structure.StructureBoundingBox; -import net.minecraft.world.gen.structure.StructureComponent; -import net.minecraft.world.gen.structure.StructureVillagePieces; -import net.minecraft.world.gen.structure.template.PlacementSettings; -import net.minecraft.world.gen.structure.template.Template; -import net.minecraft.world.gen.structure.template.TemplateManager; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession; - -public class VillageComponentEngineerHouse extends StructureVillagePieces.House1 { - - private static final ResourceLocation STRUCTURE_RES_LOC = new ResourceLocation(ActuallyAdditions.MODID, "andrew_period_house"); - - private static final int X_SIZE = 13; - private static final int Y_SIZE = 11; - private static final int Z_SIZE = 10; - - private int averageGroundLevel = -1; - - public VillageComponentEngineerHouse() { - - } - - 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) { - 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) { - 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); - } - - 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++) { - this.clearCurrentPositionBlocksUpwards(world, i, Y_SIZE, j, sbb); - this.replaceAirAndLiquidDownwards(world, Blocks.DIRT.getDefaultState(), i, -1, j, sbb); - } - } - - this.spawnVillagers(world, sbb, 7, 4, 6, 1); - - return true; - } - - 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()) { - TileEntity compost = this.getTileAtPos(world, 6, 1, 2, sbb); - 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; - tile.stopFromDropping = true; - 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; - tile.stopFromDropping = true; - 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)); - } - - TileEntity press = this.getTileAtPos(world, 2, 1, 5, sbb); - 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())); - } - - TileEntity crusher = this.getTileAtPos(world, 2, 1, 6, sbb); - 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())); - } - } - - TileEntity coal = this.getTileAtPos(world, 5, 5, 6, sbb); - 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)); - } - - TileEntity reconstructor = this.getTileAtPos(world, 8, 4, 3, sbb); - 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); - } - - 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; - ActuallyAdditionsAPI.connectionHandler.addConnection(firstRelay.getPos(), secondRelay.getPos(), LaserType.ENERGY, world); - } - - int meta = world.rand.nextInt(TheColoredLampColors.values().length); - 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) { - TemplateManager manager = world.getSaveHandler().getStructureTemplateManager(); - MinecraftServer server = world.getMinecraftServer(); - - if (manager != null && server != null) { - EnumFacing facing = this.getCoordBaseMode(); - - Mirror mirror; - Rotation rotation; - if (facing == EnumFacing.SOUTH) { - mirror = Mirror.NONE; - rotation = Rotation.NONE; - } else if (facing == EnumFacing.WEST) { - mirror = Mirror.NONE; - rotation = Rotation.CLOCKWISE_90; - } else if (facing == EnumFacing.EAST) { - mirror = Mirror.LEFT_RIGHT; - rotation = Rotation.CLOCKWISE_90; - } else { - mirror = Mirror.LEFT_RIGHT; - rotation = Rotation.NONE; - } - - PlacementSettings placement = new PlacementSettings().setRotation(rotation).setMirror(mirror).setBoundingBox(sbb); - Template template = manager.getTemplate(server, STRUCTURE_RES_LOC); - - 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) { - BlockPos pos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z)); - if (sbb.isVecInside(pos)) { - return world.getTileEntity(pos); - } else { - return null; - } - } - - @Override - 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 deleted file mode 100644 index d9be48266..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentJamHouse.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * This file ("VillageComponentJamHouse.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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.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; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.gen.structure.StructureBoundingBox; -import net.minecraft.world.gen.structure.StructureComponent; -import net.minecraft.world.gen.structure.StructureVillagePieces; -import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession; - -public class VillageComponentJamHouse extends StructureVillagePieces.House1 { - - private static final int X_SIZE = 11; - private static final int Y_SIZE = 8; - private static final int Z_SIZE = 12; - - private int averageGroundLevel = -1; - - public VillageComponentJamHouse() { - - } - - 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) { - 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) { - BlockPos pos = new BlockPos(x, y, z); - - if (box.isVecInside(pos)) { - world.setBlockState(pos, InitBlocks.blockGiantChest.getDefaultState(), 2); - - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityGiantChest) { - ((TileEntityGiantChest) tile).lootTable = loot; - } - - return true; - } else { - return false; - } - } - - @Override - 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); - } - - 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++) { - this.clearCurrentPositionBlocksUpwards(world, i, Y_SIZE, j, sbb); - this.replaceAirAndLiquidDownwards(world, Blocks.COBBLESTONE.getDefaultState(), i, -1, j, sbb); - } - } - - this.spawnVillagers(world, sbb, 3, 1, 3, 1); - - return true; - } - - 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) { - //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); - this.fillWithBlocks(world, sbb, 2, 0, 0, 4, 0, 1, Blocks.COBBLESTONE); - this.fillWithBlocks(world, sbb, 9, 0, 0, 10, 0, 7, Blocks.COBBLESTONE); - this.fillWithBlocks(world, sbb, 6, 0, 0, 8, 0, 1, Blocks.COBBLESTONE); - this.setBlockState(world, Blocks.STONE_STAIRS.getStateFromMeta(3), 5, 0, 0, sbb); - this.fillWithBlocks(world, sbb, 2, 0, 7, 3, 0, 7, Blocks.COBBLESTONE); - this.fillWithBlocks(world, sbb, 5, 0, 7, 8, 0, 7, Blocks.COBBLESTONE); - this.fillWithBlocks(world, sbb, 10, 0, 8, 10, 0, 11, Blocks.COBBLESTONE); - this.fillWithBlocks(world, sbb, 0, 0, 8, 0, 0, 11, Blocks.COBBLESTONE); - this.fillWithBlocks(world, sbb, 0, 0, 11, 10, 0, 11, Blocks.COBBLESTONE); - this.fillWithBlocks(world, sbb, 2, 0, 2, 8, 0, 6, Blocks.PLANKS.getStateFromMeta(1), Blocks.PLANKS.getStateFromMeta(1), false); - this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(1), 5, 0, 1, sbb); - this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(1), 4, 0, 7, sbb); - - //Garden FENCE - this.fillWithBlocks(world, sbb, 0, 1, 8, 0, 1, 11, Blocks.OAK_FENCE); - this.fillWithBlocks(world, sbb, 10, 1, 8, 10, 1, 11, Blocks.OAK_FENCE); - 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); - } - - //Front Wall - this.fillWithBlocks(world, sbb, 7, 1, 1, 8, 4, 1, Blocks.COBBLESTONE); - this.fillWithBlocks(world, sbb, 2, 1, 1, 3, 4, 1, Blocks.COBBLESTONE); - this.fillWithBlocks(world, sbb, 4, 4, 1, 7, 4, 1, Blocks.COBBLESTONE); - this.fillWithBlocks(world, sbb, 6, 1, 1, 6, 3, 1, Blocks.PLANKS); - this.fillWithBlocks(world, sbb, 4, 1, 1, 4, 3, 1, Blocks.PLANKS); - this.fillWithBlocks(world, sbb, 5, 3, 1, 5, 3, 1, Blocks.PLANKS); - 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); - this.fillWithBlocks(world, sbb, 4, 3, 7, 8, 3, 7, Blocks.PLANKS); - this.fillWithBlocks(world, sbb, 3, 4, 7, 8, 4, 7, Blocks.COBBLESTONE); - this.fillWithBlocks(world, sbb, 5, 1, 7, 5, 2, 7, Blocks.PLANKS); - this.fillWithBlocks(world, sbb, 6, 1, 7, 8, 1, 7, Blocks.COBBLESTONE); - this.fillWithBlocks(world, sbb, 6, 2, 7, 7, 2, 7, Blocks.GLASS_PANE); - this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(0), 8, 2, 7, sbb); - this.setBlockState(world, Blocks.SPRUCE_DOOR.getDefaultState().withProperty(BlockDoor.FACING, EnumFacing.SOUTH), 4, 1, 7, sbb); - this.setBlockState(world, Blocks.SPRUCE_DOOR.getDefaultState().withProperty(BlockDoor.FACING, EnumFacing.SOUTH).withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 4, 2, 7, sbb); - - //FENCE Supports - this.fillWithBlocks(world, sbb, 0, 1, 8, 0, 3, 8, Blocks.OAK_FENCE); - this.fillWithBlocks(world, sbb, 10, 1, 8, 10, 3, 8, Blocks.OAK_FENCE); - this.fillWithBlocks(world, sbb, 0, 1, 0, 0, 3, 0, Blocks.OAK_FENCE); - this.fillWithBlocks(world, sbb, 10, 1, 0, 10, 3, 0, Blocks.OAK_FENCE); - - //Roof - this.fillWithBlocks(world, sbb, 1, 6, 3, 9, 6, 5, Blocks.PLANKS); - IBlockState stairSouth = Blocks.OAK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.SOUTH); - IBlockState stairNorth = Blocks.OAK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.NORTH); - this.fillWithBlocks(world, sbb, 0, 4, 0, 10, 4, 0, stairNorth, stairNorth, false); - this.fillWithBlocks(world, sbb, 0, 5, 1, 10, 5, 1, stairNorth, stairNorth, false); - this.fillWithBlocks(world, sbb, 0, 6, 2, 10, 6, 2, stairNorth, stairNorth, false); - this.fillWithBlocks(world, sbb, 0, 4, 8, 10, 4, 8, stairSouth, stairSouth, false); - this.fillWithBlocks(world, sbb, 0, 5, 7, 10, 5, 7, stairSouth, stairSouth, false); - this.fillWithBlocks(world, sbb, 0, 6, 6, 10, 6, 6, stairSouth, stairSouth, false); - this.fillWithBlocks(world, sbb, 0, 7, 3, 10, 7, 5, Blocks.WOODEN_SLAB); - - //Roof Gadgets - this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 0, 4, 1, sbb); - this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 0, 5, 2, sbb); - this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 10, 4, 1, sbb); - this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 10, 5, 2, sbb); - this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 0, 4, 7, sbb); - this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 0, 5, 6, sbb); - this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 10, 4, 7, sbb); - this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 10, 5, 6, sbb); - this.fillWithBlocks(world, sbb, 0, 6, 3, 0, 6, 5, Blocks.PLANKS); - this.fillWithBlocks(world, sbb, 10, 6, 3, 10, 6, 5, Blocks.PLANKS); - - //Counter - this.fillWithBlocks(world, sbb, 6, 3, 2, 6, 3, 4, Blocks.WOODEN_SLAB.getStateFromMeta(8), Blocks.WOODEN_SLAB.getStateFromMeta(8), false); - this.fillWithBlocks(world, sbb, 5, 3, 4, 5, 3, 6, Blocks.WOODEN_SLAB.getStateFromMeta(8), Blocks.WOODEN_SLAB.getStateFromMeta(8), false); - this.fillWithBlocks(world, sbb, 6, 1, 2, 6, 1, 4, Blocks.PLANKS); - this.fillWithBlocks(world, sbb, 5, 1, 4, 5, 1, 5, Blocks.PLANKS); - this.fillWithBlocks(world, sbb, 6, 4, 2, 6, 5, 2, Blocks.OAK_FENCE); - this.fillWithBlocks(world, sbb, 5, 4, 4, 5, 5, 4, Blocks.OAK_FENCE); - this.fillWithBlocks(world, sbb, 5, 4, 6, 5, 5, 6, Blocks.OAK_FENCE); - - //Decoration - this.setBlockState(world, Blocks.OAK_FENCE.getDefaultState(), 2, 1, 2, sbb); - this.setBlockState(world, Blocks.LEAVES.getDefaultState().withProperty(BlockLeaves.DECAYABLE, false), 2, 2, 2, sbb); - this.setBlockState(world, Blocks.OAK_FENCE.getDefaultState(), 8, 1, 2, sbb); - this.setBlockState(world, Blocks.LEAVES.getDefaultState().withProperty(BlockLeaves.DECAYABLE, false), 8, 2, 2, sbb); - this.setBlockState(world, Blocks.OAK_FENCE.getDefaultState(), 2, 1, 6, sbb); - this.setBlockState(world, Blocks.LEAVES.getDefaultState().withProperty(BlockLeaves.DECAYABLE, false), 2, 2, 6, sbb); - IBlockState stairWest = Blocks.OAK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.WEST); - this.fillWithBlocks(world, sbb, 2, 1, 3, 2, 1, 5, stairWest, stairWest, false); - this.fillWithBlocks(world, sbb, 3, 1, 2, 5, 1, 3, Blocks.CARPET.getStateFromMeta(10), Blocks.CARPET.getStateFromMeta(10), false); - 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()) { - generateCrate(world, this.boundingBox, this.getXWithOffset(8, 6), this.getYWithOffset(1), this.getZWithOffset(8, 6), DungeonLoot.JAM_HOUSE); - } - - //Torches - this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.SOUTH), 6, 2, 0, sbb); - this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.SOUTH), 4, 2, 0, sbb); - this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.NORTH), 5, 2, 8, sbb); - this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.NORTH), 3, 2, 8, sbb); - this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.EAST), 2, 3, 2, sbb); - this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.EAST), 2, 3, 6, sbb); - this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.WEST), 8, 3, 2, sbb); - this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.WEST), 8, 3, 6, sbb); - } - - @Override - 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 deleted file mode 100644 index 491ac68eb..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/handler/VillageCustomCropFieldHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file ("VillageCustomCropFieldHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; - -public class VillageCustomCropFieldHandler implements VillagerRegistry.IVillageCreationHandler { - - @Override - public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i) { - return new StructureVillagePieces.PieceWeight(VillageComponentCustomCropField.class, 5, 1); - } - - @Override - 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) { - 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 deleted file mode 100644 index 0b1144c82..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/handler/VillageEngineerHouseHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file ("VillageEngineerHouseHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; - -public class VillageEngineerHouseHandler implements VillagerRegistry.IVillageCreationHandler { - - @Override - public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i) { - return new StructureVillagePieces.PieceWeight(VillageComponentEngineerHouse.class, 10, 1); - } - - @Override - 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) { - 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 deleted file mode 100644 index c9a4a50e7..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/handler/VillageJamHouseHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file ("VillageJamHouseHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; - -public class VillageJamHouseHandler implements VillagerRegistry.IVillageCreationHandler { - - @Override - public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i) { - return new StructureVillagePieces.PieceWeight(VillageComponentJamHouse.class, 3, 1); - } - - @Override - 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) { - return VillageComponentJamHouse.buildComponent(pieces, p1, p2, p3, facing); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBag.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBag.java deleted file mode 100644 index 0c9e9f106..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBag.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * This file ("ContainerBag.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.tuple.Pair; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotDeletion; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotImmovable; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.items.ItemBag; -import de.ellpeck.actuallyadditions.mod.items.ItemDrill; -import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; -import de.ellpeck.actuallyadditions.mod.tile.FilterSettings; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ClickType; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.IContainerListener; -import net.minecraft.inventory.Slot; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.registry.ForgeRegistries; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class ContainerBag extends Container implements IButtonReactor { - - public final FilterSettings filter = new FilterSettings(4, false, true, false, false, 0, -1000); - private final ItemStackHandlerAA bagInventory; - private final InventoryPlayer inventory; - private final boolean isVoid; - public boolean autoInsert; - private boolean oldAutoInsert; - private final ItemStack sack; - - public ContainerBag(ItemStack sack, InventoryPlayer inventory, boolean isVoid) { - this.inventory = inventory; - this.bagInventory = new ItemStackHandlerAA(getSlotAmount(isVoid), (slot, stack, automation) -> !isBlacklisted(stack), ItemStackHandlerAA.REMOVE_TRUE); - this.isVoid = isVoid; - this.sack = sack; - - for (int i = 0; i < 4; i++) { - this.addSlotToContainer(new SlotFilter(this.filter, i, 155, 10 + i * 18)); - } - - if (this.isVoid) { - this.addSlotToContainer(new SlotDeletion(this.bagInventory, 0, 64, 65) { - @Override - public boolean isItemValid(ItemStack stack) { - return ContainerBag.this.filter.check(stack); - } - }); - } else { - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 7; j++) { - this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.bagInventory, j + i * 7, 10 + j * 18, 10 + i * 18) { - @Override - public boolean isItemValid(ItemStack stack) { - return !isBlacklisted(stack) && ContainerBag.this.filter.check(stack); - } - }); - } - } - } - - 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)); - } - } - - ItemStack stack = inventory.getCurrentItem(); - if (StackUtil.isValid(stack) && stack.getItem() instanceof ItemBag) { - ItemDrill.loadSlotsFromNBT(this.bagInventory, inventory.getCurrentItem()); - if (stack.hasTagCompound()) { - NBTTagCompound compound = stack.getTagCompound(); - this.filter.readFromNBT(compound, "Filter"); - this.autoInsert = compound.getBoolean("AutoInsert"); - } - } - } - - public static int getSlotAmount(boolean isVoid) { - return isVoid ? 1 : 28; - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - - if (this.filter.needsUpdateSend() || this.autoInsert != this.oldAutoInsert) { - for (IContainerListener listener : this.listeners) { - listener.sendWindowProperty(this, 0, this.filter.isWhitelist ? 1 : 0); - listener.sendWindowProperty(this, 1, this.filter.respectMeta ? 1 : 0); - listener.sendWindowProperty(this, 2, this.filter.respectNBT ? 1 : 0); - listener.sendWindowProperty(this, 3, this.filter.respectOredict); - listener.sendWindowProperty(this, 4, this.autoInsert ? 1 : 0); - listener.sendWindowProperty(this, 5, this.filter.respectMod ? 1 : 0); - } - this.filter.updateLasts(); - this.oldAutoInsert = this.autoInsert; - } - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int id, int data) { - if (id == 0) { - this.filter.isWhitelist = data == 1; - } else if (id == 1) { - this.filter.respectMeta = data == 1; - } else if (id == 2) { - this.filter.respectNBT = data == 1; - } else if (id == 3) { - this.filter.respectOredict = data; - } else if (id == 4) { - this.autoInsert = data == 1; - } else if (id == 5) { - this.filter.respectMod = data == 1; - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = this.bagInventory.getSlots() + 4; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - if (theSlot != null && theSlot.getHasStack()) { - ItemStack newStack = theSlot.getStack(); - ItemStack currentStack = newStack.copy(); - - //Other Slots in Inventory excluded - if (slot >= inventoryStart) { - //Shift from Inventory - if (this.isVoid || !this.filter.check(newStack) || !this.mergeItemStack(newStack, 4, 32, 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(); } - } - // - - } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - - if (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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) { - return ItemStack.EMPTY; - } else { - return super.slotClick(slotId, dragType, clickTypeIn, player); - } - } - - @Override - public void onContainerClosed(EntityPlayer player) { - ItemStack stack = this.inventory.getCurrentItem(); - if (StackUtil.isValid(stack) && stack.getItem() instanceof ItemBag) { - ItemDrill.writeSlotsToNBT(this.bagInventory, this.inventory.getCurrentItem()); - NBTTagCompound compound = stack.getTagCompound(); - this.filter.writeToNBT(compound, "Filter"); - compound.setBoolean("AutoInsert", this.autoInsert); - } - super.onContainerClosed(player); - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - return !this.sack.isEmpty() && player.getHeldItemMainhand() == this.sack; - } - - @Override - public void onButtonPressed(int buttonID, EntityPlayer player) { - if (buttonID == 0) { - this.autoInsert = !this.autoInsert; - } else { - this.filter.onButtonPressed(buttonID); - } - } - - private static final List> BLACKLIST = new ArrayList<>(); - - private static boolean runOnce = false; - - public static boolean isBlacklisted(ItemStack stack) { - if (!runOnce) { - runOnce = true; - for (String s : ConfigStringListValues.SACK_BLACKLIST.getValue()) { - String[] split = s.split("@"); - Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(split[0])); - if (item == null) { - ActuallyAdditions.LOGGER.error("Invalid item in sack blacklist: " + s); - continue; - } - if (split.length == 1) BLACKLIST.add(Pair.of(item, 0)); - else if (split.length == 2) { - BLACKLIST.add(Pair.of(item, Integer.parseInt(split[1]))); - } - } - } - return BLACKLIST.contains(Pair.of(stack.getItem(), stack.getMetadata())); - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBioReactor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBioReactor.java deleted file mode 100644 index 172ee7928..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBioReactor.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This file ("ContainerBioReactor.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBioReactor; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerBioReactor extends Container { - - private final 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 < 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)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 8; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - if (theSlot != null && theSlot.getHasStack()) { - ItemStack newStack = theSlot.getStack(); - ItemStack currentStack = newStack.copy(); - - //Other Slots in Inventory excluded - if (slot >= inventoryStart) { - //Shift from Inventory - 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(); } - - if (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index 45be35e3e..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBreaker.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file ("ContainerBreaker.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerBreaker extends Container { - - private final TileEntityBreaker breaker; - - 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 < 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)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 9; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - if (theSlot != null && theSlot.getHasStack()) { - ItemStack newStack = theSlot.getStack(); - ItemStack currentStack = newStack.copy(); - - //Other Slots in Inventory excluded - if (slot >= inventoryStart) { - //Shift from Inventory - 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(); } - } - } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - - if (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index 712f513fe..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCanolaPress.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file ("ContainerCanolaPress.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerCanolaPress extends Container { - - private final TileEntityCanolaPress press; - - 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 < 9; i++) { - this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 1; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - if (theSlot != null && theSlot.getHasStack()) { - ItemStack newStack = theSlot.getStack(); - ItemStack currentStack = newStack.copy(); - - //Other Slots in Inventory excluded - 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(); } - } - // - - 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)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index 01e1422d3..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoalGenerator.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * This file ("ContainerCoalGenerator.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityFurnace; - -public class ContainerCoalGenerator extends Container { - - private final TileEntityCoalGenerator generator; - - 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 < 9; i++) { - this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 1; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - if (theSlot != null && theSlot.getHasStack()) { - ItemStack newStack = theSlot.getStack(); - ItemStack currentStack = newStack.copy(); - - //Other Slots in Inventory excluded - if (slot >= inventoryStart) { - //Shift from Inventory - 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(); } - - if (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index 5c210df53..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoffeeMachine.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * This file ("ContainerCoffeeMachine.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.ItemCoffee; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerCoffeeMachine extends Container { - - private final TileEntityCoffeeMachine machine; - - 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 < 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)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 11; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - 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(); } - theSlot.onSlotChange(newStack, currentStack); - } - //Other Slots in Inventory excluded - 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(); } - } - // - - 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)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index 4a0c6ce72..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDirectionalBreaker.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file ("ContainerDirectionalBreaker.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityDirectionalBreaker; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerDirectionalBreaker extends Container { - - private final TileEntityDirectionalBreaker breaker; - - 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 < 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)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 9; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - if (theSlot != null && theSlot.getHasStack()) { - ItemStack newStack = theSlot.getStack(); - ItemStack currentStack = newStack.copy(); - - //Other Slots in Inventory excluded - if (slot >= inventoryStart) { - //Shift from Inventory - 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(); } - } - } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - - if (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index 4313404ec..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDrill.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * This file ("ContainerDrill.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotImmovable; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.items.ItemDrill; -import de.ellpeck.actuallyadditions.mod.items.ItemDrillUpgrade; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ClickType; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -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) { - this.inventory = inventory; - - 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) { - 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 < 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) { - ItemDrill.loadSlotsFromNBT(this.drillInventory, inventory.getCurrentItem()); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 5; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - if (theSlot != null && theSlot.getHasStack()) { - ItemStack newStack = theSlot.getStack(); - ItemStack currentStack = newStack.copy(); - - //Other Slots in Inventory excluded - if (slot >= inventoryStart) { - //Shift from Inventory - 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(); } - - if (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) { - if (clickTypeIn == ClickType.SWAP && dragType == this.inventory.currentItem) { - return ItemStack.EMPTY; - } else { - return super.slotClick(slotId, dragType, clickTypeIn, player); - } - } - - @Override - public void onContainerClosed(EntityPlayer player) { - ItemStack stack = this.inventory.getCurrentItem(); - if (StackUtil.isValid(stack) && stack.getItem() instanceof ItemDrill) { - ItemDrill.writeSlotsToNBT(this.drillInventory, this.inventory.getCurrentItem()); - } - super.onContainerClosed(player); - } - - @Override - 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 deleted file mode 100644 index a839ba4c7..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDropper.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This file ("ContainerDropper.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerDropper extends Container { - - private final TileEntityDropper dropper; - EntityPlayer player; - - 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 < 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)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 9; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - if (theSlot != null && theSlot.getHasStack()) { - ItemStack newStack = theSlot.getStack(); - ItemStack currentStack = newStack.copy(); - - //Other Slots in Inventory excluded - if (slot >= inventoryStart) { - //Shift from Inventory - 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(); } - } - } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - - if (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - return this.dropper.canPlayerUse(player); - } - - @Override - public void onContainerClosed(EntityPlayer playerIn) { - super.onContainerClosed(playerIn); - if (!this.player.isSpectator()) this.dropper.getWorld().notifyNeighborsOfStateChange(this.dropper.getPos(), InitBlocks.blockDropper, false); - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnergizer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnergizer.java deleted file mode 100644 index 066786a94..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnergizer.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * This file ("ContainerEnergizer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.EntityEquipmentSlot; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemArmor; -import net.minecraft.item.ItemStack; -import net.minecraftforge.energy.CapabilityEnergy; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class ContainerEnergizer extends Container { - - public static final EntityEquipmentSlot[] VALID_EQUIPMENT_SLOTS = new EntityEquipmentSlot[] { EntityEquipmentSlot.HEAD, EntityEquipmentSlot.CHEST, EntityEquipmentSlot.LEGS, EntityEquipmentSlot.FEET }; - private final TileEntityEnergizer energizer; - - public ContainerEnergizer(final EntityPlayer player, TileEntityBase tile) { - this.energizer = (TileEntityEnergizer) tile; - InventoryPlayer inventory = player.inventory; - - this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.energizer.inv, 0, 76, 73) { - @Override - public boolean isItemValid(ItemStack stack) { - return super.isItemValid(stack) && stack.hasCapability(CapabilityEnergy.ENERGY, null); - } - }); - this.addSlotToContainer(new SlotOutput(this.energizer.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 < 9; i++) { - this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); - } - - for (int k = 0; k < 4; ++k) { - final EntityEquipmentSlot slot = VALID_EQUIPMENT_SLOTS[k]; - this.addSlotToContainer(new Slot(player.inventory, 36 + 3 - k, 102, 19 + k * 18) { - @Override - public int getSlotStackLimit() { - return 1; - } - - @Override - public boolean isItemValid(ItemStack stack) { - return StackUtil.isValid(stack) && stack.getItem().isValidArmor(stack, slot, player); - } - - @Override - public boolean canTakeStack(EntityPlayer player) { - ItemStack itemstack = this.getStack(); - return !itemstack.isEmpty() && !player.isCreative() && EnchantmentHelper.hasBindingCurse(itemstack) ? false : super.canTakeStack(player); - } - - @Override - @SideOnly(Side.CLIENT) - public String getSlotTexture() { - return ItemArmor.EMPTY_SLOT_NAMES[slot.getIndex()]; - } - }); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 2; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - 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(); } - theSlot.onSlotChange(newStack, currentStack); - } - //Other Slots in Inventory excluded - else if (slot >= inventoryStart) { - //Shift from Inventory - 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(); } - - if (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - return this.energizer.canPlayerUse(player); - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnervator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnervator.java deleted file mode 100644 index e607122bb..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerEnervator.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * This file ("ContainerEnervator.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.EntityEquipmentSlot; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemArmor; -import net.minecraft.item.ItemStack; -import net.minecraftforge.energy.CapabilityEnergy; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class ContainerEnervator extends Container { - - private final TileEntityEnervator enervator; - - 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 < 9; i++) { - this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); - } - - 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) { - @Override - public int getSlotStackLimit() { - return 1; - } - - @Override - public boolean isItemValid(ItemStack stack) { - return StackUtil.isValid(stack) && stack.getItem().isValidArmor(stack, slot, player); - } - - @Override - @SideOnly(Side.CLIENT) - public String getSlotTexture() { - return ItemArmor.EMPTY_SLOT_NAMES[slot.getIndex()]; - } - }); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 2; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - 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(); } - theSlot.onSlotChange(newStack, currentStack); - } - //Other Slots in Inventory excluded - else if (slot >= inventoryStart) { - //Shift from Inventory - 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(); } - - if (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index a680ad5d8..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFarmer.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file ("ContainerFarmer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFarmer; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerFarmer extends Container { - - private final TileEntityFarmer farmer; - - 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, 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 < 9; i++) { - this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 12; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - if (theSlot != null && theSlot.getHasStack()) { - ItemStack newStack = theSlot.getStack(); - ItemStack currentStack = newStack.copy(); - - //Other Slots in Inventory excluded - if (slot >= inventoryStart) { - //Shift from Inventory - 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(); } - } - } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - - if (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index 909a68e92..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFeeder.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file ("ContainerFeeder.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFeeder; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerFeeder extends Container { - - private final TileEntityFeeder tileFeeder; - - 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 < 9; i++) { - this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 132)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 1; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - if (theSlot != null && theSlot.getHasStack()) { - ItemStack newStack = theSlot.getStack(); - ItemStack currentStack = newStack.copy(); - - //Other Slots in Inventory excluded - if (slot >= inventoryStart) { - //Shift from Inventory - 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(); } - } - } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - - if (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index bd9f51091..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFermentingBarrel.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This file ("ContainerFermentingBarrel.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFermentingBarrel; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerFermentingBarrel extends Container { - - private final TileEntityFermentingBarrel barrel; - - 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 < 9; i++) { - this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 0; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - 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 (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index afa306218..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFilter.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * This file ("ContainerFilter.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotImmovable; -import de.ellpeck.actuallyadditions.mod.items.ItemDrill; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ClickType; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -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) { - 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 < 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)); - } - } - - ItemStack stack = inventory.getCurrentItem(); - if (SlotFilter.isFilter(stack)) { - ItemDrill.loadSlotsFromNBT(this.filterInventory, inventory.getCurrentItem()); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = SLOT_AMOUNT; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - if (theSlot != null && theSlot.getHasStack()) { - ItemStack newStack = theSlot.getStack(); - ItemStack currentStack = newStack.copy(); - - //Other Slots in Inventory excluded - 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 (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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) { - return ItemStack.EMPTY; - } else { - return super.slotClick(slotId, dragType, clickTypeIn, player); - } - } - - @Override - public void onContainerClosed(EntityPlayer player) { - ItemStack stack = this.inventory.getCurrentItem(); - if (SlotFilter.isFilter(stack)) { - ItemDrill.writeSlotsToNBT(this.filterInventory, this.inventory.getCurrentItem()); - } - super.onContainerClosed(player); - } - - @Override - 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 deleted file mode 100644 index 319210ce0..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFireworkBox.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file ("ContainerFireworkBox.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.item.ItemStack; - -public class ContainerFireworkBox extends Container { - - @Override - public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { - return ItemStack.EMPTY; - } - - @Override - 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 deleted file mode 100644 index 1fbf30a60..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFluidCollector.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file ("ContainerFluidCollector.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidCollector; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerFluidCollector extends Container { - - private final TileEntityFluidCollector collector; - - 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 < 9; i++) { - this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 0; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - 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(); } - 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(); } - - if (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index c11205223..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFurnaceDouble.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file ("ContainerFurnaceDouble.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceDouble; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.FurnaceRecipes; - -public class ContainerFurnaceDouble extends Container { - - private final TileEntityFurnaceDouble tileFurnace; - - 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 < 9; i++) { - this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 4; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - 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(); } - theSlot.onSlotChange(newStack, currentStack); - } - //Other Slots in Inventory excluded - 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(); } - } - } - // - - 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)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index 4ea41feeb..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerGiantChest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This file ("ContainerGiantChest.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import invtweaks.api.container.ChestContainer; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -@ChestContainer(rowSize = 13, isLargeChest = true) -public class ContainerGiantChest extends Container { - - public final TileEntityGiantChest tileChest; - - 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 < 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)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 117; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - if (theSlot != null && theSlot.getHasStack()) { - ItemStack newStack = theSlot.getStack(); - ItemStack currentStack = newStack.copy(); - - //Other Slots in Inventory excluded - if (slot >= inventoryStart) { - //Shift from Inventory - 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(); } - } - } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, true)) { return StackUtil.getEmpty(); } - - if (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index 2edaab084..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerGrinder.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * This file ("ContainerGrinder.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput; -import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinder; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -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; - 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) { - 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 < 9; i++) { - this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); - } - } - - @Override - 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; - - Slot theSlot = this.inventorySlots.get(slot); - - 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(); } - theSlot.onSlotChange(newStack, currentStack); - } - //Other Slots in Inventory excluded - 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 { - 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)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index dc5e6116c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerInputter.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * This file ("ContainerInputter.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiInputter; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityInputter; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ClickType; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -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; - this.isAdvanced = isAdvanced; - - 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)); - } - } - } - } - - 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))); - } - } - - @Override - 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; - - Slot theSlot = this.inventorySlots.get(slot); - - if (theSlot != null && theSlot.getHasStack()) { - ItemStack newStack = theSlot.getStack(); - ItemStack currentStack = newStack.copy(); - - //Other Slots in Inventory excluded - if (slot >= inventoryStart) { - //Shift from Inventory - 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(); } - } - } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - - if (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) { - if (SlotFilter.checkFilter(this, slotId, player)) { - return StackUtil.getEmpty(); - } else { - return super.slotClick(slotId, dragType, clickTypeIn, player); - } - } - - @Override - 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 deleted file mode 100644 index 178b98bf4..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerLaserRelayItemWhitelist.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file ("ContainerLaserRelayItemWhitelist.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItemWhitelist; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ClickType; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerLaserRelayItemWhitelist extends Container { - - private final 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 < 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)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 24; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - 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 (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) { - if (SlotFilter.checkFilter(this, slotId, player)) { - return StackUtil.getEmpty(); - } else { - return super.slotClick(slotId, dragType, clickTypeIn, player); - } - } - - @Override - 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 deleted file mode 100644 index b85faa13f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerMiner.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file ("ContainerMiner.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityMiner; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerMiner extends Container { - - private final TileEntityMiner miner; - - 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 < 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)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 9; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - if (theSlot != null && theSlot.getHasStack()) { - ItemStack newStack = theSlot.getStack(); - ItemStack currentStack = newStack.copy(); - - //Other Slots in Inventory excluded - if (slot >= inventoryStart) { - //Shift from Inventory - 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(); } - } - } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - - if (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index 3c96a3230..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerOilGenerator.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This file ("ContainerOilGenerator.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerOilGenerator extends Container { - - private final TileEntityOilGenerator generator; - - 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 < 9; i++) { - this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 0; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - 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 (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index 69ad4b61c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerPhantomPlacer.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file ("ContainerPhantomPlacer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomPlacer; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerPhantomPlacer extends Container { - - private final TileEntityPhantomPlacer placer; - - 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 < 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)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 9; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - if (theSlot != null && theSlot.getHasStack()) { - ItemStack newStack = theSlot.getStack(); - ItemStack currentStack = newStack.copy(); - - //Other Slots in Inventory excluded - if (slot >= inventoryStart) { - //Shift from Inventory - 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(); } - } - } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - - if (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index b5e360a40..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerRangedCollector.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * This file ("ContainerRangedCollector.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityRangedCollector; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ClickType; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerRangedCollector extends Container { - - private final TileEntityRangedCollector collector; - - 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 < 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 < 9; i++) { - this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 148)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 18; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - if (theSlot != null && theSlot.getHasStack()) { - ItemStack newStack = theSlot.getStack(); - ItemStack currentStack = newStack.copy(); - - //Other Slots in Inventory excluded - if (slot >= inventoryStart) { - //Shift from Inventory - 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(); } - } - } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - - if (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) { - if (SlotFilter.checkFilter(this, slotId, player)) { - return StackUtil.getEmpty(); - } else { - return super.slotClick(slotId, dragType, clickTypeIn, player); - } - } - - @Override - 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 deleted file mode 100644 index 6ca69a116..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerRepairer.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file ("ContainerRepairer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemRepairer; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerRepairer extends Container { - - private final TileEntityItemRepairer tileRepairer; - - 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 < 9; i++) { - this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 2; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - if (theSlot != null && theSlot.getHasStack()) { - ItemStack newStack = theSlot.getStack(); - ItemStack currentStack = newStack.copy(); - - //Other Slots in Inventory excluded - 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(); } - } - // - - 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)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index 6cfd89925..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerSmileyCloud.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file ("ContainerSmileyCloud.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.item.ItemStack; - -public class ContainerSmileyCloud extends Container { - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - return ItemStack.EMPTY; - } - - @Override - 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 deleted file mode 100644 index c2fb8ceee..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerXPSolidifier.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file ("ContainerXPSolidifier.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput; -import de.ellpeck.actuallyadditions.mod.items.ItemSolidifiedExperience; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityXPSolidifier; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerXPSolidifier extends Container { - - private final TileEntityXPSolidifier solidifier; - - 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 < 9; i++) { - this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); - } - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slot) { - int inventoryStart = 2; - int inventoryEnd = inventoryStart + 26; - int hotbarStart = inventoryEnd + 1; - int hotbarEnd = hotbarStart + 8; - - Slot theSlot = this.inventorySlots.get(slot); - - 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 (!StackUtil.isValid(newStack)) { - theSlot.putStack(StackUtil.getEmpty()); - } else { - theSlot.onSlotChanged(); - } - - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } - theSlot.onTake(player, newStack); - - return currentStack; - } - return StackUtil.getEmpty(); - } - - @Override - 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 deleted file mode 100644 index 98c518c36..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/GuiFireworkBox.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * This file ("GuiFireworkBox.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFireworkBox; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiPageButtonList.GuiResponder; -import net.minecraft.client.gui.GuiSlider; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class GuiFireworkBox extends GuiContainer implements GuiResponder { - - private final TileEntityFireworkBox tile; - - public GuiFireworkBox(TileEntity tile) { - super(new ContainerFireworkBox()); - this.tile = (TileEntityFireworkBox) tile; - this.xSize = 300; - this.ySize = 120; - } - - @Override - 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, 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)); - } - - @Override - 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 + "!!"); - PacketHandlerHelper.sendNumberPacket(this.tile, value, id); - } - } - } - - @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { - - } - - @Override - public void drawGuiContainerForegroundLayer(int x, int y) { - AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.tile); - } - - @Override - public void setEntryValue(int id, boolean value) { - - } - - @Override - public void setEntryValue(int id, String value) { - - } - - 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) { - super(guiResponder, idIn, x, y, name, min, max, defaultValue, formatter); - this.responder = guiResponder; - } - - @Override - 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 { - - public static final IntFormatter INSTANCE = new IntFormatter(); - - @Override - 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 deleted file mode 100644 index 18c7f7879..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/GuiHandler.java +++ /dev/null @@ -1,287 +0,0 @@ -/* - * This file ("GuiHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet; -import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiMainPage; -import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; -import de.ellpeck.actuallyadditions.mod.data.PlayerData; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiBag; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiBioReactor; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiBreaker; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiCanolaPress; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiCoalGenerator; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiCoffeeMachine; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiDirectionalBreaker; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiDrill; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiDropper; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiEnergizer; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiEnervator; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFarmer; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFeeder; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFermentingBarrel; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFilter; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFluidCollector; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFurnaceDouble; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiGiantChest; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiGrinder; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiInputter; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiLaserRelayItemWhitelist; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiMiner; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiOilGenerator; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiPhantomPlacer; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiRangedCollector; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiRepairer; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiSmileyCloud; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiXPSolidifier; -import de.ellpeck.actuallyadditions.mod.items.ItemBooklet; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.util.compat.CompatUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.math.BlockPos; -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 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) { - TileEntityBase tile = null; - if (GuiTypes.values()[id].checkTileEntity) { - tile = (TileEntityBase) world.getTileEntity(new BlockPos(x, y, z)); - } - switch (GuiTypes.values()[id]) { - case FEEDER: - return new ContainerFeeder(player.inventory, tile); - case GIANT_CHEST: - return new ContainerGiantChest(player.inventory, tile, 0); - case GIANT_CHEST_PAGE_2: - return new ContainerGiantChest(player.inventory, tile, 1); - case GIANT_CHEST_PAGE_3: - return new ContainerGiantChest(player.inventory, tile, 2); - case CRAFTER: - return CompatUtil.getCrafterContainerElement(player, world, x, y, z); - case GRINDER: - return new ContainerGrinder(player.inventory, tile, false); - case GRINDER_DOUBLE: - return new ContainerGrinder(player.inventory, tile, true); - case FURNACE_DOUBLE: - return new ContainerFurnaceDouble(player.inventory, tile); - case INPUTTER: - return new ContainerInputter(player.inventory, tile, false); - case INPUTTER_ADVANCED: - return new ContainerInputter(player.inventory, tile, true); - case REPAIRER: - return new ContainerRepairer(player.inventory, tile); - case BREAKER: - return new ContainerBreaker(player.inventory, tile); - case DROPPER: - return new ContainerDropper(player, tile); - case CANOLA_PRESS: - return new ContainerCanolaPress(player.inventory, tile); - case FERMENTING_BARREL: - return new ContainerFermentingBarrel(player.inventory, tile); - case COAL_GENERATOR: - return new ContainerCoalGenerator(player.inventory, tile); - case OIL_GENERATOR: - return new ContainerOilGenerator(player.inventory, tile); - case PHANTOM_PLACER: - return new ContainerPhantomPlacer(player.inventory, tile); - case FLUID_COLLECTOR: - return new ContainerFluidCollector(player.inventory, tile); - case COFFEE_MACHINE: - return new ContainerCoffeeMachine(player.inventory, tile); - case DRILL: - return new ContainerDrill(player.inventory); - case FILTER: - return new ContainerFilter(player.inventory); - case ENERGIZER: - return new ContainerEnergizer(player, tile); - case ENERVATOR: - return new ContainerEnervator(player, tile); - case XP_SOLIDIFIER: - return new ContainerXPSolidifier(player.inventory, tile); - case CLOUD: - return new ContainerSmileyCloud(); - case DIRECTIONAL_BREAKER: - return new ContainerDirectionalBreaker(player.inventory, tile); - case RANGED_COLLECTOR: - return new ContainerRangedCollector(player.inventory, tile); - case MINER: - return new ContainerMiner(player.inventory, tile); - case LASER_RELAY_ITEM_WHITELIST: - return new ContainerLaserRelayItemWhitelist(player.inventory, tile); - case BAG: - return new ContainerBag(player.getHeldItemMainhand(), player.inventory, false); - case VOID_BAG: - return new ContainerBag(player.getHeldItemMainhand(), player.inventory, true); - case BIO_REACTOR: - return new ContainerBioReactor(player.inventory, tile); - case FARMER: - return new ContainerFarmer(player.inventory, tile); - case FIREWORK_BOX: - return new ContainerFireworkBox(); - default: - return null; - } - } - - @Override - 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)); - } - switch (GuiTypes.values()[id]) { - case FEEDER: - return new GuiFeeder(player.inventory, tile); - case GIANT_CHEST: - return new GuiGiantChest(player.inventory, tile, 0); - case GIANT_CHEST_PAGE_2: - return new GuiGiantChest(player.inventory, tile, 1); - case GIANT_CHEST_PAGE_3: - return new GuiGiantChest(player.inventory, tile, 2); - case CRAFTER: - return CompatUtil.getCrafterGuiElement(player, world, x, y, z); - case GRINDER: - return new GuiGrinder(player.inventory, tile); - case GRINDER_DOUBLE: - return new GuiGrinder.GuiGrinderDouble(player.inventory, tile); - case FURNACE_DOUBLE: - return new GuiFurnaceDouble(player.inventory, tile); - case INPUTTER: - return new GuiInputter(player.inventory, tile, false); - case INPUTTER_ADVANCED: - return new GuiInputter(player.inventory, tile, true); - case REPAIRER: - return new GuiRepairer(player.inventory, tile); - case BREAKER: - return new GuiBreaker(player.inventory, tile); - case DROPPER: - return new GuiDropper(player, tile); - case CANOLA_PRESS: - return new GuiCanolaPress(player.inventory, tile); - case FERMENTING_BARREL: - return new GuiFermentingBarrel(player.inventory, tile); - case COAL_GENERATOR: - return new GuiCoalGenerator(player.inventory, tile); - case OIL_GENERATOR: - return new GuiOilGenerator(player.inventory, tile); - case PHANTOM_PLACER: - return new GuiPhantomPlacer(player.inventory, tile); - case FLUID_COLLECTOR: - return new GuiFluidCollector(player.inventory, tile); - case COFFEE_MACHINE: - return new GuiCoffeeMachine(player.inventory, tile); - case DRILL: - return new GuiDrill(player.inventory); - case FILTER: - return new GuiFilter(player.inventory); - case ENERGIZER: - return new GuiEnergizer(player, tile); - case ENERVATOR: - return new GuiEnervator(player, tile); - case XP_SOLIDIFIER: - return new GuiXPSolidifier(player.inventory, tile); - case CLOUD: - return new GuiSmileyCloud(tile, x, y, z, world); - case BOOK: - if (ItemBooklet.forcedPage != null) { - GuiBooklet gui = BookletUtils.createBookletGuiFromPage(null, ItemBooklet.forcedPage); - ItemBooklet.forcedPage = null; - return gui; - } else { - PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player); - if (data.lastOpenBooklet != null) { - return data.lastOpenBooklet; - } else { - return new GuiMainPage(null); - } - } - case DIRECTIONAL_BREAKER: - return new GuiDirectionalBreaker(player.inventory, tile); - case RANGED_COLLECTOR: - return new GuiRangedCollector(player.inventory, tile); - case MINER: - return new GuiMiner(player.inventory, tile); - case LASER_RELAY_ITEM_WHITELIST: - return new GuiLaserRelayItemWhitelist(player.inventory, tile); - case BAG: - return new GuiBag(player.getHeldItemMainhand(), player.inventory, false); - case VOID_BAG: - return new GuiBag(player.getHeldItemMainhand(), player.inventory, true); - case BIO_REACTOR: - return new GuiBioReactor(player.inventory, tile); - case FARMER: - return new GuiFarmer(player.inventory, tile); - case FIREWORK_BOX: - return new GuiFireworkBox(tile); - default: - return null; - } - } - - public enum GuiTypes { - FEEDER, - GIANT_CHEST, - GIANT_CHEST_PAGE_2, - GIANT_CHEST_PAGE_3, - CRAFTER(false), - GRINDER, - GRINDER_DOUBLE, - FURNACE_DOUBLE, - INPUTTER, - REPAIRER, - INPUTTER_ADVANCED, - BREAKER, - DROPPER, - CANOLA_PRESS, - FERMENTING_BARREL, - COAL_GENERATOR, - OIL_GENERATOR, - PHANTOM_PLACER, - FLUID_COLLECTOR, - COFFEE_MACHINE, - DRILL(false), - ENERGIZER, - ENERVATOR, - XP_SOLIDIFIER, - CLOUD, - BOOK(false), - DIRECTIONAL_BREAKER, - RANGED_COLLECTOR, - MINER, - LASER_RELAY_ITEM_WHITELIST, - FILTER(false), - BAG(false), - VOID_BAG(false), - BIO_REACTOR, - FARMER, - FIREWORK_BOX; - - public final boolean checkTileEntity; - - GuiTypes() { - this(true); - } - - GuiTypes(boolean checkTileEntity) { - this.checkTileEntity = checkTileEntity; - } - } -} \ No newline at end of file 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 deleted file mode 100644 index 97e00004d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/EnergyDisplay.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file ("EnergyDisplay.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraftforge.fml.client.config.GuiUtils; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class EnergyDisplay extends Gui { - - private CustomEnergyStorage rfReference; - private int x; - private int y; - private boolean outline; - private 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) { - this(x, y, rfReference, false, false); - } - - public void setData(int x, int y, CustomEnergyStorage rfReference, boolean outline, boolean drawTextNextTo) { - this.x = x; - this.y = y; - this.rfReference = rfReference; - this.outline = outline; - this.drawTextNextTo = drawTextNextTo; - } - - 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) { - this.drawTexturedModalRect(this.x, this.y, 52, 163, 26, 93); - - barX += 4; - barY += 4; - } - this.drawTexturedModalRect(barX, barY, 18, 171, 18, 85); - - 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); - GlStateManager.color(1F, 1F, 1F); - } - - 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)) { - Minecraft mc = Minecraft.getMinecraft(); - - List text = new ArrayList<>(); - text.add(this.getOverlayText()); - GuiUtils.drawHoveringText(text, mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRenderer); - } - } - - 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() { - 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 deleted file mode 100644 index 16022195f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FilterSettingsGui.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This file ("FilterSettingsGui.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.client.config.GuiUtils; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class FilterSettingsGui extends Gui { - - private final FilterSettings theSettings; - - public SmallerButton whitelistButton; - public SmallerButton metaButton; - public SmallerButton nbtButton; - public SmallerButton modButton; - public SmallerButton oredictButton; - - public FilterSettingsGui(FilterSettings settings, int x, int y, List buttonList) { - this.theSettings = settings; - - this.whitelistButton = new SmallerButton(this.theSettings.whitelistButtonId, x, y, "", true); - buttonList.add(this.whitelistButton); - y += 14; - this.metaButton = new SmallerButton(this.theSettings.metaButtonId, x, y, "", true); - buttonList.add(this.metaButton); - y += 14; - this.nbtButton = new SmallerButton(this.theSettings.nbtButtonId, x, y, "", true); - buttonList.add(this.nbtButton); - y += 14; - this.oredictButton = new SmallerButton(this.theSettings.oredictButtonId, x, y, "", true); - buttonList.add(this.oredictButton); - y += 15; - this.modButton = new SmallerButton(this.theSettings.modButtonId, x, y, "", true); - buttonList.add(this.modButton); - - 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 drawHover(int mouseX, int mouseY) { - Minecraft mc = Minecraft.getMinecraft(); - - 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)); - 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()) { - 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.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()) { - 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"))); - - String type = null; - if (this.theSettings.respectOredict == 1) { - type = "one"; - } 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)); - } - 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 deleted file mode 100644 index 31f615196..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/FluidDisplay.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * This file ("FluidDisplay.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; -import net.minecraftforge.fml.client.config.GuiUtils; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class FluidDisplay extends Gui { - - private FluidTank fluidReference; - private Fluid oldFluid; - - private int x; - private int y; - private boolean outline; - - private ResourceLocation resLoc; - - private 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) { - this(x, y, fluidReference, false, false); - } - - public void setData(int x, int y, FluidTank fluidReference, boolean outline, boolean drawTextNextTo) { - this.x = x; - this.y = y; - this.fluidReference = fluidReference; - this.outline = outline; - this.drawTextNextTo = drawTextNextTo; - } - - 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) { - this.drawTexturedModalRect(this.x, this.y, 52, 163, 26, 93); - - barX += 4; - barY += 4; - } - this.drawTexturedModalRect(barX, barY, 0, 171, 18, 85); - - FluidStack stack = this.fluidReference.getFluid(); - Fluid fluid = stack == null ? null : stack.getFluid(); - - 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 (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); - GlStateManager.disableBlend(); - GlStateManager.enableAlpha(); - GlStateManager.popMatrix(); - } - - 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)) { - Minecraft mc = Minecraft.getMinecraft(); - GuiUtils.drawHoveringText(Collections.singletonList(this.getOverlayText()), mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRenderer); - } - } - - 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(); - } -} 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 deleted file mode 100644 index e230d5be5..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBag.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * This file ("GuiBag.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.network.PacketHandler; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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"); - - private final ContainerBag container; - private final boolean isVoid; - private FilterSettingsGui filter; - private GuiButton buttonAutoInsert; - - public GuiBag(ItemStack sack, InventoryPlayer inventory, boolean isVoid) { - this(isVoid, new ContainerBag(sack, inventory, isVoid)); - } - - private GuiBag(boolean isVoid, ContainerBag container) { - super(container); - this.xSize = 176; - this.ySize = 90 + 86; - this.isVoid = isVoid; - this.container = container; - } - - @Override - public void initGui() { - super.initGui(); - - 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.buttonList.add(this.buttonAutoInsert); - } - - @Override - protected void actionPerformed(GuiButton button) throws IOException { - NBTTagCompound data = new NBTTagCompound(); - data.setInteger("ButtonID", button.id); - data.setInteger("PlayerID", Minecraft.getMinecraft().player.getEntityId()); - data.setInteger("WorldID", Minecraft.getMinecraft().world.provider.getDimension()); - PacketHandler.theNetwork.sendToServer(new PacketClientToServer(data, PacketHandler.GUI_BUTTON_TO_CONTAINER_HANDLER)); - } - - @Override - public void updateScreen() { - super.updateScreen(); - this.filter.update(); - - 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")); - } - - @Override - 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.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) { - super.drawScreen(mouseX, mouseY, partialTicks); - this.filter.drawHover(mouseX, mouseY); - - if (this.buttonAutoInsert.isMouseOver()) { - List text = new ArrayList<>(); - 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)); - this.drawHoveringText(text, mouseX, mouseY); - } - } -} \ No newline at end of file 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 deleted file mode 100644 index 2f39e853b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBioReactor.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file ("GuiBioReactor.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerBioReactor; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBioReactor; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; - -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) { - super(new ContainerBioReactor(inventory, tile)); - this.tile = (TileEntityBioReactor) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - public void initGui() { - super.initGui(); - this.energy = new EnergyDisplay(this.guiLeft + 116, this.guiTop + 5, this.tile.storage); - } - - @Override - 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) { - AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.tile); - } - - @Override - 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.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.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 deleted file mode 100644 index 98649cdf5..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBreaker.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file ("GuiBreaker.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerBreaker; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(new ContainerBreaker(inventory, tile)); - this.breaker = (TileEntityBreaker) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - 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) { - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - } -} \ No newline at end of file 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 deleted file mode 100644 index d06c1d20b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCanolaPress.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file ("GuiCanolaPress.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerCanolaPress; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(new ContainerCanolaPress(inventory, tile)); - this.press = (TileEntityCanolaPress) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - 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); - } - - @Override - 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) { - AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.press); - } - - @Override - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - - if (this.press.currentProcessTime > 0) { - int i = this.press.getProcessScaled(29); - this.drawTexturedModalRect(this.guiLeft + 83, this.guiTop + 32, 176, 0, 12, i); - } - - this.energy.draw(); - this.fluid.draw(); - } -} \ No newline at end of file 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 deleted file mode 100644 index 8ab878610..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoalGenerator.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file ("GuiCoalGenerator.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerCoalGenerator; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(new ContainerCoalGenerator(inventory, tile)); - this.generator = (TileEntityCoalGenerator) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - public void initGui() { - super.initGui(); - this.energy = new EnergyDisplay(this.guiLeft + 42, this.guiTop + 5, this.generator.storage); - } - - @Override - 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) { - AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.generator); - } - - @Override - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - - 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.energy.draw(); - } -} \ No newline at end of file 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 deleted file mode 100644 index fcc879603..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiCoffeeMachine.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This file ("GuiCoffeeMachine.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class GuiCoffeeMachine extends GuiWtfMojang { - - private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_coffee_machine"); - private final TileEntityCoffeeMachine machine; - - private EnergyDisplay energy; - private FluidDisplay fluid; - - public GuiCoffeeMachine(InventoryPlayer inventory, TileEntityBase tile) { - super(new ContainerCoffeeMachine(inventory, tile)); - this.machine = (TileEntityCoffeeMachine) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - 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")); - 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); - } - - @Override - 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) { - this.drawHoveringText(Collections.singletonList(text2), x, y); - } - - this.energy.drawOverlay(x, y); - this.fluid.drawOverlay(x, y); - } - - @Override - 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) { - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - - if (this.machine.coffeeCacheAmount > 0) { - int i = this.machine.getCoffeeScaled(30); - this.drawTexturedModalRect(this.guiLeft + 41, this.guiTop + 56 - i, 192, 0, 8, i); - } - - if (this.machine.brewTime > 0) { - int i = this.machine.getBrewScaled(23); - 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.energy.draw(); - this.fluid.draw(); - } - - @Override - 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 deleted file mode 100644 index 50a4fffef..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDirectionalBreaker.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file ("GuiDirectionalBreaker.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerDirectionalBreaker; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityDirectionalBreaker; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(new ContainerDirectionalBreaker(inventory, tile)); - this.breaker = (TileEntityDirectionalBreaker) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - public void initGui() { - super.initGui(); - this.energy = new EnergyDisplay(this.guiLeft + 42, this.guiTop + 5, this.breaker.storage); - } - - @Override - 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) { - AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.breaker); - } - - @Override - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - - this.energy.draw(); - } -} \ No newline at end of file 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 deleted file mode 100644 index 7ed16f66d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDrill.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file ("GuiDrill.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.inventory.ContainerDrill; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class GuiDrill extends GuiWtfMojang { - - private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_drill"); - - public GuiDrill(InventoryPlayer inventory) { - super(new ContainerDrill(inventory)); - this.xSize = 176; - 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")); - } - - @Override - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 54); - } -} \ No newline at end of file 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 deleted file mode 100644 index 7175054a3..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiDropper.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file ("GuiDropper.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerDropper; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(new ContainerDropper(player, tile)); - this.dropper = (TileEntityDropper) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - 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) { - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - } -} \ No newline at end of file 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 deleted file mode 100644 index d29b30f3b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnergizer.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file ("GuiEnergizer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerEnergizer; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(new ContainerEnergizer(inventory, tile)); - this.energizer = (TileEntityEnergizer) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - public void initGui() { - super.initGui(); - this.energy = new EnergyDisplay(this.guiLeft + 56, this.guiTop + 5, this.energizer.storage); - } - - @Override - 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) { - AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.energizer); - } - - @Override - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - - this.energy.draw(); - } -} \ No newline at end of file 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 deleted file mode 100644 index 0fd6a5df3..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiEnervator.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file ("GuiEnervator.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerEnervator; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(new ContainerEnervator(inventory, tile)); - this.enervator = (TileEntityEnervator) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - public void initGui() { - super.initGui(); - this.energy = new EnergyDisplay(this.guiLeft + 56, this.guiTop + 5, this.enervator.storage); - } - - @Override - 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) { - AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.enervator); - } - - @Override - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - - this.energy.draw(); - } -} \ No newline at end of file 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 deleted file mode 100644 index 44c5ae42b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFarmer.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This file ("GuiFarmer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerFarmer; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFarmer; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(new ContainerFarmer(inventory, tile)); - this.farmer = (TileEntityFarmer) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - public void initGui() { - super.initGui(); - - this.energy = new EnergyDisplay(this.guiLeft + 33, this.guiTop + 6, this.farmer.storage); - } - - @Override - 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) { - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - - this.energy.draw(); - } - - @Override - public void drawScreen(int x, int y, float f) { - super.drawScreen(x, y, f); - this.energy.drawOverlay(x, y); - } -} \ No newline at end of file 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 deleted file mode 100644 index 45bfe2da5..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFeeder.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file ("GuiFeeder.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFeeder; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(new ContainerFeeder(inventory, tile)); - this.tileFeeder = (TileEntityFeeder) tile; - this.xSize = 176; - this.ySize = 70 + 86; - } - - @Override - 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") }; - this.drawHoveringText(Arrays.asList(array), x, y); - } - } - - @Override - 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) { - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 70); - - 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); - } - - 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); - } - } -} \ 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 deleted file mode 100644 index 818940186..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFermentingBarrel.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file ("GuiFermentingBarrel.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerFermentingBarrel; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFermentingBarrel; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(new ContainerFermentingBarrel(inventory, tile)); - this.press = (TileEntityFermentingBarrel) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - 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() { - 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); - } - - @Override - 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) { - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - - if (this.press.currentProcessTime > 0) { - int i = this.press.getProcessScaled(29); - this.drawTexturedModalRect(this.guiLeft + 82, this.guiTop + 34, 176, 0, 12, i); - } - - this.input.draw(); - this.output.draw(); - } -} \ No newline at end of file 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 deleted file mode 100644 index 48e27d4ee..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFilter.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file ("GuiFilter.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.inventory.ContainerFilter; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class GuiFilter extends GuiWtfMojang { - - private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_filter"); - - public GuiFilter(InventoryPlayer inventory) { - super(new ContainerFilter(inventory)); - this.xSize = 176; - 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")); - } - - @Override - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 90); - } -} \ No newline at end of file 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 deleted file mode 100644 index b50c2aa24..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFluidCollector.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file ("GuiFluidCollector.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerFluidCollector; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidCollector; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(new ContainerFluidCollector(inventory, tile)); - this.collector = (TileEntityFluidCollector) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - public void drawScreen(int x, int y, float f) { - super.drawScreen(x, y, f); - - this.fluid.drawOverlay(x, y); - } - - @Override - public void initGui() { - super.initGui(); - this.fluid = new FluidDisplay(this.guiLeft + 67, this.guiTop + 5, this.collector.tank); - } - - @Override - 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) { - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - - this.fluid.draw(); - } -} \ No newline at end of file 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 deleted file mode 100644 index 84d7ef70a..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiFurnaceDouble.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * This file ("GuiFurnaceDouble.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceDouble; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class GuiFurnaceDouble extends GuiWtfMojang { - - private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_furnace_double"); - private final TileEntityFurnaceDouble tileFurnace; - private EnergyDisplay energy; - - private GuiButton buttonAutoSplit; - - public GuiFurnaceDouble(InventoryPlayer inventory, TileEntityBase tile) { - super(new ContainerFurnaceDouble(inventory, tile)); - this.tileFurnace = (TileEntityFurnaceDouble) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - 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); - } - } - - @Override - public void initGui() { - super.initGui(); - 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() { - super.updateScreen(); - - this.buttonAutoSplit.displayString = (this.tileFurnace.isAutoSplit ? TextFormatting.DARK_GREEN : TextFormatting.RED) + "S"; - } - - @Override - 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) { - AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.tileFurnace); - } - - @Override - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - - if (this.tileFurnace.firstSmeltTime > 0) { - int i = this.tileFurnace.getFirstTimeToScale(23); - this.drawTexturedModalRect(this.guiLeft + 51, this.guiTop + 40, 176, 0, 24, i); - } - if (this.tileFurnace.secondSmeltTime > 0) { - int i = this.tileFurnace.getSecondTimeToScale(23); - this.drawTexturedModalRect(this.guiLeft + 101, this.guiTop + 40, 176, 22, 24, i); - } - - this.energy.draw(); - } -} \ No newline at end of file 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 deleted file mode 100644 index 981eff115..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGiantChest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file ("GuiGiantChest.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestLarge; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestMedium; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(new ContainerGiantChest(inventory, tile, page)); - this.chest = (TileEntityGiantChest) tile; - this.page = page; - - this.xSize = 242; - this.ySize = 172 + 86; - } - - @Override - 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.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) { - PacketHandlerHelper.sendButtonPacket(this.chest, button.id); - } - } - - @Override - 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) { - 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); - } -} \ 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 deleted file mode 100644 index fe4c13473..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiGrinder.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * This file ("GuiGrinder.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinder; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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"); - private final TileEntityGrinder tileGrinder; - private final boolean isDouble; - private EnergyDisplay energy; - - private GuiButton buttonAutoSplit; - - public GuiGrinder(InventoryPlayer inventoryPlayer, TileEntityBase tile) { - this(inventoryPlayer, tile, false); - } - - private GuiGrinder(InventoryPlayer inventory, TileEntityBase tile, boolean isDouble) { - super(new ContainerGrinder(inventory, tile, isDouble)); - this.tileGrinder = (TileEntityGrinder) tile; - this.isDouble = isDouble; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - public void initGui() { - super.initGui(); - 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"); - this.buttonList.add(this.buttonAutoSplit); - } - } - - @Override - protected void actionPerformed(GuiButton button) throws IOException { - if (this.isDouble && button.id == 0) { - PacketHandlerHelper.sendButtonPacket(this.tileGrinder, button.id); - } - } - - @Override - public void updateScreen() { - super.updateScreen(); - - 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) { - super.drawScreen(x, y, f); - this.energy.drawOverlay(x, y); - - 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); - } - } - - @Override - 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) { - 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.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) { - int i = this.tileGrinder.getFirstTimeToScale(23); - this.drawTexturedModalRect(this.guiLeft + (this.isDouble ? 51 : 80), this.guiTop + 40, 176, 0, 24, i); - } - 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.energy.draw(); - } - - public static class GuiGrinderDouble extends GuiGrinder { - - public GuiGrinderDouble(InventoryPlayer inventory, TileEntityBase tile) { - super(inventory, tile, true); - } - } -} \ No newline at end of file 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 deleted file mode 100644 index 880a376d7..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiInputter.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * This file ("GuiInputter.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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.ContainerInputter; -import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityInputter; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiTextField; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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") }; - 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; - private final boolean isAdvanced; - private GuiTextField fieldPutStart; - private GuiTextField fieldPutEnd; - private GuiTextField fieldPullStart; - private GuiTextField fieldPullEnd; - - private FilterSettingsGui leftFilter; - private FilterSettingsGui rightFilter; - - public GuiInputter(InventoryPlayer inventory, TileEntityBase tile, boolean isAdvanced) { - super(new ContainerInputter(inventory, tile, isAdvanced)); - this.tileInputter = (TileEntityInputter) tile; - this.xSize = 176; - this.ySize = 97 + 86 + (isAdvanced ? OFFSET_ADVANCED : 0); - this.isAdvanced = isAdvanced; - } - - @Override - 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); - } - - 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.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.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.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 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))); - } - - @Override - public void drawScreen(int x, int y, float f) { - super.drawScreen(x, y, f); - - 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 + 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 + 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) { - this.leftFilter.drawHover(x, y); - this.rightFilter.drawHover(x, y); - } - } - - @Override - 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) { - 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.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.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(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(); - this.fieldPullStart.drawTextBox(); - this.fieldPullEnd.drawTextBox(); - } - - @Override - 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); - this.fieldPullEnd.mouseClicked(par1, par2, par3); - - super.mouseClicked(par1, par2, par3); - } - - @Override - 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()) { - this.setVariable(this.fieldPutEnd, 1); - } - if (this.fieldPullStart.isFocused()) { - this.setVariable(this.fieldPullStart, 2); - } - 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) { - this.fieldPutStart.textboxKeyTyped(theChar, key); - this.fieldPutEnd.textboxKeyTyped(theChar, key); - this.fieldPullStart.textboxKeyTyped(theChar, key); - this.fieldPullEnd.textboxKeyTyped(theChar, key); - } else { - super.keyTyped(theChar, key); - } - } - - @Override - public void updateScreen() { - super.updateScreen(); - - this.fieldPutStart.updateCursorCounter(); - this.fieldPutEnd.updateCursorCounter(); - this.fieldPullStart.updateCursorCounter(); - this.fieldPullEnd.updateCursorCounter(); - - if (this.isAdvanced) { - this.leftFilter.update(); - this.rightFilter.update(); - } - } - - 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) { - PacketHandlerHelper.sendNumberPacket(this.tileInputter, text, textID); - } - - private int parse(String theInt) { - try { - return Integer.parseInt(theInt); - } catch (Exception e) { - return -1; - } - } - - @Override - 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 { - PacketHandlerHelper.sendButtonPacket(this.tileInputter, button.id); - } - } - - @SideOnly(Side.CLIENT) - 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) { - this(id, x, y, display, false); - } - - 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) { - 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; - 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.mouseDragged(mc, x, y); - - int color = 14737632; - if (this.packedFGColour != 0) { - color = this.packedFGColour; - } else if (!this.enabled) { - color = 10526880; - } else if (this.hovered) { - color = 16777120; - } - - 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 final ResourceLocation resLoc = AssetUtil.getGuiLocation("gui_inputter"); - - 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) { - 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; - 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.mouseDragged(mc, x, y); - } - } - } -} \ No newline at end of file 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 deleted file mode 100644 index 22d653987..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiLaserRelayItemWhitelist.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * This file ("GuiLaserRelayItemWhitelist.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItemWhitelist; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class GuiLaserRelayItemWhitelist extends GuiWtfMojang { - - private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_laser_relay_item_whitelist"); - private final TileEntityLaserRelayItemWhitelist tile; - - private FilterSettingsGui leftFilter; - private FilterSettingsGui rightFilter; - - private GuiButton buttonSmartWhitelistLeft; - private GuiButton buttonSmartWhitelistRight; - - public GuiLaserRelayItemWhitelist(InventoryPlayer inventory, TileEntityBase tile) { - super(new ContainerLaserRelayItemWhitelist(inventory, tile)); - this.tile = (TileEntityLaserRelayItemWhitelist) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - public void updateScreen() { - super.updateScreen(); - - this.leftFilter.update(); - this.rightFilter.update(); - } - - @Override - 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.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) { - PacketHandlerHelper.sendButtonPacket(this.tile, button.id); - } - - @Override - public void drawScreen(int x, int y, float f) { - super.drawScreen(x, y, f); - - 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)); - this.drawHoveringText(list, x, y); - } - - this.leftFilter.drawHover(x, y); - this.rightFilter.drawHover(x, y); - } - - @Override - 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); - } - - @Override - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - - } -} \ No newline at end of file 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 deleted file mode 100644 index a225dfec2..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiMiner.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file ("GuiMiner.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerMiner; -import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityMiner; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(new ContainerMiner(inventory, tile)); - this.miner = (TileEntityMiner) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - public void initGui() { - super.initGui(); - - 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"); - this.buttonList.add(buttonReset); - } - - @Override - 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) { - 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.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); - } - - @Override - 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 deleted file mode 100644 index 2b76070a2..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiOilGenerator.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file ("GuiOilGenerator.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerOilGenerator; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class GuiOilGenerator extends GuiWtfMojang { - - private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_oil_generator"); - private final TileEntityOilGenerator generator; - - private EnergyDisplay energy; - private FluidDisplay fluid; - - public GuiOilGenerator(InventoryPlayer inventory, TileEntityBase tile) { - super(new ContainerOilGenerator(inventory, tile)); - this.generator = (TileEntityOilGenerator) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - 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); - } - - @Override - 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) { - AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.generator); - } - - @Override - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - - 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); - } - - 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; - StringUtil.renderScaledAsciiString(this.fontRenderer, "(per 50 mB)", xS, (this.guiTop + 85) * 1.345F, 0xFFFFFF, true, 0.75F); - GlStateManager.popMatrix(); - } - - this.energy.draw(); - this.fluid.draw(); - } -} \ No newline at end of file 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 deleted file mode 100644 index 32aa3ad8d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiPhantomPlacer.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This file ("GuiPhantomPlacer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomPlacer; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(new ContainerPhantomPlacer(inventory, tile)); - this.placer = (TileEntityPhantomPlacer) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - 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())); - } - } - - @Override - public void updateScreen() { - super.updateScreen(); - - if (!this.placer.isBreaker) { - this.buttonList.get(0).displayString = this.getSide(); - } - } - - @Override - 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"; - - List textList = new ArrayList<>(); - 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) { - PacketHandlerHelper.sendButtonPacket(this.placer, button.id); - } - } - - private String getSide() { - return GuiInputter.SIDES[this.placer.side + 1]; - } - - @Override - 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) { - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - } -} \ No newline at end of file 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 deleted file mode 100644 index 014844b8e..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRangedCollector.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file ("GuiRangedCollector.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerRangedCollector; -import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityRangedCollector; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(new ContainerRangedCollector(inventory, tile)); - this.collector = (TileEntityRangedCollector) tile; - this.xSize = 176; - this.ySize = 86 + 86; - } - - @Override - public void initGui() { - super.initGui(); - - 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) { - super.drawScreen(x, y, f); - - this.filter.drawHover(x, y); - } - - @Override - public void updateScreen() { - super.updateScreen(); - - this.filter.update(); - } - - @Override - 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) { - 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.mc.getTextureManager().bindTexture(RES_LOC); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 86); - } - - @Override - 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 deleted file mode 100644 index 2568f9dd2..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiRepairer.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file ("GuiRepairer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerRepairer; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemRepairer; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(new ContainerRepairer(inventory, tile)); - this.tileRepairer = (TileEntityItemRepairer) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - public void initGui() { - super.initGui(); - this.energy = new EnergyDisplay(this.guiLeft + 27, this.guiTop + 5, this.tileRepairer.storage); - } - - @Override - 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) { - AssetUtil.displayNameString(this.fontRenderer, this.xSize, -10, this.tileRepairer); - } - - @Override - 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.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))) { - int i = this.tileRepairer.getItemDamageToScale(22); - this.drawTexturedModalRect(this.guiLeft + 73, this.guiTop + 52, 176, 28, i, 16); - } - - this.energy.draw(); - } -} \ No newline at end of file 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 deleted file mode 100644 index 653e103a8..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiSmileyCloud.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * This file ("GuiSmileyCloud.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.network.PacketHandler; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiTextField; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class GuiSmileyCloud extends GuiWtfMojang { - - private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_smiley_cloud"); - - private final int x; - private final int y; - private final int z; - private final World world; - private final TileEntitySmileyCloud cloud; - private GuiTextField nameField; - - public GuiSmileyCloud(TileEntityBase tile, int x, int y, int z, World world) { - super(new ContainerSmileyCloud()); - this.cloud = (TileEntitySmileyCloud) tile; - this.x = x; - this.y = y; - this.z = z; - this.world = world; - this.xSize = 124; - this.ySize = 20; - } - - @Override - public void initGui() { - super.initGui(); - - 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); - } - - @Override - 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, this.xSize, this.ySize); - - this.nameField.drawTextBox(); - } - - @Override - 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) { - this.setVariable(this.nameField); - } else { - this.nameField.textboxKeyTyped(theChar, key); - } - } else { - super.keyTyped(theChar, key); - } - } - - @Override - public void updateScreen() { - super.updateScreen(); - this.nameField.updateCursorCounter(); - } - - public void setVariable(GuiTextField field) { - this.sendPacket(field.getText(), 0); - field.setText(""); - } - - private void sendPacket(String text, int textID) { - NBTTagCompound compound = new NBTTagCompound(); - compound.setInteger("X", this.x); - compound.setInteger("Y", this.y); - compound.setInteger("Z", this.z); - compound.setInteger("WorldID", this.world.provider.getDimension()); - compound.setInteger("PlayerID", Minecraft.getMinecraft().player.getEntityId()); - compound.setInteger("TextID", textID); - compound.setString("Text", text); - PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_STRING_TO_TILE_HANDLER)); - } -} \ No newline at end of file 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 deleted file mode 100644 index 4304dbd44..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiWtfMojang.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file ("GuiWtfMojang.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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 GuiWtfMojang(Container inventorySlotsIn) { - super(inventorySlotsIn); - } - - @Override - 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 deleted file mode 100644 index 23438b279..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiXPSolidifier.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * This file ("GuiXPSolidifier.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.gui; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerXPSolidifier; -import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityXPSolidifier; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - super(new ContainerXPSolidifier(inventory, tile)); - this.solidifier = (TileEntityXPSolidifier) tile; - this.xSize = 176; - this.ySize = 93 + 86; - } - - @Override - 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"); - - this.buttonList.add(buttonOne); - this.buttonList.add(buttonFive); - this.buttonList.add(buttonTen); - this.buttonList.add(buttonTwenty); - this.buttonList.add(buttonThirty); - this.buttonList.add(buttonForty); - this.buttonList.add(buttonFifty); - this.buttonList.add(buttonSixtyFour); - this.buttonList.add(buttonAll); - } - - @Override - 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) { - 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.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); - } - - @Override - public void actionPerformed(GuiButton button) { - PacketHandlerHelper.sendButtonPacket(this.solidifier, button.id); - - this.solidifier.onButtonPressed(button.id, Minecraft.getMinecraft().player); - } -} \ No newline at end of file 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 deleted file mode 100644 index e3401f027..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/TexturedButton.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file ("TexturedButton.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.client.config.GuiUtils; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -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) { - 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) { - super(id, x, y, width, height, ""); - this.texturePosX = texturePosX; - this.texturePosY = texturePosY; - this.resLoc = resLoc; - this.textList.addAll(hoverTextList); - } - - @Override - 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; - int k = this.getHoverState(this.hovered); - 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.mouseDragged(minecraft, x, y); - } - } - - 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 deleted file mode 100644 index eaa9b6a5a..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotDeletion.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file ("SlotDeletion.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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 SlotDeletion(ItemStackHandlerAA inv, int slot, int x, int y) { - super(inv, slot, x, y); - } - - @Override - 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 deleted file mode 100644 index a2ce69533..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotFilter.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This file ("SlotFilter.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.slot; - -import de.ellpeck.actuallyadditions.mod.items.ItemFilter; -import de.ellpeck.actuallyadditions.mod.tile.FilterSettings; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class SlotFilter extends SlotItemHandlerUnconditioned { - - 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) { - this(inv.filterInventory, slot, x, y); - } - - 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); - return true; - } - } - return false; - } - - public static boolean isFilter(ItemStack stack) { - return StackUtil.isValid(stack) && stack.getItem() instanceof ItemFilter; - } - - private void slotClick(EntityPlayer player) { - ItemStack heldStack = player.inventory.getItemStack(); - ItemStack stackInSlot = this.getStack(); - - 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)) { - ItemStack s = heldStack.copy(); - s.setCount(1); - this.putStack(s); - - if (isFilter(heldStack)) { - heldStack.shrink(1); - } - } - } - } - - @Override - public boolean isItemValid(ItemStack stack) { - return false; - } - - @Override - public void putStack(ItemStack stack) { - super.putStack(stack.copy()); - } - - @Override - 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 deleted file mode 100644 index cec0555ce..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotImmovable.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file ("SlotImmovable.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.slot; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class SlotImmovable extends Slot { - - public SlotImmovable(IInventory inventory, int id, int x, int y) { - super(inventory, id, x, y); - } - - @Override - public boolean isItemValid(ItemStack stack) { - return false; - } - - @Override - public void putStack(ItemStack stack) { - - } - - @Override - public ItemStack decrStackSize(int i) { - return ItemStack.EMPTY; - } - - @Override - public boolean canTakeStack(EntityPlayer player) { - return false; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotItemHandlerUnconditioned.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotItemHandlerUnconditioned.java deleted file mode 100644 index 6246f4f64..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotItemHandlerUnconditioned.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file ("SlotItemHandlerUnconditioned.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.inventory.slot; - -import javax.annotation.Nonnull; - -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.items.SlotItemHandler; - -public class SlotItemHandlerUnconditioned extends SlotItemHandler { - - private final ItemStackHandlerAA inv; - - public SlotItemHandlerUnconditioned(ItemStackHandlerAA inv, int index, int xPosition, int yPosition) { - super(inv, index, xPosition, yPosition); - this.inv = inv; - } - - @Override - public boolean isItemValid(ItemStack stack) { - if (stack.isEmpty() || !this.inv.canAccept(this.getSlotIndex(), stack, false)) return false; - - ItemStack currentStack = this.inv.getStackInSlot(this.getSlotIndex()); - this.inv.setStackInSlot(this.getSlotIndex(), ItemStack.EMPTY); - ItemStack remainder = this.inv.insertItem(this.getSlotIndex(), stack, true, false); - this.inv.setStackInSlot(this.getSlotIndex(), currentStack); - return remainder.isEmpty() || remainder.getCount() < stack.getCount(); - } - - /** - * Helper fnct to get the stack in the slot. - */ - @Override - @Nonnull - public ItemStack getStack() { - return this.inv.getStackInSlot(this.getSlotIndex()); - } - - @Override - public void putStack(ItemStack stack) { - this.inv.setStackInSlot(this.getSlotIndex(), stack); - this.onSlotChanged(); - } - - @Override - public int getItemStackLimit(ItemStack stack) { - ItemStack maxAdd = stack.copy(); - maxAdd.setCount(stack.getMaxStackSize()); - ItemStack currentStack = this.inv.getStackInSlot(this.getSlotIndex()); - this.inv.setStackInSlot(this.getSlotIndex(), ItemStack.EMPTY); - ItemStack remainder = this.inv.insertItem(this.getSlotIndex(), maxAdd, true, false); - this.inv.setStackInSlot(this.getSlotIndex(), currentStack); - return stack.getMaxStackSize() - remainder.getCount(); - } - - @Override - public boolean canTakeStack(EntityPlayer playerIn) { - return !this.inv.extractItem(this.getSlotIndex(), 1, true, false).isEmpty(); - } - - @Override - public ItemStack decrStackSize(int amount) { - return this.inv.extractItem(this.getSlotIndex(), amount, false, 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 deleted file mode 100644 index 564b8a3ae..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotOutput.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file ("SlotOutput.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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 SlotOutput(ItemStackHandlerAA inventory, int id, int x, int y) { - super(inventory, id, x, y); - } - - @Override - public boolean isItemValid(ItemStack stack) { - return false; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/item/AAItems.java b/src/main/java/de/ellpeck/actuallyadditions/mod/item/AAItems.java new file mode 100644 index 000000000..8ff27d9bc --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/item/AAItems.java @@ -0,0 +1,20 @@ +package de.ellpeck.actuallyadditions.mod.item; + +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import net.minecraft.item.Item; +import net.minecraftforge.event.RegistryEvent.Register; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; +import net.minecraftforge.registries.ObjectHolder; + +@EventBusSubscriber(modid = ActuallyAdditions.MODID, bus = Bus.MOD) +@ObjectHolder(ActuallyAdditions.MODID) +public class AAItems { + + @SubscribeEvent + public static void register(Register e) { + + } + +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitItems.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitItems.java deleted file mode 100644 index b763a4eb7..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitItems.java +++ /dev/null @@ -1,378 +0,0 @@ -/* - * This file ("InitItems.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.items.base.ItemArmorAA; -import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodSeed; -import de.ellpeck.actuallyadditions.mod.items.base.ItemHoeAA; -import de.ellpeck.actuallyadditions.mod.items.base.ItemSeed; -import de.ellpeck.actuallyadditions.mod.items.base.ItemSwordAA; -import de.ellpeck.actuallyadditions.mod.items.lens.ItemLens; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.material.InitArmorMaterials; -import de.ellpeck.actuallyadditions.mod.material.InitToolMaterials; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestMedium; -import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.init.MobEffects; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.PotionEffect; -import net.minecraft.tileentity.TileEntityChest; - -public final class InitItems { - - public static Item itemBooklet; - public static Item itemFertilizer; - public static Item itemMisc; - public static Item itemFoods; - public static Item itemJams; - public static Item itemKnife; - public static Item itemCrafterOnAStick; - public static Item itemDust; - public static Item itemSolidifiedExperience; - public static Item itemLeafBlower; - public static Item itemLeafBlowerAdvanced; - public static Item itemPotionRing; - public static Item itemPotionRingAdvanced; - public static Item itemPickaxeEmerald; - public static Item itemAxeEmerald; - public static Item itemShovelEmerald; - public static Item itemSwordEmerald; - public static Item itemHoeEmerald; - public static Item itemHelmEmerald; - public static Item itemChestEmerald; - public static Item itemPantsEmerald; - public static Item itemBootsEmerald; - public static Item itemPickaxeObsidian; - public static Item itemAxeObsidian; - public static Item itemShovelObsidian; - public static Item itemSwordObsidian; - public static Item itemHoeObsidian; - public static Item itemPickaxeQuartz; - public static Item itemAxeQuartz; - public static Item itemShovelQuartz; - public static Item itemSwordQuartz; - public static Item itemHoeQuartz; - public static Item itemHelmObsidian; - public static Item itemChestObsidian; - public static Item itemPantsObsidian; - public static Item itemBootsObsidian; - public static Item itemHelmQuartz; - public static Item itemChestQuartz; - public static Item itemPantsQuartz; - public static Item itemBootsQuartz; - public static Item itemHairyBall; - public static Item itemRiceSeed; - public static Item itemCanolaSeed; - public static Item itemFlaxSeed; - public static Item itemCoffeeSeed; - public static Item itemResonantRice; - public static Item itemPhantomConnector; - public static Item itemCoffeeBean; - public static Item itemCoffee; - public static Item woodenPaxel; - public static Item stonePaxel; - public static Item ironPaxel; - public static Item diamondPaxel; - public static Item goldPaxel; - public static Item emeraldPaxel; - public static Item obsidianPaxel; - public static Item quartzPaxel; - public static Item itemDrill; - public static Item itemDrillUpgradeSpeed; - public static Item itemDrillUpgradeSpeedII; - public static Item itemDrillUpgradeSpeedIII; - public static Item itemDrillUpgradeSilkTouch; - public static Item itemDrillUpgradeFortune; - public static Item itemDrillUpgradeFortuneII; - public static Item itemDrillUpgradeThreeByThree; - public static Item itemDrillUpgradeFiveByFive; - public static Item itemDrillUpgradeBlockPlacing; - public static Item itemBattery; - public static Item itemBatteryDouble; - public static Item itemBatteryTriple; - public static Item itemBatteryQuadruple; - public static Item itemBatteryQuintuple; - public static Item itemTeleStaff; - public static Item itemWingsOfTheBats; - public static Item itemGrowthRing; - public static Item itemMagnetRing; - public static Item itemWaterRemovalRing; - public static Item itemChestToCrateUpgrade; - public static Item itemSmallToMediumCrateUpgrade; - public static Item itemMediumToLargeCrateUpgrade; - public static Item itemCrateKeeper; - public static Item itemSpawnerChanger; - public static Item itemLaserWrench; - public static Item itemCrystal; - public static Item itemCrystalEmpowered; - public static Item itemColorLens; - public static Item itemExplosionLens; - public static Item itemDamageLens; - public static Item itemMoreDamageLens; - public static Item itemDisenchantingLens; - public static Item itemMiningLens; - public static Item itemPickaxeCrystalRed; - public static Item itemAxeCrystalRed; - public static Item itemShovelCrystalRed; - public static Item itemSwordCrystalRed; - public static Item itemHoeCrystalRed; - public static Item itemHelmCrystalRed; - public static Item itemChestCrystalRed; - public static Item itemPantsCrystalRed; - public static Item itemBootsCrystalRed; - public static Item itemPaxelCrystalRed; - public static Item itemPickaxeCrystalBlue; - public static Item itemAxeCrystalBlue; - public static Item itemShovelCrystalBlue; - public static Item itemSwordCrystalBlue; - public static Item itemHoeCrystalBlue; - public static Item itemHelmCrystalBlue; - public static Item itemChestCrystalBlue; - public static Item itemPantsCrystalBlue; - public static Item itemBootsCrystalBlue; - public static Item itemPaxelCrystalBlue; - public static Item itemPickaxeCrystalLightBlue; - public static Item itemAxeCrystalLightBlue; - public static Item itemShovelCrystalLightBlue; - public static Item itemSwordCrystalLightBlue; - public static Item itemHoeCrystalLightBlue; - public static Item itemHelmCrystalLightBlue; - public static Item itemChestCrystalLightBlue; - public static Item itemPantsCrystalLightBlue; - public static Item itemBootsCrystalLightBlue; - public static Item itemPaxelCrystalLightBlue; - public static Item itemPickaxeCrystalBlack; - public static Item itemAxeCrystalBlack; - public static Item itemShovelCrystalBlack; - public static Item itemSwordCrystalBlack; - public static Item itemHoeCrystalBlack; - public static Item itemHelmCrystalBlack; - public static Item itemChestCrystalBlack; - public static Item itemPantsCrystalBlack; - public static Item itemBootsCrystalBlack; - public static Item itemPaxelCrystalBlack; - public static Item itemPickaxeCrystalGreen; - public static Item itemAxeCrystalGreen; - public static Item itemShovelCrystalGreen; - public static Item itemSwordCrystalGreen; - public static Item itemHoeCrystalGreen; - public static Item itemHelmCrystalGreen; - public static Item itemChestCrystalGreen; - public static Item itemPantsCrystalGreen; - public static Item itemBootsCrystalGreen; - public static Item itemPaxelCrystalGreen; - public static Item itemPickaxeCrystalWhite; - public static Item itemAxeCrystalWhite; - public static Item itemShovelCrystalWhite; - public static Item itemSwordCrystalWhite; - public static Item itemHoeCrystalWhite; - public static Item itemHelmCrystalWhite; - public static Item itemChestCrystalWhite; - public static Item itemPantsCrystalWhite; - public static Item itemBootsCrystalWhite; - public static Item itemPaxelCrystalWhite; - public static Item itemWaterBowl; - public static Item itemFilter; - public static Item itemPlayerProbe; - public static Item itemWorm; - public static Item itemBag; - public static Item itemVoidBag; - public static Item itemFillingWand; - public static Item itemLaserUpgradeInvisibility; - public static Item itemLaserUpgradeRange; - public static Item itemEngineerGoggles; - public static Item itemEngineerGogglesAdvanced; - public static Item itemCrystalShard; - - public static void init() { - ActuallyAdditions.LOGGER.info("Initializing Items..."); - - itemCrystalShard = new ItemCrystalShard("item_crystal_shard"); - itemEngineerGogglesAdvanced = new ItemEngineerGoggles("item_engineer_goggles_advanced", true); - itemEngineerGoggles = new ItemEngineerGoggles("item_engineer_goggles", false); - itemLaserUpgradeRange = new ItemLaserRelayUpgrade("item_laser_upgrade_range"); - itemLaserUpgradeInvisibility = new ItemLaserRelayUpgrade("item_laser_upgrade_invisibility"); - itemFillingWand = new ItemFillingWand("item_filling_wand"); - itemBag = new ItemBag("item_bag", false); - itemVoidBag = new ItemBag("item_void_bag", true); - itemWorm = new ItemWorm("item_worm"); - itemPlayerProbe = new ItemPlayerProbe("item_player_probe"); - itemFilter = new ItemFilter("item_filter"); - itemWaterBowl = new ItemWaterBowl("item_water_bowl"); - itemSpawnerChanger = new ItemSpawnerChanger("item_spawner_changer"); - itemMisc = new ItemMisc("item_misc"); - itemCrateKeeper = new ItemGeneric("item_crate_keeper").setMaxStackSize(1); - itemColorLens = new ItemLens("item_color_lens", ActuallyAdditionsAPI.lensColor); - itemExplosionLens = new ItemLens("item_explosion_lens", ActuallyAdditionsAPI.lensDetonation); - itemDamageLens = new ItemLens("item_damage_lens", ActuallyAdditionsAPI.lensDeath); - itemMoreDamageLens = new ItemLens("item_more_damage_lens", ActuallyAdditionsAPI.lensEvenMoarDeath); - itemDisenchantingLens = new ItemLens("item_disenchanting_lens", ActuallyAdditionsAPI.lensDisenchanting); - itemMiningLens = new ItemLens("item_mining_lens", ActuallyAdditionsAPI.lensMining); - itemCrystal = new ItemCrystal("item_crystal", false); - itemCrystalEmpowered = new ItemCrystal("item_crystal_empowered", true); - itemLaserWrench = new ItemLaserWrench("item_laser_wrench"); - itemChestToCrateUpgrade = new ItemChestToCrateUpgrade("item_chest_to_crate_upgrade", TileEntityChest.class, InitBlocks.blockGiantChest.getDefaultState()); - itemSmallToMediumCrateUpgrade = new ItemChestToCrateUpgrade("item_small_to_medium_crate_upgrade", TileEntityGiantChest.class, InitBlocks.blockGiantChestMedium.getDefaultState()); - itemMediumToLargeCrateUpgrade = new ItemChestToCrateUpgrade("item_medium_to_large_crate_upgrade", TileEntityGiantChestMedium.class, InitBlocks.blockGiantChestLarge.getDefaultState()); - itemBooklet = new ItemBooklet("item_booklet"); - itemGrowthRing = new ItemGrowthRing("item_growth_ring"); - itemMagnetRing = new ItemMagnetRing("item_suction_ring"); - itemWaterRemovalRing = new ItemWaterRemovalRing("item_water_removal_ring"); - itemHelmEmerald = new ItemArmorAA("item_helm_emerald", InitArmorMaterials.armorMaterialEmerald, 0, new ItemStack(Items.EMERALD)); - itemChestEmerald = new ItemArmorAA("item_chest_emerald", InitArmorMaterials.armorMaterialEmerald, 1, new ItemStack(Items.EMERALD)); - itemPantsEmerald = new ItemArmorAA("item_pants_emerald", InitArmorMaterials.armorMaterialEmerald, 2, new ItemStack(Items.EMERALD)); - itemBootsEmerald = new ItemArmorAA("item_boots_emerald", InitArmorMaterials.armorMaterialEmerald, 3, new ItemStack(Items.EMERALD)); - itemHelmObsidian = new ItemArmorAA("item_helm_obsidian", InitArmorMaterials.armorMaterialObsidian, 0, new ItemStack(Blocks.OBSIDIAN)); - itemChestObsidian = new ItemArmorAA("item_chest_obsidian", InitArmorMaterials.armorMaterialObsidian, 1, new ItemStack(Blocks.OBSIDIAN)); - itemPantsObsidian = new ItemArmorAA("item_pants_obsidian", InitArmorMaterials.armorMaterialObsidian, 2, new ItemStack(Blocks.OBSIDIAN)); - itemBootsObsidian = new ItemArmorAA("item_boots_obsidian", InitArmorMaterials.armorMaterialObsidian, 3, new ItemStack(Blocks.OBSIDIAN)); - itemHelmQuartz = new ItemArmorAA("item_helm_quartz", InitArmorMaterials.armorMaterialQuartz, 0, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())); - itemChestQuartz = new ItemArmorAA("item_chest_quartz", InitArmorMaterials.armorMaterialQuartz, 1, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())); - itemPantsQuartz = new ItemArmorAA("item_pants_quartz", InitArmorMaterials.armorMaterialQuartz, 2, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())); - itemBootsQuartz = new ItemArmorAA("item_boots_quartz", InitArmorMaterials.armorMaterialQuartz, 3, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal())); - itemTeleStaff = new ItemTeleStaff("item_tele_staff"); - itemWingsOfTheBats = new ItemWingsOfTheBats("item_wings_of_the_bats"); - itemDrill = new ItemDrill("item_drill"); - itemBattery = new ItemBattery("item_battery", 200000, 1000); - itemBatteryDouble = new ItemBattery("item_battery_double", 350000, 5000); - itemBatteryTriple = new ItemBattery("item_battery_triple", 600000, 10000); - itemBatteryQuadruple = new ItemBattery("item_battery_quadruple", 1000000, 30000); - itemBatteryQuintuple = new ItemBattery("item_battery_quintuple", 2000000, 100000); - itemDrillUpgradeSpeed = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED, "item_drill_upgrade_speed"); - itemDrillUpgradeSpeedII = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED_II, "item_drill_upgrade_speed_ii"); - itemDrillUpgradeSpeedIII = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED_III, "item_drill_upgrade_speed_iii"); - itemDrillUpgradeSilkTouch = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SILK_TOUCH, "item_drill_upgrade_silk_touch"); - itemDrillUpgradeFortune = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.FORTUNE, "item_drill_upgrade_fortune"); - itemDrillUpgradeFortuneII = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.FORTUNE_II, "item_drill_upgrade_fortune_ii"); - itemDrillUpgradeThreeByThree = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.THREE_BY_THREE, "item_drill_upgrade_three_by_three"); - itemDrillUpgradeFiveByFive = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE, "item_drill_upgrade_five_by_five"); - itemDrillUpgradeBlockPlacing = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.PLACER, "item_drill_upgrade_block_placing"); - itemFertilizer = new ItemFertilizer("item_fertilizer"); - itemCoffee = new ItemCoffee("item_coffee"); - itemPhantomConnector = new ItemPhantomConnector("item_phantom_connector"); - itemResonantRice = new ItemResonantRice("item_resonant_rice"); - itemFoods = new ItemFoods("item_food"); - itemJams = new ItemJams("item_jam"); - itemKnife = new ItemKnife("item_knife"); - itemCrafterOnAStick = new ItemCrafterOnAStick("item_crafter_on_a_stick"); - itemDust = new ItemDust("item_dust"); - itemSolidifiedExperience = new ItemSolidifiedExperience("item_solidified_experience"); - itemLeafBlower = new ItemLeafBlower(false, "item_leaf_blower"); - itemLeafBlowerAdvanced = new ItemLeafBlower(true, "item_leaf_blower_advanced"); - itemPotionRing = new ItemPotionRing(false, "item_potion_ring"); - itemPotionRingAdvanced = new ItemPotionRing(true, "item_potion_ring_advanced"); - itemHairyBall = new ItemHairyBall("item_hairy_ball"); - itemCoffeeBean = new ItemCoffeeBean("item_coffee_beans"); - itemRiceSeed = new ItemSeed("item_rice_seed", "seedRice", InitBlocks.blockRice, itemFoods, TheFoods.RICE.ordinal()); - itemCanolaSeed = new ItemFoodSeed("item_canola_seed", "seedCanola", InitBlocks.blockCanola, itemMisc, TheMiscItems.CANOLA.ordinal(), 1, 0.01F, 10).setPotionEffect(new PotionEffect(MobEffects.NAUSEA, 1000, 0), 0.2F); - itemFlaxSeed = new ItemSeed("item_flax_seed", "seedFlax", InitBlocks.blockFlax, Items.STRING, 0); - itemCoffeeSeed = new ItemSeed("item_coffee_seed", "seedCoffeeBeans", InitBlocks.blockCoffee, itemCoffeeBean, 0); - itemPickaxeEmerald = new ItemPickaxeAA(InitToolMaterials.toolMaterialEmerald, new ItemStack(Items.EMERALD), "item_pickaxe_emerald", EnumRarity.EPIC); - itemAxeEmerald = new ItemAxeAA(InitToolMaterials.toolMaterialEmerald, new ItemStack(Items.EMERALD), "item_axe_emerald", EnumRarity.EPIC); - itemShovelEmerald = new ItemShovelAA(InitToolMaterials.toolMaterialEmerald, new ItemStack(Items.EMERALD), "item_shovel_emerald", EnumRarity.EPIC); - itemSwordEmerald = new ItemSwordAA(InitToolMaterials.toolMaterialEmerald, new ItemStack(Items.EMERALD), "item_sword_emerald", EnumRarity.EPIC); - itemHoeEmerald = new ItemHoeAA(InitToolMaterials.toolMaterialEmerald, new ItemStack(Items.EMERALD), "item_hoe_emerald", EnumRarity.EPIC); - itemPickaxeObsidian = new ItemPickaxeAA(InitToolMaterials.toolMaterialObsidian, new ItemStack(Blocks.OBSIDIAN), "item_pickaxe_obsidian", EnumRarity.UNCOMMON); - itemAxeObsidian = new ItemAxeAA(InitToolMaterials.toolMaterialObsidian, new ItemStack(Blocks.OBSIDIAN), "item_axe_obsidian", EnumRarity.UNCOMMON); - itemShovelObsidian = new ItemShovelAA(InitToolMaterials.toolMaterialObsidian, new ItemStack(Blocks.OBSIDIAN), "item_shovel_obsidian", EnumRarity.UNCOMMON); - itemSwordObsidian = new ItemSwordAA(InitToolMaterials.toolMaterialObsidian, new ItemStack(Blocks.OBSIDIAN), "item_sword_obsidian", EnumRarity.UNCOMMON); - itemHoeObsidian = new ItemHoeAA(InitToolMaterials.toolMaterialObsidian, new ItemStack(Blocks.OBSIDIAN), "item_hoe_obsidian", EnumRarity.UNCOMMON); - itemPickaxeQuartz = new ItemPickaxeAA(InitToolMaterials.toolMaterialQuartz, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), "item_pickaxe_quartz", EnumRarity.RARE); - itemAxeQuartz = new ItemAxeAA(InitToolMaterials.toolMaterialQuartz, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), "item_axe_quartz", EnumRarity.RARE); - itemShovelQuartz = new ItemShovelAA(InitToolMaterials.toolMaterialQuartz, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), "item_shovel_quartz", EnumRarity.RARE); - itemSwordQuartz = new ItemSwordAA(InitToolMaterials.toolMaterialQuartz, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), "item_sword_quartz", EnumRarity.RARE); - itemHoeQuartz = new ItemHoeAA(InitToolMaterials.toolMaterialQuartz, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), "item_hoe_quartz", EnumRarity.RARE); - woodenPaxel = new ItemAllToolAA(Item.ToolMaterial.WOOD, "plank_wood", "wooden_paxel", EnumRarity.UNCOMMON, 5192733); - stonePaxel = new ItemAllToolAA(Item.ToolMaterial.STONE, new ItemStack(Blocks.COBBLESTONE), "stone_paxel", EnumRarity.UNCOMMON, 7040621); - ironPaxel = new ItemAllToolAA(Item.ToolMaterial.IRON, new ItemStack(Items.IRON_INGOT), "iron_paxel", EnumRarity.RARE, 10920613); - goldPaxel = new ItemAllToolAA(Item.ToolMaterial.GOLD, new ItemStack(Items.GOLD_INGOT), "gold_paxel", EnumRarity.RARE, 16770048); - diamondPaxel = new ItemAllToolAA(Item.ToolMaterial.DIAMOND, new ItemStack(Items.DIAMOND), "diamond_paxel", EnumRarity.EPIC, 3250376); - emeraldPaxel = new ItemAllToolAA(InitToolMaterials.toolMaterialEmerald, new ItemStack(Items.EMERALD), "emerald_paxel", EnumRarity.EPIC, 7723338); - obsidianPaxel = new ItemAllToolAA(InitToolMaterials.toolMaterialObsidian, new ItemStack(Blocks.OBSIDIAN), "obsidian_paxel", EnumRarity.EPIC, 4166); - quartzPaxel = new ItemAllToolAA(InitToolMaterials.toolMaterialQuartz, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), "quartz_paxel", EnumRarity.RARE, 1710103); - - itemPickaxeCrystalRed = new ItemPickaxeAA(InitToolMaterials.toolMaterialCrystalRed, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), "item_pickaxe_crystal_red", Util.CRYSTAL_RED_RARITY); - itemAxeCrystalRed = new ItemAxeAA(InitToolMaterials.toolMaterialCrystalRed, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), "item_axe_crystal_red", Util.CRYSTAL_RED_RARITY); - itemShovelCrystalRed = new ItemShovelAA(InitToolMaterials.toolMaterialCrystalRed, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), "item_shovel_crystal_red", Util.CRYSTAL_RED_RARITY); - itemSwordCrystalRed = new ItemSwordAA(InitToolMaterials.toolMaterialCrystalRed, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), "item_sword_crystal_red", Util.CRYSTAL_RED_RARITY); - itemHoeCrystalRed = new ItemHoeAA(InitToolMaterials.toolMaterialCrystalRed, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), "item_hoe_crystal_red", Util.CRYSTAL_RED_RARITY); - itemHelmCrystalRed = new ItemArmorAA("item_helm_crystal_red", InitArmorMaterials.armorMaterialCrystalRed, 0, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), Util.CRYSTAL_RED_RARITY); - itemChestCrystalRed = new ItemArmorAA("item_chest_crystal_red", InitArmorMaterials.armorMaterialCrystalRed, 1, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), Util.CRYSTAL_RED_RARITY); - itemPantsCrystalRed = new ItemArmorAA("item_pants_crystal_red", InitArmorMaterials.armorMaterialCrystalRed, 2, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), Util.CRYSTAL_RED_RARITY); - itemBootsCrystalRed = new ItemArmorAA("item_boots_crystal_red", InitArmorMaterials.armorMaterialCrystalRed, 3, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), Util.CRYSTAL_RED_RARITY); - itemPaxelCrystalRed = new ItemAllToolAA(InitToolMaterials.toolMaterialCrystalRed, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), "item_paxel_crystal_red", Util.CRYSTAL_RED_RARITY, 16711689); - - itemPickaxeCrystalBlue = new ItemPickaxeAA(InitToolMaterials.toolMaterialCrystalBlue, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), "item_pickaxe_crystal_blue", Util.CRYSTAL_BLUE_RARITY); - itemAxeCrystalBlue = new ItemAxeAA(InitToolMaterials.toolMaterialCrystalBlue, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), "item_axe_crystal_blue", Util.CRYSTAL_BLUE_RARITY); - itemShovelCrystalBlue = new ItemShovelAA(InitToolMaterials.toolMaterialCrystalBlue, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), "item_shovel_crystal_blue", Util.CRYSTAL_BLUE_RARITY); - itemSwordCrystalBlue = new ItemSwordAA(InitToolMaterials.toolMaterialCrystalBlue, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), "item_sword_crystal_blue", Util.CRYSTAL_BLUE_RARITY); - itemHoeCrystalBlue = new ItemHoeAA(InitToolMaterials.toolMaterialCrystalBlue, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), "item_hoe_crystal_blue", Util.CRYSTAL_BLUE_RARITY); - itemHelmCrystalBlue = new ItemArmorAA("item_helm_crystal_blue", InitArmorMaterials.armorMaterialCrystalBlue, 0, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), Util.CRYSTAL_BLUE_RARITY); - itemChestCrystalBlue = new ItemArmorAA("item_chest_crystal_blue", InitArmorMaterials.armorMaterialCrystalBlue, 1, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), Util.CRYSTAL_BLUE_RARITY); - itemPantsCrystalBlue = new ItemArmorAA("item_pants_crystal_blue", InitArmorMaterials.armorMaterialCrystalBlue, 2, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), Util.CRYSTAL_BLUE_RARITY); - itemBootsCrystalBlue = new ItemArmorAA("item_boots_crystal_blue", InitArmorMaterials.armorMaterialCrystalBlue, 3, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), Util.CRYSTAL_BLUE_RARITY); - itemPaxelCrystalBlue = new ItemAllToolAA(InitToolMaterials.toolMaterialCrystalBlue, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), "item_paxel_crystal_blue", Util.CRYSTAL_BLUE_RARITY, 3014911); - - itemPickaxeCrystalLightBlue = new ItemPickaxeAA(InitToolMaterials.toolMaterialCrystalLightBlue, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), "item_pickaxe_crystal_light_blue", Util.CRYSTAL_LIGHT_BLUE_RARITY); - itemAxeCrystalLightBlue = new ItemAxeAA(InitToolMaterials.toolMaterialCrystalLightBlue, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), "item_axe_crystal_light_blue", Util.CRYSTAL_LIGHT_BLUE_RARITY); - itemShovelCrystalLightBlue = new ItemShovelAA(InitToolMaterials.toolMaterialCrystalLightBlue, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), "item_shovel_crystal_light_blue", Util.CRYSTAL_LIGHT_BLUE_RARITY); - itemSwordCrystalLightBlue = new ItemSwordAA(InitToolMaterials.toolMaterialCrystalLightBlue, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), "item_sword_crystal_light_blue", Util.CRYSTAL_LIGHT_BLUE_RARITY); - itemHoeCrystalLightBlue = new ItemHoeAA(InitToolMaterials.toolMaterialCrystalLightBlue, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), "item_hoe_crystal_light_blue", Util.CRYSTAL_LIGHT_BLUE_RARITY); - itemHelmCrystalLightBlue = new ItemArmorAA("item_helm_crystal_light_blue", InitArmorMaterials.armorMaterialCrystalLightBlue, 0, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), Util.CRYSTAL_LIGHT_BLUE_RARITY); - itemChestCrystalLightBlue = new ItemArmorAA("item_chest_crystal_light_blue", InitArmorMaterials.armorMaterialCrystalLightBlue, 1, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), Util.CRYSTAL_LIGHT_BLUE_RARITY); - itemPantsCrystalLightBlue = new ItemArmorAA("item_pants_crystal_light_blue", InitArmorMaterials.armorMaterialCrystalLightBlue, 2, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), Util.CRYSTAL_LIGHT_BLUE_RARITY); - itemBootsCrystalLightBlue = new ItemArmorAA("item_boots_crystal_light_blue", InitArmorMaterials.armorMaterialCrystalLightBlue, 3, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), Util.CRYSTAL_LIGHT_BLUE_RARITY); - itemPaxelCrystalLightBlue = new ItemAllToolAA(InitToolMaterials.toolMaterialCrystalLightBlue, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), "item_paxel_crystal_light_blue", Util.CRYSTAL_LIGHT_BLUE_RARITY, 4093108); - - itemPickaxeCrystalBlack = new ItemPickaxeAA(InitToolMaterials.toolMaterialCrystalBlack, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), "item_pickaxe_crystal_black", Util.CRYSTAL_BLACK_RARITY); - itemAxeCrystalBlack = new ItemAxeAA(InitToolMaterials.toolMaterialCrystalBlack, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), "item_axe_crystal_black", Util.CRYSTAL_BLACK_RARITY); - itemShovelCrystalBlack = new ItemShovelAA(InitToolMaterials.toolMaterialCrystalBlack, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), "item_shovel_crystal_black", Util.CRYSTAL_BLACK_RARITY); - itemSwordCrystalBlack = new ItemSwordAA(InitToolMaterials.toolMaterialCrystalBlack, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), "item_sword_crystal_black", Util.CRYSTAL_BLACK_RARITY); - itemHoeCrystalBlack = new ItemHoeAA(InitToolMaterials.toolMaterialCrystalBlack, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), "item_hoe_crystal_black", Util.CRYSTAL_BLACK_RARITY); - itemHelmCrystalBlack = new ItemArmorAA("item_helm_crystal_black", InitArmorMaterials.armorMaterialCrystalBlack, 0, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), Util.CRYSTAL_BLACK_RARITY); - itemChestCrystalBlack = new ItemArmorAA("item_chest_crystal_black", InitArmorMaterials.armorMaterialCrystalBlack, 1, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), Util.CRYSTAL_BLACK_RARITY); - itemPantsCrystalBlack = new ItemArmorAA("item_pants_crystal_black", InitArmorMaterials.armorMaterialCrystalBlack, 2, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), Util.CRYSTAL_BLACK_RARITY); - itemBootsCrystalBlack = new ItemArmorAA("item_boots_crystal_black", InitArmorMaterials.armorMaterialCrystalBlack, 3, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), Util.CRYSTAL_BLACK_RARITY); - itemPaxelCrystalBlack = new ItemAllToolAA(InitToolMaterials.toolMaterialCrystalBlack, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), "item_paxel_crystal_black", Util.CRYSTAL_BLACK_RARITY, 2631982); - - itemPickaxeCrystalGreen = new ItemPickaxeAA(InitToolMaterials.toolMaterialCrystalGreen, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), "item_pickaxe_crystal_green", Util.CRYSTAL_GREEN_RARITY); - itemAxeCrystalGreen = new ItemAxeAA(InitToolMaterials.toolMaterialCrystalGreen, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), "item_axe_crystal_green", Util.CRYSTAL_GREEN_RARITY); - itemShovelCrystalGreen = new ItemShovelAA(InitToolMaterials.toolMaterialCrystalGreen, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), "item_shovel_crystal_green", Util.CRYSTAL_GREEN_RARITY); - itemSwordCrystalGreen = new ItemSwordAA(InitToolMaterials.toolMaterialCrystalGreen, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), "item_sword_crystal_green", Util.CRYSTAL_GREEN_RARITY); - itemHoeCrystalGreen = new ItemHoeAA(InitToolMaterials.toolMaterialCrystalGreen, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), "item_hoe_crystal_green", Util.CRYSTAL_GREEN_RARITY); - itemHelmCrystalGreen = new ItemArmorAA("item_helm_crystal_green", InitArmorMaterials.armorMaterialCrystalGreen, 0, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), Util.CRYSTAL_GREEN_RARITY); - itemChestCrystalGreen = new ItemArmorAA("item_chest_crystal_green", InitArmorMaterials.armorMaterialCrystalGreen, 1, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), Util.CRYSTAL_GREEN_RARITY); - itemPantsCrystalGreen = new ItemArmorAA("item_pants_crystal_green", InitArmorMaterials.armorMaterialCrystalGreen, 2, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), Util.CRYSTAL_GREEN_RARITY); - itemBootsCrystalGreen = new ItemArmorAA("item_boots_crystal_green", InitArmorMaterials.armorMaterialCrystalGreen, 3, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), Util.CRYSTAL_GREEN_RARITY); - itemPaxelCrystalGreen = new ItemAllToolAA(InitToolMaterials.toolMaterialCrystalGreen, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), "item_paxel_crystal_green", Util.CRYSTAL_GREEN_RARITY, 46848); - - itemPickaxeCrystalWhite = new ItemPickaxeAA(InitToolMaterials.toolMaterialCrystalWhite, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), "item_pickaxe_crystal_white", Util.CRYSTAL_WHITE_RARITY); - itemAxeCrystalWhite = new ItemAxeAA(InitToolMaterials.toolMaterialCrystalWhite, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), "item_axe_crystal_white", Util.CRYSTAL_WHITE_RARITY); - itemShovelCrystalWhite = new ItemShovelAA(InitToolMaterials.toolMaterialCrystalWhite, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), "item_shovel_crystal_white", Util.CRYSTAL_WHITE_RARITY); - itemSwordCrystalWhite = new ItemSwordAA(InitToolMaterials.toolMaterialCrystalWhite, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), "item_sword_crystal_white", Util.CRYSTAL_WHITE_RARITY); - itemHoeCrystalWhite = new ItemHoeAA(InitToolMaterials.toolMaterialCrystalWhite, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), "item_hoe_crystal_white", Util.CRYSTAL_WHITE_RARITY); - itemHelmCrystalWhite = new ItemArmorAA("item_helm_crystal_white", InitArmorMaterials.armorMaterialCrystalWhite, 0, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), Util.CRYSTAL_WHITE_RARITY); - itemChestCrystalWhite = new ItemArmorAA("item_chest_crystal_white", InitArmorMaterials.armorMaterialCrystalWhite, 1, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), Util.CRYSTAL_WHITE_RARITY); - itemPantsCrystalWhite = new ItemArmorAA("item_pants_crystal_white", InitArmorMaterials.armorMaterialCrystalWhite, 2, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), Util.CRYSTAL_WHITE_RARITY); - itemBootsCrystalWhite = new ItemArmorAA("item_boots_crystal_white", InitArmorMaterials.armorMaterialCrystalWhite, 3, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), Util.CRYSTAL_WHITE_RARITY); - itemPaxelCrystalWhite = new ItemAllToolAA(InitToolMaterials.toolMaterialCrystalWhite, new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), "item_paxel_crystal_white", Util.CRYSTAL_WHITE_RARITY, 14606302); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java deleted file mode 100644 index 40241b6d9..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * This file ("ItemAllToolAA.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import java.util.HashSet; -import java.util.Set; - -import com.google.common.collect.Sets; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; -import de.ellpeck.actuallyadditions.mod.items.base.ItemToolAA; -import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.color.IItemColor; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.common.IRarity; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class ItemAllToolAA extends ItemToolAA implements IColorProvidingItem { - - public final int color; - - public ItemAllToolAA(ToolMaterial toolMat, String repairItem, String unlocalizedName, IRarity rarity, int color) { - super(4.0F, -2F, toolMat, repairItem, unlocalizedName, rarity, new HashSet<>()); - this.color = color; - - this.setMaxDamage(toolMat.getMaxUses() * 4); - this.setHarvestLevels(toolMat.getHarvestLevel()); - } - - public ItemAllToolAA(ToolMaterial toolMat, ItemStack repairItem, String unlocalizedName, IRarity rarity, int color) { - super(4.0F, -2F, toolMat, repairItem, unlocalizedName, rarity, new HashSet<>()); - this.color = color; - - this.setMaxDamage(toolMat.getMaxUses() * 4); - this.setHarvestLevels(toolMat.getHarvestLevel()); - } - - private void setHarvestLevels(int amount) { - for (String s : this.getToolClasses(null)) { - this.setHarvestLevel(s, amount); - } - } - - @Override - protected void registerRendering() { - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), new ResourceLocation(ActuallyAdditions.MODID, "item_paxel"), "inventory"); - } - - @Override - public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { - if (!playerIn.isSneaking()) return Items.IRON_HOE.onItemUse(playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ); - return Items.IRON_SHOVEL.onItemUse(playerIn, worldIn, pos, hand, side, hitX, hitY, hitZ); - } - - @Override - public boolean canHarvestBlock(IBlockState state, ItemStack stack) { - return this.hasExtraWhitelist(state.getBlock()) || state.getMaterial().isToolNotRequired() || state.getBlock() == Blocks.SNOW_LAYER || state.getBlock() == Blocks.SNOW || (state.getBlock() == Blocks.OBSIDIAN ? this.toolMaterial.getHarvestLevel() >= 3 : state.getBlock() != Blocks.DIAMOND_BLOCK && state.getBlock() != Blocks.DIAMOND_ORE ? state.getBlock() != Blocks.EMERALD_ORE && state.getBlock() != Blocks.EMERALD_BLOCK ? state.getBlock() != Blocks.GOLD_BLOCK && state.getBlock() != Blocks.GOLD_ORE ? state.getBlock() != Blocks.IRON_BLOCK && state.getBlock() != Blocks.IRON_ORE ? state.getBlock() != Blocks.LAPIS_BLOCK && state.getBlock() != Blocks.LAPIS_ORE ? state.getBlock() != Blocks.REDSTONE_ORE && state.getBlock() != Blocks.LIT_REDSTONE_ORE ? state.getMaterial() == Material.ROCK || state.getMaterial() == Material.IRON || state.getMaterial() == Material.ANVIL : this.toolMaterial.getHarvestLevel() >= 2 : this.toolMaterial.getHarvestLevel() >= 1 : this.toolMaterial.getHarvestLevel() >= 1 : this.toolMaterial.getHarvestLevel() >= 2 : this.toolMaterial.getHarvestLevel() >= 2 : this.toolMaterial.getHarvestLevel() >= 2); - } - - private boolean hasExtraWhitelist(Block block) { - String name = block.getRegistryName().toString(); - for (String list : ConfigStringListValues.PAXEL_EXTRA_MINING_WHITELIST.getValue()) { - if (list.equals(name)) { return true; } - } - return false; - } - - @Override - public Set getToolClasses(ItemStack stack) { - return Sets.newHashSet("pickaxe", "axe", "shovel"); - } - - @Override - public float getDestroySpeed(ItemStack stack, IBlockState state) { - if (state.getBlock() == Blocks.WEB) { - return 15.0F; - } else { - return this.hasExtraWhitelist(state.getBlock()) || state.getBlock().getHarvestTool(state) == null || state.getBlock().getHarvestTool(state).isEmpty() || this.getToolClasses(stack).contains(state.getBlock().getHarvestTool(state)) ? this.efficiency : 1.0F; - } - } - - @SideOnly(Side.CLIENT) - @Override - public IItemColor getItemColor() { - return (stack, pass) -> pass > 0 ? ItemAllToolAA.this.color : 0xFFFFFF; - } - - @Override - public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { - return super.canApplyAtEnchantingTable(stack, enchantment) || enchantment.type.canEnchantItem(Items.DIAMOND_SWORD); - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java deleted file mode 100644 index 040d7bd44..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file ("ItemAxeAA.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import java.util.Collections; -import java.util.Set; - -import com.google.common.collect.Sets; - -import de.ellpeck.actuallyadditions.mod.items.base.ItemToolAA; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.IRarity; - -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) { - 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) { - super(6.0F, -3.0F, material, repairItem, unlocalizedName, rarity, EFFECTIVE_ON); - this.setHarvestLevel("axe", material.getHarvestLevel()); - } - - @Override - 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) { - return Collections.singleton("axe"); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBag.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBag.java deleted file mode 100644 index d827ef3cb..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBag.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This file ("ItemBag.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.inventory.ContainerBag; -import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler.GuiTypes; -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.items.CapabilityItemHandler; -import net.minecraftforge.items.IItemHandler; - -public class ItemBag extends ItemBase { - - public final boolean isVoid; - - public ItemBag(String name, boolean isVoid) { - super(name); - this.isVoid = isVoid; - this.setMaxStackSize(1); - } - - @Override - public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - ItemStack stack = playerIn.getHeldItem(hand); - if (!this.isVoid) { - TileEntity tile = worldIn.getTileEntity(pos); - if (tile != null && tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)) { - if (!worldIn.isRemote) { - IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing); - if (handler != null) { - boolean changed = false; - - ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerBag.getSlotAmount(this.isVoid)); - ItemDrill.loadSlotsFromNBT(inv, stack); - - for (int j = 0; j < inv.getSlots(); j++) { - ItemStack invStack = inv.getStackInSlot(j); - if (StackUtil.isValid(invStack)) { - for (int i = 0; i < handler.getSlots(); i++) { - ItemStack remain = handler.insertItem(i, invStack, false); - if (!ItemStack.areItemStacksEqual(remain, invStack)) { - inv.setStackInSlot(j, remain.copy()); - changed = true; - if (!StackUtil.isValid(remain)) { - break; - } - invStack = remain; - } - } - } - } - - if (changed) { - ItemDrill.writeSlotsToNBT(inv, stack); - } - } - } - return EnumActionResult.SUCCESS; - } - } - return EnumActionResult.PASS; - } - - @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { - if (!world.isRemote && hand == EnumHand.MAIN_HAND) { - player.openGui(ActuallyAdditions.INSTANCE, (this.isVoid ? GuiTypes.VOID_BAG : GuiTypes.BAG).ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ); - } - return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand)); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return this.isVoid ? EnumRarity.RARE : EnumRarity.UNCOMMON; - } - - @Override - public NBTTagCompound getNBTShareTag(ItemStack stack) { - return null; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBattery.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBattery.java deleted file mode 100644 index bd0a4b90f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBattery.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * This file ("ItemBattery.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import java.util.List; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.world.World; -import net.minecraftforge.energy.CapabilityEnergy; -import net.minecraftforge.energy.IEnergyStorage; - -public class ItemBattery extends ItemEnergy { - - public ItemBattery(String name, int capacity, int transfer) { - super(capacity, transfer, name); - this.setMaxStackSize(1); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; - } - - @Override - 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++) { - ItemStack slot = player.inventory.getStackInSlot(i); - 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)) { - IEnergyStorage cap = slot.getCapability(CapabilityEnergy.ENERGY, null); - if (cap != null) { - received = cap.receiveEnergy(extractable, false); - } - } - - if (received > 0) { - this.extractEnergy(stack, received, false); - } - } - } - } - } - - @Override - 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)); - } - return super.onItemRightClick(worldIn, player, hand); - } - - @Override - 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")); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java deleted file mode 100644 index f92450c62..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * This file ("ItemBooklet.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; -import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class ItemBooklet extends ItemBase implements IHudDisplay { - - @SideOnly(Side.CLIENT) - public static IBookletPage forcedPage; - - 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()) { - 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) { - forcedPage = page; - } - this.onItemRightClick(world, player, hand); - return EnumActionResult.SUCCESS; - } - } - 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); - - if (!world.isRemote) { - //TheAchievements.OPEN_BOOKLET.get(player); - //TheAchievements.OPEN_BOOKLET_MILESTONE.get(player); - } - return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand)); - } - - @Override - 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)); - } - } - - @Override - 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) { - 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())) { - ItemStack blockStack = new ItemStack(block, 1, block.getMetaFromState(state)); - int height = resolution.getScaledHeight() / 5 * 3; - if (player.isSneaking()) { - IBookletPage page = BookletUtils.findFirstPageForStack(blockStack); - 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"); - - 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); - } - } - } - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemChestToCrateUpgrade.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemChestToCrateUpgrade.java deleted file mode 100644 index 6aa66069d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemChestToCrateUpgrade.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file ("ItemChestToCrateUpgrade.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.items.IItemHandlerModifiable; -import net.minecraftforge.items.wrapper.InvWrapper; - -public class ItemChestToCrateUpgrade extends ItemBase { - - private final Class start; - private final 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) { - ItemStack heldStack = player.getHeldItem(hand); - if (player.isSneaking()) { - TileEntity tileHit = world.getTileEntity(pos); - 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 (chest != null) { - ItemStack[] stacks = new ItemStack[chest.getSlots()]; - for (int i = 0; i < stacks.length; i++) { - ItemStack aStack = chest.getStackInSlot(i); - stacks[i] = aStack.copy(); - } - - //Set New Block - world.playEvent(2001, pos, Block.getStateId(world.getBlockState(pos))); - - world.removeTileEntity(pos); - world.setBlockState(pos, this.end, 2); - 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; - - for (int i = 0; i < stacks.length; i++) { - if (StackUtil.isValid(stacks[i])) { - if (newChest.getSlots() > i) { - newChest.setStackInSlot(i, stacks[i].copy()); - } - } - } - } - } - } - return EnumActionResult.SUCCESS; - } - } - - return EnumActionResult.PASS; - } - - @Override - 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 deleted file mode 100644 index 153371d76..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffee.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * This file ("ItemCoffee.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nullable; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.init.Items; -import net.minecraft.init.MobEffects; -import net.minecraft.item.EnumAction; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.StringUtils; -import net.minecraft.world.World; -import net.minecraftforge.fml.common.Loader; - -public class ItemCoffee extends ItemFoodBase { - - public ItemCoffee(String name) { - super(8, 5.0F, false, name); - this.setMaxDamage(3); - this.setAlwaysEdible(); - this.setMaxStackSize(1); - this.setNoRepair(); - } - - 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")) { - Item item = ItemUtil.getItemFromName("harvestcraft:soymilkitem"); - if (item != null) { - ActuallyAdditionsAPI.addCoffeeMachineIngredient(new MilkIngredient(Ingredient.fromItem(item))); - } - } - - ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.fromItems(Items.SUGAR), 4, new PotionEffect(MobEffects.SPEED, 30, 0))); - ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.fromItems(Items.MAGMA_CREAM), 2, new PotionEffect(MobEffects.FIRE_RESISTANCE, 20, 0))); - ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.fromStacks(new ItemStack(Items.FISH, 1, 3)), 2, new PotionEffect(MobEffects.WATER_BREATHING, 10, 0))); - ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.fromItems(Items.GOLDEN_CARROT), 2, new PotionEffect(MobEffects.NIGHT_VISION, 30, 0))); - ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.fromItems(Items.GHAST_TEAR), 3, new PotionEffect(MobEffects.REGENERATION, 5, 0))); - ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.fromItems(Items.BLAZE_POWDER), 4, new PotionEffect(MobEffects.STRENGTH, 15, 0))); - ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.fromItems(Items.FERMENTED_SPIDER_EYE), 2, new PotionEffect(MobEffects.INVISIBILITY, 25, 0))); - } - - @Nullable - 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) { - 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())); - } - } - } - - @Override - 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) { - return new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()); - } else { - return theStack; - } - } - - @Override - public EnumAction getItemUseAction(ItemStack stack) { - return EnumAction.DRINK; - } - - @Override - public int getMetadata(int damage) { - return damage; - } - - @Override - public boolean getShareTag() { - return true; - } - - @Override - 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)); - } - } else { - tooltip.add(StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".coffeeCup.noEffect")); - } - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; - } - - public static class MilkIngredient extends CoffeeIngredient { - - public MilkIngredient(Ingredient ingredient) { - super(ingredient, 0); - } - - @Override - 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)); - } - } - stack.setTagCompound(new NBTTagCompound()); - if (effectsNew.size() > 0) { - this.effects = effectsNew.toArray(new PotionEffect[effectsNew.size()]); - ActuallyAdditionsAPI.methodHandler.addEffectToStack(stack, this); - } - } - this.effects = null; - return true; - } - - @Override - 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 deleted file mode 100644 index 90601ec3f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCoffeeBean.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file ("ItemCoffeeBean.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; - -public class ItemCoffeeBean extends ItemFoodBase { - - public ItemCoffeeBean(String name) { - super(1, 1F, false, name); - this.setMaxDamage(0); - } - - @Override - 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 deleted file mode 100644 index f78cabee1..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrafterOnAStick.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file ("ItemCrafterOnAStick.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.world.World; - -public class ItemCrafterOnAStick extends ItemBase { - - 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); - } - return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand)); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrystal.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrystal.java deleted file mode 100644 index cacd108e1..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrystal.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file ("ItemCrystal.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.BlockCrystal; -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.IRarity; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class ItemCrystal extends ItemBase { - - private final boolean isEmpowered; - - public ItemCrystal(String name, boolean isEmpowered) { - super(name); - this.isEmpowered = isEmpowered; - this.setHasSubtypes(true); - this.setMaxDamage(0); - } - - @Override - public int getMetadata(int damage) { - return damage; - } - - @Override - public boolean hasEffect(ItemStack stack) { - return this.isEmpowered; - } - - @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; - } - - @Override - public IRarity getForgeRarity(ItemStack stack) { - return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length ? EnumRarity.COMMON : BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].rarity; - } - - @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++) { - list.add(new ItemStack(this, 1, j)); - } - } - } - - @Override - protected void registerRendering() { - for (int i = 0; i < BlockCrystal.ALL_CRYSTALS.length; i++) { - String name = this.getRegistryName() + "_" + BlockCrystal.ALL_CRYSTALS[i].name; - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), new ResourceLocation(name), "inventory"); - } - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrystalShard.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrystalShard.java deleted file mode 100644 index ddb89fd2f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrystalShard.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file ("ItemCrystalShard.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.BlockCrystal; -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.renderer.color.IItemColor; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -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 ItemCrystalShard(String name) { - super(name); - this.setHasSubtypes(true); - this.setMaxDamage(0); - } - - @Override - 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; - } - - @Override - public IRarity getForgeRarity(ItemStack stack) { - return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length ? EnumRarity.COMMON : BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].rarity; - } - - @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++) { - list.add(new ItemStack(this, 1, j)); - } - } - } - - @Override - 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() { - return (stack, tintIndex) -> { - int damage = stack.getItemDamage(); - if (damage >= 0 && damage < BlockCrystal.ALL_CRYSTALS.length) { - return BlockCrystal.ALL_CRYSTALS[damage].clusterColor; - } else { - return 0; - } - }; - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java deleted file mode 100644 index 8cd52e3a3..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java +++ /dev/null @@ -1,487 +0,0 @@ -/* - * This file ("ItemDrill.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import com.google.common.collect.Multimap; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; -import de.ellpeck.actuallyadditions.mod.inventory.ContainerDrill; -import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; -import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Enchantments; -import net.minecraft.inventory.EntityEquipmentSlot; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumFacing.Axis; -import net.minecraft.util.EnumHand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.World; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.items.IItemHandler; -import net.minecraftforge.items.IItemHandlerModifiable; - -public class ItemDrill extends ItemEnergy { - - public static final int HARVEST_LEVEL = 4; - private static final int ENERGY_USE = 100; - - public ItemDrill(String name) { - super(250000, 1000, name); - this.setMaxDamage(0); - this.setHasSubtypes(true); - this.setHarvestLevel("shovel", HARVEST_LEVEL); - this.setHarvestLevel("pickaxe", HARVEST_LEVEL); - } - - /** - * Gets all of the Slots from NBT - * - * @param stack The Drill - */ - public static void loadSlotsFromNBT(IItemHandlerModifiable slots, ItemStack stack) { - NBTTagCompound compound = stack.getTagCompound(); - if (compound != null) { - TileEntityInventoryBase.loadSlots(slots, compound); - } - } - - /** - * Writes all of the Slots to NBT - * - * @param slots The Slots - * @param stack The Drill - */ - public static void writeSlotsToNBT(IItemHandler slots, ItemStack stack) { - NBTTagCompound compound = stack.getTagCompound(); - if (compound == null) { - compound = new NBTTagCompound(); - } - TileEntityInventoryBase.saveSlots(slots, compound); - stack.setTagCompound(compound); - } - - @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) { - ItemStack stack = player.getHeldItem(hand); - ItemStack upgrade = this.getHasUpgradeAsStack(stack, ItemDrillUpgrade.UpgradeType.PLACER); - if (StackUtil.isValid(upgrade)) { - int slot = ItemDrillUpgrade.getSlotToPlaceFrom(upgrade); - if (slot >= 0 && slot < InventoryPlayer.getHotbarSize()) { - ItemStack equip = player.inventory.getStackInSlot(slot); - if (StackUtil.isValid(equip) && equip != stack) { - ItemStack toPlaceStack = equip.copy(); - - WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, toPlaceStack); - - //tryPlaceItemIntoWorld could throw an Exception - try { - //Places the Block into the World - 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!"); - } - - player.inventory.setInventorySlotContents(slot, player.getHeldItem(hand)); - WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, stack); - - return EnumActionResult.SUCCESS; - } - } - } - return EnumActionResult.FAIL; - } - - /** - * Checks if a certain Upgrade is installed and returns it as an ItemStack - * - * @param stack The Drill - * @param upgrade The Upgrade to be checked - * @return The Upgrade, if it's installed - */ - public ItemStack getHasUpgradeAsStack(ItemStack stack, ItemDrillUpgrade.UpgradeType upgrade) { - NBTTagCompound compound = stack.getTagCompound(); - if (compound == null) { return StackUtil.getEmpty(); } - - ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerDrill.SLOT_AMOUNT); - loadSlotsFromNBT(inv, stack); - 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; } - } - } - 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); - } - return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand)); - } - - @Override - public int getMetadata(int damage) { - return damage; - } - - @Override - 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) { - this.extractEnergyInternal(stack, use, false); - } - } - return true; - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; - } - - @Override - public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { - Multimap map = super.getAttributeModifiers(slot, stack); - - 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)); - } - - return map; - } - - @Override - 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) { - boolean toReturn = false; - int use = this.getEnergyUsePerBlock(stack); - if (this.getEnergyStored(stack) >= use) { - //Enchants the Drill depending on the Upgrades it has - if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SILK_TOUCH)) { - ItemUtil.addEnchantment(stack, Enchantments.SILK_TOUCH, 1); - } 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) { - - //Breaks the Blocks - 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 { - toReturn = this.breakBlocks(stack, 1, player.world, pos, ray.sideHit, player); - } - } else { - toReturn = this.breakBlocks(stack, 0, player.world, pos, ray.sideHit, player); - } - - //Removes Enchantments added above - ItemUtil.removeEnchantment(stack, Enchantments.SILK_TOUCH); - ItemUtil.removeEnchantment(stack, Enchantments.FORTUNE); - } - } - return toReturn; - } - - @Override - 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) { - HashSet hashSet = new HashSet<>(); - hashSet.add("pickaxe"); - hashSet.add("shovel"); - return hashSet; - } - - @Override - public int getHarvestLevel(ItemStack stack, String toolClass, EntityPlayer player, IBlockState blockState) { - return HARVEST_LEVEL; - } - - /** - * Gets the Energy that is used per Block broken - * - * @param stack The Drill - * @return The Energy use per Block - */ - public int getEnergyUsePerBlock(ItemStack stack) { - int use = ENERGY_USE; - - //Speed - if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED)) { - use += 50; - if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED_II)) { - use += 75; - if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED_III)) { - use += 175; - } - } - } - - //Silk Touch - if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SILK_TOUCH)) { - use += 100; - } - - //Fortune - if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE)) { - use += 40; - if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE_II)) { - use += 80; - } - } - - //Size - if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)) { - use += 10; - if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)) { - use += 30; - } - } - - return use; - } - - /** - * Checks if a certain Upgrade is applied - * - * @param stack The Drill - * @param upgrade The Upgrade to be checked - * @return Is the Upgrade applied? - */ - 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; - 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++) { - this.addDrillStack(list, i); - } - } - } - - private void addDrillStack(List list, int meta) { - ItemStack stackFull = new ItemStack(this, 1, meta); - this.setEnergy(stackFull, this.getMaxEnergyStored(stackFull)); - list.add(stackFull); - - ItemStack stackEmpty = new ItemStack(this, 1, meta); - this.setEnergy(stackEmpty, 0); - list.add(stackEmpty); - } - - /** - * Gets the Mining Speed of the Drill - * - * @param stack The Drill - * @return The Mining Speed depending on the Speed Upgrades - */ - 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)) { - efficiency += 37.0F; - } else { - efficiency += 25.0F; - } - } else { - efficiency += 8.0F; - } - } - if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)) { - efficiency *= 0.5F; - if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)) { - efficiency *= 0.35F; - } - } - return efficiency; - } - - /** - * Breaks Blocks in a certain Radius - * Has to be called on both Server and Client - * - * @param stack The Drill - * @param radius The Radius to break Blocks in (0 means only 1 Block will be broken!) - * @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) { - 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) { - zRange = radius; - yRange = 0; - } - if (side.getAxis() == Axis.X) { - xRange = 0; - zRange = radius; - } - - //Not defined later because main Block is getting broken below - IBlockState state = world.getBlockState(aPos); - float mainHardness = state.getBlockHardness(world, aPos); - - //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 { - return false; - } - - if (radius == 2 && side.getAxis() != Axis.Y) { - aPos = aPos.up(); - IBlockState theState = world.getBlockState(aPos); - 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) { - //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) { - this.tryHarvestBlock(world, thePos, true, stack, player, use); - } - } else { - return false; - } - } - } - } - } - } - return true; - } - - /** - * Tries to harvest a certain Block - * Breaks the Block, drops Particles etc. - * Has to be called on both Server and Client - * - * @param world The World - * @param isExtra If the Block is the Block that was looked at when breaking or an additional Block - * @param stack The Drill - * @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) { - 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) { - this.extractEnergyInternal(stack, use, false); - } - //Break the Block - return WorldUtil.breakExtraBlock(stack, world, player, pos); - } - return false; - } - - private boolean hasExtraWhitelist(Block block) { - if (block != null) { - ResourceLocation location = block.getRegistryName(); - 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; } - } - } - } - } - return false; - } - - @Override - public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) { - return !newStack.isItemEqual(oldStack); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java deleted file mode 100644 index c12138e06..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file ("ItemDrillUpgrade.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.world.World; - -public class ItemDrillUpgrade extends ItemBase { - - public final UpgradeType type; - - public ItemDrillUpgrade(UpgradeType type, String unlocName) { - super(unlocName); - this.type = type; - this.setMaxStackSize(1); - } - - public static int getSlotToPlaceFrom(ItemStack stack) { - NBTTagCompound compound = stack.getTagCompound(); - if (compound != null) { return compound.getInteger("SlotToPlaceFrom") - 1; } - return -1; - } - - @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { - ItemStack stack = player.getHeldItem(hand); - 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) { - NBTTagCompound compound = stack.getTagCompound(); - if (compound == null) { - compound = new NBTTagCompound(); - } - - compound.setInteger("SlotToPlaceFrom", slot + 1); - - stack.setTagCompound(compound); - } - - public enum UpgradeType { - SPEED, - SPEED_II, - SPEED_III, - SILK_TOUCH, - FORTUNE, - FORTUNE_II, - THREE_BY_THREE, - FIVE_BY_FIVE, - PLACER - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDust.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDust.java deleted file mode 100644 index 376789b7d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDust.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file ("ItemDust.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheDusts; -import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.renderer.color.IItemColor; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -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 static final TheDusts[] ALL_DUSTS = TheDusts.values(); - - public ItemDust(String name) { - super(name); - this.setHasSubtypes(true); - } - - @Override - 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; - } - - @Override - 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++) { - list.add(new ItemStack(this, 1, j)); - } - } - } - - @Override - 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() { - 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; - 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 deleted file mode 100644 index 5aad503f0..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemEngineerGoggles.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * This file ("ItemInfraredGoggles.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.material.InitArmorMaterials; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import io.netty.util.internal.ConcurrentSet; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class ItemEngineerGoggles extends ItemArmorAA implements IGoggles { - - private final Set cachedGlowingEntities = new ConcurrentSet<>(); - - private final boolean displayMobs; - - public ItemEngineerGoggles(String name, boolean displayMobs) { - super(name, InitArmorMaterials.armorMaterialGoggles, 0, StackUtil.getEmpty()); - this.displayMobs = displayMobs; - this.setMaxDamage(0); - - MinecraftForge.EVENT_BUS.register(this); - } - - 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) { - EntityPlayer player = ActuallyAdditions.PROXY.getCurrentPlayer(); - if (player != null && isWearing(player)) { - ItemStack face = player.inventory.armorInventory.get(3); - 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); - List entities = player.world.getEntitiesWithinAABB(Entity.class, aabb); - 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) { - entity.setGlowing(false); - - this.cachedGlowingEntities.remove(entity); - } else { - entity.setGlowing(true); - } - } - } - - return; - } - } - - if (!this.cachedGlowingEntities.isEmpty()) { - for (Entity entity : this.cachedGlowingEntities) { - if (!entity.isDead) { - entity.setGlowing(false); - } - } - this.cachedGlowingEntities.clear(); - } - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; - } - - @Override - 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 deleted file mode 100644 index dce158405..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFertilizer.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file ("ItemFertilizer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import de.ellpeck.actuallyadditions.mod.misc.DispenserHandlerFertilize; -import net.minecraft.block.BlockDispenser; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemDye; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class ItemFertilizer extends ItemBase { - - 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) { - ItemStack stack = player.getHeldItem(hand); - if (ItemDye.applyBonemeal(stack, world, pos, player, hand)) { - if (!world.isRemote) { - world.playEvent(2005, pos, 0); - } - return EnumActionResult.SUCCESS; - } - return super.onItemUse(player, world, pos, hand, side, par8, par9, par10); - } - - @Override - 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 deleted file mode 100644 index b16e772d7..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFillingWand.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * This file ("ItemFillingWand.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import net.minecraft.block.Block; -import net.minecraft.block.SoundType; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; - -public class ItemFillingWand extends ItemEnergy { - - public ItemFillingWand(String name) { - super(500000, 1000, name); - } - - private static boolean removeFittingItem(IBlockState state, EntityPlayer player) { - Block block = state.getBlock(); - ItemStack stack = new ItemStack(block, 1, block.damageDropped(state)); - - if (StackUtil.isValid(stack)) { - for (int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack slot = player.inventory.getStackInSlot(i); - if (StackUtil.isValid(slot) && slot.isItemEqual(stack)) { - slot.shrink(1); - if (!StackUtil.isValid(slot)) { - player.inventory.setInventorySlotContents(i, StackUtil.getEmpty()); - } - - return true; - } - } - } - - return false; - } - - private static void saveData(ItemStack pickBlock, IBlockState state, ItemStack wand) { - if (!wand.hasTagCompound()) wand.setTagCompound(new NBTTagCompound()); - wand.getTagCompound().setInteger("state", Block.getStateId(state)); - wand.getTagCompound().setString("name", pickBlock.getDisplayName()); - - } - - private static Pair loadData(ItemStack stack) { - if (stack.hasTagCompound()) return Pair.of(Block.getStateById(stack.getTagCompound().getInteger("state")), stack.getTagCompound().getString("name")); - return null; - } - - @Override - 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 (!world.isRemote && player.getItemInUseCount() <= 0) { - if (player.isSneaking()) { - IBlockState state = world.getBlockState(pos); - ItemStack pick = state.getBlock().getPickBlock(state, world.rayTraceBlocks(player.getPositionVector(), new Vec3d(pos.getX() + hitX, pos.getY() + hitY, pos.getZ() + hitZ)), world, pos, player); - saveData(pick, state, stack); - return EnumActionResult.SUCCESS; - } else if (loadData(stack) != null) { - if (!stack.hasTagCompound()) { - stack.setTagCompound(new NBTTagCompound()); - } - NBTTagCompound compound = stack.getTagCompound(); - - if (compound.getInteger("CurrX") == 0 && compound.getInteger("CurrY") == 0 && compound.getInteger("CurrZ") == 0) { - compound.setInteger("FirstX", pos.getX()); - compound.setInteger("FirstY", pos.getY()); - compound.setInteger("FirstZ", pos.getZ()); - - player.setActiveHand(hand); - return EnumActionResult.SUCCESS; - } - } - } - return EnumActionResult.PASS; - } - - @Override - public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entity, int timeLeft) { - if (!world.isRemote) { - boolean clear = true; - if (entity instanceof EntityPlayer) { - RayTraceResult result = WorldUtil.getNearestBlockWithDefaultReachDistance(world, (EntityPlayer) entity); - if (result != null && result.getBlockPos() != null) { - if (!stack.hasTagCompound()) { - stack.setTagCompound(new NBTTagCompound()); - } - NBTTagCompound compound = stack.getTagCompound(); - - BlockPos pos = result.getBlockPos(); - compound.setInteger("SecondX", pos.getX()); - compound.setInteger("SecondY", pos.getY()); - compound.setInteger("SecondZ", pos.getZ()); - - clear = false; - } - } - - if (clear) { - ItemPhantomConnector.clearStorage(stack, "FirstX", "FirstY", "FirstZ"); - } - } - - super.onPlayerStoppedUsing(stack, world, entity, timeLeft); - } - - @Override - public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) { - super.onUpdate(stack, world, entity, itemSlot, isSelected); - - if (!world.isRemote) { - boolean shouldClear = false; - - if (isSelected) { - if (entity instanceof EntityPlayer && stack.hasTagCompound()) { - EntityPlayer player = (EntityPlayer) entity; - boolean creative = player.capabilities.isCreativeMode; - - NBTTagCompound compound = stack.getTagCompound(); - - BlockPos firstPos = new BlockPos(compound.getInteger("FirstX"), compound.getInteger("FirstY"), compound.getInteger("FirstZ")); - BlockPos secondPos = new BlockPos(compound.getInteger("SecondX"), compound.getInteger("SecondY"), compound.getInteger("SecondZ")); - - if (!BlockPos.ORIGIN.equals(firstPos) && !BlockPos.ORIGIN.equals(secondPos)) { - int energyUse = 1500; - - Pair data = loadData(stack); - if (data != null && (creative || this.getEnergyStored(stack) >= energyUse)) { - IBlockState replaceState = data.getLeft(); - int lowestX = Math.min(firstPos.getX(), secondPos.getX()); - int lowestY = Math.min(firstPos.getY(), secondPos.getY()); - int lowestZ = Math.min(firstPos.getZ(), secondPos.getZ()); - - int currX = compound.getInteger("CurrX"); - int currY = compound.getInteger("CurrY"); - int currZ = compound.getInteger("CurrZ"); - - BlockPos pos = new BlockPos(lowestX + currX, lowestY + currY, lowestZ + currZ); - IBlockState state = world.getBlockState(pos); - - if (state.getBlock().isReplaceable(world, pos) && replaceState.getBlock().canPlaceBlockAt(world, pos)) { - if (creative || removeFittingItem(replaceState, player)) { - world.setBlockState(pos, replaceState, 2); - - SoundType sound = replaceState.getBlock().getSoundType(replaceState, world, pos, player); - world.playSound(null, pos, sound.getPlaceSound(), SoundCategory.BLOCKS, sound.getVolume() / 2F + .5F, sound.getPitch() * 0.8F); - - if (!creative) { - this.extractEnergyInternal(stack, energyUse, false); - } - } else { - shouldClear = true; - } - } - - int distX = Math.abs(secondPos.getX() - firstPos.getX()); - int distY = Math.abs(secondPos.getY() - firstPos.getY()); - int distZ = Math.abs(secondPos.getZ() - firstPos.getZ()); - - currX++; - if (currX > distX) { - currX = 0; - currY++; - if (currY > distY) { - currY = 0; - currZ++; - if (currZ > distZ) { - shouldClear = true; - } - } - } - - if (!shouldClear) { - compound.setInteger("CurrX", currX); - compound.setInteger("CurrY", currY); - compound.setInteger("CurrZ", currZ); - } - } else { - shouldClear = true; - } - } - } - } else { - shouldClear = true; - } - - if (shouldClear) { - ItemPhantomConnector.clearStorage(stack, "FirstX", "FirstY", "FirstZ", "SecondX", "SecondY", "SecondZ", "CurrX", "CurrY", "CurrZ"); - } - } - } - - @Override - public void addInformation(ItemStack stack, World playerIn, List tooltip, ITooltipFlag advanced) { - super.addInformation(stack, playerIn, tooltip, advanced); - - String display = StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".item_filling_wand.selectedBlock.none"); - - Pair data = loadData(stack); - if (data != null) { - display = data.getRight(); - } - - tooltip.add(String.format("%s: %s", StringUtil.localize("tooltip." + ActuallyAdditions.MODID + ".item_filling_wand.selectedBlock"), display)); - } - - @Override - public int getMaxItemUseDuration(ItemStack stack) { - return Integer.MAX_VALUE; - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFilter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFilter.java deleted file mode 100644 index e8658583b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFilter.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file ("ItemFilter.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import java.util.List; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.inventory.ContainerFilter; -import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.world.World; - -public class ItemFilter extends ItemBase { - - public ItemFilter(String name) { - super(name); - this.setMaxStackSize(1); - } - - @Override - 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); - } - return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand)); - } - - @Override - 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++) { - ItemStack slot = inv.getStackInSlot(i); - 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 deleted file mode 100644 index aed981b8c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFoods.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * This file ("ItemFoods.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.renderer.block.model.ModelResourceLocation; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumAction; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class ItemFoods extends ItemFoodBase { - - public static final TheFoods[] ALL_FOODS = TheFoods.values(); - - public ItemFoods(String name) { - super(0, 0.0F, false, name); - this.setHasSubtypes(true); - this.setMaxDamage(0); - TheFoods.setReturnItems(); - } - - @Override - 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) { - EntityItem entityItem = new EntityItem(player.world, player.posX, player.posY, player.posZ, returnItem.copy()); - entityItem.setPickupDelay(0); - player.world.spawnEntity(entityItem); - } - } - } - return stackToReturn; - } - - @Override - public int getMaxItemUseDuration(ItemStack stack) { - return stack.getItemDamage() >= ALL_FOODS.length ? 0 : ALL_FOODS[stack.getItemDamage()].useDuration; - } - - @Override - 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) { - return stack.getItemDamage() >= ALL_FOODS.length ? 0 : ALL_FOODS[stack.getItemDamage()].healAmount; - } - - @Override - public float getSaturationModifier(ItemStack stack) { - return stack.getItemDamage() >= ALL_FOODS.length ? 0 : ALL_FOODS[stack.getItemDamage()].saturation; - } - - @Override - 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; - } - - @Override - 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++) { - 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; - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), new ModelResourceLocation(name), "inventory"); - } - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGeneric.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGeneric.java deleted file mode 100644 index fe9ddab4a..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGeneric.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file ("ItemGeneric.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; - -public class ItemGeneric extends ItemBase { - - public ItemGeneric(String name) { - super(name); - this.setMaxDamage(0); - } - - @Override - 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 deleted file mode 100644 index 51de42b1a..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGrowthRing.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file ("ItemGrowthRing.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.block.BlockGrass; -import net.minecraft.block.IGrowable; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraftforge.common.IPlantable; - -public class ItemGrowthRing extends ItemEnergy { - - 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; } - - EntityPlayer player = (EntityPlayer) entity; - ItemStack equipped = player.getHeldItemMainhand(); - - int energyUse = 300; - if (StackUtil.isValid(equipped) && equipped == stack && this.getEnergyStored(stack) >= energyUse) { - List blocks = new ArrayList<>(); - - //Adding all possible Blocks - 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); - BlockPos posInQuestion = new BlockPos(theX, theY, theZ); - Block theBlock = world.getBlockState(posInQuestion).getBlock(); - if ((theBlock instanceof IGrowable || theBlock instanceof IPlantable) && !(theBlock instanceof BlockGrass)) { - blocks.add(posInQuestion); - } - } - } - } - - //Fertilizing the Blocks - 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); - Block block = state.getBlock(); - int metaBefore = block.getMetaFromState(state); - block.updateTick(world, pos, world.getBlockState(pos), world.rand); - - //Show Particles if Metadata changed - IBlockState newState = world.getBlockState(pos); - if (newState.getBlock().getMetaFromState(newState) != metaBefore) { - world.playEvent(2005, pos, 0); - } - - if (!player.capabilities.isCreativeMode) { - this.extractEnergyInternal(stack, energyUse, false); - } - } else { - break; - } - } - } - } - } - } - - @Override - 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 deleted file mode 100644 index 6778174a5..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemHairyBall.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This file ("ItemHairyBall.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import java.util.Random; -import java.util.UUID; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.passive.EntityOcelot; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.SoundEvents; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.WeightedRandom; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -public class ItemHairyBall extends ItemBase { - - private final UUID KittyVanCatUUID = UUID.fromString("681d4e20-10ef-40c9-a0a5-ba2f1995ef44"); - - public ItemHairyBall(String name) { - super(name); - - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - 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)); - event.getEntityLiving().world.spawnEntity(item); - } - } - } - } - - @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { - ItemStack stack = player.getHeldItem(hand); - if (!world.isRemote) { - ItemStack returnItem = this.getRandomReturnItem(world.rand); - 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); - } - return new ActionResult<>(EnumActionResult.SUCCESS, stack); - } - - public ItemStack getRandomReturnItem(Random rand) { - return WeightedRandom.getRandomItem(rand, ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS).returnItem.copy(); - } - - @Override - 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 deleted file mode 100644 index 83b8f3d8f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemJams.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * This file ("ItemJams.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheJams; -import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.renderer.color.IItemColor; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.NonNullList; -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 static final TheJams[] ALL_JAMS = TheJams.values(); - - public ItemJams(String name) { - super(0, 0.0F, false, name); - this.setHasSubtypes(true); - this.setMaxDamage(0); - this.setAlwaysEdible(); - } - - @Override - 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; - } - - @Override - 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++) { - list.add(new ItemStack(this, 1, j)); - } - } - } - - @Override - 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) { - PotionEffect firstEffectToGet = new PotionEffect(Potion.getPotionById(ALL_JAMS[stack.getItemDamage()].firstEffectToGet), 200); - player.addPotionEffect(firstEffectToGet); - - PotionEffect secondEffectToGet = new PotionEffect(Potion.getPotionById(ALL_JAMS[stack.getItemDamage()].secondEffectToGet), 600); - player.addPotionEffect(secondEffectToGet); - - ItemStack returnItem = new ItemStack(Items.GLASS_BOTTLE); - 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); - } - } - return stackToReturn; - } - - @Override - public int getHealAmount(ItemStack stack) { - return stack.getItemDamage() >= ALL_JAMS.length ? 0 : ALL_JAMS[stack.getItemDamage()].healAmount; - } - - @Override - 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++) { - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), "inventory"); - } - } - - @Override - @SideOnly(Side.CLIENT) - 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 deleted file mode 100644 index 110315ef6..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemKnife.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file ("ItemKnife.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import com.google.common.collect.Multimap; - -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.inventory.EntityEquipmentSlot; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; - -public class ItemKnife extends ItemBase { - - public ItemKnife(String name) { - super(name); - this.setMaxDamage(100); - this.setMaxStackSize(1); - this.setContainerItem(this); - this.setNoRepair(); - } - - @Override - public boolean getShareTag() { - return true; - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; - } - - @Override - public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { - Multimap map = super.getAttributeModifiers(slot, stack); - 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) { - ItemStack theStack = stack.copy(); - 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 deleted file mode 100644 index cdfe53048..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserRelayUpgrade.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * This file ("ItemLaserRelayUpgrade.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; - -public class ItemLaserRelayUpgrade extends ItemBase { - - public ItemLaserRelayUpgrade(String name) { - super(name); - } - - @Override - 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 deleted file mode 100644 index 3c2068efc..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLaserWrench.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This file ("ItemLaserWrench.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.util.ITooltipFlag; -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.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextComponentTranslation; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; - -public class ItemLaserWrench extends ItemBase { - - 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) { - 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) { - ItemPhantomConnector.storeConnection(stack, pos.getX(), pos.getY(), pos.getZ(), world); - player.sendStatusMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".laser.stored.desc"), true); - } else { - BlockPos savedPos = ItemPhantomConnector.getStoredPosition(stack); - if (savedPos != null) { - TileEntity savedTile = world.getTileEntity(savedPos); - 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)) { - ItemPhantomConnector.clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored"); - - ((TileEntityLaserRelay) savedTile).sendUpdate(); - relay.sendUpdate(); - - player.sendStatusMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".laser.connected.desc"), true); - - return EnumActionResult.SUCCESS; - } - } - - player.sendMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".laser.cantConnect.desc")); - ItemPhantomConnector.clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored"); - } - } - } - return EnumActionResult.SUCCESS; - } - return EnumActionResult.FAIL; - } - - @Override - public boolean getShareTag() { - return true; - } - - @Override - 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")); - } - } - - @Override - 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 deleted file mode 100644 index e07ae858c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLeafBlower.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * This file ("ItemLeafBlower.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.block.BlockBush; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.SoundEvents; -import net.minecraft.item.EnumAction; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraftforge.common.IShearable; - -public class ItemLeafBlower extends ItemBase implements IDisplayStandItem { - - private final boolean isAdvanced; - - public ItemLeafBlower(boolean isAdvanced, String name) { - super(name); - this.isAdvanced = isAdvanced; - this.setMaxStackSize(1); - } - - @Override - 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) { - return EnumAction.BOW; - } - - @Override - 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) { - return this.isAdvanced ? EnumRarity.EPIC : EnumRarity.RARE; - } - - @Override - 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)) { - //Breaks the Blocks - boolean broke = this.breakStuff(world, x, y, z); - //Plays a Minecart sounds (It really sounds like a Leaf Blower!) - world.playSound(null, x, y, z, SoundEvents.ENTITY_MINECART_RIDING, SoundCategory.PLAYERS, 0.3F, 0.001F); - return broke; - } - } - return false; - } - - /** - * Breaks (harvests) Grass and Leaves around - * - * @param world The World - * @param x The X Position of the Player - * @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) { - 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++) { - //The current Block to break - 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))) { - breakPositions.add(pos); - } - } - } - } - - if (!breakPositions.isEmpty()) { - Collections.shuffle(breakPositions); - - BlockPos theCoord = breakPositions.get(0); - IBlockState theState = world.getBlockState(theCoord); - - theState.getBlock().dropBlockAsItem(world, theCoord, theState, 0); - //Plays the Breaking Sound - world.playEvent(2001, theCoord, Block.getStateId(theState)); - - //Deletes the Block - world.setBlockToAir(theCoord); - - return true; - } - return false; - } - - @Override - 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) { - 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 deleted file mode 100644 index ada7e71c7..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file ("ItemMagnetRing.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import java.util.List; - -import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.world.World; - -public class ItemMagnetRing extends ItemEnergy { - - public ItemMagnetRing(String name) { - super(200000, 1000, name); - } - - @Override - 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()) { - //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(); - - 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)) { - this.extractEnergyInternal(stack, energyForItem, false); - } - } - } - } - } - } - } - } - } - - @Override - 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)); - } - return super.onItemRightClick(worldIn, player, hand); - } - - @Override - 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 deleted file mode 100644 index db4f923f6..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMisc.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * This file ("ItemMisc.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.common.IRarity; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.IFluidBlock; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class ItemMisc extends ItemBase { - - public static final TheMiscItems[] ALL_MISC_ITEMS = TheMiscItems.values(); - - public ItemMisc(String name) { - super(name); - this.setHasSubtypes(true); - } - - @Override - 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; - } - - @Override - 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()) { - list.add(new ItemStack(this, 1, j)); - } - } - } - } - - @Override - 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) { - ItemStack stack = entity.getItem(); - if (stack != null) { - boolean isEmpowered = stack.getItemDamage() == TheMiscItems.EMPOWERED_CANOLA_SEED.ordinal(); - 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)) { - entity.setDead(); - entity.world.setBlockState(pos, (isEmpowered ? InitFluids.blockEmpoweredOil : InitFluids.blockCrystalOil).getDefaultState()); - } - } - } - } - } - - return super.onEntityItemUpdate(entity); - } - - @Override - public boolean hasEffect(ItemStack stack) { - return stack.getItemDamage() == TheMiscItems.EMPOWERED_CANOLA_SEED.ordinal(); - } - - @Override - 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; - - 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 deleted file mode 100644 index 2555fd0af..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPhantomConnector.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * This file ("ItemPhantomConnector.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextComponentTranslation; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; -import net.minecraftforge.common.DimensionManager; - -public class ItemPhantomConnector extends ItemBase { - - public ItemPhantomConnector(String name) { - super(name); - this.setMaxStackSize(1); - } - - public static World getStoredWorld(ItemStack stack) { - NBTTagCompound tag = stack.getTagCompound(); - if (tag != null) { return DimensionManager.getWorld(tag.getInteger("WorldOfTileStored")); } - return null; - } - - public static BlockPos getStoredPosition(ItemStack stack) { - NBTTagCompound tag = stack.getTagCompound(); - 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); } - } - return null; - } - - public static void clearStorage(ItemStack stack, String... keys) { - if (stack.hasTagCompound()) { - NBTTagCompound compound = stack.getTagCompound(); - for (String key : keys) { - compound.removeTag(key); - } - } - } - - public static void storeConnection(ItemStack stack, int x, int y, int z, World world) { - NBTTagCompound tag = stack.getTagCompound(); - if (tag == null) { - tag = new NBTTagCompound(); - } - - tag.setInteger("XCoordOfTileStored", x); - tag.setInteger("YCoordOfTileStored", y); - tag.setInteger("ZCoordOfTileStored", z); - tag.setInteger("WorldOfTileStored", world.provider.getDimension()); - - stack.setTagCompound(tag); - } - - @Override - 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) { - //Passing Data to Phantoms - TileEntity tile = world.getTileEntity(pos); - if (tile != null) { - //Passing to Phantom - 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(); - } - clearStorage(stack, "XCoordOfTileStored", "YCoordOfTileStored", "ZCoordOfTileStored", "WorldOfTileStored"); - player.sendStatusMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".phantom.connected.desc"), true); - return EnumActionResult.SUCCESS; - } - return EnumActionResult.FAIL; - } - } - //Storing Connections - storeConnection(stack, pos.getX(), pos.getY(), pos.getZ(), world); - player.sendStatusMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".phantom.stored.desc"), true); - } - return EnumActionResult.SUCCESS; - } - - @Override - public boolean getShareTag() { - return true; - } - - @Override - 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")); - } - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPickaxeAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPickaxeAA.java deleted file mode 100644 index 4d674f9ef..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPickaxeAA.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file ("ItemPickaxeAA.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import java.util.Collections; -import java.util.Set; - -import com.google.common.collect.Sets; - -import de.ellpeck.actuallyadditions.mod.items.base.ItemToolAA; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.IRarity; - -public class ItemPickaxeAA extends ItemToolAA { - - private static final Set EFFECTIVE_ON = Sets.newHashSet(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.DOUBLE_STONE_SLAB, Blocks.GOLDEN_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.LIT_REDSTONE_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.STONE_SLAB, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE); - - public ItemPickaxeAA(Item.ToolMaterial material, String repairItem, String unlocalizedName, IRarity rarity) { - super(1.0F, -2.8F, material, repairItem, unlocalizedName, rarity, EFFECTIVE_ON); - this.setHarvestLevel("pickaxe", material.getHarvestLevel()); - } - - public ItemPickaxeAA(Item.ToolMaterial material, ItemStack repairItem, String unlocalizedName, IRarity rarity) { - super(1.0F, -2.8F, material, repairItem, unlocalizedName, rarity, EFFECTIVE_ON); - this.setHarvestLevel("pickaxe", material.getHarvestLevel()); - } - - @Override - public boolean canHarvestBlock(IBlockState blockIn) { - Block block = blockIn.getBlock(); - - if (block == Blocks.OBSIDIAN) { - return this.toolMaterial.getHarvestLevel() == 3; - } else if (block != Blocks.DIAMOND_BLOCK && block != Blocks.DIAMOND_ORE) { - if (block != Blocks.EMERALD_ORE && block != Blocks.EMERALD_BLOCK) { - if (block != Blocks.GOLD_BLOCK && block != Blocks.GOLD_ORE) { - if (block != Blocks.IRON_BLOCK && block != Blocks.IRON_ORE) { - if (block != Blocks.LAPIS_BLOCK && block != Blocks.LAPIS_ORE) { - if (block != Blocks.REDSTONE_ORE && block != Blocks.LIT_REDSTONE_ORE) { - Material material = blockIn.getMaterial(); - return material == Material.ROCK || material == Material.IRON || material == Material.ANVIL; - } else { - return this.toolMaterial.getHarvestLevel() >= 2; - } - } else { - return this.toolMaterial.getHarvestLevel() >= 1; - } - } else { - return this.toolMaterial.getHarvestLevel() >= 1; - } - } else { - return this.toolMaterial.getHarvestLevel() >= 2; - } - } else { - return this.toolMaterial.getHarvestLevel() >= 2; - } - } else { - return this.toolMaterial.getHarvestLevel() >= 2; - } - } - - @Override - public float getDestroySpeed(ItemStack stack, IBlockState state) { - Material material = state.getMaterial(); - return material != Material.IRON && material != Material.ANVIL && material != Material.ROCK ? super.getDestroySpeed(stack, state) : this.efficiency; - } - - @Override - public Set getToolClasses(ItemStack stack) { - return Collections.singleton("pickaxe"); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPlayerProbe.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPlayerProbe.java deleted file mode 100644 index a0c78bd3f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPlayerProbe.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * This file ("ItemPlayerProbe.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextComponentTranslation; -import net.minecraft.world.World; - -public class ItemPlayerProbe extends ItemBase { - - 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()) { - NBTTagCompound compound = stack.getTagCompound(); - if (compound.hasKey("UUIDMost")) { - UUID id = compound.getUniqueId("UUID"); - EntityPlayer player = world.getPlayerEntityByUUID(id); - 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")); - //TheAchievements.GET_UNPROBED.get(player); - } - } else { - ItemPhantomConnector.clearStorage(stack, "UUIDLeast", "UUIDMost", "Name"); - entity.sendMessage(new TextComponentTranslation("tooltip." + ActuallyAdditions.MODID + ".playerProbe.disconnect.2")); - } - } - } - } - } - - @Override - 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()) { - NBTTagCompound compound = stack.getTagCompound(); - if (compound.hasKey("UUIDMost")) { - if (!world.isRemote) { - TileEntityPlayerInterface face = (TileEntityPlayerInterface) tile; - face.connectedPlayer = compound.getUniqueId("UUID"); - face.playerName = compound.getString("Name"); - face.markDirty(); - face.sendUpdate(); - - ItemPhantomConnector.clearStorage(stack, "UUIDLeast", "UUIDMost", "Name"); - } - return EnumActionResult.SUCCESS; - } - } - } - return EnumActionResult.FAIL; - } - - @Override - 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 (!playerHit.isSneaking()) { - if (!stack.hasTagCompound()) { - stack.setTagCompound(new NBTTagCompound()); - } - - NBTTagCompound compound = stack.getTagCompound(); - compound.setString("Name", playerHit.getName()); - compound.setUniqueId("UUID", playerHit.getUniqueID()); - return true; - } - } - } - } - return false; - } - - @Override - 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); - } - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPotionRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPotionRing.java deleted file mode 100644 index 3a0c7a1f4..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPotionRing.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * This file ("ItemPotionRing.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.items.metalists.ThePotionRings; -import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.client.renderer.color.IItemColor; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -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) { - super(name); - this.setHasSubtypes(true); - this.setMaxStackSize(1); - this.isAdvanced = isAdvanced; - } - - public static int getStoredBlaze(ItemStack stack) { - if (!StackUtil.isValid(stack) || !stack.hasTagCompound()) { - return 0; - } else { - return stack.getTagCompound().getInteger("Blaze"); - } - } - - public static void setStoredBlaze(ItemStack stack, int amount) { - if (StackUtil.isValid(stack)) { - if (!stack.hasTagCompound()) { - stack.setTagCompound(new NBTTagCompound()); - } - stack.getTagCompound().setInteger("Blaze", amount); - } - } - - @Override - public int getMetadata(int damage) { - return damage; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) { - double diff = MAX_BLAZE - getStoredBlaze(stack); - return diff / MAX_BLAZE; - } - - @Override - 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); - } - - @Override - 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) { - return true; - } - - @Override - 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; - - int storedBlaze = getStoredBlaze(stack); - 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); - } - } - } - } - } - } - - @Override - 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) { - String effect = StringUtil.localize(ALL_RINGS[stack.getItemDamage()].name); - return standardName + " " + effect; - } - return standardName; - } - 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; - } - - @Override - 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++) { - list.add(new ItemStack(this, 1, j)); - - ItemStack full = new ItemStack(this, 1, j); - setStoredBlaze(full, MAX_BLAZE); - list.add(full); - } - } - } - - @Override - 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() { - 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; - 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) { - //Give all entities the effect - for (EntityLivingBase entity : entities) { - this.effectEntity(entity, stack, true); - } - return true; - } else { - Potion potion = Potion.getPotionById(ThePotionRings.values()[stack.getItemDamage()].effectID); - for (EntityLivingBase entity : entities) { - if (entity.isPotionActive(potion)) { - //Sometimes make the effect switch to someone else - if (tile.getWorld().rand.nextInt(100) <= 0) { - entity.removePotionEffect(potion); - break; - } 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); - return true; - } - } - } - - //Give the effect to someone new if no one had it or it randomly switched - Collections.shuffle(entities); - this.effectEntity(entities.get(0), stack, true); - return true; - } - } - return false; - } - - @Override - public int getUsePerTick(ItemStack stack, TileEntity tile, int elapsedTicks) { - return 325; - } - - 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) { - thePlayer.addPotionEffect(new PotionEffect(potion, effect.activeTime, effect.normalAmplifier, true, false)); - return true; - } - } else { - thePlayer.addPotionEffect(new PotionEffect(potion, effect.activeTime, effect.advancedAmplifier, true, false)); - return true; - } - } - return false; - } - - @Override - 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"))); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemResonantRice.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemResonantRice.java deleted file mode 100644 index 78a59f2a4..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemResonantRice.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file ("ItemResonantRice.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.world.World; - -public class ItemResonantRice extends ItemBase { - - public ItemResonantRice(String name) { - super(name); - } - - @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { - ItemStack stack = player.getHeldItem(hand); - 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) { - return EnumRarity.EPIC; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemShovelAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemShovelAA.java deleted file mode 100644 index 7180d8ded..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemShovelAA.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file ("ItemShovelAA.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import java.util.Collections; -import java.util.Set; - -import com.google.common.collect.Sets; - -import de.ellpeck.actuallyadditions.mod.items.base.ItemToolAA; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.common.IRarity; - -public class ItemShovelAA extends ItemToolAA { - - private static final Set EFFECTIVE_ON = Sets.newHashSet(Blocks.CLAY, Blocks.DIRT, Blocks.FARMLAND, Blocks.GRASS, Blocks.GRAVEL, Blocks.MYCELIUM, Blocks.SAND, Blocks.SNOW, Blocks.SNOW_LAYER, Blocks.SOUL_SAND, Blocks.GRASS_PATH); - - public ItemShovelAA(Item.ToolMaterial material, String repairItem, String unlocalizedName, IRarity rarity) { - super(1.5F, -3.0F, material, repairItem, unlocalizedName, rarity, EFFECTIVE_ON); - this.setHarvestLevel("shovel", material.getHarvestLevel()); - } - - public ItemShovelAA(Item.ToolMaterial material, ItemStack repairItem, String unlocalizedName, IRarity rarity) { - super(1.5F, -3.0F, material, repairItem, unlocalizedName, rarity, EFFECTIVE_ON); - this.setHarvestLevel("shovel", material.getHarvestLevel()); - } - - @Override - public boolean canHarvestBlock(IBlockState blockIn) { - Block block = blockIn.getBlock(); - return block == Blocks.SNOW_LAYER || block == Blocks.SNOW; - } - - @Override - public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - return Items.IRON_SHOVEL.onItemUse(playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ); - } - - @Override - public Set getToolClasses(ItemStack stack) { - return Collections.singleton("shovel"); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSolidifiedExperience.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSolidifiedExperience.java deleted file mode 100644 index 37b393c1e..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSolidifiedExperience.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file ("ItemSolidifiedExperience.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import net.minecraft.entity.EntityCreature; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.item.EntityXPOrb; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -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 static final int SOLID_XP_AMOUNT = 8; - - 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")) { - //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))); - } - } - } - } - } - - @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { - ItemStack stack = player.getHeldItem(hand); - if (!world.isRemote) { - int amount; - if (!player.isSneaking()) { - amount = SOLID_XP_AMOUNT; - if (!player.capabilities.isCreativeMode) { - stack.shrink(1); - } - } 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); - world.spawnEntity(orb); - } else player.addExperience(amount); - } - return new ActionResult<>(EnumActionResult.SUCCESS, stack); - } - - @Override - 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 deleted file mode 100644 index fa805acb3..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSpawnerChanger.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * This file ("ItemSpawnerChanger.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.entity.EntityList; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.MobSpawnerBaseLogic; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityMobSpawner; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; - -public class ItemSpawnerChanger extends ItemBase { - - 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) { - ItemStack stack = player.getHeldItemMainhand(); - if (player.canPlayerEdit(pos.offset(facing), facing, stack)) { - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityMobSpawner) { - String entity = this.getStoredEntity(stack); - 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 - NBTTagCompound compound = new NBTTagCompound(); - logic.writeToNBT(compound); - compound.removeTag("SpawnPotentials"); - compound.removeTag("SpawnData"); - logic.readFromNBT(compound); - - logic.setEntityId(new ResourceLocation(entity)); - - tile.markDirty(); - - IBlockState state = world.getBlockState(pos); - world.notifyBlockUpdate(pos, state, state, 3); - - ItemPhantomConnector.clearStorage(stack, "Entity"); - - if (!player.capabilities.isCreativeMode) { - player.setHeldItem(hand, StackUtil.shrink(stack, 1)); - } - - return EnumActionResult.SUCCESS; - } - } - } - } - return EnumActionResult.FAIL; - } - - @Override - 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)) { - entity.setDead(); - } - } - return true; - } - return false; - } - - private boolean storeClickedEntity(ItemStack stack, EntityLivingBase entity) { - if (!stack.hasTagCompound()) { - stack.setTagCompound(new NBTTagCompound()); - } - - if (!(entity instanceof EntityPlayer) && entity.isNonBoss()) { - ResourceLocation entityLoc = EntityList.getKey(entity.getClass()); - 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; } - } - - stack.getTagCompound().setString("Entity", entityName); - return true; - } - } - } - return false; - } - - private String getStoredEntity(ItemStack stack) { - if (stack.hasTagCompound()) { - String entity = stack.getTagCompound().getString("Entity"); - if (entity != null && !entity.isEmpty()) { return entity; } - } - return null; - } - - @Override - 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")); - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTeleStaff.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTeleStaff.java deleted file mode 100644 index 1d3e8fb54..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemTeleStaff.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This file ("ItemTeleStaff.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.SoundEvents; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; - -public class ItemTeleStaff extends ItemEnergy { - - public ItemTeleStaff(String name) { - super(250000, 1000, name); - } - - @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { - ItemStack stack = player.getHeldItem(hand); - if (!world.isRemote) { - RayTraceResult pos = WorldUtil.getNearestPositionWithAir(world, player, 100); - 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); - 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); - 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) { - this.extractEnergyInternal(stack, use, false); - player.getCooldownTracker().setCooldown(this, 50); - } - return ActionResult.newResult(EnumActionResult.SUCCESS, stack); - } - } - } - } - player.swingArm(hand); - return ActionResult.newResult(EnumActionResult.FAIL, stack); - } - - @Override - 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 deleted file mode 100644 index ec14ce369..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterBowl.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * This file ("ItemWaterBowl.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import net.minecraft.block.Block; -import net.minecraft.block.BlockLiquid; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.init.SoundEvents; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -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; -import net.minecraftforge.common.MinecraftForge; -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 ItemWaterBowl(String name) { - super(name); - this.setMaxStackSize(1); - - MinecraftForge.EVENT_BUS.register(this); - } - - @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) { - 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())) { - IBlockState state = event.getWorld().getBlockState(trace.getBlockPos()); - Block block = state.getBlock(); - - 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) { - 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)) { - event.getEntityPlayer().setHeldItem(event.getHand(), bowl); - } 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); - } - } - } - } - } - } - } - } - } - - @Override - 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 (trace == null) { - return new ActionResult<>(EnumActionResult.PASS, stack); - } else if (trace.typeOfHit != RayTraceResult.Type.BLOCK) { - return new ActionResult<>(EnumActionResult.PASS, stack); - } else { - BlockPos pos = trace.getBlockPos(); - - if (!world.isBlockModifiable(player, pos)) { - return new ActionResult<>(EnumActionResult.FAIL, stack); - } 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)) { - return new ActionResult<>(EnumActionResult.FAIL, stack); - } 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 { - return new ActionResult<>(EnumActionResult.FAIL, stack); - } - } - } - } - - @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) { - int lastX = 0; - int lastY = 0; - - 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)) { - this.checkReplace(player, stack, new ItemStack(Items.BOWL), itemSlot); - } - } - } - change = true; - } - - 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); - } - } - } - } - } - - 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); - } - - @Override - 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) { - 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) { - 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); - - 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()) { - world.destroyBlock(pos, true); - } - - world.playSound(player, pos, SoundEvents.ITEM_BUCKET_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F); - - IBlockState placeState; - if (finite) { - placeState = Blocks.FLOWING_WATER.getDefaultState(); - } else { - placeState = Blocks.FLOWING_WATER.getDefaultState(); - } - world.setBlockState(pos, placeState, 3); - } - - return true; - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java deleted file mode 100644 index ef420d299..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file ("ItemWaterRemovalRing.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; - -public class ItemWaterRemovalRing extends ItemEnergy { - - 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; } - - EntityPlayer player = (EntityPlayer) entity; - ItemStack equipped = player.getHeldItemMainhand(); - - int energyUse = 150; - 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); - - //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) { - world.setBlockToAir(pos); - - 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) { - world.setBlockToAir(pos); - - if (!player.capabilities.isCreativeMode) { - this.extractEnergyInternal(stack, energyUse * 2, false); - } - } - } - } - } - } - } - - @Override - 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 deleted file mode 100644 index 49291f1bc..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * This file ("ItemWingsOfTheBats.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; -import de.ellpeck.actuallyadditions.mod.data.PlayerData; -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.passive.EntityBat; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemSword; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraftforge.common.MinecraftForge; -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 static final String THE_BAT_BAT = "the bat bat"; - public static final int MAX_FLY_TIME = 800; - - public ItemWingsOfTheBats(String name) { - super(name); - this.setMaxStackSize(1); - - MinecraftForge.EVENT_BUS.register(this); - } - - /** - * Checks if the Player has Wings in its Inventory - * - * @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); } - } - return StackUtil.getEmpty(); - } - - @Override - public boolean showDurabilityBar(ItemStack stack) { - return true; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) { - EntityPlayer player = ActuallyAdditions.PROXY.getCurrentPlayer(); - 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; - } - } - return super.getDurabilityForDisplay(stack); - } - - @Override - public int getRGBDurabilityForDisplay(ItemStack stack) { - EntityPlayer player = ActuallyAdditions.PROXY.getCurrentPlayer(); - if (player != null) { - PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player); - 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 super.getRGBDurabilityForDisplay(stack); - } - - @SubscribeEvent - public void onEntityDropEvent(LivingDropsEvent event) { - Entity source = event.getSource().getTrueSource(); - - 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) { - 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) { - 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()))); - } - } - } - } - - @SubscribeEvent - public void livingUpdateEvent(LivingEvent.LivingUpdateEvent event) { - if (event.getEntityLiving() instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) event.getEntityLiving(); - - if (!player.capabilities.isCreativeMode && !player.isSpectator()) { - PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player); - - 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) { - data.hasBatWings = true; - shouldSend = true; - } - } else { - tryDeduct = true; - } - } else { - if (wingsEquipped && data.batWingsFlyTime < MAX_FLY_TIME) { - player.capabilities.allowFlying = true; - - if (player.capabilities.isFlying) { - data.batWingsFlyTime++; - - if (player.world.getTotalWorldTime() % 10 == 0) { - shouldSend = true; - } - } - - tryDeduct = true; - } else { - data.hasBatWings = false; - data.shouldDisableBatWings = true; - shouldSend = true; - - player.capabilities.allowFlying = false; - player.capabilities.isFlying = false; - player.capabilities.disableDamage = false; - } - } - - if (tryDeduct && data.batWingsFlyTime > 0) { - int deductTime = 0; - - if (!player.capabilities.isFlying) { - deductTime = 2; - } 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)) { - deductTime = 10; - } - } - - if (deductTime > 0) { - data.batWingsFlyTime = Math.max(0, data.batWingsFlyTime - deductTime); - - if (player.world.getTotalWorldTime() % 10 == 0) { - shouldSend = true; - } - } - } - - if (shouldSend) { - PacketHandlerHelper.syncPlayerData(player, false); - data.shouldDisableBatWings = false; //was set only temporarily to send it - } - } else { - if (data.hasBatWings) { - player.capabilities.allowFlying = true; - } else if (data.shouldDisableBatWings) { //so that other modded flying won't be disabled - data.shouldDisableBatWings = false; - - player.capabilities.allowFlying = false; - player.capabilities.isFlying = false; - player.capabilities.disableDamage = false; - } - } - } - } - } - - @Override - 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 deleted file mode 100644 index fc57f8f39..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWorm.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * This file ("ItemWorm.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items; - -import java.util.List; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; -import de.ellpeck.actuallyadditions.mod.entity.EntityWorm; -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import net.minecraft.block.BlockGrass; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.IItemPropertyGetter; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.player.UseHoeEvent; -import net.minecraftforge.fml.common.eventhandler.Event.Result; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -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 ItemWorm(String name) { - super(name); - - MinecraftForge.EVENT_BUS.register(this); - - this.addPropertyOverride(new ResourceLocation(ActuallyAdditions.MODID, "snail"), new IItemPropertyGetter() { - @Override - @SideOnly(Side.CLIENT) - 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) { - 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) { - EntityWorm worm = new EntityWorm(world); - 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); - } - return EnumActionResult.SUCCESS; - } - } - return super.onItemUse(player, world, pos, hand, side, par8, par9, par10); - } - - @SubscribeEvent(priority = EventPriority.LOW) - public void onHoe(UseHoeEvent event) { - if (ConfigBoolValues.WORMS.isEnabled() && event.getResult() != Result.DENY) { - World world = event.getWorld(); - if (!world.isRemote) { - BlockPos pos = event.getPos(); - 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); - world.spawnEntity(item); - } - } - } - } - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.UNCOMMON; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemArmorAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemArmorAA.java deleted file mode 100644 index da2fe2b04..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemArmorAA.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This file ("ItemArmorAA.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.base; - -import de.ellpeck.actuallyadditions.api.misc.IDisableableItem; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler; -import de.ellpeck.actuallyadditions.mod.inventory.ContainerEnergizer; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemArmor; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.IRarity; - -public class ItemArmorAA extends ItemArmor implements IDisableableItem { - - private final ItemStack repairItem; - private final String name; - private final IRarity rarity; - private final boolean disabled; - - public ItemArmorAA(String name, ArmorMaterial material, int type, ItemStack repairItem) { - this(name, material, type, repairItem, EnumRarity.RARE); - } - - public ItemArmorAA(String name, ArmorMaterial material, int type, ItemStack repairItem, IRarity rarity) { - super(material, 0, ContainerEnergizer.VALID_EQUIPMENT_SLOTS[type]); - this.repairItem = repairItem; - this.name = name; - this.rarity = rarity; - this.disabled = ConfigurationHandler.config.getBoolean("Disable: " + StringUtil.badTranslate(name), "Tool Control", false, "This will disable the " + StringUtil.badTranslate(name) + ". It will not be registered."); - if (!this.disabled) this.register(); - } - - private void register() { - ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative()); - - this.registerRendering(); - } - - protected String getBaseName() { - return this.name; - } - - public boolean shouldAddCreative() { - return true; - } - - protected void registerRendering() { - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); - } - - @Override - public IRarity getForgeRarity(ItemStack stack) { - return this.rarity; - } - - @Override - public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack) { - return StackUtil.isValid(this.repairItem) && ItemUtil.areItemsEqual(this.repairItem, stack, false); - } - - @Override - public boolean isDisabled() { - return this.disabled; - } -} 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 deleted file mode 100644 index db0256b6a..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemBase.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file ("ItemBase.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.base; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -public class ItemBase extends Item { - - private final String name; - - public ItemBase(String name) { - this.name = name; - - this.register(); - } - - private void register() { - ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative()); - - this.registerRendering(); - } - - protected String getBaseName() { - return this.name; - } - - public boolean shouldAddCreative() { - return true; - } - - 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 deleted file mode 100644 index 5f7fc9cfd..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemEnergy.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * This file ("ItemEnergy.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.base; - -import java.text.NumberFormat; -import java.util.List; - -import javax.annotation.Nullable; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.tile.CustomEnergyStorage; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.energy.CapabilityEnergy; -import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public abstract class ItemEnergy extends ItemBase { - - private final int maxPower; - private final int transfer; - - public ItemEnergy(int maxPower, int transfer, String name) { - super(name); - this.maxPower = maxPower; - this.transfer = transfer; - - this.setHasSubtypes(true); - this.setMaxStackSize(1); - } - - @Override - public boolean getShareTag() { - return true; - } - - @Override - 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) { - NumberFormat format = NumberFormat.getInstance(); - tooltip.add(String.format("%s/%s Crystal Flux", format.format(storage.getEnergyStored()), format.format(storage.getMaxEnergyStored()))); - } - } - } - - @Override - @SideOnly(Side.CLIENT) - public boolean hasEffect(ItemStack stack) { - return false; - } - - @Override - public void getSubItems(CreativeTabs tabs, NonNullList list) { - if (this.isInCreativeTab(tabs)) { - ItemStack stackFull = new ItemStack(this); - if (stackFull.hasCapability(CapabilityEnergy.ENERGY, null)) { - IEnergyStorage storage = stackFull.getCapability(CapabilityEnergy.ENERGY, null); - if (storage != null) { - this.setEnergy(stackFull, storage.getMaxEnergyStored()); - list.add(stackFull); - } - } - - ItemStack stackEmpty = new ItemStack(this); - this.setEnergy(stackEmpty, 0); - list.add(stackEmpty); - } - } - - @Override - public boolean showDurabilityBar(ItemStack itemStack) { - return true; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) { - if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) { - IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null); - if (storage != null) { - double maxAmount = storage.getMaxEnergyStored(); - double energyDif = maxAmount - storage.getEnergyStored(); - return energyDif / maxAmount; - } - } - return super.getDurabilityForDisplay(stack); - } - - @Override - 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); - } - return super.getRGBDurabilityForDisplay(stack); - } - - 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); - } - } - } - - 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); - } - } - return 0; - } - - 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); - } - } - return 0; - } - - 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); } - } - return 0; - } - - 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); } - } - return 0; - } - - public int getEnergyStored(ItemStack stack) { - if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) { - IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null); - if (storage != null) { return storage.getEnergyStored(); } - } - return 0; - } - - public int getMaxEnergyStored(ItemStack stack) { - if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) { - IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null); - if (storage != null) { return storage.getMaxEnergyStored(); } - } - return 0; - } - - @Override - public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { - return new EnergyCapabilityProvider(stack, this); - } - - 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) { - @Override - public int getEnergyStored() { - if (stack.hasTagCompound()) { - return stack.getTagCompound().getInteger("Energy"); - } else { - return 0; - } - } - - @Override - public void setEnergyStored(int energy) { - if (!stack.hasTagCompound()) { - stack.setTagCompound(new NBTTagCompound()); - } - - stack.getTagCompound().setInteger("Energy", energy); - } - }; - } - - @Override - 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); } - 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 deleted file mode 100644 index c9d28134a..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemFoodBase.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file ("ItemFoodBase.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.base; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; - -public class ItemFoodBase extends ItemFood { - - private final String name; - - public ItemFoodBase(int heal, float saturation, boolean wolfFood, String name) { - super(heal, saturation, wolfFood); - this.name = name; - - this.register(); - } - - private void register() { - ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative()); - - this.registerRendering(); - } - - protected String getBaseName() { - return this.name; - } - - public boolean shouldAddCreative() { - return true; - } - - 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 deleted file mode 100644 index 9b642a4eb..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemFoodSeed.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file ("ItemFoodSeed.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.base; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemSeedFood; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; - -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) { - 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); - } - - this.register(); - } - - private void register() { - ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative()); - - this.registerRendering(); - } - - @Override - public int getMaxItemUseDuration(ItemStack stack) { - return this.maxUseDuration; - } - - protected String getBaseName() { - return this.name; - } - - public boolean shouldAddCreative() { - return true; - } - - protected void registerRendering() { - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; - } - - @Override - public IBlockState getPlant(IBlockAccess world, BlockPos pos) { - return this.plant.getDefaultState(); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemHoeAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemHoeAA.java deleted file mode 100644 index 705810399..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemHoeAA.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This file ("ItemHoeAA.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.base; - -import de.ellpeck.actuallyadditions.api.misc.IDisableableItem; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.item.Item; -import net.minecraft.item.ItemHoe; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.IRarity; - -public class ItemHoeAA extends ItemHoe implements IDisableableItem { - - private final String name; - private final IRarity rarity; - private final ItemStack repairItem; - private final boolean disabled; - - public ItemHoeAA(Item.ToolMaterial toolMat, ItemStack repairItem, String unlocalizedName, IRarity rarity) { - super(toolMat); - - this.repairItem = repairItem; - this.name = unlocalizedName; - this.rarity = rarity; - - this.disabled = ConfigurationHandler.config.getBoolean("Disable: " + StringUtil.badTranslate(this.name), "Tool Control", false, "This will disable the " + StringUtil.badTranslate(this.name) + ". It will not be registered."); - if (!this.disabled) this.register(); - } - - private void register() { - ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative()); - - this.registerRendering(); - } - - protected String getBaseName() { - return this.name; - } - - public boolean shouldAddCreative() { - return true; - } - - protected void registerRendering() { - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); - } - - @Override - public IRarity getForgeRarity(ItemStack stack) { - return this.rarity; - } - - @Override - public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack) { - return ItemUtil.areItemsEqual(this.repairItem, stack, false); - } - - @Override - public boolean isDisabled() { - return this.disabled; - } -} 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 deleted file mode 100644 index 1b7f6708b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemSeed.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file ("ItemSeed.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.base; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemSeeds; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; - -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) { - super(plant, Blocks.FARMLAND); - this.name = name; - this.oredictName = oredictName; - this.plant = plant; - - if (plant instanceof BlockPlant) { - ((BlockPlant) plant).doStuff(this, returnItem, returnMeta); - } - - this.register(); - } - - private void register() { - ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative()); - - this.registerRendering(); - } - - protected String getBaseName() { - return this.name; - } - - public boolean shouldAddCreative() { - return true; - } - - protected void registerRendering() { - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; - } - - @Override - 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/base/ItemSwordAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemSwordAA.java deleted file mode 100644 index 051a80b54..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemSwordAA.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This file ("ItemSwordAA.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.base; - -import de.ellpeck.actuallyadditions.api.misc.IDisableableItem; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase; -import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemSword; -import net.minecraftforge.common.IRarity; - -public class ItemSwordAA extends ItemSword implements IDisableableItem { - - private final String name; - private final IRarity rarity; - private final ItemStack repairItem; - private final boolean disabled; - - public ItemSwordAA(ToolMaterial toolMat, ItemStack repairItem, String unlocalizedName, IRarity rarity) { - super(toolMat); - - this.repairItem = repairItem; - this.name = unlocalizedName; - this.rarity = rarity; - - this.disabled = ConfigurationHandler.config.getBoolean("Disable: " + StringUtil.badTranslate(this.name), "Tool Control", false, "This will disable the " + StringUtil.badTranslate(this.name) + ". It will not be registered."); - if (!this.disabled) this.register(); - } - - private void register() { - ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative()); - - this.registerRendering(); - } - - protected String getBaseName() { - return this.name; - } - - public boolean shouldAddCreative() { - return true; - } - - protected void registerRendering() { - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); - } - - protected Class getItemBlock() { - return ItemBlockBase.class; - } - - @Override - public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack) { - return ItemUtil.areItemsEqual(this.repairItem, stack, false); - } - - @Override - public IRarity getForgeRarity(ItemStack stack) { - return this.rarity; - } - - @Override - public boolean isDisabled() { - return this.disabled; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemToolAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemToolAA.java deleted file mode 100644 index b72fa70fd..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemToolAA.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This file ("ItemToolAA.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.base; - -import java.util.Set; - -import de.ellpeck.actuallyadditions.api.misc.IDisableableItem; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTool; -import net.minecraftforge.common.IRarity; -import net.minecraftforge.oredict.OreDictionary; - -public class ItemToolAA extends ItemTool implements IDisableableItem { - - private final String name; - private final IRarity rarity; - private final ItemStack repairItem; - private String repairOredict; - private final boolean disabled; - - public ItemToolAA(float attack, float speed, ToolMaterial toolMat, String repairItem, String unlocalizedName, IRarity rarity, Set effectiveStuff) { - this(attack, speed, toolMat, ItemStack.EMPTY, unlocalizedName, rarity, effectiveStuff); - this.repairOredict = repairItem; - } - - public ItemToolAA(float attack, float speed, ToolMaterial toolMat, ItemStack repairItem, String unlocalizedName, IRarity rarity, Set effectiveStuff) { - super(attack, speed, toolMat, effectiveStuff); - - this.repairItem = repairItem; - this.name = unlocalizedName; - this.rarity = rarity; - this.disabled = ConfigurationHandler.config.getBoolean("Disable: " + StringUtil.badTranslate(unlocalizedName), "Tool Control", false, "This will disable the " + StringUtil.badTranslate(unlocalizedName) + ". It will not be registered."); - if (!this.disabled) this.register(); - } - - private void register() { - ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative()); - - this.registerRendering(); - } - - protected String getBaseName() { - return this.name; - } - - public boolean shouldAddCreative() { - return true; - } - - protected void registerRendering() { - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory"); - } - - @Override - public IRarity getForgeRarity(ItemStack stack) { - return this.rarity; - } - - @Override - public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack) { - if (StackUtil.isValid(this.repairItem)) { - return ItemUtil.areItemsEqual(this.repairItem, stack, false); - } else if (this.repairOredict != null) { - int[] idsStack = OreDictionary.getOreIDs(stack); - for (int id : idsStack) { - if (OreDictionary.getOreName(id).equals(this.repairOredict)) { return true; } - } - } - return false; - } - - @Override - public boolean isDisabled() { - return this.disabled; - } -} 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 deleted file mode 100644 index eb6d1ba95..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/ItemLens.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file ("ItemLens.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.lens; - -import de.ellpeck.actuallyadditions.api.lens.ILensItem; -import de.ellpeck.actuallyadditions.api.lens.Lens; -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 { - - private final Lens type; - - public ItemLens(String name, Lens type) { - super(name); - this.type = type; - this.setMaxStackSize(1); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.UNCOMMON; - } - - @Override - 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 deleted file mode 100644 index 4f897762d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * This file ("LensColor.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.lens; - -import java.util.List; -import java.util.Map; -import java.util.Random; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; -import de.ellpeck.actuallyadditions.api.lens.Lens; -import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldServer; -import net.minecraftforge.common.util.FakePlayerFactory; - -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 - }; - private final Random rand = new Random(); - - @Override - 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) { - 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); - tile.extractEnergy(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)) { - item.setDead(); - - EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, newStack); - tile.getWorldObject().spawnEntity(newItem); - - tile.extractEnergy(ENERGY_USE); - } - } - } - } - return false; - } - - 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); } - } - } - return ItemStack.EMPTY; - } - - @Override - 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 }; - } - - @Override - public int getDistance() { - return 10; - } - - @Override - 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 deleted file mode 100644 index 302f495bf..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDeath.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file ("LensDeath.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; - -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) { - int use = this.getUsePerEntity(); - if (tile.getEnergy() >= use) { - tile.extractEnergy(use); - - this.onAttacked(entity, tile); - } - } - - return hitBlock != null && !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock); - } - - protected void onAttacked(EntityLivingBase entity, IAtomicReconstructor tile) { - entity.attackEntityFrom(DamageSources.DAMAGE_ATOMIC_RECONSTRUCTOR, 20F); - } - - protected int getUsePerEntity() { - return 350; - } - - @Override - public float[] getColor() { - return new float[] { 188F / 255F, 222F / 255F, 1F }; - } - - @Override - 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 deleted file mode 100644 index 65afac6f2..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDetonation.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file ("LensDetonation.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.lens; - -import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; -import de.ellpeck.actuallyadditions.api.lens.Lens; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; - -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); - tile.extractEnergy(ENERGY_USE); - } - return true; - } - return false; - } - - @Override - public float[] getColor() { - return new float[] { 158F / 255F, 43F / 255F, 39F / 255F }; - } - - @Override - public int getDistance() { - return 30; - } - - @Override - 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 deleted file mode 100644 index e902b69cb..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisenchanting.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * This file ("LensDisenchanting.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.state.IBlockState; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentData; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemEnchantedBook; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; - -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()) { - EntityItem book = null; - EntityItem toDisenchant = null; - for (EntityItem item : items) { - if (item != null && !item.isDead) { - ItemStack stack = item.getItem(); - if (StackUtil.isValid(stack) && stack.getCount() == 1) { - Item stackItem = stack.getItem(); - if (stackItem == Items.BOOK || stackItem == Items.ENCHANTED_BOOK) { - if (book == null) { - book = item; - } else { - return false; - } - } else { - Map enchants = EnchantmentHelper.getEnchantments(stack); - if (enchants != null && !enchants.isEmpty()) { - if (toDisenchant == null) { - toDisenchant = item; - } else { - return false; - } - } - } - } - } - } - - if (book != null && toDisenchant != null) { - ItemStack disenchantStack = toDisenchant.getItem(); - ItemStack bookStack = book.getItem(); - - Map enchants = EnchantmentHelper.getEnchantments(disenchantStack); - 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) { - newBookStack = new ItemStack(Items.ENCHANTED_BOOK); - } else { - newBookStack = bookStack.copy(); - } - - ItemUtil.removeEnchantment(newDisenchantStack, enchant); - ItemEnchantedBook.addEnchantment(newBookStack, new EnchantmentData(enchant, level)); - - EntityItem disenchanted = new EntityItem(toDisenchant.getEntityWorld(), toDisenchant.posX, toDisenchant.posY, toDisenchant.posZ, newDisenchantStack); - EntityItem newBook = new EntityItem(book.getEntityWorld(), book.posX, book.posY, book.posZ, newBookStack); - toDisenchant.setDead(); - book.setDead(); - tile.getWorldObject().spawnEntity(newBook); - tile.getWorldObject().spawnEntity(disenchanted); - - tile.extractEnergy(ENERGY_USE); - - return true; - } - } - } - } - return false; - } - - @Override - public float[] getColor() { - return new float[] { 234F / 255F, 173F / 255F, 255F / 255F }; - } - - @Override - public int getDistance() { - return 5; - } - - @Override - 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 deleted file mode 100644 index d2fe0886f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisruption.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file ("LensDisruption.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; - -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)) { - 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) { - ItemStack stack = item.getItem(); - if (!item.isDead && StackUtil.isValid(stack)) { - if (!stack.hasTagCompound() || !stack.getTagCompound().getBoolean(ActuallyAdditions.MODID + "DisruptedAlready")) { - - ItemStack newStack; - do { - if (tile.getWorldObject().rand.nextBoolean()) { - newStack = new ItemStack(Item.REGISTRY.getRandomObject(tile.getWorldObject().rand)); - } else { - newStack = new ItemStack(Block.REGISTRY.getRandomObject(tile.getWorldObject().rand)); - } - } while (!StackUtil.isValid(newStack)); - - newStack.setCount(stack.getCount()); - - if (!newStack.hasTagCompound()) { - newStack.setTagCompound(new NBTTagCompound()); - } - newStack.getTagCompound().setBoolean(ActuallyAdditions.MODID + "DisruptedAlready", true); - - item.setDead(); - - EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, newStack); - tile.getWorldObject().spawnEntity(newItem); - - tile.extractEnergy(ENERGY_USE); - } - } - } - return true; - } - return false; - } - - @Override - public float[] getColor() { - return new float[] { 246F / 255F, 255F / 255F, 183F / 255F }; - } - - @Override - public int getDistance() { - return 3; - } - - @Override - 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/LensKiller.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensKiller.java deleted file mode 100644 index c4d9af9b4..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensKiller.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file ("LensEvenMoarDeath.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.lens; - -import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.DamageSource; -import net.minecraft.world.WorldServer; -import net.minecraftforge.common.util.FakePlayerFactory; - -public class LensKiller extends LensDeath { - - @Override - protected void onAttacked(EntityLivingBase entity, IAtomicReconstructor tile) { - if (!tile.getWorldObject().isRemote) { - entity.attackEntityFrom(DamageSource.causePlayerDamage(FakePlayerFactory.getMinecraft((WorldServer) tile.getWorldObject())), 20); - } - } - - @Override - protected int getUsePerEntity() { - return 2500; - } -} 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 deleted file mode 100644 index 0adfecc9c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * This file ("LensMining.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.api.recipe.WeightedOre; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; -import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.Block; -import net.minecraft.block.BlockNetherrack; -import net.minecraft.block.BlockStone; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.WeightedRandom; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldServer; -import net.minecraftforge.common.util.FakePlayerFactory; -import net.minecraftforge.oredict.OreDictionary; - -public class LensMining extends Lens { - - public static void init() { - ActuallyAdditionsAPI.addMiningLensStoneOre("oreCoal", 5000); - ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherCoal", 5000); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreIron", 3000); - ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherIron", 3000); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreGold", 500); - ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherGold", 500); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreDiamond", 50); - ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherDiamond", 50); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreLapis", 250); - ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherLapis", 250); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreRedstone", 200); - ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherRedstone", 200); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreEmerald", 30); - ActuallyAdditionsAPI.addMiningLensNetherOre("oreQuartz", 3000); - - ActuallyAdditionsAPI.addMiningLensStoneOre("oreCopper", 2000); - ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherCopper", 2000); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreTin", 1800); - ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherTin", 1800); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreLead", 1500); - ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherLead", 1500); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreSilver", 1000); - ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherSilver", 1000); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreNickel", 100); - ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherNickel", 100); - ActuallyAdditionsAPI.addMiningLensStoneOre("orePlatinum", 20); - ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherPlatinum", 20); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreAluminum", 1200); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreAluminium", 1200); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreOsmium", 1500); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreZinc", 1000); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreYellorite", 1200); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreUranium", 400); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreCertusQuartz", 800); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreApatite", 700); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreQuartzBlack", 3000); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreRuby", 40); - ActuallyAdditionsAPI.addMiningLensStoneOre("orePeridot", 40); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreTopaz", 40); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreTanzanite", 40); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreMalachite", 40); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreSapphire", 40); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreAmber", 150); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreResonating", 50); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreSulfur", 3000); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreSaltpeter", 250); - ActuallyAdditionsAPI.addMiningLensNetherOre("oreFirestone", 30); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreSalt", 2900); - ActuallyAdditionsAPI.addMiningLensStoneOre("oreDraconium", 5); - - ActuallyAdditionsAPI.addMiningLensStoneOre("orePoorIron", 3000); - ActuallyAdditionsAPI.addMiningLensStoneOre("orePoorGold", 500); - ActuallyAdditionsAPI.addMiningLensStoneOre("orePoorCopper", 2000); - ActuallyAdditionsAPI.addMiningLensStoneOre("orePoorTin", 1800); - ActuallyAdditionsAPI.addMiningLensStoneOre("orePoorLead", 1500); - ActuallyAdditionsAPI.addMiningLensStoneOre("orePoorSilver", 1000); - - ActuallyAdditionsAPI.addMiningLensNetherOre("oreCobalt", 50); - ActuallyAdditionsAPI.addMiningLensNetherOre("oreArdite", 50); - - 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)) { - ActuallyAdditionsAPI.addMiningLensNetherOre(ore, weight); - } 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!"); - } - } - } - } - - @Override - public boolean invoke(IBlockState hitState, BlockPos hitPos, IAtomicReconstructor tile) { - if (!tile.getWorldObject().isAirBlock(hitPos)) { - if (tile.getEnergy() >= ConfigIntValues.MINING_LENS_USE.getValue()) { - int adaptedUse = ConfigIntValues.MINING_LENS_USE.getValue(); - - List ores = null; - Block hitBlock = hitState.getBlock(); - if (hitBlock instanceof BlockStone) { - ores = ActuallyAdditionsAPI.STONE_ORES; - } else if (hitBlock instanceof BlockNetherrack) { - ores = ActuallyAdditionsAPI.NETHERRACK_ORES; - adaptedUse += 10000; - } - - if (ores != null) { - int totalWeight = WeightedRandom.getTotalWeight(ores); - ItemStack stack = null; - - boolean found = false; - while (!found) { - WeightedOre ore = WeightedRandom.getRandomItem(tile.getWorldObject().rand, ores, totalWeight); - 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) { - if (ConfigBoolValues.MINING_LENS_ADAPTED_USE.isEnabled()) adaptedUse += (totalWeight - ore.itemWeight) % 40000; - - stack = aStack; - found = true; - break; - } - } - } - } - } - - if (tile.getEnergy() >= adaptedUse) { - Block block = Block.getBlockFromItem(stack.getItem()); - 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); - - tile.getWorldObject().playEvent(2001, hitPos, Block.getStateId(state)); - - tile.extractEnergy(adaptedUse); - } - } - } - } - - return true; - } else { - return false; - } - } - - @Override - public float[] getColor() { - return new float[] { 76F / 255F, 76F / 255F, 76F / 255F }; - } - - @Override - public int getDistance() { - return 10; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensRecipeHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensRecipeHandler.java deleted file mode 100644 index 1df55b711..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensRecipeHandler.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * This file ("LensRecipeHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.lens; - -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nullable; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.lens.Lens; -import de.ellpeck.actuallyadditions.api.recipe.ColorLensChangerByDyeMeta; -import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger; -import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.recipe.ColorLensRotator; -import de.ellpeck.actuallyadditions.mod.recipe.EnchBookConversion; -import de.ellpeck.actuallyadditions.mod.util.RecipeUtil; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.NonNullList; -import net.minecraftforge.oredict.OreDictionary; - -public final class LensRecipeHandler { - - public static final ArrayList MAIN_PAGE_RECIPES = new ArrayList<>(); - public static LensConversionRecipe recipeColorLens; - public static LensConversionRecipe recipeSoulSand; - public static LensConversionRecipe recipeGreenWall; - public static LensConversionRecipe recipeWhiteWall; - public static LensConversionRecipe recipeExplosionLens; - public static LensConversionRecipe recipeDamageLens; - public static LensConversionRecipe recipeLeather; - public static LensConversionRecipe recipeNetherWart; - public static LensConversionRecipe recipePrismarine; - public static LensConversionRecipe recipeCrystallizedCanolaSeed; - public static LensConversionRecipe recipeItemLaser; - public static LensConversionRecipe recipeFluidLaser; - public static EnchBookConversion recipeEnchBook; - - public static void init() { - //Crystal Blocks - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.REDSTONE_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.REDSTONE.ordinal()), 400); - MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.LAPIS_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.LAPIS.ordinal()), 400); - MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.DIAMOND_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.DIAMOND.ordinal()), 600); - MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.EMERALD_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.EMERALD.ordinal()), 1000); - MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.COAL_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.COAL.ordinal()), 600); - MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.IRON_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.IRON.ordinal()), 800); - MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe()); - - //Crystal Items - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(Items.REDSTONE), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 40); - MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromStacks(new ItemStack(Items.DYE, 1, 4)), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), 40); - MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(Items.DIAMOND), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), 60); - MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(Items.EMERALD), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), 100); - MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(Items.COAL), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), 60); - MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe()); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(Items.IRON_INGOT), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 80); - MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe()); - - //Lenses - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromStacks(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal())), new ItemStack(InitItems.itemColorLens), 5000); - recipeColorLens = RecipeUtil.lastReconstructorRecipe(); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(InitItems.itemColorLens), new ItemStack(InitItems.itemExplosionLens), 5000); - recipeExplosionLens = RecipeUtil.lastReconstructorRecipe(); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(InitItems.itemExplosionLens), new ItemStack(InitItems.itemDamageLens), 5000); - recipeDamageLens = RecipeUtil.lastReconstructorRecipe(); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(InitItems.itemDamageLens), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), 5000); - - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(InitBlocks.blockLaserRelay), new ItemStack(InitBlocks.blockLaserRelayFluids), 2000); - recipeFluidLaser = RecipeUtil.lastReconstructorRecipe(); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(InitBlocks.blockLaserRelayFluids), new ItemStack(InitBlocks.blockLaserRelayItem), 2000); - recipeItemLaser = RecipeUtil.lastReconstructorRecipe(); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(InitBlocks.blockLaserRelayItem), new ItemStack(InitBlocks.blockLaserRelay), 2000); - - //Misc - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.SAND), new ItemStack(Blocks.SOUL_SAND), 20000); - recipeSoulSand = RecipeUtil.lastReconstructorRecipe(); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(Items.ROTTEN_FLESH), new ItemStack(Items.LEATHER), 8000); - recipeLeather = RecipeUtil.lastReconstructorRecipe(); - - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.RED_MUSHROOM), new ItemStack(Items.NETHER_WART), 150000); - recipeNetherWart = RecipeUtil.lastReconstructorRecipe(); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(Items.QUARTZ), new ItemStack(Items.PRISMARINE_SHARD), 30000); - recipePrismarine = RecipeUtil.lastReconstructorRecipe(); - - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItems(InitItems.itemCanolaSeed), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CRYSTALLIZED_CANOLA_SEED.ordinal()), 2000); - recipeCrystallizedCanolaSeed = RecipeUtil.lastReconstructorRecipe(); - - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.QUARTZ_BLOCK), new ItemStack(InitBlocks.blockTestifiBucksWhiteWall), 10); - recipeWhiteWall = RecipeUtil.lastReconstructorRecipe(); - ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromStacks(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 1)), new ItemStack(InitBlocks.blockTestifiBucksGreenWall), 10); - recipeGreenWall = RecipeUtil.lastReconstructorRecipe(); - - ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(recipeEnchBook = new EnchBookConversion()); - - IColorLensChanger changer = new ColorLensChangerByDyeMeta(); - if (ConfigBoolValues.COLOR_LENS_USES_OREDICT.isEnabled()) { - initOredictDyeRotator(); - } else { - ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Items.DYE, changer); - } - ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(Blocks.WOOL), changer); - ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(Blocks.STAINED_GLASS), changer); - ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(Blocks.STAINED_GLASS_PANE), changer); - ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(Blocks.STAINED_HARDENED_CLAY), changer); - ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(Blocks.CARPET), changer); - ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(InitBlocks.blockColoredLamp), changer); - ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(InitBlocks.blockColoredLampOn), changer); - } - - @Deprecated //Use lens-checking method below. - public static List getRecipesFor(ItemStack input) { - List possibleRecipes = new ArrayList<>(); - for (LensConversionRecipe recipe : ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES) - if (recipe.getInput().apply(input)) possibleRecipes.add(recipe); - return possibleRecipes; - } - - @Nullable - public static LensConversionRecipe findMatchingRecipe(ItemStack input, Lens lens) { - for (LensConversionRecipe recipe : ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES) - if (recipe.matches(input, lens)) return recipe; - return null; - } - - private static Ingredient fromBlock(Block b) { - return Ingredient.fromItems(Item.getItemFromBlock(b)); - } - - private static void initOredictDyeRotator() { - List stacks = NonNullList.withSize(16, ItemStack.EMPTY); - List dyeItems = new ArrayList<>(); - String[] dyes = { "White", "Orange", "Magenta", "LightBlue", "Yellow", "Lime", "Pink", "Gray", "LightGray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black" }; - for (int i = 0; i < dyes.length; i++) { - List ores = OreDictionary.getOres("dye" + dyes[i]); - dyeItems.addAll(ores); - stacks.set(i, ores.get(ores.size() - 1)); - } - ColorLensRotator rotator = new ColorLensRotator(stacks); - for (ItemStack s : dyeItems) - ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(s.getItem(), rotator); - } -} 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 deleted file mode 100644 index ddff275f9..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/Lenses.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file ("Lenses.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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 static void init() { - ActuallyAdditionsAPI.lensDefaultConversion = new LensConversion(); - ActuallyAdditionsAPI.lensDetonation = new LensDetonation(); - ActuallyAdditionsAPI.lensDeath = new LensDeath(); - ActuallyAdditionsAPI.lensEvenMoarDeath = new LensKiller(); - ActuallyAdditionsAPI.lensColor = new LensColor(); - ActuallyAdditionsAPI.lensDisruption = new LensDisruption(); - ActuallyAdditionsAPI.lensDisenchanting = new LensDisenchanting(); - ActuallyAdditionsAPI.lensMining = new LensMining(); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheCrystals.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheCrystals.java deleted file mode 100644 index 39b17f42a..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheCrystals.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file ("TheCrystals.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.metalists; - -import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.util.IStringSerializable; -import net.minecraftforge.common.IRarity; - -public enum TheCrystals implements IStringSerializable { - - REDSTONE("red", Util.CRYSTAL_RED_RARITY, 0xFF2F21, 158F / 255F, 43F / 255F, 39F / 255F), - LAPIS("blue", Util.CRYSTAL_BLUE_RARITY, 0x5171FF, 37F / 255F, 49F / 255F, 147F / 255F), - DIAMOND("light_blue", Util.CRYSTAL_LIGHT_BLUE_RARITY, 0x35F1FF, 99F / 255F, 135F / 255F, 210F / 255F), - COAL("black", Util.CRYSTAL_BLACK_RARITY, 0x434442, 0.2F, 0.2F, 0.2F), - EMERALD("green", Util.CRYSTAL_GREEN_RARITY, 0x44E033, 54F / 255F, 75F / 255F, 24F / 255F), - IRON("white", Util.CRYSTAL_WHITE_RARITY, 0xCEDDD4, 0.8F, 0.8F, 0.8F); - - public final String name; - public final IRarity rarity; - public final float[] conversionColorParticles; - public final int clusterColor; - - TheCrystals(String name, IRarity rarity, int clusterColor, float... conversionColorParticles) { - this.name = name; - this.rarity = rarity; - this.conversionColorParticles = conversionColorParticles; - this.clusterColor = clusterColor; - } - - @Override - public String getName() { - return this.name; - } -} \ No newline at end of file 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 deleted file mode 100644 index 27b85b0eb..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheDusts.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file ("TheDusts.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.metalists; - -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.item.EnumRarity; - -public enum TheDusts { - - IRON("iron", 7826534, EnumRarity.COMMON), - GOLD("gold", 14335744, EnumRarity.UNCOMMON), - DIAMOND("diamond", 292003, EnumRarity.RARE), - EMERALD("emerald", 4319527, EnumRarity.EPIC), - LAPIS("lapis", 1849791, EnumRarity.UNCOMMON), - QUARTZ("quartz", StringUtil.DECIMAL_COLOR_WHITE, EnumRarity.UNCOMMON), - COAL("coal", 0, EnumRarity.UNCOMMON), - QUARTZ_BLACK("quartz_black", 18, EnumRarity.RARE); - - public final String name; - public final int color; - public final 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 deleted file mode 100644 index dea0e3b24..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheFoods.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file ("TheFoods.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.metalists; - -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.init.Items; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; - -public enum TheFoods { - - CHEESE("cheese", 1, 0.05F, false, 3, EnumRarity.COMMON), - PUMPKIN_STEW("pumpkin_stew", 6, 0.3F, true, 30, EnumRarity.COMMON), - CARROT_JUICE("carrot_juice", 4, 0.2F, true, 20, EnumRarity.COMMON), - FISH_N_CHIPS("fish_n_chips", 14, 0.65F, false, 40, EnumRarity.UNCOMMON), - FRENCH_FRIES("french_fries", 10, 0.6F, false, 32, EnumRarity.COMMON), - FRENCH_FRY("french_fry", 2, 0.025F, false, 3, EnumRarity.COMMON), - SPAGHETTI("spaghetti", 7, 0.4F, false, 38, EnumRarity.COMMON), - NOODLE("noodle", 1, 0.01F, false, 3, EnumRarity.COMMON), - CHOCOLATE_CAKE("chocolate_cake", 16, 0.8F, false, 45, EnumRarity.UNCOMMON), - CHOCOLATE("chocolate", 3, 0.3F, false, 15, EnumRarity.COMMON), - TOAST("toast", 3, 0.08F, false, 25, EnumRarity.COMMON), - SUBMARINE_SANDWICH("submarine_sandwich", 9, 0.4F, false, 40, EnumRarity.UNCOMMON), - BIG_COOKIE("big_cookie", 4, 0.25F, false, 20, EnumRarity.UNCOMMON), - HAMBURGER("hamburger", 13, 0.65F, false, 40, EnumRarity.COMMON), - PIZZA("pizza", 16, 0.8F, false, 45, EnumRarity.UNCOMMON), - BAGUETTE("baguette", 6, 0.5F, false, 25, EnumRarity.COMMON), - RICE("rice", 2, 0.05F, false, 10, EnumRarity.UNCOMMON), - RICE_BREAD("rice_bread", 6, 0.5F, false, 25, EnumRarity.UNCOMMON), - DOUGHNUT("doughnut", 2, 0.1F, false, 10, EnumRarity.EPIC), - CHOCOLATE_TOAST("chocolate_toast", 5, 0.2F, false, 40, EnumRarity.RARE), - BACON("bacon", 4, 0.1F, false, 30, EnumRarity.COMMON); - - public final String name; - public final int healAmount; - public final float saturation; - public final boolean getsDrunken; - public final int useDuration; - public final EnumRarity rarity; - public ItemStack returnItem = StackUtil.getEmpty(); - - TheFoods(String name, int healAmount, float saturation, boolean getsDrunken, int useDuration, EnumRarity rarity) { - this.name = name; - this.getsDrunken = getsDrunken; - this.healAmount = healAmount; - this.saturation = saturation; - this.useDuration = useDuration; - this.rarity = rarity; - } - - 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); - FRENCH_FRIES.returnItem = new ItemStack(InitItems.itemMisc, 1, TheMiscItems.PAPER_CONE.ordinal()); - FISH_N_CHIPS.returnItem = new ItemStack(InitItems.itemMisc, 1, TheMiscItems.PAPER_CONE.ordinal()); - } -} \ No newline at end of file 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 deleted file mode 100644 index 1088a74a5..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheJams.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file ("TheJams.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.metalists; - -import net.minecraft.item.EnumRarity; - -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), - PL_AP_LE("pl_ap_le", 6, 0.1F, EnumRarity.RARE, 15, 3, 13226009), - CH_AP_CI("ch_ap_ci", 6, 0.1F, EnumRarity.RARE, 10, 1, 13189222), - HO_ME_KI("ho_me_ki", 6, 0.1F, EnumRarity.RARE, 10, 14, 2031360), - PI_CO("pi_co", 6, 0.1F, EnumRarity.RARE, 9, 1, 16056203), - HO_ME_CO("ho_me_co", 6, 0.1F, EnumRarity.RARE, 10, 13, 10462208); - - public final String name; - public final int healAmount; - public final float saturation; - public final EnumRarity rarity; - public final int firstEffectToGet; - public final int secondEffectToGet; - public final 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; - this.rarity = rarity; - this.firstEffectToGet = firstEffectID; - this.secondEffectToGet = secondEffectID; - this.color = color; - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheMiscItems.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheMiscItems.java deleted file mode 100644 index 732435443..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/TheMiscItems.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file ("TheMiscItems.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.metalists; - -import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.item.EnumRarity; -import net.minecraftforge.common.IRarity; - -public enum TheMiscItems { - - PAPER_CONE("paper_cone", EnumRarity.COMMON), - MASHED_FOOD("mashed_food", EnumRarity.UNCOMMON), - KNIFE_BLADE("knife_blade", EnumRarity.COMMON), - KNIFE_HANDLE("knife_handle", EnumRarity.COMMON), - DOUGH("dough", EnumRarity.COMMON), - QUARTZ("black_quartz", EnumRarity.EPIC), - RING("ring", EnumRarity.UNCOMMON), - COIL("coil", EnumRarity.COMMON), - COIL_ADVANCED("coil_advanced", EnumRarity.UNCOMMON), - RICE_DOUGH("rice_dough", EnumRarity.UNCOMMON), - TINY_COAL("tiny_coal", EnumRarity.COMMON), - TINY_CHAR("tiny_charcoal", EnumRarity.COMMON), - RICE_SLIME("rice_slime", EnumRarity.UNCOMMON), - CANOLA("canola", EnumRarity.UNCOMMON), - CUP("cup", EnumRarity.UNCOMMON), - BAT_WING("bat_wing", EnumRarity.RARE), - DRILL_CORE("drill_core", EnumRarity.UNCOMMON), - BLACK_DYE("black_dye", EnumRarity.EPIC), - LENS("lens", EnumRarity.UNCOMMON), - ENDER_STAR("ender_star", EnumRarity.EPIC), - SPAWNER_SHARD("spawner_shard", EnumRarity.EPIC), - BIOMASS("biomass", EnumRarity.UNCOMMON), - BIOCOAL("biocoal", EnumRarity.RARE), - CRYSTALLIZED_CANOLA_SEED("crystallized_canola_seed", EnumRarity.UNCOMMON), - EMPOWERED_CANOLA_SEED("empowered_canola_seed", EnumRarity.RARE), - YOUTUBE_ICON("youtube_icon", Util.FALLBACK_RARITY); - - public final String name; - public final IRarity rarity; - - TheMiscItems(String name, IRarity rarity) { - this.name = name; - this.rarity = rarity; - } -} \ No newline at end of file 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 deleted file mode 100644 index 0c812cb79..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/metalists/ThePotionRings.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * This file ("ThePotionRings.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.items.metalists; - -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.init.MobEffects; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.Potion; - -public enum ThePotionRings { - - 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)), - //Mining Fatigue - 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)), - //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)), - //Blindness - NIGHT_VISION( - MobEffects.NIGHT_VISION.getName(), - 2039713, - MobEffects.NIGHT_VISION, - 0, - 0, - 300, - false, - EnumRarity.RARE, - new ItemStack(Items.GOLDEN_CARROT)); - //Hunger - //Weakness - //Poison - //Withering - //Health Boost (Not Happening) - //Absorption (Not Happening) - - public final String name; - public final int color; - public final EnumRarity rarity; - public final int effectID; - public final int normalAmplifier; - public final int advancedAmplifier; - public final int activeTime; - 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) { - this.name = name; - this.color = color; - this.rarity = rarity; - this.effectID = Potion.getIdFromPotion(effect); - this.normalAmplifier = normalAmplifier; - this.advancedAmplifier = advancedAmplifier; - this.activeTime = activeTime; - this.needsWaitBeforeActivating = needsWaitBeforeActivating; - this.craftingItem = craftingItem; - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java deleted file mode 100644 index a61f4f20f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file ("JEIActuallyAdditionsPlugin.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.jei; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; -import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe; -import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; -import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe; -import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiCoffeeMachine; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFurnaceDouble; -import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiGrinder; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.jei.booklet.BookletRecipeCategory; -import de.ellpeck.actuallyadditions.mod.jei.booklet.BookletRecipeWrapper; -import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineRecipeCategory; -import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineRecipeWrapper; -import de.ellpeck.actuallyadditions.mod.jei.compost.CompostRecipeCategory; -import de.ellpeck.actuallyadditions.mod.jei.compost.CompostRecipeWrapper; -import de.ellpeck.actuallyadditions.mod.jei.crusher.CrusherRecipeCategory; -import de.ellpeck.actuallyadditions.mod.jei.crusher.CrusherRecipeWrapper; -import de.ellpeck.actuallyadditions.mod.jei.empowerer.EmpowererRecipeCategory; -import de.ellpeck.actuallyadditions.mod.jei.empowerer.EmpowererRecipeWrapper; -import de.ellpeck.actuallyadditions.mod.jei.reconstructor.ReconstructorRecipeCategory; -import de.ellpeck.actuallyadditions.mod.jei.reconstructor.ReconstructorRecipeWrapper; -import de.ellpeck.actuallyadditions.mod.util.Util; -import mezz.jei.api.IJeiHelpers; -import mezz.jei.api.IModPlugin; -import mezz.jei.api.IModRegistry; -import mezz.jei.api.JEIPlugin; -import mezz.jei.api.ingredients.IIngredientBlacklist; -import mezz.jei.api.recipe.IRecipeCategoryRegistration; -import mezz.jei.api.recipe.VanillaRecipeCategoryUid; -import net.minecraft.item.ItemStack; - -@JEIPlugin -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())); - } - - @Override - public void register(IModRegistry registry) { - IJeiHelpers helpers = registry.getJeiHelpers(); - - registry.handleRecipes(IBookletPage.class, BookletRecipeWrapper::new, BookletRecipeCategory.NAME); - registry.handleRecipes(CoffeeIngredient.class, CoffeeMachineRecipeWrapper::new, CoffeeMachineRecipeCategory.NAME); - registry.handleRecipes(CrusherRecipe.class, CrusherRecipeWrapper::new, CrusherRecipeCategory.NAME); - registry.handleRecipes(LensConversionRecipe.class, ReconstructorRecipeWrapper.FACTORY, ReconstructorRecipeCategory.NAME); - registry.handleRecipes(EmpowererRecipe.class, EmpowererRecipeWrapper::new, EmpowererRecipeCategory.NAME); - registry.handleRecipes(CompostRecipe.class, CompostRecipeWrapper::new, CompostRecipeCategory.NAME); - - registry.addRecipes(ActuallyAdditionsAPI.BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA, BookletRecipeCategory.NAME); - registry.addRecipes(ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS, CoffeeMachineRecipeCategory.NAME); - registry.addRecipes(ActuallyAdditionsAPI.CRUSHER_RECIPES, CrusherRecipeCategory.NAME); - registry.addRecipes(ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES, ReconstructorRecipeCategory.NAME); - registry.addRecipes(ActuallyAdditionsAPI.EMPOWERER_RECIPES, EmpowererRecipeCategory.NAME); - registry.addRecipes(ActuallyAdditionsAPI.COMPOST_RECIPES, CompostRecipeCategory.NAME); - - registry.addRecipeClickArea(GuiCoffeeMachine.class, 53, 42, 22, 16, CoffeeMachineRecipeCategory.NAME); - registry.addRecipeClickArea(GuiGrinder.class, 80, 40, 24, 22, CrusherRecipeCategory.NAME); - registry.addRecipeClickArea(GuiGrinder.GuiGrinderDouble.class, 51, 40, 74, 22, CrusherRecipeCategory.NAME); - registry.addRecipeClickArea(GuiFurnaceDouble.class, 51, 40, 74, 22, VanillaRecipeCategoryUid.SMELTING); - - IIngredientBlacklist blacklist = helpers.getIngredientBlacklist(); - blacklist.addIngredientToBlacklist(new ItemStack(InitBlocks.blockRice)); - blacklist.addIngredientToBlacklist(new ItemStack(InitBlocks.blockCanola)); - blacklist.addIngredientToBlacklist(new ItemStack(InitBlocks.blockFlax)); - blacklist.addIngredientToBlacklist(new ItemStack(InitBlocks.blockCoffee)); - blacklist.addIngredientToBlacklist(new ItemStack(InitBlocks.blockWildPlant, 1, Util.WILDCARD)); - blacklist.addIngredientToBlacklist(new ItemStack(InitBlocks.blockColoredLampOn, 1, Util.WILDCARD)); - blacklist.addIngredientToBlacklist(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.YOUTUBE_ICON.ordinal())); - - registry.addRecipeCatalyst(new ItemStack(InitItems.itemCrafterOnAStick), VanillaRecipeCategoryUid.CRAFTING); - registry.addRecipeCatalyst(new ItemStack(InitBlocks.blockFurnaceDouble), VanillaRecipeCategoryUid.SMELTING); - registry.addRecipeCatalyst(new ItemStack(InitBlocks.blockGrinder), CrusherRecipeCategory.NAME); - registry.addRecipeCatalyst(new ItemStack(InitBlocks.blockGrinderDouble), CrusherRecipeCategory.NAME); - registry.addRecipeCatalyst(new ItemStack(InitBlocks.blockCoffeeMachine), CoffeeMachineRecipeCategory.NAME); - registry.addRecipeCatalyst(new ItemStack(InitBlocks.blockAtomicReconstructor), ReconstructorRecipeCategory.NAME); - registry.addRecipeCatalyst(new ItemStack(InitBlocks.blockEmpowerer), EmpowererRecipeCategory.NAME); - registry.addRecipeCatalyst(new ItemStack(InitItems.itemBooklet), BookletRecipeCategory.NAME); - registry.addRecipeCatalyst(new ItemStack(InitBlocks.blockCompost), CompostRecipeCategory.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 deleted file mode 100644 index 14a588fe0..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/RecipeWrapperWithButton.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file ("RecipeWrapperWithButton.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; -import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import mezz.jei.api.recipe.IRecipeWrapper; -import net.minecraft.client.Minecraft; - -public abstract class RecipeWrapperWithButton implements IRecipeWrapper { - - protected final TexturedButton theButton; - - public RecipeWrapperWithButton() { - this.theButton = new TexturedButton(GuiBooklet.RES_LOC_GADGETS, 23782, this.getButtonX(), this.getButtonY(), 0, 0, 20, 20); - } - - public abstract int getButtonX(); - - public abstract int getButtonY(); - - @Override - 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) { - Minecraft.getMinecraft().displayGuiScreen(BookletUtils.createBookletGuiFromPage(Minecraft.getMinecraft().currentScreen, page)); - return true; - } - } - return false; - } - - public abstract IBookletPage getPage(); - - @Override - 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 { - 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 deleted file mode 100644 index df974b9ea..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/booklet/BookletRecipeCategory.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file ("BookletRecipeCategory.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.IRecipeCategory; -import net.minecraft.item.ItemStack; - -public class BookletRecipeCategory implements IRecipeCategory { - - public static final String NAME = "actuallyadditions.booklet"; - - private final IDrawable background; - - public BookletRecipeCategory(IGuiHelper helper) { - this.background = helper.createBlankDrawable(160, 105); - } - - @Override - public String getUid() { - return NAME; - } - - @Override - public String getTitle() { - return StringUtil.localize("container.nei." + NAME + ".name"); - } - - @Override - public String getModName() { - return ActuallyAdditions.NAME; - } - - @Override - public IDrawable getBackground() { - return this.background; - } - - @Override - public void setRecipe(IRecipeLayout recipeLayout, BookletRecipeWrapper wrapper, IIngredients ingredients) { - recipeLayout.getItemStacks().init(0, true, 70, -4); - - List list = new ArrayList<>(); - wrapper.thePage.getItemStacksForPage(list); - recipeLayout.getItemStacks().set(0, list); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/booklet/BookletRecipeWrapper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/booklet/BookletRecipeWrapper.java deleted file mode 100644 index b60f62a43..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/booklet/BookletRecipeWrapper.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file ("BookletRecipeWrapper.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.jei.booklet; - -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; -import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import net.minecraft.client.Minecraft; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fluids.FluidStack; - -public class BookletRecipeWrapper extends RecipeWrapperWithButton { - - public final IBookletPage thePage; - - public BookletRecipeWrapper(IBookletPage page) { - this.thePage = page; - } - - @Override - public void getIngredients(IIngredients ingredients) { - List itemList = new ArrayList<>(); - this.thePage.getItemStacksForPage(itemList); - ingredients.setInputs(VanillaTypes.ITEM, itemList); - ingredients.setOutputs(VanillaTypes.ITEM, itemList); - - List fluidList = new ArrayList<>(); - this.thePage.getFluidStacksForPage(fluidList); - ingredients.setInputs(VanillaTypes.FLUID, fluidList); - ingredients.setOutputs(VanillaTypes.FLUID, fluidList); - } - - @Override - public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { - List header = minecraft.fontRenderer.listFormattedStringToWidth(StringUtil.localize("container.nei." + ActuallyAdditions.MODID + ".booklet.header").replaceAll("", TextFormatting.BLUE + "").replaceAll("", TextFormatting.BLACK + ""), 150); - for (int i = 0; i < header.size(); i++) { - minecraft.fontRenderer.drawString(header.get(i), 0, 17 + i * (minecraft.fontRenderer.FONT_HEIGHT + 1), 0, false); - } - - int maxLines = 4; - IBookletChapter chapter = this.thePage.getChapter(); - String aText = chapter.getAllPages()[0].getInfoText(); - List text = minecraft.fontRenderer.listFormattedStringToWidth(aText != null ? aText : TextFormatting.DARK_RED + StringUtil.localize("container.nei." + ActuallyAdditions.MODID + ".booklet.noText"), 150); - for (int i = 0; i < Math.min(maxLines, text.size()); i++) { - minecraft.fontRenderer.drawString(text.get(i) + (i == maxLines - 1 && text.size() > maxLines ? TextFormatting.RESET + "" + TextFormatting.BLACK + "..." : ""), 0, 16 + 25 + i * (minecraft.fontRenderer.FONT_HEIGHT + 1), 0, false); - } - minecraft.fontRenderer.drawString(TextFormatting.ITALIC + chapter.getLocalizedName(), 25, 85, 0, false); - minecraft.fontRenderer.drawString(TextFormatting.ITALIC + "Page " + (chapter.getPageIndex(this.thePage) + 1), 25, 95, 0, false); - - super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); - } - - @Override - public int getButtonX() { - return 0; - } - - @Override - public int getButtonY() { - return 84; - } - - @Override - public IBookletPage getPage() { - return this.thePage; - } -} 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 deleted file mode 100644 index cda7917a4..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeCategory.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file ("CoffeeMachineRecipeCategory.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.jei.coffee; - -import java.util.Arrays; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.IRecipeCategory; - -public class CoffeeMachineRecipeCategory implements IRecipeCategory { - - public static final String NAME = "actuallyadditions.coffee"; - - private final IDrawable background; - - public CoffeeMachineRecipeCategory(IGuiHelper helper) { - this.background = helper.createDrawable(AssetUtil.getGuiLocation("gui_nei_coffee_machine"), 0, 0, 126, 92); - } - - @Override - public String getUid() { - return NAME; - } - - @Override - public String getTitle() { - return StringUtil.localize("container.nei." + NAME + ".name"); - } - - @Override - public String getModName() { - return ActuallyAdditions.NAME; - } - - @Override - public IDrawable getBackground() { - return this.background; - } - - @Override - 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())); - - recipeLayout.getItemStacks().init(1, true, 44, 38); - recipeLayout.getItemStacks().set(1, wrapper.cup); - - recipeLayout.getItemStacks().init(2, true, 1, 38); - recipeLayout.getItemStacks().set(2, Arrays.asList(TileEntityCoffeeMachine.COFFEE.getMatchingStacks())); - - recipeLayout.getItemStacks().init(3, false, 44, 69); - recipeLayout.getItemStacks().set(3, wrapper.theOutput); - } -} 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 deleted file mode 100644 index 08eb89731..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/coffee/CoffeeMachineRecipeWrapper.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file ("CoffeeMachineRecipeWrapper.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.jei.coffee; - -import java.util.ArrayList; -import java.util.List; - -import com.google.common.base.Strings; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import net.minecraft.client.Minecraft; -import net.minecraft.item.ItemStack; - -public class CoffeeMachineRecipeWrapper extends RecipeWrapperWithButton { - - public final CoffeeIngredient ingredient; - public final ItemStack theOutput; - public final ItemStack cup = new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()); - - public CoffeeMachineRecipeWrapper(CoffeeIngredient ingredient) { - this.ingredient = ingredient; - - this.theOutput = new ItemStack(InitItems.itemCoffee); - ActuallyAdditionsAPI.methodHandler.addEffectToStack(this.theOutput, this.ingredient); - } - - @Override - public void getIngredients(IIngredients ingredients) { - List list = new ArrayList<>(); - for (ItemStack s : this.ingredient.getInput().getMatchingStacks()) - list.add(s); - list.add(this.cup); - for (ItemStack s : TileEntityCoffeeMachine.COFFEE.getMatchingStacks()) - list.add(s); - ingredients.setInputs(VanillaTypes.ITEM, list); - - ingredients.setOutput(VanillaTypes.ITEM, this.theOutput); - } - - @Override - public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { - if (!Strings.isNullOrEmpty(this.ingredient.getExtraText())) { - minecraft.fontRenderer.drawString(StringUtil.localize("container.nei." + ActuallyAdditions.MODID + ".coffee.special") + ":", 2, 4, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); - minecraft.fontRenderer.drawString(this.ingredient.getExtraText(), 2, 16, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); - } - - if (this.ingredient.getMaxAmplifier() > 0) { - minecraft.fontRenderer.drawString(StringUtil.localize("container.nei." + ActuallyAdditions.MODID + ".coffee.maxAmount") + ": " + this.ingredient.getMaxAmplifier(), 2, 28, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); - } - - super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); - } - - @Override - public int getButtonX() { - return 0; - } - - @Override - public int getButtonY() { - return 68; - } - - @Override - public IBookletPage getPage() { - return BookletUtils.findFirstPageForStack(new ItemStack(InitBlocks.blockCoffeeMachine)); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/compost/CompostRecipeCategory.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/compost/CompostRecipeCategory.java deleted file mode 100644 index 3afadf75d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/compost/CompostRecipeCategory.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file ("CompostRecipeCategory.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.jei.compost; - -import java.util.Arrays; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.IRecipeCategory; - -public class CompostRecipeCategory implements IRecipeCategory { - - public static final String NAME = "actuallyadditions.compost"; - - private final IDrawable background; - - public CompostRecipeCategory(IGuiHelper helper) { - this.background = helper.createDrawable(AssetUtil.getGuiLocation("gui_nei_simple"), 0, 0, 96, 60); - } - - @Override - public String getUid() { - return NAME; - } - - @Override - public String getTitle() { - return StringUtil.localize("container.nei." + NAME + ".name"); - } - - @Override - public String getModName() { - return ActuallyAdditions.NAME; - } - - @Override - public IDrawable getBackground() { - return this.background; - } - - @Override - public void setRecipe(IRecipeLayout recipeLayout, CompostRecipeWrapper wrapper, IIngredients ingredients) { - recipeLayout.getItemStacks().init(0, true, 4, 18); - recipeLayout.getItemStacks().set(0, Arrays.asList(wrapper.recipe.getInput().getMatchingStacks())); - - recipeLayout.getItemStacks().init(1, false, 66, 18); - recipeLayout.getItemStacks().set(1, wrapper.recipe.getOutput()); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/compost/CompostRecipeWrapper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/compost/CompostRecipeWrapper.java deleted file mode 100644 index 599fd7618..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/compost/CompostRecipeWrapper.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file ("CompostRecipeWrapper.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.jei.compost; - -import java.util.Arrays; - -import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; -import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import net.minecraft.client.Minecraft; -import net.minecraft.item.ItemStack; - -public class CompostRecipeWrapper extends RecipeWrapperWithButton { - - public final CompostRecipe recipe; - - public CompostRecipeWrapper(CompostRecipe recipe) { - this.recipe = recipe; - } - - @Override - public void getIngredients(IIngredients ingredients) { - ingredients.setInputs(VanillaTypes.ITEM, Arrays.asList(this.recipe.getInput().getMatchingStacks())); - ingredients.setOutput(VanillaTypes.ITEM, this.recipe.getOutput()); - } - - @Override - public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { - int bake_time = TileEntityCompost.COMPOST_TIME_TICKS / 20; - minecraft.fontRenderer.drawString(bake_time + "s", 28, 3, 0xFFFFFF, true); - //super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); Not sure the button needs to be here. - } - - @Override - public int getButtonX() { - return 32; - } - - @Override - public int getButtonY() { - return 35; - } - - @Override - public IBookletPage getPage() { - return BookletUtils.findFirstPageForStack(new ItemStack(InitBlocks.blockCompost)); - } -} 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 deleted file mode 100644 index 06f56fbe9..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/crusher/CrusherRecipeCategory.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This file ("CrusherRecipeCategory.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.jei.crusher; - -import java.util.Arrays; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.IRecipeCategory; - -public class CrusherRecipeCategory implements IRecipeCategory { - - public static final String NAME = "actuallyadditions.crushing"; - - private final IDrawable background; - - public CrusherRecipeCategory(IGuiHelper helper) { - this.background = helper.createDrawable(AssetUtil.getGuiLocation("gui_grinder"), 60, 13, 56, 79); - } - - @Override - public String getUid() { - return NAME; - } - - @Override - public String getTitle() { - return StringUtil.localize("container.nei." + NAME + ".name"); - } - - @Override - public String getModName() { - return ActuallyAdditions.NAME; - } - - @Override - public IDrawable getBackground() { - return this.background; - } - - @Override - 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())) { - 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/crusher/CrusherRecipeWrapper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/crusher/CrusherRecipeWrapper.java deleted file mode 100644 index d85ce1893..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/crusher/CrusherRecipeWrapper.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file ("CrusherRecipeWrapper.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.jei.crusher; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; -import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import net.minecraft.client.Minecraft; -import net.minecraft.item.ItemStack; - -public class CrusherRecipeWrapper extends RecipeWrapperWithButton { - - public final CrusherRecipe theRecipe; - - public CrusherRecipeWrapper(CrusherRecipe recipe) { - this.theRecipe = recipe; - } - - @Override - public void getIngredients(IIngredients ingredients) { - ingredients.setInputs(VanillaTypes.ITEM, Arrays.asList(this.theRecipe.getInput().getMatchingStacks())); - - List list = new ArrayList<>(); - list.add(this.theRecipe.getOutputOne()); - if (StackUtil.isValid(this.theRecipe.getOutputTwo())) { - list.add(this.theRecipe.getOutputTwo()); - } - ingredients.setOutputs(VanillaTypes.ITEM, list); - } - - @Override - public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { - if (StackUtil.isValid(this.theRecipe.getOutputTwo())) { - minecraft.fontRenderer.drawString(this.theRecipe.getSecondChance() + "%", 60, 60, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); - } - - super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); - } - - @Override - public int getButtonX() { - return -5; - } - - @Override - public int getButtonY() { - return 26; - } - - @Override - public IBookletPage getPage() { - return BookletUtils.findFirstPageForStack(new ItemStack(InitBlocks.blockGrinder)); - } -} 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 deleted file mode 100644 index 341664e70..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/empowerer/EmpowererRecipeCategory.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file ("EmpowererRecipeCategory.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.jei.empowerer; - -import java.util.Arrays; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.recipe.IRecipeCategory; - -public class EmpowererRecipeCategory implements IRecipeCategory { - - public static final String NAME = "actuallyadditions.empowerer"; - - private final IDrawable background; - - public EmpowererRecipeCategory(IGuiHelper helper) { - this.background = helper.createDrawable(AssetUtil.getGuiLocation("gui_nei_empowerer"), 0, 0, 135, 80); - } - - @Override - public String getUid() { - return NAME; - } - - @Override - public String getTitle() { - return StringUtil.localize("container.nei." + NAME + ".name"); - } - - @Override - public String getModName() { - return ActuallyAdditions.NAME; - } - - @Override - public IDrawable getBackground() { - return this.background; - } - - @Override - 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())); - - recipeLayout.getItemStacks().init(1, true, 1, 31); - recipeLayout.getItemStacks().set(1, Arrays.asList(wrapper.theRecipe.getStandOne().getMatchingStacks())); - - recipeLayout.getItemStacks().init(2, true, 31, 1); - recipeLayout.getItemStacks().set(2, Arrays.asList(wrapper.theRecipe.getStandTwo().getMatchingStacks())); - - recipeLayout.getItemStacks().init(3, true, 61, 31); - recipeLayout.getItemStacks().set(3, Arrays.asList(wrapper.theRecipe.getStandThree().getMatchingStacks())); - - recipeLayout.getItemStacks().init(4, true, 31, 61); - recipeLayout.getItemStacks().set(4, Arrays.asList(wrapper.theRecipe.getStandFour().getMatchingStacks())); - - recipeLayout.getItemStacks().init(5, false, 112, 31); - recipeLayout.getItemStacks().set(5, wrapper.theRecipe.getOutput()); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/empowerer/EmpowererRecipeWrapper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/empowerer/EmpowererRecipeWrapper.java deleted file mode 100644 index b592805b9..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/empowerer/EmpowererRecipeWrapper.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This file ("EmpowererRecipeWrapper.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.jei.empowerer; - -import java.util.ArrayList; -import java.util.List; - -import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; -import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import net.minecraft.item.ItemStack; - -public class EmpowererRecipeWrapper extends RecipeWrapperWithButton { - - public final EmpowererRecipe theRecipe; - - public EmpowererRecipeWrapper(EmpowererRecipe recipe) { - this.theRecipe = recipe; - } - - @Override - public void getIngredients(IIngredients ingredients) { - List inputs = new ArrayList<>(); - for (ItemStack s : this.theRecipe.getInput().getMatchingStacks()) - inputs.add(s); - for (ItemStack s : this.theRecipe.getStandOne().getMatchingStacks()) - inputs.add(s); - for (ItemStack s : this.theRecipe.getStandTwo().getMatchingStacks()) - inputs.add(s); - for (ItemStack s : this.theRecipe.getStandThree().getMatchingStacks()) - inputs.add(s); - for (ItemStack s : this.theRecipe.getStandFour().getMatchingStacks()) - inputs.add(s); - - ingredients.setInputs(VanillaTypes.ITEM, inputs); - ingredients.setOutput(VanillaTypes.ITEM, this.theRecipe.getOutput()); - } - - @Override - public int getButtonX() { - return 2; - } - - @Override - public int getButtonY() { - return 2; - } - - @Override - public IBookletPage getPage() { - return BookletUtils.findFirstPageForStack(new ItemStack(InitBlocks.blockEmpowerer)); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/reconstructor/ReconstructorRecipeCategory.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/reconstructor/ReconstructorRecipeCategory.java deleted file mode 100644 index 032bd3965..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/reconstructor/ReconstructorRecipeCategory.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file ("ReconstructorRecipeCategory.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.jei.reconstructor; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import mezz.jei.api.recipe.IRecipeCategory; -import net.minecraft.client.Minecraft; -import net.minecraft.item.ItemStack; - -public class ReconstructorRecipeCategory implements IRecipeCategory { - - public static final String NAME = "actuallyadditions.reconstructor"; - - private static final ItemStack RECONSTRUCTOR = new ItemStack(InitBlocks.blockAtomicReconstructor); - private final IDrawable background; - - public ReconstructorRecipeCategory(IGuiHelper helper) { - this.background = helper.createDrawable(AssetUtil.getGuiLocation("gui_nei_atomic_reconstructor"), 0, 0, 96, 60); - } - - @Override - public String getUid() { - return NAME; - } - - @Override - public String getTitle() { - return StringUtil.localize("container.nei." + NAME + ".name"); - } - - @Override - public String getModName() { - return ActuallyAdditions.NAME; - } - - @Override - public IDrawable getBackground() { - return this.background; - } - - @Override - public void drawExtras(Minecraft minecraft) { - AssetUtil.renderStackToGui(RECONSTRUCTOR, 34, 19, 1.0F); - } - - @Override - public void setRecipe(IRecipeLayout recipeLayout, ReconstructorRecipeWrapper wrapper, IIngredients ingredients) { - recipeLayout.getItemStacks().init(0, true, 4, 18); - recipeLayout.getItemStacks().set(0, ingredients.getInputs(VanillaTypes.ITEM).get(0).get(0)); - recipeLayout.getItemStacks().init(1, false, 66, 18); - recipeLayout.getItemStacks().set(1, ingredients.getOutputs(VanillaTypes.ITEM).get(0).get(0)); - } -} 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 deleted file mode 100644 index e3b807e78..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/reconstructor/ReconstructorRecipeWrapper.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file ("ReconstructorRecipeWrapper.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.jei.reconstructor; - -import java.util.Arrays; - -import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; -import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton; -import de.ellpeck.actuallyadditions.mod.recipe.EnchBookConversion; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import mezz.jei.api.recipe.IRecipeWrapperFactory; -import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.I18n; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; - -public class ReconstructorRecipeWrapper extends RecipeWrapperWithButton { - - public static final IRecipeWrapperFactory FACTORY = (recipe) -> { - if (recipe instanceof EnchBookConversion) return new EnchBookWrapper((EnchBookConversion) recipe); - return new ReconstructorRecipeWrapper(recipe); - }; - - public final LensConversionRecipe theRecipe; - - public ReconstructorRecipeWrapper(LensConversionRecipe recipe) { - this.theRecipe = recipe; - } - - @Override - public void getIngredients(IIngredients ingredients) { - ingredients.setInputs(VanillaTypes.ITEM, Arrays.asList(this.theRecipe.getInput().getMatchingStacks())); - ingredients.setOutput(VanillaTypes.ITEM, this.theRecipe.getOutput()); - } - - @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); - super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY); - } - - @Override - public int getButtonX() { - return 3; - } - - @Override - public int getButtonY() { - return 40; - } - - @Override - public IBookletPage getPage() { - return BookletUtils.findFirstPageForStack(new ItemStack(InitBlocks.blockAtomicReconstructor)); - } - - public static class EnchBookWrapper extends ReconstructorRecipeWrapper { - - private static final ItemStack BOOK = new ItemStack(Items.ENCHANTED_BOOK); - private static final ItemStack OUT = new ItemStack(Items.ENCHANTED_BOOK); - - static { - OUT.setStackDisplayName("Split Book"); - NBTTagCompound t = OUT.getTagCompound().getCompoundTag("display"); - NBTTagList l = new NBTTagList(); - l.appendTag(new NBTTagString("Book will be split based on enchantments!")); - t.setTag("Lore", l); - } - - public EnchBookWrapper(EnchBookConversion recipe) { - super(recipe); - } - - @Override - public void getIngredients(IIngredients ingredients) { - ingredients.setInput(VanillaTypes.ITEM, BOOK); - ingredients.setOutput(VanillaTypes.ITEM, OUT); - } - - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/material/InitArmorMaterials.java b/src/main/java/de/ellpeck/actuallyadditions/mod/material/InitArmorMaterials.java deleted file mode 100644 index 93457d79f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/material/InitArmorMaterials.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file ("InitArmorMaterials.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; - -public final class InitArmorMaterials { - - public static ArmorMaterial armorMaterialEmerald; - public static ArmorMaterial armorMaterialObsidian; - public static ArmorMaterial armorMaterialQuartz; - - public static ArmorMaterial armorMaterialCrystalRed; - public static ArmorMaterial armorMaterialCrystalBlue; - public static ArmorMaterial armorMaterialCrystalLightBlue; - public static ArmorMaterial armorMaterialCrystalBlack; - public static ArmorMaterial armorMaterialCrystalGreen; - public static ArmorMaterial armorMaterialCrystalWhite; - - public static ArmorMaterial armorMaterialGoggles; - - 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); - - 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); - } - - 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 deleted file mode 100644 index 366f19d87..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/material/InitToolMaterials.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file ("InitToolMaterials.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; - -public final class InitToolMaterials { - - public static ToolMaterial toolMaterialEmerald; - public static ToolMaterial toolMaterialObsidian; - public static ToolMaterial toolMaterialQuartz; - - public static ToolMaterial toolMaterialCrystalRed; - public static ToolMaterial toolMaterialCrystalBlue; - public static ToolMaterial toolMaterialCrystalLightBlue; - public static ToolMaterial toolMaterialCrystalBlack; - public static ToolMaterial toolMaterialCrystalGreen; - public static ToolMaterial toolMaterialCrystalWhite; - - public static void init() { - ActuallyAdditions.LOGGER.info("Initializing Tool Materials..."); - - toolMaterialEmerald = addToolMaterial("toolMaterialEmerald", 3, 2000, 9.0F, 5.0F, 15); - toolMaterialObsidian = addToolMaterial("toolMaterialObsidian", 3, 8000, 4.0F, 2.0F, 15); - toolMaterialQuartz = addToolMaterial("toolMaterialQuartz", 2, 280, 6.5F, 2.0F, 10); - - toolMaterialCrystalRed = addToolMaterial("toolMaterialCrystalRed", 2, 300, 7.0F, 2.25F, 12); - toolMaterialCrystalBlue = addToolMaterial("toolMaterialCrystalBlue", 2, 300, 7.0F, 2.25F, 12); - toolMaterialCrystalLightBlue = addToolMaterial("toolMaterialCrystalLightBlue", 3, 1600, 9.0F, 4.0F, 14); - toolMaterialCrystalBlack = addToolMaterial("toolMaterialCrystalBlack", 2, 280, 6.0F, 2.0F, 8); - toolMaterialCrystalGreen = addToolMaterial("toolMaterialCrystalGreen", 4, 2200, 9.5F, 5.5F, 18); - toolMaterialCrystalWhite = addToolMaterial("toolMaterialCrystalWhite", 2, 280, 6.25F, 2.5F, 15); - - } - - 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 deleted file mode 100644 index 322699528..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/BannerHelper.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file ("BannerHelper.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; - -public final class BannerHelper { - - public static void init() { - addCraftingPattern("drill", new ItemStack(InitItems.itemDrill, 1, 3)); - addCraftingPattern("leaf_blo", new ItemStack(InitItems.itemLeafBlower)); - addCraftingPattern("phan_con", new ItemStack(InitItems.itemPhantomConnector)); - addCraftingPattern("book", new ItemStack(InitItems.itemBooklet)); - } - - /** - * (Excerpted from Additional Banners by Darkhax with permission, thanks!) - *

- * Adds a new banner pattern to the game. This banner pattern will be applied by using the - * provided item in a crafting recipe with the banner. - * - * @param name The name of the banner pattern. This is used for the texture file, and is - * also converted into upper case and used for the enum entry. Given how this - * system works, it's critical that this value is unique, consider adding the - * mod id to the name. - * //@param id A small string used to represent the pattern without taking up much space. An - * example of this is "bri". Given how the system works, it is critical that - * this is a unique value. please consider adding the mod id to the pattern id. - * @param craftingStack An ItemStack which is used in the crafting recipe for this pattern. - * An example of this would be the creeper skull being used for the creeper - * pattern. - */ - public static void addCraftingPattern(String name, ItemStack craftingStack) { - Class[] paramTypes = { String.class, String.class, ItemStack.class }; - Object[] paramValues = { ActuallyAdditions.MODID + "_" + name, ActuallyAdditions.MODID + "_" + name, craftingStack }; - EnumHelper.addEnum(BannerPattern.class, (ActuallyAdditions.MODID + "_" + name).toUpperCase(Locale.ROOT), paramTypes, paramValues); - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DamageSources.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DamageSources.java deleted file mode 100644 index 8253398da..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DamageSources.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file ("DamageSources.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.DamageSource; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentTranslation; - -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) { - 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); - 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 deleted file mode 100644 index b8c8524a8..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DispenserHandlerFertilize.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file ("DispenserHandlerFertilize.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc; - -import net.minecraft.block.BlockDispenser; -import net.minecraft.dispenser.BehaviorDefaultDispenseItem; -import net.minecraft.dispenser.IBlockSource; -import net.minecraft.item.ItemDye; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; - -public class DispenserHandlerFertilize extends BehaviorDefaultDispenseItem { - - @Override - 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)) { - source.getWorld().playEvent(2005, pos, 0); - } - - return stack; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DungeonLoot.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DungeonLoot.java deleted file mode 100644 index 92de05e09..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DungeonLoot.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * This file ("DungeonLoot.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -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.TheCrystals; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheJams; -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.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; -import net.minecraft.world.storage.loot.functions.SetDamage; -import net.minecraft.world.storage.loot.functions.SetMetadata; -import net.minecraftforge.event.LootTableLoadEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -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() { - 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) { - LootCondition[] noCondition = new LootCondition[0]; - - LootPool pool = event.getTable().getPool("main"); - if (pool == null) { - pool = new LootPool(new LootEntry[0], noCondition, new RandomValueRange(5, 10), new RandomValueRange(0), "main"); - event.getTable().addPool(pool); - } - - boolean addCrystals = false; - boolean addDrillCore = false; - boolean addQuartz = false; - boolean addBatWings = false; - - 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())) { - addCrystals = true; - addDrillCore = true; - } else if (LootTableList.CHESTS_VILLAGE_BLACKSMITH.equals(event.getName())) { - addDrillCore = true; - addQuartz = true; - } else if (LootTableList.CHESTS_STRONGHOLD_LIBRARY.equals(event.getName())) { - addBatWings = true; - } else if (LootTableList.CHESTS_IGLOO_CHEST.equals(event.getName())) { - addBatWings = true; - } else if (LootTableList.CHESTS_DESERT_PYRAMID.equals(event.getName())) { - addDrillCore = true; - addBatWings = true; - } 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())) { - addBatWings = true; - addCrystals = true; - addDrillCore = true; - addQuartz = true; - } else if (LootTableList.CHESTS_WOODLAND_MANSION.equals(event.getName())) { - addBatWings = true; - addCrystals = true; - addDrillCore = true; - addQuartz = true; - } - } - - 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")); - - 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())) { - addQuartz = true; - addBatWings = true; - addCrystals = true; - - 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")); - - 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)); - } - - 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)); - } - } else if (ENGINEER_HOUSE.equals(event.getName())) { - addQuartz = true; - addBatWings = true; - addCrystals = true; - addDrillCore = true; - - 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")); - - 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")); - } - - 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 }; - - 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) { - 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")); - } - - 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")); - } - - 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")); - } - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/SoundHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/SoundHandler.java deleted file mode 100644 index 3384ecc27..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/SoundHandler.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file ("SoundHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.RegistryHandler; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundEvent; - -public final class SoundHandler { - - public static SoundEvent duhDuhDuhDuuuh; - public static SoundEvent coffeeMachine; - public static SoundEvent reconstructor; - public static SoundEvent crusher; - - 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) { - ResourceLocation resLoc = new ResourceLocation(ActuallyAdditions.MODID, name); - - SoundEvent event = new SoundEvent(resLoc); - event.setRegistryName(resLoc); - RegistryHandler.SOUNDS_TO_REGISTER.add(event); - return event; - } -} 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 deleted file mode 100644 index fcf47ea26..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/ConnectionPair.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This file ("ConnectionPair.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc.apiimpl; - -import de.ellpeck.actuallyadditions.api.laser.IConnectionPair; -import de.ellpeck.actuallyadditions.api.laser.LaserType; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.BlockPos; - -public class ConnectionPair implements IConnectionPair { - - private final BlockPos[] positions = new BlockPos[2]; - private boolean suppressConnectionRender; - private LaserType type; - - public ConnectionPair() { - - } - - public ConnectionPair(BlockPos firstRelay, BlockPos secondRelay, LaserType type, boolean suppressConnectionRender) { - this.positions[0] = firstRelay; - this.positions[1] = secondRelay; - this.suppressConnectionRender = suppressConnectionRender; - this.type = type; - } - - @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); - this.positions[i] = new BlockPos(anX, aY, aZ); - } - this.suppressConnectionRender = compound.getBoolean("SuppressRender"); - - String typeStrg = compound.getString("Type"); - if (typeStrg != null && !typeStrg.isEmpty()) { - this.type = LaserType.valueOf(typeStrg); - } - } - } - - @Override - public BlockPos[] getPositions() { - return this.positions; - } - - @Override - public boolean doesSuppressRender() { - return this.suppressConnectionRender; - } - - @Override - 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; } - } - return false; - } - - @Override - 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++) { - BlockPos relay = this.positions[i]; - compound.setInteger("x" + i, relay.getX()); - compound.setInteger("y" + i, relay.getY()); - compound.setInteger("z" + i, relay.getZ()); - } - 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; } - } - } - 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 deleted file mode 100644 index bffff80e7..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/LaserRelayConnectionHandler.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * This file ("LaserRelayConnectionHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc.apiimpl; - -import de.ellpeck.actuallyadditions.api.laser.IConnectionPair; -import de.ellpeck.actuallyadditions.api.laser.ILaserRelayConnectionHandler; -import de.ellpeck.actuallyadditions.api.laser.LaserType; -import de.ellpeck.actuallyadditions.api.laser.Network; -import de.ellpeck.actuallyadditions.mod.data.WorldData; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay; -import io.netty.util.internal.ConcurrentSet; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public final class LaserRelayConnectionHandler implements ILaserRelayConnectionHandler { - - public static NBTTagCompound writeNetworkToNBT(Network network) { - NBTTagList list = new NBTTagList(); - for (IConnectionPair pair : network.connections) { - NBTTagCompound tag = new NBTTagCompound(); - pair.writeToNBT(tag); - list.appendTag(tag); - } - NBTTagCompound compound = new NBTTagCompound(); - compound.setTag("Network", list); - return compound; - } - - public static Network readNetworkFromNBT(NBTTagCompound tag) { - NBTTagList list = tag.getTagList("Network", 10); - Network network = new Network(); - for (int i = 0; i < list.tagCount(); i++) { - ConnectionPair pair = new ConnectionPair(); - pair.readFromNBT(list.getCompoundTagAt(i)); - network.connections.add(pair); - } - return network; - } - - /** - * 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) { - firstNetwork.connections.add(secondPair); - } - - WorldData data = WorldData.get(world); - secondNetwork.changeAmount++; - data.laserRelayNetworks.remove(secondNetwork); - data.markDirty(); - //System.out.println("Merged Two Networks!"); - } - - /** - * Gets all Connections for a Relay - */ - @Override - 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)) { - allPairs.add(pair); - } - } - } - return allPairs; - } - - /** - * Removes a Relay from its Network - */ - @Override - public void removeRelayFromNetwork(BlockPos relay, World world) { - Network network = this.getNetworkFor(relay, world); - 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)) { - this.addConnection(pair.getPositions()[0], pair.getPositions()[1], pair.getType(), world, pair.doesSuppressRender()); - } - } - //System.out.println("Removing a Relay from the Network!"); - } - } - - /** - * 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; } - } - } - return null; - } - - @Override - public boolean addConnection(BlockPos firstRelay, BlockPos secondRelay, LaserType type, World world) { - return this.addConnection(firstRelay, secondRelay, type, world, false); - } - - /** - * Adds a new connection between two relays - * (Puts it into the correct network!) - */ - @Override - 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; } - 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) { - 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) { - this.removeConnection(world, firstRelay, secondRelay); - return true; - } else { - return false; - } - } - //Both relays have laserRelayNetworks - 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) { - firstNetwork.connections.add(new ConnectionPair(firstRelay, secondRelay, type, suppressConnectionRender)); - firstNetwork.changeAmount++; - } - //Only second network exists - else { - secondNetwork.connections.add(new ConnectionPair(firstRelay, secondRelay, type, suppressConnectionRender)); - secondNetwork.changeAmount++; - } - //System.out.println("Connected "+firstRelay.toString()+" to "+secondRelay.toString()); - //System.out.println(firstNetwork == null ? secondNetwork.toString() : firstNetwork.toString()); - //System.out.println(laserRelayNetworks); - data.markDirty(); - return true; - } - - @Override - 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) { - 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)) { - this.addConnection(pair.getPositions()[0], pair.getPositions()[1], pair.getType(), world, pair.doesSuppressRender()); - } - } - } - } - } - - @Override - public LaserType getTypeFromLaser(TileEntity tile) { - if (tile instanceof TileEntityLaserRelay) { - return ((TileEntityLaserRelay) tile).type; - } else { - return null; - } - } - - @Override - public LaserType getTypeFromLaser(BlockPos pos, World world) { - return this.getTypeFromLaser(world.getTileEntity(pos)); - } - -} \ No newline at end of file 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 deleted file mode 100644 index 8bb3a2e1b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/MethodHandler.java +++ /dev/null @@ -1,370 +0,0 @@ -/* - * This file ("MethodHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc.apiimpl; - -import java.util.ArrayList; -import java.util.List; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; -import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; -import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; -import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; -import de.ellpeck.actuallyadditions.api.internal.IMethodHandler; -import de.ellpeck.actuallyadditions.api.lens.Lens; -import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; -import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; -import de.ellpeck.actuallyadditions.mod.blocks.BlockLaserRelay; -import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapter; -import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapterTrials; -import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrafting; -import de.ellpeck.actuallyadditions.mod.booklet.page.PageFurnace; -import de.ellpeck.actuallyadditions.mod.booklet.page.PagePicture; -import de.ellpeck.actuallyadditions.mod.booklet.page.PageTextOnly; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; -import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler; -import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3i; -import net.minecraft.world.WorldServer; -import net.minecraftforge.common.util.FakePlayerFactory; - -public class MethodHandler implements IMethodHandler { - - @Override - public boolean addEffectToStack(ItemStack stack, CoffeeIngredient ingredient) { - boolean worked = false; - if (ingredient != null) { - PotionEffect[] effects = ingredient.getEffects(); - 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) { - this.addEffectProperties(stack, effect, false, true); - worked = true; - } - } else { - this.addEffectToStack(stack, effect); - worked = true; - } - } - } - } - return worked; - } - - @Override - 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; } - } - } - return null; - } - - @Override - 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)); - } - this.addEffectToStack(stack, effects[i]); - } - } - - @Override - public void addEffectToStack(ItemStack stack, PotionEffect effect) { - NBTTagCompound tag = stack.getTagCompound(); - if (tag == null) { - tag = new NBTTagCompound(); - } - - int prevCounter = tag.getInteger("Counter"); - NBTTagCompound compound = new NBTTagCompound(); - compound.setInteger("ID", Potion.getIdFromPotion(effect.getPotion())); - compound.setInteger("Duration", effect.getDuration()); - compound.setInteger("Amplifier", effect.getAmplifier()); - - int counter = prevCounter + 1; - tag.setTag(counter + "", compound); - tag.setInteger("Counter", counter); - - stack.setTagCompound(tag); - } - - @Override - public PotionEffect[] getEffectsFromStack(ItemStack stack) { - ArrayList effects = new ArrayList<>(); - NBTTagCompound tag = stack.getTagCompound(); - if (tag != null) { - int counter = tag.getInteger("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--; - } - } - return effects.size() > 0 ? effects.toArray(new PotionEffect[effects.size()]) : null; - } - - @Override - 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) { - rangeY = range; - - if (facing == EnumFacing.NORTH || facing == EnumFacing.SOUTH) { - rangeX = range; - } else { - rangeZ = range; - } - } 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)) { - IBlockState state = tile.getWorldObject().getBlockState(pos); - 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()) { - ItemStack output = recipe.getOutput(); - if (StackUtil.isValid(output)) { - tile.getWorldObject().playEvent(2001, pos, Block.getStateId(state)); - recipe.transformHook(ItemStack.EMPTY, state, pos, tile); - 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()); - tile.getWorldObject().spawnEntity(item); - tile.getWorldObject().setBlockToAir(pos); - } - - tile.extractEnergy(recipe.getEnergyUsed()); - break; - } - } - } - } - } - } - - //Converting the Items - AxisAlignedBB aabb = new AxisAlignedBB(tile.getPosition().getX(), tile.getPosition().getY(), tile.getPosition().getZ(), hitBlock.getX() + 1, hitBlock.getY() + 1, hitBlock.getZ() + 1); - Vec3i dir = tile.getOrientation().getDirectionVec(); - aabb = aabb.grow(0.02, 0.02, 0.02).expand(dir.getX(), dir.getY(), dir.getZ()); - List items = tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, aabb); - for (EntityItem item : items) { - ItemStack stack = item.getItem(); - if (!item.isDead && StackUtil.isValid(stack) && !item.getEntityData().getBoolean("aa_cnv")) { - LensConversionRecipe recipe = LensRecipeHandler.findMatchingRecipe(stack, tile.getLens()); - if (recipe != null) { - int itemsPossible = Math.min(tile.getEnergy() / recipe.getEnergyUsed(), stack.getCount()); - - if (itemsPossible > 0) { - recipe.transformHook(item.getItem(), null, item.getPosition(), tile); - item.setDead(); - - if (stack.getCount() - itemsPossible > 0) { - ItemStack stackCopy = stack.copy(); - stackCopy.shrink(itemsPossible); - - EntityItem inputLeft = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, stackCopy); - tile.getWorldObject().spawnEntity(inputLeft); - } - - ItemStack outputCopy = recipe.getOutput().copy(); - outputCopy.setCount(itemsPossible); - - EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, outputCopy); - newItem.getEntityData().setBoolean("aa_cnv", true); - tile.getWorldObject().spawnEntity(newItem); - - tile.extractEnergy(recipe.getEnergyUsed() * itemsPossible); - break; - } - } - } - } - return !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock); - } - return false; - } - - @Override - 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)) { - tile.extractEnergy(TileEntityAtomicReconstructor.ENERGY_USE); - - int distance = currentLens.getDistance(); - 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) { - TileEntityAtomicReconstructor.shootLaser(tile.getWorldObject(), tile.getX(), tile.getY(), tile.getZ(), hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens); - break; - } - } - - return true; - } - } - return false; - } - - @Override - 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())) { - ItemStack outputOneCopy = outputOne.copy(); - outputOneCopy.setCount(outputOneAmounts); - - 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())) { - ItemStack outputTwoCopy = outputTwo.copy(); - outputTwoCopy.setCount(outputTwoAmounts); - - ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, outputTwoCopy, outputTwoChance); - hasWorkedOnce = true; - } - } - } - } - } - } - } - return hasWorkedOnce; - } - - @Override - 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())) { - ItemStack outputOneCopy = outputOne.copy(); - outputOneCopy.setCount(outputOneAmount); - - 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())) { - ItemStack outputTwoCopy = outputTwo.copy(); - outputTwoCopy.setCount(outputTwoAmount); - - ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, outputTwoCopy, outputTwoChance); - hasWorkedOnce = true; - } - } - } - } - return hasWorkedOnce; - } - - @Override - public IBookletPage generateTextPage(int id) { - return this.generateTextPage(id, 0); - } - - @Override - public IBookletPage generatePicturePage(int id, ResourceLocation resLoc, int textStartY) { - return this.generatePicturePage(id, resLoc, textStartY, 0); - } - - @Override - public IBookletPage generateCraftingPage(int id, IRecipe... recipes) { - return this.generateCraftingPage(id, 0, recipes); - } - - @Override - 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) { - return this.generateBookletChapter(identifier, entry, displayStack, 0, pages); - } - - @Override - public IBookletPage generateTextPage(int id, int priority) { - return new PageTextOnly(id, priority); - } - - @Override - 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) { - return new PageCrafting(id, priority, recipes); - } - - @Override - 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) { - return new BookletChapter(identifier, entry, displayStack, priority, pages); - } - - @Override - 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 deleted file mode 100644 index 17c5b92be..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/CactusFarmerBehavior.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * This file ("CactusFarmerBehavior.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer; - -import de.ellpeck.actuallyadditions.api.farmer.FarmerResult; -import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior; -import de.ellpeck.actuallyadditions.api.internal.IFarmer; -import net.minecraft.block.Block; -import net.minecraft.block.BlockCactus; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class CactusFarmerBehavior implements IFarmerBehavior { - - @Override - public FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer) { - int use = 250; - if (farmer.getEnergy() >= use) { - Item item = seed.getItem(); - if (item instanceof ItemBlock) { - Block block = Block.getBlockFromItem(item); - 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)); - - farmer.extractEnergy(use); - return FarmerResult.SUCCESS; - } - return FarmerResult.FAIL; - } - } - } - return FarmerResult.FAIL; - } - - @Override - public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer) { - int use = 250; - if (farmer.getEnergy() >= use) { - IBlockState state = world.getBlockState(pos); - if (state.getBlock() instanceof BlockCactus) { - FarmerResult result = FarmerResult.STOP_PROCESSING; - - 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) { - NonNullList drops = NonNullList.create(); - upState.getBlock().getDrops(drops, world, up, upState, 0); - - if (!drops.isEmpty()) { - if (farmer.canAddToOutput(drops)) { - world.playEvent(2001, up, Block.getStateId(upState)); - world.setBlockToAir(up); - - farmer.extractEnergy(use); - farmer.addToOutput(drops); - - result = FarmerResult.SUCCESS; - } - } - } - } - } - return result; - } - } - return FarmerResult.FAIL; - } - - @Override - public int getPriority() { - return 4; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/DefaultFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/DefaultFarmerBehavior.java deleted file mode 100644 index edad90037..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/DefaultFarmerBehavior.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * This file ("DefaultFarmerBehavior.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer; - -import java.util.ArrayList; -import java.util.List; - -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.util.StackUtil; -import net.minecraft.block.Block; -import net.minecraft.block.BlockCrops; -import net.minecraft.block.BlockDirt; -import net.minecraft.block.BlockGrass; -import net.minecraft.block.BlockStem; -import net.minecraft.block.IGrowable; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.init.SoundEvents; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.NonNullList; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.WorldServer; -import net.minecraftforge.common.IPlantable; -import net.minecraftforge.common.util.FakePlayerFactory; - -public class DefaultFarmerBehavior implements IFarmerBehavior { - - public static boolean defaultPlant(World world, BlockPos pos, IBlockState toPlant, IFarmer farmer, int use) { - if (toPlant != null) { - BlockPos farmland = pos.down(); - Block farmlandBlock = world.getBlockState(farmland).getBlock(); - if (farmlandBlock instanceof BlockDirt || farmlandBlock instanceof BlockGrass) { - world.setBlockToAir(pos); - useHoeAt(world, farmland); - world.playSound(null, farmland, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F); - farmer.extractEnergy(use); - } - - if (tryPlant(toPlant, world, pos)) { - farmer.extractEnergy(use); - return true; - } - } - return false; - } - - private static boolean tryPlant(IBlockState toPlant, World world, BlockPos pos) { - if (toPlant.getBlock().canPlaceBlockAt(world, pos)) { - world.setBlockState(pos, toPlant); - return true; - } - return false; - } - - @Override - public FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer) { - int use = 350; - if (farmer.getEnergy() >= use * 2) { - if (defaultPlant(world, pos, this.getPlantablePlantFromStack(seed, world, pos), farmer, use)) return FarmerResult.SUCCESS; - } - return FarmerResult.FAIL; - } - - @Override - public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer) { - int use = 250; - if (farmer.getEnergy() >= use) { - IBlockState state = world.getBlockState(pos); - Block block = state.getBlock(); - - if (block instanceof BlockCrops) { - if (((BlockCrops) block).isMaxAge(state)) { return this.doFarmerStuff(state, world, pos, farmer); } - } else if (BlockCrops.AGE.equals(block.getBlockState().getProperty("age"))) { - if (state.getValue(BlockCrops.AGE) >= 7 && !(block instanceof BlockStem)) return this.doFarmerStuff(state, world, pos, farmer); - } - } - return FarmerResult.FAIL; - } - - private FarmerResult doFarmerStuff(IBlockState state, World world, BlockPos pos, IFarmer farmer) { - List seeds = new ArrayList<>(); - List other = new ArrayList<>(); - NonNullList drops = NonNullList.create(); - state.getBlock().getDrops(drops, world, pos, state, 0); - for (ItemStack stack : drops) { - if (this.getPlantableFromStack(stack) != null) { - seeds.add(stack); - } else { - other.add(stack); - } - } - - boolean addSeeds = true; - if (!farmer.canAddToSeeds(seeds)) { - other.addAll(seeds); - addSeeds = false; - } - - if (farmer.canAddToOutput(other)) { - farmer.addToOutput(other); - - if (addSeeds) { - farmer.addToSeeds(seeds); - } - - world.playEvent(2001, pos, Block.getStateId(state)); - world.setBlockToAir(pos); - - farmer.extractEnergy(250); - return FarmerResult.SUCCESS; - } - return FarmerResult.FAIL; - } - - @Override - public int getPriority() { - return 0; - } - - private IBlockState getPlantablePlantFromStack(ItemStack stack, World world, BlockPos pos) { - if (StackUtil.isValid(stack)) { - IPlantable plantable = this.getPlantableFromStack(stack); - if (plantable != null) { - IBlockState state = plantable.getPlant(world, pos); - if (state != null && state.getBlock() instanceof IGrowable) return state; - } - } - return null; - } - - private IPlantable getPlantableFromStack(ItemStack stack) { - Item item = stack.getItem(); - if (item instanceof IPlantable) { - return (IPlantable) item; - } else if (item instanceof ItemBlock) { - Block block = Block.getBlockFromItem(item); - if (block instanceof IPlantable) return (IPlantable) block; - } - return null; - } - - private static ItemStack hoe = ItemStack.EMPTY; - - private static ItemStack getHoeStack() { - if (hoe.isEmpty()) hoe = new ItemStack(Items.DIAMOND_HOE); - return hoe; - } - - public static EnumActionResult useHoeAt(World world, BlockPos pos) { - - EntityPlayer player = FakePlayerFactory.getMinecraft((WorldServer) world); - - ItemStack itemstack = getHoeStack(); - - if (!player.canPlayerEdit(pos.offset(EnumFacing.UP), EnumFacing.UP, itemstack)) { - return EnumActionResult.FAIL; - } else { - int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(itemstack, player, world, pos); - if (hook != 0) return hook > 0 ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; - - IBlockState iblockstate = world.getBlockState(pos); - Block block = iblockstate.getBlock(); - - if (world.isAirBlock(pos.up())) { - if (block == Blocks.GRASS || block == Blocks.GRASS_PATH) { - world.setBlockState(pos, Blocks.FARMLAND.getDefaultState()); - return EnumActionResult.SUCCESS; - } - - if (block == Blocks.DIRT) { - switch (iblockstate.getValue(BlockDirt.VARIANT)) { - case DIRT: - world.setBlockState(pos, Blocks.FARMLAND.getDefaultState()); - return EnumActionResult.SUCCESS; - case COARSE_DIRT: - world.setBlockState(pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT)); - return EnumActionResult.SUCCESS; - default: - } - } - } - - return EnumActionResult.PASS; - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/MelonPumpkinFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/MelonPumpkinFarmerBehavior.java deleted file mode 100644 index 3c72ef7a9..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/MelonPumpkinFarmerBehavior.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This file ("MelonPumpkinFarmerBehavior.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer; - -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.util.StackUtil; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class MelonPumpkinFarmerBehavior implements IFarmerBehavior { - - @Override - public FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer) { - int use = 350; - if (farmer.getEnergy() >= use * 2) { - if (StackUtil.isValid(seed)) { - Item seedItem = seed.getItem(); - boolean isPumpkin = seedItem == Items.PUMPKIN_SEEDS; - if (isPumpkin || seedItem == Items.MELON_SEEDS) { - if (pos.getX() % 2 == 0 == (pos.getZ() % 2 == 0)) { - IBlockState toPlant = (isPumpkin ? Blocks.PUMPKIN_STEM : Blocks.MELON_STEM).getDefaultState(); - if (DefaultFarmerBehavior.defaultPlant(world, pos, toPlant, farmer, use)) return FarmerResult.SUCCESS; - } - return FarmerResult.STOP_PROCESSING; - } - return FarmerResult.FAIL; - } - } - return FarmerResult.FAIL; - } - - @Override - public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer) { - int use = 500; - if (farmer.getEnergy() >= use) { - IBlockState state = world.getBlockState(pos); - Block block = state.getBlock(); - if (block == Blocks.PUMPKIN || block == Blocks.MELON_BLOCK) { - NonNullList drops = NonNullList.create(); - block.getDrops(drops, world, pos, state, 0); - if (!drops.isEmpty()) { - if (farmer.canAddToOutput(drops)) { - world.playEvent(2001, pos, Block.getStateId(state)); - world.setBlockToAir(pos); - - farmer.extractEnergy(use); - farmer.addToOutput(drops); - - return FarmerResult.SUCCESS; - } - } - return FarmerResult.STOP_PROCESSING; - } - } - return FarmerResult.FAIL; - } - - @Override - public int getPriority() { - return 10; - } -} 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 deleted file mode 100644 index 23fe4e854..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/NetherWartFarmerBehavior.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file ("NetherWartFarmerBehavior.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer; - -import de.ellpeck.actuallyadditions.api.farmer.FarmerResult; -import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior; -import de.ellpeck.actuallyadditions.api.internal.IFarmer; -import net.minecraft.block.Block; -import net.minecraft.block.BlockNetherWart; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.common.IPlantable; - -public class NetherWartFarmerBehavior implements IFarmerBehavior { - - @Override - 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)) { - world.setBlockState(pos, Blocks.NETHER_WART.getDefaultState(), 2); - farmer.extractEnergy(use); - return FarmerResult.SUCCESS; - } - return FarmerResult.FAIL; - } - } - return FarmerResult.FAIL; - } - - @Override - public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer) { - int use = 500; - if (farmer.getEnergy() >= use) { - IBlockState state = world.getBlockState(pos); - 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()) { - boolean toInput = farmer.canAddToSeeds(drops); - if (toInput || farmer.canAddToOutput(drops)) { - world.playEvent(2001, pos, Block.getStateId(state)); - world.setBlockToAir(pos); - - if (toInput) { - farmer.addToSeeds(drops); - } else { - farmer.addToOutput(drops); - } - - farmer.extractEnergy(use); - return FarmerResult.SUCCESS; - } - } - } - return FarmerResult.FAIL; - } - } - return FarmerResult.FAIL; - } - - @Override - public int getPriority() { - return 3; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/ReedFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/ReedFarmerBehavior.java deleted file mode 100644 index af8ee9d7c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/ReedFarmerBehavior.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file ("ReedFarmerBehavior.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer; - -import de.ellpeck.actuallyadditions.api.farmer.FarmerResult; -import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior; -import de.ellpeck.actuallyadditions.api.internal.IFarmer; -import net.minecraft.block.Block; -import net.minecraft.block.BlockReed; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class ReedFarmerBehavior implements IFarmerBehavior { - - @Override - public FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer) { - int use = 250; - if (farmer.getEnergy() >= use) { - if (seed.getItem() == Items.REEDS) { - if (Blocks.REEDS.canPlaceBlockAt(world, pos)) { - world.setBlockState(pos, Blocks.REEDS.getDefaultState(), 2); - farmer.extractEnergy(use); - return FarmerResult.SUCCESS; - } - return FarmerResult.STOP_PROCESSING; - } - } - return FarmerResult.FAIL; - } - - @Override - public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer) { - int use = 250; - if (farmer.getEnergy() >= use) { - IBlockState state = world.getBlockState(pos); - if (state.getBlock() instanceof BlockReed) { - FarmerResult result = FarmerResult.STOP_PROCESSING; - - 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 BlockReed) { - NonNullList drops = NonNullList.create(); - upState.getBlock().getDrops(drops, world, pos, state, 0); - - if (!drops.isEmpty()) { - if (farmer.canAddToOutput(drops)) { - world.playEvent(2001, up, Block.getStateId(upState)); - world.setBlockToAir(up); - - farmer.extractEnergy(use); - farmer.addToOutput(drops); - - result = FarmerResult.STOP_PROCESSING; - } - } - } - } - } - - return result; - } - } - return FarmerResult.FAIL; - } - - @Override - public int getPriority() { - return 2; - } -} 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 deleted file mode 100644 index b8e1db5a6..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/EnderlillyFarmerBehavior.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file ("EnderlillyFarmerBehavior.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.exu; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockDirt; -import net.minecraft.block.BlockGrass; -import net.minecraft.init.Blocks; - -public class EnderlillyFarmerBehavior extends ExUPlantFarmerBehavior { - - @Override - protected String getPlantName() { - return "extrautils2:enderlilly"; - } - - @Override - protected boolean canPlaceOn(Block block) { - return block == Blocks.END_STONE || block instanceof BlockDirt || block instanceof BlockGrass; - } - - @Override - 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 deleted file mode 100644 index a956657b8..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/ExUPlantFarmerBehavior.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * This file ("ExUPlantFarmerBehavior.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.exu; - -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.util.StackUtil; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public abstract class ExUPlantFarmerBehavior implements IFarmerBehavior { - - @Override - public FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer) { - int use = 600; - 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) { - IBlockState stateThere = world.getBlockState(pos); - Block blockThere = stateThere.getBlock(); - - if (world.isAirBlock(pos) || blockThere.isReplaceable(world, pos)) { - BlockPos posBelow = pos.down(); - IBlockState stateBelow = world.getBlockState(posBelow); - - if (this.canPlaceOn(stateBelow.getBlock())) { - world.setBlockState(pos, block.getDefaultState(), 2); - farmer.extractEnergy(use); - - return FarmerResult.SUCCESS; - } - } - - return FarmerResult.STOP_PROCESSING; - } - } - } - } - } - return FarmerResult.FAIL; - } - - @Override - public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer) { - int use = 600; - 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()) { - 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)) { - ResourceLocation itemReg = stack.getItem().getRegistryName(); - if (itemReg != null && this.getPlantName().equals(itemReg.toString())) { - if (stack.getCount() <= 1) { - drops.remove(stack); - break; - } else { - stack.shrink(1); - } - } - } - } - - if (farmer.canAddToOutput(drops)) { - farmer.addToOutput(drops); - - world.playEvent(2001, pos, Block.getStateId(state)); - world.setBlockState(pos, block.getDefaultState(), 2); - - farmer.extractEnergy(use); - - return FarmerResult.SUCCESS; - } - } - - return FarmerResult.STOP_PROCESSING; - } - } - return FarmerResult.FAIL; - } - - @Override - public int getPriority() { - return 10; - } - - protected abstract String getPlantName(); - - protected abstract boolean canPlaceOn(Block block); - - protected abstract int getMaxStage(); -} 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 deleted file mode 100644 index 45556c491..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/RedOrchidFarmerBehavior.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file ("RedOrchidFarmerBehavior.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.exu; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockRedstoneOre; - -public class RedOrchidFarmerBehavior extends ExUPlantFarmerBehavior { - - @Override - protected String getPlantName() { - return "extrautils2:redorchid"; - } - - @Override - protected boolean canPlaceOn(Block block) { - return block instanceof BlockRedstoneOre; - } - - @Override - 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 deleted file mode 100644 index e8d8e1f0f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/cloud/ISmileyCloudEasterEgg.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This file ("ISmileyCloudEasterEgg.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc.cloud; - -public interface ISmileyCloudEasterEgg { - - /** - * Extra rendering function - */ - void renderExtra(float f); - - /** - * The name the cloud has to have for this effect to occur - */ - String[] getTriggerNames(); -} 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 deleted file mode 100644 index fb425f85c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/cloud/SmileyCloudEasterEggs.java +++ /dev/null @@ -1,523 +0,0 @@ -/* - * This file ("SmileyCloudEasterEggs.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - -public final class SmileyCloudEasterEggs { - - public static final List CLOUD_STUFF = new ArrayList<>(); - - static { - //Glenthor - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "glenthor", "glenthorlp", "twoofeight" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(true, new ItemStack(Items.DYE, 1, 2)); - renderHeadBlock(InitBlocks.blockHeatCollector, 0, 5F); - } - }); - //Ellpeck - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "ellpeck", "ellopecko", "peck" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(InitItems.itemPhantomConnector)); - renderHeadBlock(InitBlocks.blockPhantomLiquiface, 0, 25F); - } - }); - //Tyrex - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "tyrex", "lord_tobinho", "tobinho" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(Items.FISHING_ROD)); - renderHoldingItem(true, new ItemStack(Items.FISH)); - } - }); - //Hose - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "dqmhose", "xdqmhose", "hose" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(Items.REEDS)); - renderHeadBlock(Blocks.TORCH, 0, 15F); - } - }); - //Tobi - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "jemx", "jemxx", "jemxxx", "spielertobi200" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(true, new ItemStack(Items.MILK_BUCKET)); - renderHeadBlock(Blocks.REDSTONE_LAMP, 0, 35F); - } - }); - //Vazkii - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "vazkii", "vaski", "waskie" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(true, new ItemStack(Items.DYE, 1, 15)); - renderHeadBlock(Blocks.RED_FLOWER, 5, 20F); - } - }); - //Kitty - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "kitty", "kiddy", "kittyvancat", "kittyvancatlp" }; - } - - @Override - 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() { - @Override - public String[] getTriggerNames() { - return new String[] { "canitz", "canitzp", "kannnichts", "kannnichtsp" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(Items.WOODEN_SWORD)); - renderHeadBlock(Blocks.CHEST, 0, 70F); - } - }); - //Lari - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "lari", "larixine", "xine", "laxi", "lachsirine", "lala", "lalilu" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(Items.IRON_HELMET)); - renderHeadBlock(InitBlocks.blockBlackLotus, 0, 28F); - } - }); - //RotesDing - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "rotesding", "dotesring" }; - } - - @Override - 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() { - @Override - public String[] getTriggerNames() { - return new String[] { "bande", "bandelenth" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(Items.DIAMOND_PICKAXE)); - renderHeadBlock(Blocks.WOOL, 4, 18F); - } - }); - //Wolle - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "wolle", "wuitoi" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(Items.STRING)); - renderHeadBlock(Blocks.WOOL, 0, 18F); - } - }); - //Pakto - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "pakto", "paktosan", "paktosanlp" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(Items.DYE, 1, 9)); - renderHeadBlock(InitBlocks.blockColoredLampOn, 6, 18F); - } - }); - //Honka - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "honka", "honkalonka", "lonka", "lonki" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(InitItems.itemLeafBlowerAdvanced, 1, 9)); - renderHeadBlock(Blocks.HAY_BLOCK, 0, 74F); - } - }); - //Acid - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "acid", "acid_blues", "acidblues" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(InitItems.itemFoods, 1, TheFoods.PIZZA.ordinal())); - renderHeadBlock(Blocks.BOOKSHELF, 0, 27F); - } - }); - //Jasin - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "jasin", "jasindow" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(Items.WRITTEN_BOOK)); - renderHeadBlock(Blocks.WEB, 0, 56F); - } - }); - //ShadowNinjaCat - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "shadowninjacat", "ninja", "tl" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(Items.DIAMOND_SWORD)); - renderHeadBlock(Blocks.DIAMOND_BLOCK, 0, 26F); - } - }); - //NihonTiger - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "nihon", "nihontiger", "tiger" }; - } - - @Override - 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() { - @Override - public String[] getTriggerNames() { - return new String[] { "fraubaerchen", "baerchen", "nina" }; - } - - @Override - 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() { - @Override - public String[] getTriggerNames() { - return new String[] { "0xdd", "didi", "diddi", "theultimatehose" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(true, new ItemStack(InitItems.itemDrill)); - renderHeadBlock(Blocks.REDSTONE_BLOCK, 0, 30F); - } - }); - //MineLoad - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "mineload", "miney", "loady", "mineyloady" }; - } - - @Override - 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() { - @Override - public String[] getTriggerNames() { - return new String[] { "kilobyte", "kilo", "byte" }; - } - - @Override - 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() { - @Override - public String[] getTriggerNames() { - return new String[] { "jackie", "xdjackiexd", "xdjackie", "jackiexd" }; - } - - @Override - 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() { - @Override - public String[] getTriggerNames() { - return new String[] { "lampi", "littlelampi", "little lampi" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(Items.GLOWSTONE_DUST)); - renderHeadBlock(InitBlocks.blockColoredLampOn, 4, 40F); - } - }); - //AtomSponge - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "sponge", "atomsponge", "atom", "explosions", "explosion" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(Items.GUNPOWDER)); - renderHeadBlock(Blocks.SPONGE, 0, 20F); - } - }); - //Mattzimann - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "mattzimann", "mattziman", "matziman", "marzipan", "mattzi" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(InitItems.itemSwordEmerald)); - renderHeadBlock(InitBlocks.blockCoffeeMachine, 0, 35F); - } - }); - //Etho - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "etho", "ethoslab" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(Items.REDSTONE)); - renderHeadBlock(Blocks.REDSTONE_BLOCK, 0, 48F); - } - }); - //Direwolf20 - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "direwolf", "dire", "direwolf20", "dw20" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(Items.BONE)); - renderHeadBlock(Blocks.BONE_BLOCK, 0, 48F); - } - }); - //Jessassin - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "jessassin", "thejessassin" }; - } - - @Override - public void renderExtra(float f) { - renderHeadBlock(InitBlocks.blockLaserRelayItem, 0, 27F); - renderHoldingItem(false, new ItemStack(InitItems.itemLaserWrench)); - } - }); - //Biffa - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "biffa", "biffatech", "biffaplays", "biffa2001" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(InitItems.itemCoffee)); - } - }); - //Xisuma - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "xisuma", "xisumavoid" }; - } - - @Override - public void renderExtra(float f) { - renderHeadBlock(Blocks.REDSTONE_BLOCK, 0, 93F); - renderHoldingItem(false, new ItemStack(Items.ELYTRA)); - } - }); - //Welsknight - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "welsknight", "wels" }; - } - - @Override - public void renderExtra(float f) { - renderHeadBlock(Blocks.STONE_BRICK_STAIRS, 0, 10F); - renderHoldingItem(false, new ItemStack(Items.DIAMOND_PICKAXE)); - } - }); - //xbony2 - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "bony", "xbony", "xbony2" }; - } - - @Override - public void renderExtra(float f) { - renderHoldingItem(false, new ItemStack(InitItems.itemBooklet)); - renderHeadBlock(InitBlocks.blockSmileyCloud, 0, 13F); - } - }); - //MattaBase - register(new ISmileyCloudEasterEgg() { - @Override - public String[] getTriggerNames() { - return new String[] { "themattabase", "mattabase", "matt", "mad" }; - } - - @Override - 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() { - @Override - public String[] getTriggerNames() { - return new String[] { "cloudy", "cloudhunter" }; - } - - @Override - public void renderExtra(float f) { - renderHeadBlock(Blocks.REDSTONE_BLOCK, 0, 17F); - //other hand is for fapping - renderHoldingItem(true, new ItemStack(Items.BOW)); - } - }); - } - - private static void register(ISmileyCloudEasterEgg egg) { - CLOUD_STUFF.add(egg); - } - - private static void renderHoldingItem(boolean leftHand, ItemStack stack) { - GlStateManager.pushMatrix(); - GlStateManager.rotate(180F, 0F, 0F, 1F); - GlStateManager.rotate(90, 0, 1, 0); - GlStateManager.translate(-0.15, -1F, leftHand ? -0.525F : 0.525F); - GlStateManager.scale(0.75F, 0.75F, 0.75F); - - AssetUtil.renderItemInWorld(stack); - - GlStateManager.popMatrix(); - } - - private static void renderHeadBlock(Block block, int meta, float rotation) { - GlStateManager.pushMatrix(); - GlStateManager.disableLighting(); - GlStateManager.translate(-0.015F, 0.625F, 0.04F); - GlStateManager.scale(0.5F, 0.5F, 0.5F); - GlStateManager.rotate(180F, 1F, 0F, 0F); - GlStateManager.rotate(rotation, 0F, 1F, 0F); - - AssetUtil.renderBlockInWorld(block, meta); - - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); - } -} 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 deleted file mode 100644 index 1d6907db8..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/RenderSpecial.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file ("RenderSpecial.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc.special; - -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EnumPlayerModelParts; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.Vec3d; - -public class RenderSpecial { - - private final ItemStack theThingToRender; - - public RenderSpecial(ItemStack stack) { - this.theThingToRender = stack; - } - - 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); - - this.render(); - GlStateManager.popMatrix(); - } - - public void render() { - if (StackUtil.isValid(this.theThingToRender)) { - boolean isBlock = this.theThingToRender.getItem() instanceof ItemBlock; - - GlStateManager.pushMatrix(); - - if (isBlock) { - GlStateManager.translate(0D, -0.1875D, 0D); - } - GlStateManager.rotate(180F, 1.0F, 0.0F, 1.0F); - - float size = isBlock ? 0.5F : 0.4F; - GlStateManager.scale(size, size, size); - - //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); - - GlStateManager.disableLighting(); - GlStateManager.pushMatrix(); - - if (!isBlock) { - GlStateManager.translate(0D, 0.5D, 0D); - } - GlStateManager.rotate(180F, 1F, 0F, 0F); - AssetUtil.renderItemInWorld(this.theThingToRender); - GlStateManager.popMatrix(); - - GlStateManager.enableLighting(); - - GlStateManager.popMatrix(); - } - } - -} 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 deleted file mode 100644 index f7ca4b0be..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/SpecialRenderInit.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * This file ("SpecialRenderInit.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.event.RenderPlayerEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -public class SpecialRenderInit { - - public static final HashMap SPECIAL_LIST = new HashMap<>(); - - public SpecialRenderInit() { - new ThreadSpecialFetcher(); - MinecraftForge.EVENT_BUS.register(this); - } - - public static void parse(Properties properties) { - for (String key : properties.stringPropertyNames()) { - String[] values = properties.getProperty(key).split("@"); - if (values.length > 0) { - String itemName = values[0]; - - int meta; - try { - meta = Integer.parseInt(values[1]); - } catch (Exception e) { - meta = 0; - } - - ResourceLocation resLoc = new ResourceLocation(itemName); - 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)) { - String convertedItemName = ""; - for (char c : itemName.toCharArray()) { - if (Character.isUpperCase(c)) { - convertedItemName += "_"; - convertedItemName += Character.toLowerCase(c); - } else { - convertedItemName += c; - } - } - stack = findItem(new ResourceLocation(convertedItemName), meta); - } - - 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)) { - Item item = Item.REGISTRY.getObject(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); } - } - return StackUtil.getEmpty(); - } - - @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onPlayerRender(RenderPlayerEvent.Pre event) { - if (event.getEntityPlayer() != null) { - String name = event.getEntityPlayer().getName(); - if (name != null) { - String lower = name.toLowerCase(Locale.ROOT); - if (SPECIAL_LIST.containsKey(lower)) { - RenderSpecial render = SPECIAL_LIST.get(lower); - 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 deleted file mode 100644 index 7648727ed..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/ThreadSpecialFetcher.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file ("ThreadSpecialFetcher.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.misc.special; - -import java.io.InputStreamReader; -import java.net.URL; -import java.util.Properties; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; - -public class ThreadSpecialFetcher extends Thread { - - public ThreadSpecialFetcher() { - this.setName(ActuallyAdditions.NAME + " Special Fetcher"); - this.setDaemon(true); - this.start(); - } - - @Override - public void run() { - ActuallyAdditions.LOGGER.info("Fetching Special People Stuff..."); - 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) { - 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 deleted file mode 100644 index 78aaff5ee..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/IDataHandler.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * This file ("IDataHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.network; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; - -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 deleted file mode 100644 index 04253eec9..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketClientToServer.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file ("PacketClientToServer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.network; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import io.netty.buffer.ByteBuf; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraftforge.fml.common.FMLCommonHandler; -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 { - - private NBTTagCompound data; - private IDataHandler handler; - - public PacketClientToServer() { - - } - - public PacketClientToServer(NBTTagCompound data, IDataHandler handler) { - this.data = data; - this.handler = handler; - } - - @Override - public void fromBytes(ByteBuf buf) { - PacketBuffer buffer = new PacketBuffer(buf); - try { - this.data = buffer.readCompoundTag(); - - int handlerId = buffer.readInt(); - if (handlerId >= 0 && handlerId < PacketHandler.DATA_HANDLERS.size()) { - this.handler = PacketHandler.DATA_HANDLERS.get(handlerId); - } - } catch (Exception e) { - ActuallyAdditions.LOGGER.error("Something went wrong trying to receive a server packet!", e); - } - } - - @Override - 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 { - - @Override - public IMessage onMessage(final PacketClientToServer message, final MessageContext ctx) { - FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(() -> { - if (message.data != null && message.handler != null) { - message.handler.handleData(message.data, ctx); - } - }); - return null; - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java deleted file mode 100644 index 43afce109..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * This file ("PacketHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; -import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor; -import de.ellpeck.actuallyadditions.mod.network.gui.IStringReactor; -import de.ellpeck.actuallyadditions.mod.particle.ParticleLaserItem; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.particle.Particle; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.common.DimensionManager; -import net.minecraftforge.fml.common.network.NetworkRegistry; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public final class PacketHandler { - - public static final List DATA_HANDLERS = new ArrayList<>(); - 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 static final IDataHandler TILE_ENTITY_HANDLER = new IDataHandler() { - @Override - @SideOnly(Side.CLIENT) - public void handleData(NBTTagCompound compound, MessageContext context) { - World world = Minecraft.getMinecraft().world; - 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); - } - } - } - }; - public static final IDataHandler LASER_PARTICLE_HANDLER = new IDataHandler() { - @Override - @SideOnly(Side.CLIENT) - 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 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); - } - }; - public static final IDataHandler GUI_BUTTON_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 IButtonReactor) { - IButtonReactor reactor = (IButtonReactor) tile; - Entity entity = world.getEntityByID(compound.getInteger("PlayerID")); - 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); - } - } - }; - public static final IDataHandler GUI_NUMBER_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 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"))); - } - }; - public static final IDataHandler SYNC_PLAYER_DATA = new IDataHandler() { - @Override - @SideOnly(Side.CLIENT) - public void handleData(NBTTagCompound compound, MessageContext context) { - NBTTagCompound dataTag = compound.getCompoundTag("Data"); - EntityPlayer player = ActuallyAdditions.PROXY.getCurrentPlayer(); - - 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() + "."); - } - } else { - ActuallyAdditions.LOGGER.error("Tried to receive Player Data for the current player, but he doesn't seem to be present!"); - } - } - }; - 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) { - PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player); - - int type = compound.getInteger("Type"); - if (type == 0) { - data.loadBookmarks(compound.getTagList("Bookmarks", 8)); - } else if (type == 1) { - data.didBookTutorial = compound.getBoolean("DidBookTutorial"); - } else if (type == 2) { - data.loadTrials(compound.getTagList("Trials", 8)); - - 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() + "."); - } - } 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() { - 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); - - DATA_HANDLERS.add(LASER_HANDLER); - DATA_HANDLERS.add(TILE_ENTITY_HANDLER); - DATA_HANDLERS.add(GUI_BUTTON_TO_TILE_HANDLER); - DATA_HANDLERS.add(GUI_STRING_TO_TILE_HANDLER); - DATA_HANDLERS.add(GUI_NUMBER_TO_TILE_HANDLER); - DATA_HANDLERS.add(SYNC_PLAYER_DATA); - DATA_HANDLERS.add(GUI_BUTTON_TO_CONTAINER_HANDLER); - DATA_HANDLERS.add(LASER_PARTICLE_HANDLER); - DATA_HANDLERS.add(PLAYER_DATA_TO_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 deleted file mode 100644 index 294b5a8c4..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This file ("PacketHandlerHelper.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.network; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; -import de.ellpeck.actuallyadditions.mod.booklet.chapter.BookletChapterTrials; -import de.ellpeck.actuallyadditions.mod.data.PlayerData; -import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public final class PacketHandlerHelper { - - @SideOnly(Side.CLIENT) - public static void sendButtonPacket(TileEntity tile, int buttonId) { - NBTTagCompound compound = new NBTTagCompound(); - BlockPos pos = tile.getPos(); - compound.setInteger("X", pos.getX()); - compound.setInteger("Y", pos.getY()); - compound.setInteger("Z", pos.getZ()); - compound.setInteger("WorldID", tile.getWorld().provider.getDimension()); - compound.setInteger("PlayerID", Minecraft.getMinecraft().player.getEntityId()); - compound.setInteger("ButtonID", buttonId); - PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER)); - } - - public static void syncPlayerData(EntityPlayer player, boolean log) { - NBTTagCompound compound = new NBTTagCompound(); - compound.setBoolean("Log", log); - - NBTTagCompound data = new NBTTagCompound(); - 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); - } - } - - @SideOnly(Side.CLIENT) - 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) { - compound.setInteger("World", player.world.provider.getDimension()); - compound.setUniqueId("UUID", player.getUniqueID()); - - PlayerSave data = PlayerData.getDataFromPlayer(player); - - if (type == 0) { - compound.setTag("Bookmarks", data.saveBookmarks()); - } else if (type == 1) { - compound.setBoolean("DidBookTutorial", data.didBookTutorial); - } else if (type == 2) { - compound.setTag("Trials", data.saveTrials()); - - int total = 0; - for (IBookletChapter chapter : ActuallyAdditionsAPI.entryTrials.getAllChapters()) { - if (chapter instanceof BookletChapterTrials) { - total++; - } - } - - if (data.completedTrials.size() >= total) { - compound.setBoolean("Achievement", true); - } - } - - PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.PLAYER_DATA_TO_SERVER)); - } - } - - @SideOnly(Side.CLIENT) - 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()); - compound.setInteger("Z", tile.getPos().getZ()); - compound.setInteger("WorldID", tile.getWorld().provider.getDimension()); - compound.setInteger("PlayerID", Minecraft.getMinecraft().player.getEntityId()); - compound.setInteger("NumberID", id); - compound.setDouble("Number", number); - PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_NUMBER_TO_TILE_HANDLER)); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketServerToClient.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketServerToClient.java deleted file mode 100644 index 53896b25f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketServerToClient.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file ("PacketServerToClient.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.network; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import io.netty.buffer.ByteBuf; -import net.minecraft.client.Minecraft; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraftforge.fml.common.network.simpleimpl.IMessage; -import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; -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 { - - private NBTTagCompound data; - private IDataHandler handler; - - public PacketServerToClient() { - - } - - public PacketServerToClient(NBTTagCompound data, IDataHandler handler) { - this.data = data; - this.handler = handler; - } - - @Override - public void fromBytes(ByteBuf buf) { - PacketBuffer buffer = new PacketBuffer(buf); - try { - this.data = buffer.readCompoundTag(); - - int handlerId = buffer.readInt(); - if (handlerId >= 0 && handlerId < PacketHandler.DATA_HANDLERS.size()) { - this.handler = PacketHandler.DATA_HANDLERS.get(handlerId); - } - } catch (Exception e) { - ActuallyAdditions.LOGGER.error("Something went wrong trying to receive a client packet!", e); - } - } - - @Override - 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 { - - @Override - @SideOnly(Side.CLIENT) - public IMessage onMessage(final PacketServerToClient message, final MessageContext ctx) { - Minecraft.getMinecraft().addScheduledTask(() -> { - if (message.data != null && message.handler != null) { - message.handler.handleData(message.data, ctx); - } - }); - return null; - } - } -} 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 deleted file mode 100644 index 594504b6f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/gui/IButtonReactor.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This file ("IButtonReactor.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.network.gui; - -import net.minecraft.entity.player.EntityPlayer; - -public interface IButtonReactor { - - /** - * Called when a Button in a GUI is pressed - * Gets called on the Server, sent from the Client - * - * @param buttonID The button's ID - * @param player The Player pressing it - */ - void onButtonPressed(int buttonID, EntityPlayer player); -} 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 deleted file mode 100644 index 78f05a36d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/gui/INumberReactor.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This file ("INumberReactor.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.network.gui; - -import net.minecraft.entity.player.EntityPlayer; - -public interface INumberReactor { - - /** - * Called when a Number gets received after typing it in in the GUI - * - * @param number The number that was sent - * @param id The ID (meaning the place in the GUI) of the number typed in - * @param player The Player doing it - */ - void onNumberReceived(double number, int id, EntityPlayer player); -} 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 deleted file mode 100644 index a86347a9e..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/gui/IStringReactor.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This file ("IStringReactor.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.network.gui; - -import net.minecraft.entity.player.EntityPlayer; - -public interface IStringReactor { - - /** - * Called when a text gets received after typing it in in the GUI - * - * @param text The text that was sent - * @param textID The ID (meaning the place in the GUI) of the text typed in - * @param player The Player doing it - */ - void onTextReceived(String text, int textID, EntityPlayer player); -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ore/InitOreDict.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ore/InitOreDict.java deleted file mode 100644 index 70a85a075..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/ore/InitOreDict.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This file ("InitOreDict.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.ore; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -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 net.minecraft.block.Block; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; - -public final class InitOreDict { - - public static void init() { - ActuallyAdditions.LOGGER.info("Initializing OreDictionary Entries..."); - - //Vanilla Ores - addOre(Items.COAL, "coal"); - - //Ores for Pulverizers etc. - addOre(InitItems.itemDust, TheDusts.IRON.ordinal(), "dustIron"); - addOre(InitItems.itemDust, TheDusts.GOLD.ordinal(), "dustGold"); - addOre(InitItems.itemDust, TheDusts.DIAMOND.ordinal(), "dustDiamond"); - addOre(InitItems.itemDust, TheDusts.EMERALD.ordinal(), "dustEmerald"); - addOre(InitItems.itemDust, TheDusts.LAPIS.ordinal(), "dustLapis"); - addOre(InitItems.itemDust, TheDusts.QUARTZ.ordinal(), "dustQuartz"); - addOre(InitItems.itemDust, TheDusts.QUARTZ.ordinal(), "dustNetherQuartz"); - addOre(InitItems.itemDust, TheDusts.COAL.ordinal(), "dustCoal"); - addOre(InitItems.itemDust, TheDusts.QUARTZ_BLACK.ordinal(), "dustQuartzBlack"); - addOre(InitBlocks.blockMisc, TheMiscBlocks.ORE_QUARTZ.ordinal(), "oreQuartzBlack"); - addOre(InitItems.itemMisc, TheMiscItems.QUARTZ.ordinal(), "gemQuartzBlack"); - - //For Thermal Expansion Machine that "grows crops" - addOre(InitItems.itemCanolaSeed, "seedCanola"); - addOre(InitItems.itemMisc, TheMiscItems.CANOLA.ordinal(), "cropCanola"); - addOre(InitItems.itemRiceSeed, "seedRice"); - addOre(InitItems.itemFoods, TheFoods.RICE.ordinal(), "cropRice"); - addOre(InitItems.itemFlaxSeed, "seedFlax"); - addOre(Items.STRING, "cropFlax"); - addOre(InitItems.itemCoffeeSeed, "seedCoffee"); - addOre(InitItems.itemCoffeeBean, "cropCoffee"); - - //For Crafting - addOre(InitItems.itemMisc, TheMiscItems.RICE_SLIME.ordinal(), "slimeball"); - addOre(InitBlocks.blockMisc, TheMiscBlocks.CHARCOAL_BLOCK.ordinal(), "blockCharcoal"); - addOre(InitBlocks.blockMisc, TheMiscBlocks.QUARTZ.ordinal(), "blockQuartzBlack"); - addOre(InitItems.itemMisc, TheMiscItems.BLACK_DYE.ordinal(), "dyeBlack"); - addOre(InitItems.itemMisc, TheMiscItems.BLACK_DYE.ordinal(), "dye"); - } - - 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) { - addOre(item, 0, 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) { - 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 deleted file mode 100644 index 450d850a9..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/particle/ParticleBeam.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file ("ParticleBeam.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.particle; - -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import net.minecraft.client.particle.Particle; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.entity.Entity; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class ParticleBeam extends Particle { - - private final double endX; - private final double endY; - private final double endZ; - private final float[] color; - private final double rotationTime; - 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) { - super(world, startX, startY, startZ); - this.endX = endX; - this.endY = endY; - this.endZ = endZ; - this.color = color; - this.rotationTime = rotationTime; - this.size = size; - this.particleMaxAge = maxAge; - this.alpha = alpha; - } - - @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); - } - - @Override - 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 deleted file mode 100644 index f6e9cde1b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/particle/ParticleLaserItem.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This file ("ParticleLaserItem.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.entity.Entity; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class ParticleLaserItem extends Particle { - - private final double otherX; - private final double otherY; - private final double otherZ; - - private final ItemStack stack; - - 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); - this.stack = stack; - this.otherX = otherX; - this.otherY = otherY; - this.otherZ = otherZ; - - this.motionX = 0; - this.motionY = motionY; - this.motionZ = 0; - - this.particleMaxAge = 10; - this.canCollide = false; - } - - @Override - public void setExpired() { - super.setExpired(); - - 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) { - GlStateManager.pushMatrix(); - RenderHelper.enableStandardItemLighting(); - - 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); - - 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; - GL14.glBlendColor(color, color, color, color); - - AssetUtil.renderItemWithoutScrewingWithColors(this.stack); - - RenderHelper.disableStandardItemLighting(); - GlStateManager.popMatrix(); - } - - @Override - 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 deleted file mode 100644 index 10414c6a4..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * This file ("ClientProxy.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.proxy; - -import java.util.ArrayList; -import java.util.List; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.ClientRegistryHandler; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.blocks.render.RenderBatteryBox; -import de.ellpeck.actuallyadditions.mod.blocks.render.RenderDisplayStand; -import de.ellpeck.actuallyadditions.mod.blocks.render.RenderEmpowerer; -import de.ellpeck.actuallyadditions.mod.blocks.render.RenderLaserRelay; -import de.ellpeck.actuallyadditions.mod.blocks.render.RenderReconstructorLens; -import de.ellpeck.actuallyadditions.mod.blocks.render.RenderSmileyCloud; -import de.ellpeck.actuallyadditions.mod.entity.InitEntities; -import de.ellpeck.actuallyadditions.mod.entity.RenderWorm; -import de.ellpeck.actuallyadditions.mod.event.ClientEvents; -import de.ellpeck.actuallyadditions.mod.misc.special.SpecialRenderInit; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBatteryBox; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityDisplayStand; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityEmpowerer; -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.tile.TileEntitySmileyCloud; -import de.ellpeck.actuallyadditions.mod.util.IColorProvidingBlock; -import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.network.NetHandlerPlayClient; -import net.minecraft.client.renderer.block.model.ModelResourceLocation; -import net.minecraft.client.renderer.color.IBlockColor; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.network.play.client.CPacketPlayerDigging; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.client.registry.ClientRegistry; -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 { - - 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) { - ActuallyAdditions.LOGGER.info("PreInitializing ClientProxy..."); - - MinecraftForge.EVENT_BUS.register(new ClientRegistryHandler()); - - InitEntities.initClient(); - } - - @Override - public void init(FMLInitializationEvent event) { - ActuallyAdditions.LOGGER.info("Initializing ClientProxy..."); - - RenderWorm.fixItemStack(); - - new ClientEvents(); - - //ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCompost.class, new RenderCompost()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAtomicReconstructor.class, new RenderReconstructorLens()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySmileyCloud.class, new RenderSmileyCloud()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDisplayStand.class, new RenderDisplayStand()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEmpowerer.class, new RenderEmpowerer()); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBatteryBox.class, new RenderBatteryBox()); - - TileEntitySpecialRenderer laser = new RenderLaserRelay(); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLaserRelayEnergy.class, laser); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLaserRelayEnergyAdvanced.class, laser); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLaserRelayEnergyExtreme.class, laser); - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLaserRelayItem.class, laser); - 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 (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); - } - } - - IBlockColor color = (state, world, pos, tint) -> { - if (world != null && pos != null) { - TileEntity tileentity = world.getTileEntity(pos); - if (tileentity instanceof TileEntityCompost && ((TileEntityCompost) tileentity).getCurrentDisplay().getBlock() != state.getBlock()) { - IBlockState iblockstate = ((TileEntityCompost) tileentity).getCurrentDisplay(); - return Minecraft.getMinecraft().getBlockColors().colorMultiplier(iblockstate, world, pos, tint); - } - } - return -1; - }; - Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(color, InitBlocks.blockCompost); - } - - @Override - public void postInit(FMLPostInitializationEvent event) { - ActuallyAdditions.LOGGER.info("PostInitializing ClientProxy..."); - - new SpecialRenderInit(); - } - - @Override - 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) { - COLOR_PRODIVIDING_ITEMS_FOR_REGISTERING.add(item); - } - - @Override - public void addColoredBlock(Block block) { - COLOR_PRODIVIDING_BLOCKS_FOR_REGISTERING.add(block); - } - - @Override - public EntityPlayer getCurrentPlayer() { - return Minecraft.getMinecraft().player; - } - - @Override - 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)); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/IProxy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/IProxy.java deleted file mode 100644 index be9f5f760..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/IProxy.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file ("IProxy.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.proxy; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public interface IProxy { - - void preInit(FMLPreInitializationEvent event); - - void init(FMLInitializationEvent event); - - void postInit(FMLPostInitializationEvent event); - - void addRenderRegister(ItemStack stack, ResourceLocation location, String variant); - - void addColoredItem(Item item); - - void addColoredBlock(Block block); - - EntityPlayer getCurrentPlayer(); - - 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 deleted file mode 100644 index ff61b6efa..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ServerProxy.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file ("ServerProxy.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.proxy; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -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 { - - @Override - public void preInit(FMLPreInitializationEvent event) { - ActuallyAdditions.LOGGER.info("PreInitializing ServerProxy..."); - } - - @Override - public void init(FMLInitializationEvent event) { - ActuallyAdditions.LOGGER.info("Initializing ServerProxy..."); - } - - @Override - public void postInit(FMLPostInitializationEvent event) { - ActuallyAdditions.LOGGER.info("PostInitializing ServerProxy..."); - } - - @Override - public void addRenderRegister(ItemStack stack, ResourceLocation location, String variant) { - - } - - @Override - public void addColoredItem(Item item) { - - } - - @Override - public void addColoredBlock(Block block) { - - } - - @Override - public EntityPlayer getCurrentPlayer() { - return null; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/ColorLensRotator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/ColorLensRotator.java deleted file mode 100644 index 11392da16..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/ColorLensRotator.java +++ /dev/null @@ -1,53 +0,0 @@ -package de.ellpeck.actuallyadditions.mod.recipe; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; -import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.oredict.OreDictionary; - -public class ColorLensRotator implements IColorLensChanger { - - public static final Map STRING_TO_ENUM = new HashMap<>(); - static { - String[] dyes = { "White", "Orange", "Magenta", "LightBlue", "Yellow", "Lime", "Pink", "Gray", "LightGray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black" }; - for (int i = 0; i < dyes.length; i++) - STRING_TO_ENUM.put("dye" + dyes[i], EnumDyeColor.byMetadata(i)); - } - - final List rotations; - - public ColorLensRotator(List rotations) { - this.rotations = rotations; - } - - @Override - public ItemStack modifyItem(ItemStack stack, IBlockState hitBlockState, BlockPos hitBlock, IAtomicReconstructor tile) { - - int idx = -1; - - for (int i : OreDictionary.getOreIDs(stack)) { - String s = OreDictionary.getOreName(i); - if (s.startsWith("dye")) { - EnumDyeColor color = STRING_TO_ENUM.get(s); - if (color != null) { - idx = color.getMetadata(); - break; - } - } - } - - if (idx == -1) return ItemStack.EMPTY; - - ItemStack s = this.rotations.get((idx + 1) % this.rotations.size()).copy(); - s.setCount(stack.getCount()); - return s; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/CrusherRecipeRegistry.java b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/CrusherRecipeRegistry.java deleted file mode 100644 index b48bffdfb..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/CrusherRecipeRegistry.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * This file ("CrusherRecipeRegistry.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.recipe; - -import java.util.ArrayList; -import java.util.List; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; -import net.minecraftforge.oredict.OreIngredient; - -public final class CrusherRecipeRegistry { - - public static final ArrayList SEARCH_CASES = new ArrayList<>(); - - 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()); - 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)) { - oresNoResult.add(ore); - } - } else ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient(ore), output, StackUtil.getEmpty(), 0); - } - } - } - } - } - - ArrayList addedRecipes = new ArrayList<>(); - for (int i = recipeStartedAt; i < ActuallyAdditionsAPI.CRUSHER_RECIPES.size(); i++) { - CrusherRecipe recipe = ActuallyAdditionsAPI.CRUSHER_RECIPES.get(i); - 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); - removeDuplicateRecipes(); - } - - public static void removeDuplicateRecipes() { - ArrayList usable = new ArrayList<>(); - ArrayList removed = new ArrayList<>(); - 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 (canUse) usable.add(r); - else removed.add(r); - } - - ActuallyAdditionsAPI.CRUSHER_RECIPES.clear(); - ActuallyAdditionsAPI.CRUSHER_RECIPES.addAll(usable); - 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)) { - Item item = output.getItem(); - if (item != null) { - String reg = item.getRegistryName().toString(); - - for (String conf : config) { - String confReg = conf; - int meta = 0; - - 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!"); - } - } - - if (reg.equals(confReg) && output.getItemDamage() == meta) { return true; } - } - - return false; - } - } - 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; - return null; - } - - public static class SearchCase { - - final String theCase; - final int resultAmount; - final String resultPreString; - - public SearchCase(String theCase, int resultAmount) { - this(theCase, resultAmount, "dust"); - } - - 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/EmpowererHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/EmpowererHandler.java deleted file mode 100644 index b8d8c667f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/EmpowererHandler.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file ("EmpowererHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.recipe; - -import java.util.ArrayList; -import java.util.List; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.util.RecipeUtil; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraftforge.oredict.OreDictionary; -import net.minecraftforge.oredict.OreIngredient; - -public final class EmpowererHandler { - - public static final ArrayList MAIN_PAGE_RECIPES = new ArrayList<>(); - public static EmpowererRecipe recipeEmpoweredCanolaSeed; - - public static void init() { - addCrystalEmpowering(TheCrystals.REDSTONE, "dyeRed", Ingredient.fromItems(Items.NETHERBRICK), Ingredient.fromItems(Items.REDSTONE), Ingredient.fromItems(Items.BRICK)); - addCrystalEmpowering(TheCrystals.LAPIS, "dyeCyan", Ingredient.fromItems(Items.PRISMARINE_SHARD), Ingredient.fromItems(Items.PRISMARINE_SHARD), Ingredient.fromItems(Items.PRISMARINE_SHARD)); - addCrystalEmpowering(TheCrystals.DIAMOND, "dyeLightBlue", Ingredient.fromItems(Items.CLAY_BALL), Ingredient.fromItems(Items.CLAY_BALL), fromBlock(Blocks.CLAY)); - addCrystalEmpowering(TheCrystals.IRON, "dyeGray", Ingredient.fromItems(Items.SNOWBALL), fromBlock(Blocks.STONE_BUTTON), fromBlock(Blocks.COBBLESTONE)); - - addCrystalEmpowering(TheCrystals.COAL, "dyeBlack", igd(new ItemStack(Items.COAL, 1, 1)), Ingredient.fromItems(Items.FLINT), fromBlock(Blocks.STONE)); - - List balls = OreDictionary.getOres("slimeball"); - for (ItemStack ball : balls) { - addCrystalEmpowering(TheCrystals.EMERALD, "dyeLime", igd(new ItemStack(Blocks.TALLGRASS, 1, 1)), igd(new ItemStack(Blocks.SAPLING)), igd(ball.copy())); - } - - Ingredient seed = Ingredient.fromItems(InitItems.itemCanolaSeed); - ActuallyAdditionsAPI.addEmpowererRecipe(Ingredient.fromStacks(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CRYSTALLIZED_CANOLA_SEED.ordinal())), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.EMPOWERED_CANOLA_SEED.ordinal()), seed, seed, seed, seed, 1000, 30, new float[] { 1F, 91F / 255F, 76F / 255F }); - recipeEmpoweredCanolaSeed = RecipeUtil.lastEmpowererRecipe(); - } - - private static void addCrystalEmpowering(TheCrystals type, String dye, Ingredient modifier1, Ingredient modifier2, Ingredient modifier3) { - float[] color = type.conversionColorParticles; - - ActuallyAdditionsAPI.addEmpowererRecipe(Ingredient.fromStacks(new ItemStack(InitItems.itemCrystal, 1, type.ordinal())), new ItemStack(InitItems.itemCrystalEmpowered, 1, type.ordinal()), new OreIngredient(dye), modifier1, modifier2, modifier3, 5000, 50, color); - MAIN_PAGE_RECIPES.add(RecipeUtil.lastEmpowererRecipe()); - ActuallyAdditionsAPI.addEmpowererRecipe(Ingredient.fromStacks(new ItemStack(InitBlocks.blockCrystal, 1, type.ordinal())), new ItemStack(InitBlocks.blockCrystalEmpowered, 1, type.ordinal()), new OreIngredient(dye), modifier1, modifier2, modifier3, 50000, 500, color); - MAIN_PAGE_RECIPES.add(RecipeUtil.lastEmpowererRecipe()); - } - - private static Ingredient igd(ItemStack s) { - return Ingredient.fromStacks(s); - } - - private static Ingredient fromBlock(Block b) { - return Ingredient.fromItems(Item.getItemFromBlock(b)); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/EnchBookConversion.java b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/EnchBookConversion.java deleted file mode 100644 index 7052a3fa5..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/EnchBookConversion.java +++ /dev/null @@ -1,35 +0,0 @@ -package de.ellpeck.actuallyadditions.mod.recipe; - -import java.util.Map; - -import com.google.common.collect.ImmutableMap; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; -import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.math.BlockPos; - -public class EnchBookConversion extends LensConversionRecipe { - - public EnchBookConversion() { - super(Ingredient.fromItem(Items.ENCHANTED_BOOK), ItemStack.EMPTY, 155000, ActuallyAdditionsAPI.lensDefaultConversion); - } - - @Override - public void transformHook(ItemStack stack, IBlockState state, BlockPos pos, IAtomicReconstructor tile) { - 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); - Block.spawnAsEntity(tile.getWorldObject(), pos, 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 deleted file mode 100644 index 5677d581c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/HairyBallHandler.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file ("HairyBallHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.recipe; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - -public final class HairyBallHandler { - - 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); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Items.FISH), 80); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Items.FISH, 1, 1), 60); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Items.FISH, 1, 2), 10); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Items.FISH, 1, 3), 40); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Items.FEATHER), 60); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Items.LEATHER), 30); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Items.DYE), 70); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Items.CLAY_BALL), 40); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Items.STICK), 40); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Items.IRON_INGOT), 10); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Items.GOLD_INGOT), 6); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Items.BEEF), 30); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Items.ENDER_PEARL), 2); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Blocks.PLANKS), 20); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Blocks.WATERLILY), 10); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Items.EXPERIENCE_BOTTLE), 3); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Blocks.GRAVEL), 40); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Blocks.SAND), 50); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Blocks.VINE), 30); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(Blocks.WEB), 4); - ActuallyAdditionsAPI.addBallOfFurReturnItem(new ItemStack(InitItems.itemSolidifiedExperience), 20); - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/TreasureChestHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/TreasureChestHandler.java deleted file mode 100644 index bed4671dd..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/TreasureChestHandler.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file ("TreasureChestHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.recipe; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheJams; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - -public final class TreasureChestHandler { - - 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); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.GOLD_INGOT), 35, 1, 3); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.ENDER_PEARL), 10, 1, 2); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.EMERALD), 3, 1, 1); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.EXPERIENCE_BOTTLE), 5, 3, 6); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemSolidifiedExperience), 15, 3, 6); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_11), 1, 1, 1); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_13), 1, 1, 1); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_BLOCKS), 1, 1, 1); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_CAT), 1, 1, 1); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_CHIRP), 1, 1, 1); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_FAR), 1, 1, 1); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_MALL), 1, 1, 1); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_MELLOHI), 1, 1, 1); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_STAL), 1, 1, 1); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_STRAD), 1, 1, 1); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_WARD), 1, 1, 1); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_WAIT), 1, 1, 1); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.SADDLE), 5, 1, 1); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.NAME_TAG), 20, 1, 2); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.CU_BA_RA.ordinal()), 10, 1, 2); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.GRA_KI_BA.ordinal()), 10, 1, 2); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.PL_AP_LE.ordinal()), 10, 1, 2); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.CH_AP_CI.ordinal()), 10, 1, 2); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.HO_ME_KI.ordinal()), 10, 1, 2); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.PI_CO.ordinal()), 10, 1, 2); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH), 80, 1, 3); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH, 1, 1), 60, 1, 3); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH, 1, 2), 10, 1, 1); - ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH, 1, 3), 40, 1, 2); - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CustomEnergyStorage.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CustomEnergyStorage.java deleted file mode 100644 index f564c0cc0..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CustomEnergyStorage.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file ("CustomEnergyStorage.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.energy.EnergyStorage; - -public class CustomEnergyStorage extends EnergyStorage { - - public CustomEnergyStorage(int capacity, int maxReceive, int maxExtract) { - super(capacity, maxReceive, maxExtract); - } - - public int extractEnergyInternal(int maxExtract, boolean simulate) { - int before = this.maxExtract; - this.maxExtract = Integer.MAX_VALUE; - - int toReturn = this.extractEnergy(maxExtract, simulate); - - this.maxExtract = before; - return toReturn; - } - - public int receiveEnergyInternal(int maxReceive, boolean simulate) { - int before = this.maxReceive; - this.maxReceive = Integer.MAX_VALUE; - - int toReturn = this.receiveEnergy(maxReceive, simulate); - - this.maxReceive = before; - return toReturn; - } - - 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; } - int energy = this.getEnergyStored(); - - 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; } - int energy = this.getEnergyStored(); - - int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); - if (!simulate) { - this.setEnergyStored(energy - energyExtracted); - } - return energyExtracted; - } - - public void readFromNBT(NBTTagCompound compound) { - this.setEnergyStored(compound.getInteger("Energy")); - } - - public void writeToNBT(NBTTagCompound compound) { - compound.setInteger("Energy", this.getEnergyStored()); - } - - public void setEnergyStored(int energy) { - this.energy = energy; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java deleted file mode 100644 index 937193ab3..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * This file ("FilterSettings.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import org.apache.commons.lang3.ArrayUtils; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerFilter; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter; -import de.ellpeck.actuallyadditions.mod.items.ItemDrill; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.oredict.OreDictionary; - -public class FilterSettings { - - public final int whitelistButtonId; - public final int metaButtonId; - public final int nbtButtonId; - public final int oredictButtonId; - public final int modButtonId; - public final ItemStackHandlerAA filterInventory; - public boolean isWhitelist; - public boolean respectMeta; - public boolean respectNBT; - public boolean respectMod; - public int respectOredict; - private boolean lastWhitelist; - private boolean lastRespectMeta; - private boolean lastRespectNBT; - private boolean lastRespectMod; - private int lastRecpectOredict; - - public FilterSettings(int slots, boolean defaultWhitelist, boolean defaultRespectMeta, boolean defaultRespectNBT, boolean defaultRespectMod, int defaultRespectOredict, int buttonIdStart) { - this.filterInventory = new ItemStackHandlerAA(slots); - - this.isWhitelist = defaultWhitelist; - this.respectMeta = defaultRespectMeta; - this.respectNBT = defaultRespectNBT; - this.respectMod = defaultRespectMod; - this.respectOredict = defaultRespectOredict; - - this.whitelistButtonId = buttonIdStart; - this.metaButtonId = buttonIdStart + 1; - this.nbtButtonId = buttonIdStart + 2; - this.oredictButtonId = buttonIdStart + 3; - this.modButtonId = buttonIdStart + 4; - } - - public static boolean check(ItemStack stack, ItemStackHandlerAA filter, boolean whitelist, boolean meta, boolean nbt, boolean mod, int oredict) { - if (StackUtil.isValid(stack)) { - for (int i = 0; i < filter.getSlots(); i++) { - ItemStack slot = filter.getStackInSlot(i); - - if (StackUtil.isValid(slot)) { - if (SlotFilter.isFilter(slot)) { - ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerFilter.SLOT_AMOUNT); - ItemDrill.loadSlotsFromNBT(inv, slot); - for (int k = 0; k < inv.getSlots(); k++) { - ItemStack filterSlot = inv.getStackInSlot(k); - if (StackUtil.isValid(filterSlot) && areEqualEnough(filterSlot, stack, meta, nbt, mod, oredict)) { return whitelist; } - } - } else if (areEqualEnough(slot, stack, meta, nbt, mod, oredict)) { return whitelist; } - } - } - } - return !whitelist; - } - - private static boolean areEqualEnough(ItemStack first, ItemStack second, boolean meta, boolean nbt, boolean mod, int oredict) { - Item firstItem = first.getItem(); - Item secondItem = second.getItem(); - if (mod && firstItem.getRegistryName().getNamespace().equals(secondItem.getRegistryName().getNamespace())) return true; - - if (oredict != 0) { - int[] firstIds = OreDictionary.getOreIDs(first); - int[] secondIds = OreDictionary.getOreIDs(second); - boolean firstEmpty = ArrayUtils.isEmpty(firstIds); - boolean secondEmpty = ArrayUtils.isEmpty(secondIds); - - //Both empty, meaning none has OreDict entries, so they are equal - if (firstEmpty && secondEmpty) { - return true; - } - //Only one empty, meaning they are not equal - else if (firstEmpty || secondEmpty) { - return false; - } else { - for (int id : firstIds) { - if (ArrayUtils.contains(secondIds, id)) { - //Needs to match only one id, so return true on first match - if (oredict == 1) { return true; } - } - //Needs to match every id, so just return false when no match - else if (oredict == 2) { return false; } - - } - //If oredict mode 1, this will fail because nothing matched - //If oredict mode 2, this will mean nothing hasn't matched - return oredict == 2; - } - } - - if (firstItem != secondItem) return false; - - boolean metaFine = !meta || first.getItemDamage() == second.getItemDamage(); - boolean nbtFine = !nbt || ItemStack.areItemStackTagsEqual(first, second); - if (metaFine && nbtFine) return true; - return false; - } - - public void writeToNBT(NBTTagCompound tag, String name) { - NBTTagCompound compound = new NBTTagCompound(); - compound.setBoolean("Whitelist", this.isWhitelist); - compound.setBoolean("Meta", this.respectMeta); - compound.setBoolean("NBT", this.respectNBT); - compound.setBoolean("Mod", this.respectMod); - compound.setInteger("Oredict", this.respectOredict); - TileEntityInventoryBase.saveSlots(this.filterInventory, compound); - tag.setTag(name, compound); - } - - public void readFromNBT(NBTTagCompound tag, String name) { - NBTTagCompound compound = tag.getCompoundTag(name); - this.isWhitelist = compound.getBoolean("Whitelist"); - this.respectMeta = compound.getBoolean("Meta"); - this.respectNBT = compound.getBoolean("NBT"); - this.respectMod = compound.getBoolean("Mod"); - this.respectOredict = compound.getInteger("Oredict"); - TileEntityInventoryBase.loadSlots(this.filterInventory, compound); - } - - public boolean needsUpdateSend() { - return this.lastWhitelist != this.isWhitelist || this.lastRespectMeta != this.respectMeta || this.lastRespectNBT != this.respectNBT || this.lastRespectMod != this.respectMod || this.lastRecpectOredict != this.respectOredict; - } - - public void updateLasts() { - this.lastWhitelist = this.isWhitelist; - this.lastRespectMeta = this.respectMeta; - this.lastRespectNBT = this.respectNBT; - this.lastRespectMod = this.respectMod; - this.lastRecpectOredict = this.respectOredict; - } - - public void onButtonPressed(int id) { - if (id == this.whitelistButtonId) { - this.isWhitelist = !this.isWhitelist; - } else if (id == this.metaButtonId) { - this.respectMeta = !this.respectMeta; - } else if (id == this.nbtButtonId) { - this.respectNBT = !this.respectNBT; - } else if (id == this.modButtonId) { - this.respectMod = !this.respectMod; - - if (this.respectMod) { - this.respectMeta = false; - this.respectNBT = false; - this.respectOredict = 0; - } - } else if (id == this.oredictButtonId) { - if (this.respectOredict + 1 > 2) { - this.respectOredict = 0; - } else { - this.respectOredict++; - } - } - } - - public boolean check(ItemStack stack) { - return !this.needsCheck() || check(stack, this.filterInventory, this.isWhitelist, this.respectMeta, this.respectNBT, this.respectMod, this.respectOredict); - } - - public boolean needsCheck() { - for (int i = 0; i < this.filterInventory.getSlots(); i++) { - if (StackUtil.isValid(this.filterInventory.getStackInSlot(i))) { return true; } - } - return this.isWhitelist; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IEnergyDisplay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IEnergyDisplay.java deleted file mode 100644 index d601a039e..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IEnergyDisplay.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * This file ("IEnergyDisplay.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public interface IEnergyDisplay { - - @SideOnly(Side.CLIENT) - CustomEnergyStorage getEnergyStorage(); - - @SideOnly(Side.CLIENT) - boolean needsHoldShift(); -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ISharingEnergyProvider.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ISharingEnergyProvider.java deleted file mode 100644 index a5d3c39f1..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ISharingEnergyProvider.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This file ("ISharingEnergyProvider.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -public interface ISharingEnergyProvider { - - int getEnergyToSplitShare(); - - boolean doesShareEnergy(); - - EnumFacing[] getEnergyShareSides(); - - boolean canShareTo(TileEntity tile); -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ISharingFluidHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ISharingFluidHandler.java deleted file mode 100644 index 0a05d1c70..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ISharingFluidHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * This file ("ISharingFluidHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import net.minecraft.util.EnumFacing; - -public interface ISharingFluidHandler { - - int getMaxFluidAmountToSplitShare(); - - boolean doesShareFluid(); - - EnumFacing[] getFluidShareSides(); - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java deleted file mode 100644 index a55a04711..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * This file ("TileEntityAtomicReconstructor.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; -import de.ellpeck.actuallyadditions.api.lens.ILensItem; -import de.ellpeck.actuallyadditions.api.lens.Lens; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; -import de.ellpeck.actuallyadditions.mod.misc.SoundHandler; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.Item; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraftforge.energy.IEnergyStorage; - -public class TileEntityAtomicReconstructor extends TileEntityInventoryBase implements IEnergyDisplay, IAtomicReconstructor { - - public static final int ENERGY_USE = 1000; - public final CustomEnergyStorage storage; - public int counter; - private int currentTime; - private int oldEnergy; - - public TileEntityAtomicReconstructor() { - super(1, "reconstructor"); - int power = ConfigIntValues.RECONSTRUCTOR_POWER.getValue(); - int recieve = MathHelper.ceil(power * 0.016666F); - this.storage = new CustomEnergyStorage(power, recieve, 0); - } - - public static void shootLaser(World world, double startX, double startY, double startZ, double endX, double endY, double endZ, Lens currentLens) { - world.playSound(null, startX, startY, startZ, SoundHandler.reconstructor, SoundCategory.BLOCKS, 0.35F, 1.0F); - AssetUtil.spawnLaserWithTimeServer(world, startX, startY, startZ, endX, endY, endZ, currentLens.getColor(), 25, 0, 0.2F, 0.8F); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("CurrentTime", this.currentTime); - compound.setInteger("Counter", this.counter); - } - this.storage.writeToNBT(compound); - } - - @Override - public boolean shouldSyncSlots() { - return true; - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - this.currentTime = compound.getInteger("CurrentTime"); - this.counter = compound.getInteger("Counter"); - } - this.storage.readFromNBT(compound); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - if (!this.isRedstonePowered && !this.isPulseMode) { - if (this.currentTime > 0) { - this.currentTime--; - if (this.currentTime <= 0) { - ActuallyAdditionsAPI.methodHandler.invokeReconstructor(this); - } - } else { - this.currentTime = 100; - } - } - - if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { - this.oldEnergy = this.storage.getEnergyStored(); - this.world.updateComparatorOutputLevel(this.pos, InitBlocks.blockAtomicReconstructor); - } - } - - } - - @Override - public Lens getLens() { - Item item = this.inv.getStackInSlot(0).getItem(); - if (item instanceof ILensItem) return ((ILensItem) item).getLens(); - return this.counter >= 500 ? ActuallyAdditionsAPI.lensDisruption : ActuallyAdditionsAPI.lensDefaultConversion; - } - - @Override - public EnumFacing getOrientation() { - IBlockState state = this.world.getBlockState(this.pos); - return WorldUtil.getDirectionByPistonRotation(state); - } - - @Override - public BlockPos getPosition() { - return this.pos; - } - - @Override - public int getX() { - return this.getPos().getX(); - } - - @Override - public int getY() { - return this.getPos().getY(); - } - - @Override - public int getZ() { - return this.getPos().getZ(); - } - - @Override - public World getWorldObject() { - return this.getWorld(); - } - - @Override - public void extractEnergy(int amount) { - this.storage.extractEnergyInternal(amount, false); - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem; - } - - @Override - public int getEnergy() { - return this.storage.getEnergyStored(); - } - - @Override - public CustomEnergyStorage getEnergyStorage() { - return this.storage; - } - - @Override - public boolean needsHoldShift() { - return false; - } - - @Override - public boolean isRedstoneToggle() { - return true; - } - - @Override - public void activateOnPulse() { - ActuallyAdditionsAPI.methodHandler.invokeReconstructor(this); - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.storage; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java deleted file mode 100644 index 0ac6cb8cb..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java +++ /dev/null @@ -1,378 +0,0 @@ -/* - * This file ("TileEntityBase.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; -import de.ellpeck.actuallyadditions.mod.util.VanillaPacketDispatcher; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.play.server.SPacketUpdateTileEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ITickable; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentTranslation; -import net.minecraft.world.World; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.energy.CapabilityEnergy; -import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.fluids.capability.CapabilityFluidHandler; -import net.minecraftforge.fluids.capability.IFluidHandler; -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 final String name; - public boolean isRedstonePowered; - public boolean isPulseMode; - public boolean stopFromDropping; - protected int ticksElapsed; - protected TileEntity[] tilesAround = new TileEntity[6]; - protected boolean hasSavedDataOnChangeOrWorldStart; - - public TileEntityBase(String name) { - this.name = name; - } - - public static void init() { - ActuallyAdditions.LOGGER.info("Registering TileEntities..."); - - register(TileEntityCompost.class); - register(TileEntityFeeder.class); - register(TileEntityGiantChest.class); - register(TileEntityGiantChestMedium.class); - register(TileEntityGiantChestLarge.class); - register(TileEntityGrinder.class); - register(TileEntityFurnaceDouble.class); - register(TileEntityInputter.class); - register(TileEntityFishingNet.class); - register(TileEntityFurnaceSolar.class); - register(TileEntityHeatCollector.class); - register(TileEntityItemRepairer.class); - register(TileEntityBreaker.class); - register(TileEntityDropper.class); - register(TileEntityInputterAdvanced.class); - register(TileEntityPlacer.class); - register(TileEntityGrinderDouble.class); - register(TileEntityCanolaPress.class); - register(TileEntityFermentingBarrel.class); - register(TileEntityOilGenerator.class); - register(TileEntityCoalGenerator.class); - register(TileEntityPhantomItemface.class); - register(TileEntityPhantomLiquiface.class); - register(TileEntityPhantomEnergyface.class); - register(TileEntityPlayerInterface.class); - register(TileEntityPhantomPlacer.class); - register(TileEntityPhantomBreaker.class); - register(TileEntityFluidCollector.class); - register(TileEntityFluidPlacer.class); - register(TileEntityLavaFactoryController.class); - register(TileEntityCoffeeMachine.class); - register(TileEntityPhantomBooster.class); - register(TileEntityEnergizer.class); - register(TileEntityEnervator.class); - register(TileEntityXPSolidifier.class); - register(TileEntitySmileyCloud.class); - register(TileEntityLeafGenerator.class); - register(TileEntityDirectionalBreaker.class); - register(TileEntityRangedCollector.class); - register(TileEntityAtomicReconstructor.class); - register(TileEntityMiner.class); - register(TileEntityFireworkBox.class); - register(TileEntityPhantomRedstoneface.class); - register(TileEntityLaserRelayItem.class); - register(TileEntityLaserRelayEnergy.class); - register(TileEntityLaserRelayEnergyAdvanced.class); - register(TileEntityLaserRelayEnergyExtreme.class); - register(TileEntityLaserRelayItemWhitelist.class); - register(TileEntityItemViewer.class); - register(TileEntityDisplayStand.class); - register(TileEntityShockSuppressor.class); - register(TileEntityEmpowerer.class); - register(TileEntityLaserRelayFluids.class); - register(TileEntityBioReactor.class); - register(TileEntityFarmer.class); - register(TileEntityItemViewerHopping.class); - register(TileEntityBatteryBox.class); - } - - 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) { - ActuallyAdditions.LOGGER.fatal("Registering a TileEntity failed!", e); - } - } - - @Override - public final NBTTagCompound writeToNBT(NBTTagCompound compound) { - this.writeSyncableNBT(compound, NBTType.SAVE_TILE); - return compound; - } - - @Override - public final void readFromNBT(NBTTagCompound compound) { - this.readSyncableNBT(compound, NBTType.SAVE_TILE); - } - - @Override - 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) { - this.readSyncableNBT(pkt.getNbtCompound(), NBTType.SYNC); - } - - @Override - public final NBTTagCompound getUpdateTag() { - NBTTagCompound compound = new NBTTagCompound(); - this.writeSyncableNBT(compound, NBTType.SYNC); - return compound; - } - - @Override - 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); - /* - 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()); - data.setInteger("Y", this.pos.getY()); - data.setInteger("Z", this.pos.getZ()); - PacketHandler.theNetwork.sendToAllTracking(new PacketServerToClient(data, PacketHandler.TILE_ENTITY_HANDLER), new TargetPoint(this.world.provider.getDimension(), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), 0)); - }*/ - } - - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - if (type != NBTType.SAVE_BLOCK) super.writeToNBT(compound); - - 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); - - 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); - - 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"); - - if (this.isRedstoneToggle()) { - this.isPulseMode = compound.getBoolean("IsPulseMode"); - } - } - - @Override - 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"; - } - - @Override - public ITextComponent getDisplayName() { - return new TextComponentTranslation(this.getNameForTranslation()); - } - - @Override - public final void update() { - this.updateEntity(); - } - - public int getComparatorStrength() { - return 0; - } - - private boolean shareEnergy = this instanceof ISharingEnergyProvider; - private boolean shareFluid = this instanceof ISharingFluidHandler; - - public void updateEntity() { - this.ticksElapsed++; - - if (!this.world.isRemote) { - if (this.shareEnergy) { - ISharingEnergyProvider provider = (ISharingEnergyProvider) this; - if (provider.doesShareEnergy()) { - int total = provider.getEnergyToSplitShare(); - if (total > 0) { - EnumFacing[] sides = provider.getEnergyShareSides(); - - int amount = total / sides.length; - if (amount <= 0) { - amount = total; - } - - for (EnumFacing side : sides) { - TileEntity tile = this.tilesAround[side.ordinal()]; - if (tile != null && provider.canShareTo(tile)) { - WorldUtil.doEnergyInteraction(this, tile, side, amount); - } - } - } - } - } - - if (this.shareFluid) { - ISharingFluidHandler handler = (ISharingFluidHandler) this; - if (handler.doesShareFluid()) { - int total = handler.getMaxFluidAmountToSplitShare(); - if (total > 0) { - EnumFacing[] sides = handler.getFluidShareSides(); - - int amount = total / sides.length; - if (amount <= 0) { - amount = total; - } - - for (EnumFacing side : sides) { - TileEntity tile = this.tilesAround[side.ordinal()]; - if (tile != null) { - WorldUtil.doFluidInteraction(this, tile, side, amount); - } - } - } - } - } - - if (!this.hasSavedDataOnChangeOrWorldStart) { - if (this.shouldSaveDataOnChangeOrWorldStart()) { - this.saveDataOnChangeOrWorldStart(); - } - - this.hasSavedDataOnChangeOrWorldStart = true; - } - } - } - - public void saveDataOnChangeOrWorldStart() { - for (EnumFacing side : EnumFacing.values()) { - BlockPos pos = this.pos.offset(side); - if (this.world.isBlockLoaded(pos)) { - this.tilesAround[side.ordinal()] = this.world.getTileEntity(pos); - } - } - } - - public boolean shouldSaveDataOnChangeOrWorldStart() { - return this instanceof ISharingEnergyProvider || this instanceof ISharingFluidHandler; - } - - 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; - } - - protected boolean sendUpdateWithInterval() { - if (this.ticksElapsed % ConfigIntValues.TILE_ENTITY_UPDATE_INTERVAL.getValue() == 0) { - this.sendUpdate(); - return true; - } else { - return false; - } - } - - @Override - 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) { - IItemHandler handler = this.getItemHandler(facing); - 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) { - IEnergyStorage storage = this.getEnergyStorage(facing); - if (storage != null) { return (T) storage; } - } - return super.getCapability(capability, facing); - } - - public IFluidHandler getFluidHandler(EnumFacing facing) { - return null; - } - - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return null; - } - - public IItemHandler getItemHandler(EnumFacing facing) { - return null; - } - - public boolean isRedstoneToggle() { - return false; - } - - public void activateOnPulse() { - - } - - public boolean respondsToPulses() { - return this.isRedstoneToggle() && this.isPulseMode; - } - - public enum NBTType { - /** - * Use when normal writeToNBT/readToNBT is expected. - */ - SAVE_TILE, - /** - * Use when data needs to be sent to the client. - */ - SYNC, - /** - * Wat - */ - SAVE_BLOCK - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBatteryBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBatteryBox.java deleted file mode 100644 index 5666d55e8..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBatteryBox.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * This file ("TileEntityBatteryBox.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import java.util.ArrayList; -import java.util.List; - -import de.ellpeck.actuallyadditions.mod.items.ItemBattery; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.energy.CapabilityEnergy; -import net.minecraftforge.energy.IEnergyStorage; - -public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISharingEnergyProvider { - - private int lastEnergyStored; - private int lastCompare; - - public TileEntityBatteryBox() { - super(1, "batteryBox"); - } - - @Override - 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); } - } - return null; - } - - @Override - public void updateEntity() { - super.updateEntity(); - - if (!this.world.isRemote) { - int currStorage = 0; - - IEnergyStorage storage = this.getEnergyStorage(null); - if (storage != null) { - ItemStack stack = this.inv.getStackInSlot(0); - if (StackUtil.isValid(stack) && ItemUtil.isEnabled(stack)) { - if (storage.getEnergyStored() > 0) { - List tiles = new ArrayList<>(); - this.energyPushOffLoop(this, tiles); - - if (!tiles.isEmpty()) { - int amount = tiles.size(); - - int energyPer = storage.getEnergyStored() / amount; - if (energyPer <= 0) { - energyPer = storage.getEnergyStored(); - } - int maxPer = storage.extractEnergy(energyPer, true); - - for (TileEntityBatteryBox tile : tiles) { - ItemStack battery = tile.inv.getStackInSlot(0); - if (StackUtil.isValid(battery) && !ItemUtil.isEnabled(battery)) { - if (tile.hasCapability(CapabilityEnergy.ENERGY, null)) { - IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, null); - if (cap != null) { - int received = cap.receiveEnergy(maxPer, false); - storage.extractEnergy(received, false); - - if (storage.getEnergyStored() <= 0) { - break; - } - } - } - } - } - } - } - } - - currStorage = storage.getEnergyStored(); - } - - if (this.lastCompare != this.getComparatorStrength()) { - this.lastCompare = this.getComparatorStrength(); - this.markDirty(); - } - - if (this.lastEnergyStored != currStorage && this.sendUpdateWithInterval()) { - this.lastEnergyStored = currStorage; - } - } - } - - @Override - public int getComparatorStrength() { - IEnergyStorage storage = this.getEnergyStorage(null); - if (storage != null) { - float calc = (float) storage.getEnergyStored() / (float) storage.getMaxEnergyStored() * 15F; - return (int) calc; - } else { - return 0; - } - } - - @Override - public boolean respondsToPulses() { - return true; - } - - @Override - public void activateOnPulse() { - ItemStack stack = this.inv.getStackInSlot(0); - if (StackUtil.isValid(stack)) { - ItemUtil.changeEnabled(stack); - this.markDirty(); - } - } - - 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)) { - pushOffTo.add(box); - - this.energyPushOffLoop(box, pushOffTo); - } - } - } - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> stack.getItem() instanceof ItemBattery; - } - - @Override - public boolean shouldSyncSlots() { - return true; - } - - @Override - public int getEnergyToSplitShare() { - IEnergyStorage storage = this.getEnergyStorage(null); - if (storage != null) { - return storage.getEnergyStored(); - } else { - return 0; - } - } - - @Override - public boolean doesShareEnergy() { - return true; - } - - @Override - public EnumFacing[] getEnergyShareSides() { - return EnumFacing.values(); - } - - @Override - public boolean canShareTo(TileEntity tile) { - return !(tile instanceof TileEntityBatteryBox); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBioReactor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBioReactor.java deleted file mode 100644 index 4a35e7fe7..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBioReactor.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * This file ("TileEntityBioReactor.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import java.util.ArrayList; -import java.util.List; - -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.Block; -import net.minecraft.block.IGrowable; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.common.IPlantable; -import net.minecraftforge.energy.IEnergyStorage; - -public class TileEntityBioReactor extends TileEntityInventoryBase implements ISharingEnergyProvider { - - public final CustomEnergyStorage storage = new CustomEnergyStorage(200000, 0, 800); - - public int burnTime; - public int maxBurnTime; - public int producePerTick; - - private int lastBurnTime; - private int lastProducePerTick; - - public TileEntityBioReactor() { - super(8, "bioReactor"); - } - - public static boolean isValidItem(ItemStack stack) { - if (StackUtil.isValid(stack)) { - Item item = stack.getItem(); - if (isValid(item)) { - return true; - } else if (item instanceof ItemBlock) { return isValid(Block.getBlockFromItem(item)); } - } - return false; - } - - private static boolean isValid(Object o) { - return o instanceof IPlantable || o instanceof IGrowable || o instanceof ItemFood; - } - - @Override - public void updateEntity() { - super.updateEntity(); - - if (this.burnTime <= 0) { - List types = null; - - if (!this.isRedstonePowered && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored()) { - for (int i = 0; i < this.inv.getSlots(); i++) { - ItemStack stack = this.inv.getStackInSlot(i); - if (StackUtil.isValid(stack)) { - Item item = stack.getItem(); - if (isValidItem(stack) && (types == null || !types.contains(item))) { - if (types == null) { - types = new ArrayList<>(); - } - types.add(item); - - this.inv.setStackInSlot(i, StackUtil.shrink(stack, 1)); - } - } - } - - this.markDirty(); - } - - if (types != null && !types.isEmpty()) { - int amount = types.size(); - this.producePerTick = (int) Math.pow(amount * 2, 2); - - this.maxBurnTime = 200 - (int) Math.pow(1.8, amount); - this.burnTime = this.maxBurnTime; - } else { - this.burnTime = 0; - this.maxBurnTime = 0; - this.producePerTick = 0; - } - } else { - this.burnTime--; - this.storage.receiveEnergyInternal(this.producePerTick, false); - } - - if ((this.lastBurnTime != this.burnTime || this.lastProducePerTick != this.producePerTick) && this.sendUpdateWithInterval()) { - this.lastBurnTime = this.burnTime; - this.lastProducePerTick = this.producePerTick; - } - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - - this.storage.writeToNBT(compound); - compound.setInteger("BurnTime", this.burnTime); - compound.setInteger("MaxBurnTime", this.maxBurnTime); - compound.setInteger("ProducePerTick", this.producePerTick); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - - this.storage.readFromNBT(compound); - this.burnTime = compound.getInteger("BurnTime"); - this.maxBurnTime = compound.getInteger("MaxBurnTime"); - this.producePerTick = compound.getInteger("ProducePerTick"); - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> isValidItem(stack); - } - - @Override - public IRemover getRemover() { - return (slot, automation) -> !automation; - } - - @Override - public int getEnergyToSplitShare() { - return this.storage.getEnergyStored(); - } - - @Override - public boolean doesShareEnergy() { - return true; - } - - @Override - public EnumFacing[] getEnergyShareSides() { - return EnumFacing.values(); - } - - @Override - public boolean canShareTo(TileEntity tile) { - return true; - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.storage; - } - - @Override - public int getComparatorStrength() { - float calc = (float) this.storage.getEnergyStored() / (float) this.storage.getMaxEnergyStored() * 15F; - return (int) calc; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBreaker.java deleted file mode 100644 index 3b381b2a6..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBreaker.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * This file ("TileEntityBreaker.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import net.minecraft.block.Block; -import net.minecraft.block.BlockLiquid; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.fluids.IFluidBlock; - -public class TileEntityBreaker extends TileEntityInventoryBase { - - public boolean isPlacer; - private int currentTime; - - public TileEntityBreaker(int slots, String name) { - super(slots, name); - } - - public TileEntityBreaker() { - super(9, "breaker"); - this.isPlacer = false; - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("CurrentTime", this.currentTime); - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - this.currentTime = compound.getInteger("CurrentTime"); - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - if (!this.isRedstonePowered && !this.isPulseMode) { - if (this.currentTime > 0) { - this.currentTime--; - if (this.currentTime <= 0) { - this.doWork(); - } - } else { - this.currentTime = 15; - } - } - } - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !automation; - } - - private void doWork() { - EnumFacing side = WorldUtil.getDirectionByPistonRotation(this.world.getBlockState(this.pos)); - BlockPos breakCoords = this.pos.offset(side); - IBlockState stateToBreak = this.world.getBlockState(breakCoords); - Block blockToBreak = stateToBreak.getBlock(); - - if (!this.isPlacer && blockToBreak != Blocks.AIR && !(blockToBreak instanceof BlockLiquid) && !(blockToBreak instanceof IFluidBlock) && stateToBreak.getBlockHardness(this.world, breakCoords) >= 0.0F) { - NonNullList drops = NonNullList.create(); - blockToBreak.getDrops(drops, this.world, breakCoords, stateToBreak, 0); - float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.world, breakCoords); - - if (chance > 0 && this.world.rand.nextFloat() <= chance) { - if (StackUtil.canAddAll(this.inv, drops, false)) { - this.world.destroyBlock(breakCoords, false); - StackUtil.addAll(this.inv, drops, false); - this.markDirty(); - } - } - } else if (this.isPlacer) { - int slot = StackUtil.findFirstFilled(this.inv); - if (slot == -1) return; - this.inv.setStackInSlot(slot, WorldUtil.useItemAtSide(side, this.world, this.pos, this.inv.getStackInSlot(slot))); - } - } - - @Override - public boolean isRedstoneToggle() { - return true; - } - - @Override - public void activateOnPulse() { - this.doWork(); - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCanolaPress.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCanolaPress.java deleted file mode 100644 index ec9a1839f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCanolaPress.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * This file ("TileEntityCanolaPress.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class TileEntityCanolaPress extends TileEntityInventoryBase implements ISharingFluidHandler { - - public static final int PRODUCE = 80; - public static final int ENERGY_USE = 35; - private static final int TIME = 30; - public final CustomEnergyStorage storage = new CustomEnergyStorage(40000, 100, 0); - public final FluidTank tank = new FluidTank(2 * Util.BUCKET) { - @Override - public boolean canFill() { - return false; - } - }; - public int currentProcessTime; - private int lastEnergyStored; - private int lastTankAmount; - private int lastProcessTime; - - public TileEntityCanolaPress() { - super(1, "canolaPress"); - } - - @SideOnly(Side.CLIENT) - public int getTankScaled(int i) { - return this.tank.getFluidAmount() * i / this.tank.getCapacity(); - } - - @SideOnly(Side.CLIENT) - public int getProcessScaled(int i) { - return this.currentProcessTime * i / TIME; - } - - @SideOnly(Side.CLIENT) - public int getEnergyScaled(int i) { - return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored(); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("ProcessTime", this.currentProcessTime); - } - this.storage.writeToNBT(compound); - this.tank.writeToNBT(compound); - super.writeSyncableNBT(compound, type); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - if (type != NBTType.SAVE_BLOCK) { - this.currentProcessTime = compound.getInteger("ProcessTime"); - } - this.storage.readFromNBT(compound); - this.tank.readFromNBT(compound); - super.readSyncableNBT(compound, type); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - if (isCanola(this.inv.getStackInSlot(0)) && PRODUCE <= this.tank.getCapacity() - this.tank.getFluidAmount()) { - if (this.storage.getEnergyStored() >= ENERGY_USE) { - this.currentProcessTime++; - this.storage.extractEnergyInternal(ENERGY_USE, false); - if (this.currentProcessTime >= TIME) { - this.currentProcessTime = 0; - - this.inv.setStackInSlot(0, StackUtil.shrink(this.inv.getStackInSlot(0), 1)); - - this.tank.fillInternal(new FluidStack(InitFluids.fluidCanolaOil, PRODUCE), true); - this.markDirty(); - } - } - } else { - this.currentProcessTime = 0; - } - - if ((this.storage.getEnergyStored() != this.lastEnergyStored || this.tank.getFluidAmount() != this.lastTankAmount | this.currentProcessTime != this.lastProcessTime) && this.sendUpdateWithInterval()) { - this.lastEnergyStored = this.storage.getEnergyStored(); - this.lastProcessTime = this.currentProcessTime; - this.lastTankAmount = this.tank.getFluidAmount(); - } - } - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> slot == 0 && isCanola(stack); - } - - public static boolean isCanola(ItemStack stack) { - return stack.getItem() == InitItems.itemMisc && stack.getMetadata() == TheMiscItems.CANOLA.ordinal(); - } - - @Override - public IRemover getRemover() { - return (slot, automation) -> !automation; - } - - @Override - public FluidTank getFluidHandler(EnumFacing facing) { - return this.tank; - } - - @Override - public int getMaxFluidAmountToSplitShare() { - return this.tank.getFluidAmount(); - } - - @Override - public boolean doesShareFluid() { - return true; - } - - @Override - public EnumFacing[] getFluidShareSides() { - return EnumFacing.values(); - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.storage; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java deleted file mode 100644 index 0f95e3517..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * This file ("TileEntityCoalGenerator.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityFurnace; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class TileEntityCoalGenerator extends TileEntityInventoryBase implements ISharingEnergyProvider { - - public static final int PRODUCE = 30; - public final CustomEnergyStorage storage = new CustomEnergyStorage(60000, 0, 80); - public int maxBurnTime; - public int currentBurnTime; - private int lastEnergy; - private int lastBurnTime; - private int lastCurrentBurnTime; - private int lastCompare; - private ItemStack curStack = ItemStack.EMPTY; - private int curBurn = -1; - - public TileEntityCoalGenerator() { - super(1, "coalGenerator"); - } - - @SideOnly(Side.CLIENT) - public int getEnergyScaled(int i) { - return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored(); - } - - @SideOnly(Side.CLIENT) - public int getBurningScaled(int i) { - return this.currentBurnTime * i / this.maxBurnTime; - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("BurnTime", this.currentBurnTime); - compound.setInteger("MaxBurnTime", this.maxBurnTime); - } - this.storage.writeToNBT(compound); - super.writeSyncableNBT(compound, type); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - if (type != NBTType.SAVE_BLOCK) { - this.currentBurnTime = compound.getInteger("BurnTime"); - this.maxBurnTime = compound.getInteger("MaxBurnTime"); - } - this.storage.readFromNBT(compound); - super.readSyncableNBT(compound, type); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - boolean flag = this.currentBurnTime > 0; - - if (this.currentBurnTime > 0) { - this.currentBurnTime--; - this.storage.addEnergyRaw(PRODUCE); - } - - ItemStack stack = this.inv.getStackInSlot(0); - if (!stack.isEmpty() && stack != this.curStack) { - this.curStack = stack; - this.curBurn = TileEntityFurnace.getItemBurnTime(stack); - } else if (stack.isEmpty()) { - this.curStack = ItemStack.EMPTY; - this.curBurn = -1; - } - - if (!this.isRedstonePowered && this.currentBurnTime <= 0 && this.curBurn > 0 && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored()) { - this.maxBurnTime = this.curBurn; - this.currentBurnTime = this.curBurn; - this.inv.setStackInSlot(0, StackUtil.shrinkForContainer(stack, 1)); - } - - if (flag != this.currentBurnTime > 0 || this.lastCompare != this.getComparatorStrength()) { - this.lastCompare = this.getComparatorStrength(); - this.markDirty(); - } - - if ((this.storage.getEnergyStored() != this.lastEnergy || this.currentBurnTime != this.lastCurrentBurnTime || this.lastBurnTime != this.maxBurnTime) && this.sendUpdateWithInterval()) { - this.lastEnergy = this.storage.getEnergyStored(); - this.lastCurrentBurnTime = this.currentBurnTime; - this.lastBurnTime = this.currentBurnTime; - } - } - } - - @Override - public int getComparatorStrength() { - float calc = (float) this.storage.getEnergyStored() / (float) this.storage.getMaxEnergyStored() * 15F; - return (int) calc; - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> TileEntityFurnace.getItemBurnTime(stack) > 0; - } - - @Override - public IRemover getRemover() { - return (slot, automation) -> { - if (!automation) return true; - return TileEntityFurnace.getItemBurnTime(this.inv.getStackInSlot(0)) <= 0; - }; - } - - @Override - public int getEnergyToSplitShare() { - return this.storage.getEnergyStored(); - } - - @Override - public boolean doesShareEnergy() { - return true; - } - - @Override - public EnumFacing[] getEnergyShareSides() { - return EnumFacing.values(); - } - - @Override - public boolean canShareTo(TileEntity tile) { - return true; - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.storage; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java deleted file mode 100644 index 07ec5c5d7..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * This file ("TileEntityCoffeeMachine.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.ItemCoffee; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; -import de.ellpeck.actuallyadditions.mod.misc.SoundHandler; -import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.SoundCategory; -import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.oredict.OreIngredient; - -public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements IButtonReactor, ISharingFluidHandler { - - public static final int SLOT_COFFEE_BEANS = 0; - public static final int SLOT_INPUT = 1; - public static final int SLOT_OUTPUT = 2; - public static final int CACHE_USE = 35; - public static final int ENERGY_USED = 150; - public static final int WATER_USE = 500; - public static final int COFFEE_CACHE_MAX_AMOUNT = 300; - public static final int TIME_USED = 500; - public static final OreIngredient COFFEE = new OreIngredient("cropCoffee"); - public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 250, 0); - public final FluidTank tank = new FluidTank(4 * Util.BUCKET) { - @Override - public boolean canDrain() { - return false; - } - - @Override - public boolean canFillFluidType(FluidStack fluid) { - return fluid.getFluid() == FluidRegistry.WATER; - } - }; - public int coffeeCacheAmount; - public int brewTime; - private int lastEnergy; - private int lastTank; - private int lastCoffeeAmount; - private int lastBrewTime; - - public TileEntityCoffeeMachine() { - super(11, "coffeeMachine"); - } - - @SideOnly(Side.CLIENT) - public int getCoffeeScaled(int i) { - return this.coffeeCacheAmount * i / COFFEE_CACHE_MAX_AMOUNT; - } - - @SideOnly(Side.CLIENT) - public int getWaterScaled(int i) { - return this.tank.getFluidAmount() * i / this.tank.getCapacity(); - } - - @SideOnly(Side.CLIENT) - public int getEnergyScaled(int i) { - return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored(); - } - - @SideOnly(Side.CLIENT) - public int getBrewScaled(int i) { - return this.brewTime * i / TIME_USED; - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - this.storage.writeToNBT(compound); - this.tank.writeToNBT(compound); - compound.setInteger("Cache", this.coffeeCacheAmount); - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("Time", this.brewTime); - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - this.storage.readFromNBT(compound); - this.tank.readFromNBT(compound); - this.coffeeCacheAmount = compound.getInteger("Cache"); - if (type != NBTType.SAVE_BLOCK) { - this.brewTime = compound.getInteger("Time"); - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - this.storeCoffee(); - - if (this.brewTime > 0 || this.isRedstonePowered) { - this.brew(); - } - - if ((this.coffeeCacheAmount != this.lastCoffeeAmount || this.storage.getEnergyStored() != this.lastEnergy || this.tank.getFluidAmount() != this.lastTank || this.brewTime != this.lastBrewTime) && this.sendUpdateWithInterval()) { - this.lastCoffeeAmount = this.coffeeCacheAmount; - this.lastEnergy = this.storage.getEnergyStored(); - this.lastTank = this.tank.getFluidAmount(); - this.lastBrewTime = this.brewTime; - } - } - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !automation || slot >= 3 && ItemCoffee.getIngredientFromStack(stack) != null || slot == SLOT_COFFEE_BEANS && COFFEE.apply(stack) || slot == SLOT_INPUT && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CUP.ordinal(); - } - - @Override - public IRemover getRemover() { - return (slot, automation) -> !automation || slot == SLOT_OUTPUT || slot >= 3 && slot < this.inv.getSlots() && ItemCoffee.getIngredientFromStack(this.inv.getStackInSlot(slot)) == null; - } - - public void storeCoffee() { - if (StackUtil.isValid(this.inv.getStackInSlot(SLOT_COFFEE_BEANS)) && COFFEE.apply(this.inv.getStackInSlot(SLOT_COFFEE_BEANS))) { - int toAdd = 2; - if (toAdd <= COFFEE_CACHE_MAX_AMOUNT - this.coffeeCacheAmount) { - this.inv.setStackInSlot(SLOT_COFFEE_BEANS, StackUtil.shrink(this.inv.getStackInSlot(SLOT_COFFEE_BEANS), 1)); - this.coffeeCacheAmount += toAdd; - } - } - } - - public void brew() { - if (!this.world.isRemote) { - ItemStack input = this.inv.getStackInSlot(SLOT_INPUT); - if (StackUtil.isValid(input) && input.getItem() == InitItems.itemMisc && input.getItemDamage() == TheMiscItems.CUP.ordinal() && !StackUtil.isValid(this.inv.getStackInSlot(SLOT_OUTPUT)) && this.coffeeCacheAmount >= CACHE_USE && this.tank.getFluid() != null && this.tank.getFluid().getFluid() == FluidRegistry.WATER && this.tank.getFluidAmount() >= WATER_USE) { - if (this.storage.getEnergyStored() >= ENERGY_USED) { - if (this.brewTime % 30 == 0) { - this.world.playSound(null, this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), SoundHandler.coffeeMachine, SoundCategory.BLOCKS, 0.1F, 1.0F); - } - - this.brewTime++; - this.storage.extractEnergyInternal(ENERGY_USED, false); - if (this.brewTime >= TIME_USED) { - this.brewTime = 0; - ItemStack output = new ItemStack(InitItems.itemCoffee); - for (int i = 3; i < this.inv.getSlots(); i++) { - if (StackUtil.isValid(this.inv.getStackInSlot(i))) { - CoffeeIngredient ingredient = ItemCoffee.getIngredientFromStack(this.inv.getStackInSlot(i)); - if (ingredient != null) { - if (ingredient.effect(output)) { - this.inv.setStackInSlot(i, StackUtil.shrinkForContainer(this.inv.getStackInSlot(i), 1)); - } - } - } - } - this.inv.setStackInSlot(SLOT_OUTPUT, output.copy()); - this.inv.getStackInSlot(SLOT_INPUT).shrink(1); - this.coffeeCacheAmount -= CACHE_USE; - this.tank.drainInternal(WATER_USE, true); - } - } - } else { - this.brewTime = 0; - } - } - } - - @Override - public void onButtonPressed(int buttonID, EntityPlayer player) { - if (buttonID == 0 && this.brewTime <= 0) { - this.brew(); - } - } - - @Override - public FluidTank getFluidHandler(EnumFacing facing) { - return this.tank; - } - - @Override - public int getMaxFluidAmountToSplitShare() { - return 0; - } - - @Override - public boolean doesShareFluid() { - return false; - } - - @Override - public EnumFacing[] getFluidShareSides() { - return null; - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.storage; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java deleted file mode 100644 index 802bcd961..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * This file ("TileEntityCompost.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -public class TileEntityCompost extends TileEntityInventoryBase { - - public static final int COMPOST_TIME_TICKS = 3000; - - protected int conversionTime; - protected CompostRecipe recipe; - - public TileEntityCompost() { - super(1, "compost"); - } - - public static CompostRecipe getRecipeForInput(ItemStack input) { - if (StackUtil.isValid(input)) { - for (CompostRecipe recipe : ActuallyAdditionsAPI.COMPOST_RECIPES) { - if (recipe.matches(input)) return recipe; - } - } - return null; - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("ConversionTime", this.conversionTime); - } - } - - @Override - public boolean shouldSyncSlots() { - return true; - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - this.conversionTime = compound.getInteger("ConversionTime"); - } - if (type == NBTType.SYNC) this.world.markBlockRangeForRenderUpdate(this.pos, this.pos.up()); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - boolean theFlag = this.conversionTime > 0; - ItemStack input = this.inv.getStackInSlot(0); - if (StackUtil.isValid(input)) { - if (this.recipe == null || !this.recipe.matches(input)) this.recipe = getRecipeForInput(input); - if (this.recipe != null) { - this.conversionTime++; - if (this.conversionTime >= COMPOST_TIME_TICKS) { - ItemStack output = this.recipe.getOutput().copy(); - output.setCount(input.getCount()); - this.inv.setStackInSlot(0, output); - this.conversionTime = 0; - this.markDirty(); - } - } else { - this.conversionTime = 0; - } - } - - if (theFlag != this.conversionTime > 0) { - this.markDirty(); - } - } - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> getRecipeForInput(stack) != null; - } - - @Override - public IRemover getRemover() { - return (slot, automation) -> getRecipeForInput(this.inv.getStackInSlot(slot)) == null; - } - - public IBlockState getCurrentDisplay() { - ItemStack input = this.inv.getStackInSlot(0); - CompostRecipe displayRecipe = this.recipe; - if (displayRecipe == null || !displayRecipe.matches(input)) displayRecipe = getRecipeForInput(input); - - if (displayRecipe == null) for (CompostRecipe r : ActuallyAdditionsAPI.COMPOST_RECIPES) { - if (ItemUtil.areItemsEqual(input, r.getOutput(), true)) return r.getOutputDisplay(); - else if (r.getInput().apply(input)) return r.getInputDisplay(); - } - - if (displayRecipe != null) return displayRecipe.getInputDisplay(); - return Blocks.AIR.getDefaultState(); - } - - public float getHeight() { - ItemStack input = this.inv.getStackInSlot(0); - if (input.isEmpty()) return 0; - return (float) input.getCount() / input.getMaxStackSize(); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDirectionalBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDirectionalBreaker.java deleted file mode 100644 index 07734cb8c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDirectionalBreaker.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * This file ("TileEntityDirectionalBreaker.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.energy.IEnergyStorage; - -public class TileEntityDirectionalBreaker extends TileEntityInventoryBase { - - public static final int RANGE = 8; - public static final int ENERGY_USE = 5; - public final CustomEnergyStorage storage = new CustomEnergyStorage(10000, 20, 0); - private int lastEnergy; - private int currentTime; - - public TileEntityDirectionalBreaker() { - super(9, "directionalBreaker"); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - this.storage.writeToNBT(compound); - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("CurrentTime", this.currentTime); - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - this.storage.readFromNBT(compound); - if (type != NBTType.SAVE_BLOCK) { - this.currentTime = compound.getInteger("CurrentTime"); - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - if (!this.isRedstonePowered && !this.isPulseMode) { - if (this.currentTime > 0) { - this.currentTime--; - if (this.currentTime <= 0) { - this.doWork(); - } - } else { - this.currentTime = 15; - } - } - - if (this.storage.getEnergyStored() != this.lastEnergy && this.sendUpdateWithInterval()) { - this.lastEnergy = this.storage.getEnergyStored(); - } - } - } - - private void doWork() { - if (this.storage.getEnergyStored() >= ENERGY_USE * RANGE) { - IBlockState state = this.world.getBlockState(this.pos); - EnumFacing sideToManipulate = WorldUtil.getDirectionByPistonRotation(state); - - for (int i = 0; i < RANGE; i++) { - BlockPos coordsBlock = this.pos.offset(sideToManipulate, i + 1); - IBlockState breakState = this.world.getBlockState(coordsBlock); - Block blockToBreak = breakState.getBlock(); - if (blockToBreak != null && !this.world.isAirBlock(coordsBlock) && this.world.getBlockState(coordsBlock).getBlockHardness(this.world, coordsBlock) > -1.0F) { - NonNullList drops = NonNullList.create(); - blockToBreak.getDrops(drops, this.world, coordsBlock, breakState, 0); - float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.world, coordsBlock); - - if (chance > 0 && this.world.rand.nextFloat() <= chance) { - if (StackUtil.canAddAll(this.inv, drops, false)) { - this.world.playEvent(2001, coordsBlock, Block.getStateId(this.world.getBlockState(coordsBlock))); - this.world.setBlockToAir(coordsBlock); - StackUtil.addAll(this.inv, drops, false); - this.storage.extractEnergyInternal(ENERGY_USE, false); - this.markDirty(); - } - } - } - } - } - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !automation; - } - - public int getEnergyScaled(int i) { - return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored(); - } - - @Override - public boolean isRedstoneToggle() { - return true; - } - - @Override - public void activateOnPulse() { - this.doWork(); - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.storage; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java deleted file mode 100644 index 6057499b4..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This file ("TileEntityDisplayStand.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.api.misc.IDisplayStandItem; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.energy.IEnergyStorage; - -public class TileEntityDisplayStand extends TileEntityInventoryBase implements IEnergyDisplay { - - public final CustomEnergyStorage storage = new CustomEnergyStorage(80000, 1000, 0); - private int oldEnergy; - - public TileEntityDisplayStand() { - super(1, "displayStand"); - } - - @Override - public void updateEntity() { - super.updateEntity(); - - 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) { - 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)) { - this.storage.extractEnergyInternal(energy, false); - } - } - } - } - - if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { - this.oldEnergy = this.storage.getEnergyStored(); - } - } - } - - @Override - public boolean shouldSyncSlots() { - return true; - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - this.storage.writeToNBT(compound); - } - - @Override - 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) { - Block block = Block.getBlockFromItem(item); - if (block instanceof IDisplayStandItem) { return (IDisplayStandItem) block; } - } - return null; - } - - @Override - public CustomEnergyStorage getEnergyStorage() { - return this.storage; - } - - @Override - public boolean needsHoldShift() { - return false; - } - - @Override - public int getMaxStackSize(int slot) { - return 1; - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.storage; - } - - public ItemStack getStack() { - return this.inv.getStackInSlot(0); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java deleted file mode 100644 index e7cb15f6b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * This file ("TileEntityDropper.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -public class TileEntityDropper extends TileEntityInventoryBase { - - private int currentTime; - - public TileEntityDropper() { - super(9, "dropper"); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("CurrentTime", this.currentTime); - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - this.currentTime = compound.getInteger("CurrentTime"); - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - if (!this.isRedstonePowered && !this.isPulseMode) { - if (this.currentTime > 0) { - this.currentTime--; - if (this.currentTime <= 0) { - this.doWork(); - } - } else { - this.currentTime = 5; - } - } - } - } - - private void doWork() { - ItemStack theoreticalRemove = this.removeFromInventory(false); - if (StackUtil.isValid(theoreticalRemove)) { - IBlockState state = this.world.getBlockState(this.pos); - ItemStack drop = theoreticalRemove.copy(); - drop.setCount(1); - WorldUtil.dropItemAtSide(WorldUtil.getDirectionByPistonRotation(state), this.world, this.pos, drop); - this.removeFromInventory(true); - } - } - - 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) { - this.inv.setStackInSlot(i, StackUtil.shrink(this.inv.getStackInSlot(i), 1)); - this.markDirty(); - } - return slot; - } - } - return StackUtil.getEmpty(); - } - - @Override - public boolean isRedstoneToggle() { - return true; - } - - @Override - public void activateOnPulse() { - this.doWork(); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEmpowerer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEmpowerer.java deleted file mode 100644 index 2c9d1144f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEmpowerer.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * This file ("TileEntityEmpowerer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nullable; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumParticleTypes; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldServer; - -public class TileEntityEmpowerer extends TileEntityInventoryBase { - - public int processTime; - public int recipeForRenderIndex = -1; - private int lastRecipe; - - public TileEntityEmpowerer() { - super(1, "empowerer"); - } - - @Deprecated //Use findMatchingRecipe - public static List getRecipesForInput(ItemStack input) { - List recipesThatWork = new ArrayList<>(); - if (StackUtil.isValid(input)) { - for (EmpowererRecipe recipe : ActuallyAdditionsAPI.EMPOWERER_RECIPES) { - if (recipe.getInput().apply(input)) { - recipesThatWork.add(recipe); - } - } - } - return recipesThatWork; - } - - public static boolean isPossibleInput(ItemStack stack) { - for (EmpowererRecipe r : ActuallyAdditionsAPI.EMPOWERER_RECIPES) - if (r.getInput().apply(stack)) return true; - return false; - } - - @Nullable - public static EmpowererRecipe findMatchingRecipe(ItemStack base, ItemStack stand1, ItemStack stand2, ItemStack stand3, ItemStack stand4) { - for (EmpowererRecipe r : ActuallyAdditionsAPI.EMPOWERER_RECIPES) { - if (r.matches(base, stand1, stand2, stand3, stand4)) return r; - } - return null; - } - - @Override - public void updateEntity() { - super.updateEntity(); - - if (!this.world.isRemote) { - TileEntityDisplayStand[] stands = this.getNearbyStands(); - if (stands != null) { - EmpowererRecipe recipe = findMatchingRecipe(this.inv.getStackInSlot(0), stands[0].getStack(), stands[1].getStack(), stands[2].getStack(), stands[3].getStack()); - if (recipe != null) { - this.recipeForRenderIndex = ActuallyAdditionsAPI.EMPOWERER_RECIPES.indexOf(recipe); - - boolean hasPower = true; - - for (TileEntityDisplayStand stand : stands) { - if (stand.storage.getEnergyStored() < recipe.getEnergyPerStand() / recipe.getTime()) hasPower = false; - } - - if (hasPower) { - - this.processTime++; - boolean done = this.processTime >= recipe.getTime(); - - for (TileEntityDisplayStand stand : stands) { - stand.storage.extractEnergyInternal(recipe.getEnergyPerStand() / recipe.getTime(), false); - - if (done) { - stand.inv.getStackInSlot(0).shrink(1); - stand.markDirty(); - } - } - - if (this.processTime % 5 == 0 && this.world instanceof WorldServer) { - ((WorldServer) this.world).spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, false, this.pos.getX() + 0.5, this.pos.getY() + 1.1, this.pos.getZ() + 0.5, 2, 0, 0, 0, 0.1D); - } - - if (done) { - ((WorldServer) this.world).spawnParticle(EnumParticleTypes.END_ROD, false, this.pos.getX() + 0.5, this.pos.getY() + 1.1, this.pos.getZ() + 0.5, 100, 0, 0, 0, 0.25D); - - this.inv.setStackInSlot(0, recipe.getOutput().copy()); - this.markDirty(); - - this.processTime = 0; - this.recipeForRenderIndex = -1; - } - } - } else { - this.processTime = 0; - this.recipeForRenderIndex = -1; - } - - if (this.lastRecipe != this.recipeForRenderIndex) { - this.lastRecipe = this.recipeForRenderIndex; - this.sendUpdate(); - } - } - } - } - - private TileEntityDisplayStand[] getNearbyStands() { - TileEntityDisplayStand[] stands = new TileEntityDisplayStand[4]; - - for (int i = 0; i < EnumFacing.HORIZONTALS.length; i++) { - EnumFacing facing = EnumFacing.HORIZONTALS[i]; - BlockPos offset = this.pos.offset(facing, 3); - TileEntity tile = this.world.getTileEntity(offset); - if (tile instanceof TileEntityDisplayStand) stands[i] = (TileEntityDisplayStand) tile; - else return null; - } - - return stands; - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - if (type == NBTType.SAVE_TILE) { - compound.setInteger("ProcessTime", this.processTime); - } - if (type == NBTType.SYNC) { - compound.setInteger("RenderIndex", this.recipeForRenderIndex); - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - if (type == NBTType.SAVE_TILE) { - this.processTime = compound.getInteger("ProcessTime"); - } - if (type == NBTType.SYNC) { - this.recipeForRenderIndex = compound.getInteger("RenderIndex"); - } - } - - @Override - public boolean shouldSyncSlots() { - return true; - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !automation || isPossibleInput(stack); - } - - @Override - public IRemover getRemover() { - return (slot, automation) -> !automation || !isPossibleInput(this.inv.getStackInSlot(0)); - } - - @Override - public int getMaxStackSize(int slot) { - return 1; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnergizer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnergizer.java deleted file mode 100644 index af2afe57e..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnergizer.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * This file ("TileEntityEnergizer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.energy.CapabilityEnergy; -import net.minecraftforge.energy.IEnergyStorage; - -public class TileEntityEnergizer extends TileEntityInventoryBase { - - public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 1000, 0); - private int lastEnergy; - - public TileEntityEnergizer() { - super(2, "energizer"); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - this.storage.writeToNBT(compound); - super.writeSyncableNBT(compound, type); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - this.storage.readFromNBT(compound); - super.readSyncableNBT(compound, type); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - if (StackUtil.isValid(this.inv.getStackInSlot(0)) && !StackUtil.isValid(this.inv.getStackInSlot(1))) { - if (this.storage.getEnergyStored() > 0) { - int received = 0; - boolean canTakeUp = false; - - if (this.inv.getStackInSlot(0).hasCapability(CapabilityEnergy.ENERGY, null)) { - IEnergyStorage cap = this.inv.getStackInSlot(0).getCapability(CapabilityEnergy.ENERGY, null); - if (cap != null) { - received = cap.receiveEnergy(this.storage.getEnergyStored(), false); - canTakeUp = cap.getEnergyStored() >= cap.getMaxEnergyStored(); - } - } - if (received > 0) { - this.storage.extractEnergyInternal(received, false); - } - - if (canTakeUp) { - this.inv.setStackInSlot(1, this.inv.getStackInSlot(0).copy()); - this.inv.setStackInSlot(0, StackUtil.shrink(this.inv.getStackInSlot(0), 1)); - } - } - } - - if (this.lastEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { - this.lastEnergy = this.storage.getEnergyStored(); - } - } - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !automation || slot == 0 && stack.hasCapability(CapabilityEnergy.ENERGY, null); - } - - @Override - public IRemover getRemover() { - return (slot, automation) -> !EnchantmentHelper.hasBindingCurse(this.inv.getStackInSlot(slot)) && !automation || slot == 1; - } - - public int getEnergyScaled(int i) { - return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored(); - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.storage; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnervator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnervator.java deleted file mode 100644 index dee07658c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnervator.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * This file ("TileEntityEnervator.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.energy.CapabilityEnergy; -import net.minecraftforge.energy.IEnergyStorage; - -public class TileEntityEnervator extends TileEntityInventoryBase implements ISharingEnergyProvider { - - public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 0, 1000); - private int lastEnergy; - - public TileEntityEnervator() { - super(2, "enervator"); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - this.storage.writeToNBT(compound); - super.writeSyncableNBT(compound, type); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - this.storage.readFromNBT(compound); - super.readSyncableNBT(compound, type); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - if (StackUtil.isValid(this.inv.getStackInSlot(0)) && !StackUtil.isValid(this.inv.getStackInSlot(1))) { - if (this.storage.getEnergyStored() < this.storage.getMaxEnergyStored()) { - int extracted = 0; - boolean canTakeUp = false; - - int maxExtract = this.storage.getMaxEnergyStored() - this.storage.getEnergyStored(); - if (this.inv.getStackInSlot(0).hasCapability(CapabilityEnergy.ENERGY, null)) { - IEnergyStorage cap = this.inv.getStackInSlot(0).getCapability(CapabilityEnergy.ENERGY, null); - if (cap != null) { - extracted = cap.extractEnergy(maxExtract, false); - canTakeUp = cap.getEnergyStored() <= 0; - } - } - if (extracted > 0) { - this.storage.receiveEnergyInternal(extracted, false); - } - - if (canTakeUp) { - this.inv.setStackInSlot(1, this.inv.getStackInSlot(0).copy()); - this.inv.getStackInSlot(0).shrink(1); - } - } - } - - if (this.lastEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { - this.lastEnergy = this.storage.getEnergyStored(); - } - } - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !automation || slot == 0 && stack.hasCapability(CapabilityEnergy.ENERGY, null); - } - - @Override - public IRemover getRemover() { - return (slot, automation) -> !automation || slot == 1; - } - - public int getEnergyScaled(int i) { - return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored(); - } - - @Override - public int getEnergyToSplitShare() { - return this.storage.getEnergyStored(); - } - - @Override - public boolean doesShareEnergy() { - return true; - } - - @Override - public EnumFacing[] getEnergyShareSides() { - return EnumFacing.values(); - } - - @Override - public boolean canShareTo(TileEntity tile) { - return true; - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.storage; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java deleted file mode 100644 index 961e9b8e5..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * This file ("TileEntityFarmer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -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.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import net.minecraft.block.BlockHorizontal; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.energy.IEnergyStorage; - -public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer { - - private static final List SORTED_FARMER_BEHAVIORS = new ArrayList<>(); - public final CustomEnergyStorage storage = new CustomEnergyStorage(100000, 1000, 0); - - private int waitTime; - private int checkX; - private int checkY; - - private int lastEnergy; - - public TileEntityFarmer() { - super(12, "farmer"); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("WaitTime", this.waitTime); - } - if (type == NBTType.SAVE_TILE) { - compound.setInteger("CheckX", this.checkX); - compound.setInteger("CheckY", this.checkY); - } - this.storage.writeToNBT(compound); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - this.waitTime = compound.getInteger("WaitTime"); - } - if (type == NBTType.SAVE_TILE) { - this.checkX = compound.getInteger("CheckX"); - this.checkY = compound.getInteger("CheckY"); - } - this.storage.readFromNBT(compound); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - if (!this.isRedstonePowered && this.storage.getEnergyStored() > 0) { - if (this.waitTime > 0) { - this.waitTime--; - - if (this.waitTime <= 0) { - int area = ConfigIntValues.FARMER_AREA.getValue(); - if (area % 2 == 0) area++; - int radius = area / 2; - - IBlockState state = this.world.getBlockState(this.pos); - BlockPos center = this.pos.offset(state.getValue(BlockHorizontal.FACING), radius + 1); - - BlockPos query = center.add(this.checkX, 0, this.checkY); - this.checkBehaviors(query); - - this.checkX++; - if (this.checkX > radius) { - this.checkX = -radius; - this.checkY++; - if (this.checkY > radius) { - this.checkY = -radius; - } - } - } - } else { - this.waitTime = 5; - } - } - - if (this.lastEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { - this.lastEnergy = this.storage.getEnergyStored(); - } - } - } - - private static boolean sorted = false; - - private static void sort() { - SORTED_FARMER_BEHAVIORS.clear(); - SORTED_FARMER_BEHAVIORS.addAll(ActuallyAdditionsAPI.FARMER_BEHAVIORS); - Collections.sort(SORTED_FARMER_BEHAVIORS, (b1, b2) -> b2.getPrioInt().compareTo(b1.getPrioInt())); - } - - private void checkBehaviors(BlockPos query) { - - if (!sorted) sort(); - - for (IFarmerBehavior behavior : SORTED_FARMER_BEHAVIORS) { - FarmerResult harvestResult = behavior.tryHarvestPlant(this.world, query, this); - if (harvestResult == FarmerResult.STOP_PROCESSING) return; - for (int i = 0; i < 6; i++) { //Process seed slots only - ItemStack stack = this.inv.getStackInSlot(i); - IBlockState state = this.world.getBlockState(query); - if (StackUtil.isValid(stack) && state.getBlock().isReplaceable(this.world, query)) { - FarmerResult plantResult = behavior.tryPlantSeed(stack, this.world, query, this); - if (plantResult == FarmerResult.SUCCESS) { - this.inv.getStackInSlot(i).shrink(1); - return; - } else if (plantResult == FarmerResult.STOP_PROCESSING) return; - } - } - - } - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !automation || slot < 6; - } - - @Override - public IRemover getRemover() { - return (slot, automation) -> !automation || slot >= 6; - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.storage; - } - - @Override - public EnumFacing getOrientation() { - IBlockState state = this.world.getBlockState(this.pos); - return WorldUtil.getDirectionByPistonRotation(state); - } - - @Override - public BlockPos getPosition() { - return this.pos; - } - - @Override - public int getX() { - return this.pos.getX(); - } - - @Override - public int getY() { - return this.pos.getY(); - } - - @Override - public int getZ() { - return this.pos.getZ(); - } - - @Override - public World getWorldObject() { - return this.world; - } - - @Override - public void extractEnergy(int amount) { - this.storage.extractEnergyInternal(amount, false); - } - - @Override - public int getEnergy() { - return this.storage.getEnergyStored(); - } - - @Override - public boolean canAddToSeeds(List stacks) { - return StackUtil.canAddAll(this.inv, stacks, 0, 6, false); - } - - @Override - public boolean canAddToOutput(List stacks) { - return StackUtil.canAddAll(this.inv, stacks, 6, 12, false); - } - - @Override - public void addToSeeds(List stacks) { - StackUtil.addAll(this.inv, stacks, 0, 6, false); - } - - @Override - public void addToOutput(List stacks) { - StackUtil.addAll(this.inv, stacks, 6, 12, false); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java deleted file mode 100644 index b43499b00..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * This file ("TileEntityFeeder.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import java.util.List; -import java.util.Optional; - -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; -import net.minecraft.entity.passive.EntityAnimal; -import net.minecraft.entity.passive.EntityHorse; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumParticleTypes; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.MathHelper; - -public class TileEntityFeeder extends TileEntityInventoryBase { - - public static final int THRESHOLD = 30; - private static final int TIME = 100; - public int currentTimer; - public int currentAnimalAmount; - private int lastAnimalAmount; - private int lastTimer; - - public TileEntityFeeder() { - super(1, "feeder"); - } - - public int getCurrentTimerToScale(int i) { - return this.currentTimer * i / TIME; - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - compound.setInteger("Timer", this.currentTimer); - if (type == NBTType.SYNC) { - compound.setInteger("Animals", this.currentAnimalAmount); - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - this.currentTimer = compound.getInteger("Timer"); - if (type == NBTType.SYNC) { - this.currentAnimalAmount = compound.getInteger("Animals"); - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - this.currentTimer = MathHelper.clamp(++this.currentTimer, 0, 100); - if (this.world.isRemote) return; - int range = 5; - ItemStack stack = this.inv.getStackInSlot(0); - if (!stack.isEmpty() && this.currentTimer >= TIME) { - List animals = this.world.getEntitiesWithinAABB(EntityAnimal.class, new AxisAlignedBB(this.pos.getX() - range, this.pos.getY() - range, this.pos.getZ() - range, this.pos.getX() + range, this.pos.getY() + range, this.pos.getZ() + range)); - this.currentAnimalAmount = animals.size(); - if (this.currentAnimalAmount >= 2 && this.currentAnimalAmount < THRESHOLD) { - Optional opt = animals.stream().filter((e) -> canBeFed(stack, e)).findAny(); - if (opt.isPresent()) { - feedAnimal(opt.get()); - stack.shrink(1); - this.currentTimer = 0; - this.markDirty(); - } - } - } - if ((this.lastAnimalAmount != this.currentAnimalAmount || this.lastTimer != this.currentTimer) && this.sendUpdateWithInterval()) { - this.lastAnimalAmount = this.currentAnimalAmount; - this.lastTimer = this.currentTimer; - } - } - - @Override - public IRemover getRemover() { - return (slot, automation) -> !automation; - } - - private static void feedAnimal(EntityAnimal animal) { - animal.setInLove(null); - for (int i = 0; i < 7; i++) { - double d = animal.world.rand.nextGaussian() * 0.02D; - double d1 = animal.world.rand.nextGaussian() * 0.02D; - double d2 = animal.world.rand.nextGaussian() * 0.02D; - animal.world.spawnParticle(EnumParticleTypes.HEART, animal.posX + animal.world.rand.nextFloat() * animal.width * 2.0F - animal.width, animal.posY + 0.5D + animal.world.rand.nextFloat() * animal.height, animal.posZ + animal.world.rand.nextFloat() * animal.width * 2.0F - animal.width, d, d1, d2); - } - } - - private static boolean canBeFed(ItemStack stack, EntityAnimal animal) { - if (animal instanceof EntityHorse && ((EntityHorse) animal).isTame()) { - Item item = stack.getItem(); - return animal.getGrowingAge() == 0 && !animal.isInLove() && (item == Items.GOLDEN_APPLE || item == Items.GOLDEN_CARROT); - } - return animal.getGrowingAge() == 0 && !animal.isInLove() && animal.isBreedingItem(stack); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java deleted file mode 100644 index 2827558f0..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * This file ("TileEntityFermentingBarrel.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; -import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; -import net.minecraftforge.fluids.capability.IFluidHandler; -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 { - - private static final int PROCESS_TIME = 100; - public final FluidTank canolaTank = new FluidTank(2 * Util.BUCKET) { - @Override - public boolean canDrain() { - return false; - } - - @Override - public boolean canFillFluidType(FluidStack fluid) { - return fluid.getFluid() == InitFluids.fluidCanolaOil; - } - }; - public final FluidTank oilTank = new FluidTank(2 * Util.BUCKET) { - @Override - public boolean canFill() { - return false; - } - }; - private final FluidHandlerFluidMap handlerMap; - - public int currentProcessTime; - private int lastCanola; - private int lastOil; - private int lastProcessTime; - private int lastCompare; - - public TileEntityFermentingBarrel() { - super("fermentingBarrel"); - - this.handlerMap = new FluidHandlerFluidMap(); - this.handlerMap.addHandler(InitFluids.fluidCanolaOil, this.canolaTank); - this.handlerMap.addHandler(InitFluids.fluidRefinedCanolaOil, this.oilTank); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - compound.setInteger("ProcessTime", this.currentProcessTime); - this.canolaTank.writeToNBT(compound); - NBTTagCompound tag = new NBTTagCompound(); - this.oilTank.writeToNBT(tag); - compound.setTag("OilTank", tag); - super.writeSyncableNBT(compound, type); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - this.currentProcessTime = compound.getInteger("ProcessTime"); - this.canolaTank.readFromNBT(compound); - NBTTagCompound tag = compound.getCompoundTag("OilTank"); - if (tag != null) { - this.oilTank.readFromNBT(tag); - } - super.readSyncableNBT(compound, type); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - int produce = 80; - if (this.canolaTank.getFluidAmount() >= produce && produce <= this.oilTank.getCapacity() - this.oilTank.getFluidAmount()) { - this.currentProcessTime++; - if (this.currentProcessTime >= PROCESS_TIME) { - this.currentProcessTime = 0; - - this.oilTank.fillInternal(new FluidStack(InitFluids.fluidRefinedCanolaOil, produce), true); - this.canolaTank.drainInternal(produce, true); - } - } else { - this.currentProcessTime = 0; - } - - int compare = this.getComparatorStrength(); - 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()) { - this.lastProcessTime = this.currentProcessTime; - this.lastCanola = this.canolaTank.getFluidAmount(); - this.lastOil = this.oilTank.getFluidAmount(); - } - } - } - - @Override - 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; - } - - @SideOnly(Side.CLIENT) - 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(); - } - - @Override - public IFluidHandler getFluidHandler(EnumFacing facing) { - return this.handlerMap; - } - - @Override - public int getMaxFluidAmountToSplitShare() { - return this.oilTank.getFluidAmount(); - } - - @Override - public boolean doesShareFluid() { - return true; - } - - @Override - 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 deleted file mode 100644 index 6593f1158..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java +++ /dev/null @@ -1,286 +0,0 @@ -/* - * This file ("TileEntityFireworkBox.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.init.Items; -import net.minecraft.item.ItemDye; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.WeightedRandom; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; -import net.minecraftforge.energy.IEnergyStorage; - -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); - public int intValuePlay = 2; - public int chargeAmount = 2; - public int flightTime = 2; - public float trailOrFlickerChance = 0.65F; - public float flickerChance = 0.25F; - public int colorAmount = 3; - public float typeChance0 = 1F; - public float typeChance1 = 0F; - public float typeChance2 = 0F; - public float typeChance3 = 0F; - public float typeChance4 = 0F; - public int areaOfEffect = 2; - private int timeUntilNextFirework; - private int oldEnergy; - - public TileEntityFireworkBox() { - super("fireworkBox"); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - this.storage.writeToNBT(compound); - - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("Play", this.intValuePlay); - compound.setInteger("ChargeAmount", this.chargeAmount); - compound.setInteger("FlightTime", this.flightTime); - compound.setFloat("TrailFlickerChance", this.trailOrFlickerChance); - compound.setFloat("FlickerChance", this.flickerChance); - compound.setInteger("ColorAmount", this.colorAmount); - compound.setFloat("TypeChance0", this.typeChance0); - compound.setFloat("TypeChance1", this.typeChance1); - compound.setFloat("TypeChance2", this.typeChance2); - compound.setFloat("TypeChance3", this.typeChance3); - compound.setFloat("TypeChance4", this.typeChance4); - compound.setInteger("Area", this.areaOfEffect); - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - this.storage.readFromNBT(compound); - - if (type != NBTType.SAVE_BLOCK) { - this.intValuePlay = compound.getInteger("Play"); - this.chargeAmount = compound.getInteger("ChargeAmount"); - this.flightTime = compound.getInteger("FlightTime"); - this.trailOrFlickerChance = compound.getFloat("TrailFlickerChance"); - this.flickerChance = compound.getFloat("FlickerChance"); - this.colorAmount = compound.getInteger("ColorAmount"); - this.typeChance0 = compound.getFloat("TypeChance0"); - this.typeChance1 = compound.getFloat("TypeChance1"); - this.typeChance2 = compound.getFloat("TypeChance2"); - this.typeChance3 = compound.getFloat("TypeChance3"); - this.typeChance4 = compound.getFloat("TypeChance4"); - this.areaOfEffect = compound.getInteger("Area"); - } - } - - @Override - public void onNumberReceived(double number, int id, EntityPlayer player) { - switch (id) { - case 0: - this.intValuePlay = (int) number; - break; - case 1: - this.chargeAmount = (int) number; - break; - case 2: - this.flightTime = (int) number; - break; - case 3: - this.trailOrFlickerChance = (float) number; - break; - case 4: - this.flickerChance = (float) number; - break; - case 5: - this.colorAmount = (int) number; - break; - case 6: - this.typeChance0 = (float) number; - break; - case 7: - this.typeChance1 = (float) number; - break; - case 8: - this.typeChance2 = (float) number; - break; - case 9: - this.typeChance3 = (float) number; - break; - case 10: - this.typeChance4 = (float) number; - break; - case 11: - this.areaOfEffect = (int) number; - break; - } - - this.sendUpdate(); - } - - 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(); - - 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) { - return 0.5; - } else { - return MathHelper.nextDouble(this.world.rand, 0, this.areaOfEffect * 2) - this.areaOfEffect; - } - } - - private ItemStack makeFirework() { - NBTTagList list = new NBTTagList(); - 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)); - - NBTTagCompound compound = new NBTTagCompound(); - compound.setTag("Fireworks", compound1); - - ItemStack firework = new ItemStack(Items.FIREWORKS); - firework.setTagCompound(compound); - - return firework; - } - - private NBTTagCompound makeFireworkCharge() { - NBTTagCompound compound = new NBTTagCompound(); - - if (this.world.rand.nextFloat() <= this.trailOrFlickerChance) { - if (this.world.rand.nextFloat() <= this.flickerChance) { - compound.setBoolean("Flicker", true); - } else { - compound.setBoolean("Trail", true); - } - } - - int[] colors = new int[this.getRandomWithPlay(this.colorAmount)]; - 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()); - - 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 getRandomType() { - List possible = new ArrayList<>(); - - possible.add(new WeightedFireworkType(0, this.typeChance0)); - possible.add(new WeightedFireworkType(1, this.typeChance1)); - possible.add(new WeightedFireworkType(2, this.typeChance2)); - possible.add(new WeightedFireworkType(3, this.typeChance3)); - possible.add(new WeightedFireworkType(4, this.typeChance4)); - - int weight = WeightedRandom.getTotalWeight(possible); - if (weight <= 0) { - return 0; - } else { - return WeightedRandom.getRandomItem(this.world.rand, possible, weight).type; - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - - if (!this.world.isRemote) { - if (!this.isRedstonePowered && !this.isPulseMode) { - if (this.timeUntilNextFirework > 0) { - this.timeUntilNextFirework--; - if (this.timeUntilNextFirework <= 0) { - this.doWork(); - } - } else { - this.timeUntilNextFirework = 100; - } - } - - if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { - this.oldEnergy = this.storage.getEnergyStored(); - } - } - } - - 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); - } - } - - @Override - public boolean isRedstoneToggle() { - return true; - } - - @Override - public void activateOnPulse() { - this.doWork(); - } - - @Override - public CustomEnergyStorage getEnergyStorage() { - return this.storage; - } - - @Override - public boolean needsHoldShift() { - return false; - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.storage; - } - - private static class WeightedFireworkType extends WeightedRandom.Item { - - public final int type; - - 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 deleted file mode 100644 index 27d060cf3..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFishingNet.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * This file ("TileEntityFishingNet.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.world.WorldServer; -import net.minecraft.world.storage.loot.LootContext; -import net.minecraft.world.storage.loot.LootTableList; -import net.minecraftforge.items.CapabilityItemHandler; -import net.minecraftforge.items.IItemHandler; - -public class TileEntityFishingNet extends TileEntityBase { - - public int timeUntilNextDrop; - - public TileEntityFishingNet() { - super("fishingNet"); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("TimeUntilNextDrop", this.timeUntilNextDrop); - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - this.timeUntilNextDrop = compound.getInteger("TimeUntilNextDrop"); - } - } - - @Override - 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) { - this.timeUntilNextDrop--; - 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) { - 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()); - item.lifespan = 2000; - this.world.spawnEntity(item); - } - } - } - } else { - int time = 15000; - this.timeUntilNextDrop = time + this.world.rand.nextInt(time / 2); - } - } - } - } - } - - 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())) { - IItemHandler cap = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite()); - if (cap != null) { - for (int i = 0; i < cap.getSlots(); i++) { - stack = cap.insertItem(i, stack, false); - - if (!StackUtil.isValid(stack)) { return StackUtil.getEmpty(); } - } - } - } - } - } - return stack; - } - - @Override - 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 deleted file mode 100644 index 47edf2a6f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * This file ("TileEntityFluidCollector.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.util.Util; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import net.minecraft.block.Block; -import net.minecraft.block.BlockLiquid; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.init.SoundEvents; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumParticleTypes; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldServer; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; -import net.minecraftforge.fluids.IFluidBlock; -import net.minecraftforge.fluids.capability.IFluidHandler; - -public class TileEntityFluidCollector extends TileEntityBase implements ISharingFluidHandler { - - public boolean isPlacer; - public final FluidTank tank = new FluidTank(8 * Util.BUCKET) { - @Override - public boolean canFill() { - return TileEntityFluidCollector.this.isPlacer; - } - - @Override - public boolean canDrain() { - return !TileEntityFluidCollector.this.isPlacer; - } - }; - private int lastTankAmount; - private int currentTime; - private int lastCompare; - - public TileEntityFluidCollector(String name) { - super(name); - } - - public TileEntityFluidCollector() { - this("fluidCollector"); - this.isPlacer = false; - } - - @Override - public boolean isRedstoneToggle() { - return true; - } - - @Override - public void activateOnPulse() { - this.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); - 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) { - 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) { - 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) { - FluidStack stack = this.tank.getFluid(); - Block fluid = stack.getFluid().getBlock(); - if (fluid != null) { - BlockPos offsetPos = this.pos.offset(sideToManipulate); - boolean placeable = !(blockToBreak instanceof BlockLiquid) && !(blockToBreak instanceof IFluidBlock) && blockToBreak.isReplaceable(this.world, offsetPos); - 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 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 { - this.world.setBlockState(offsetPos, fluid.getDefaultState(), 3); - } - } - } - } - } - } - - @Override - public int getComparatorStrength() { - float calc = (float) this.tank.getFluidAmount() / (float) this.tank.getCapacity() * 15F; - return (int) calc; - } - - @Override - public IFluidHandler getFluidHandler(EnumFacing facing) { - return this.tank; - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("CurrentTime", this.currentTime); - } - this.tank.writeToNBT(compound); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - this.currentTime = compound.getInteger("CurrentTime"); - } - this.tank.readFromNBT(compound); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - if (!this.isRedstonePowered && !this.isPulseMode) { - if (this.currentTime > 0) { - this.currentTime--; - if (this.currentTime <= 0) { - this.doWork(); - } - } else { - this.currentTime = 15; - } - } - - if (this.lastCompare != this.getComparatorStrength()) { - this.lastCompare = this.getComparatorStrength(); - - this.markDirty(); - } - - if (this.lastTankAmount != this.tank.getFluidAmount() && this.sendUpdateWithInterval()) { - this.lastTankAmount = this.tank.getFluidAmount(); - } - } - } - - @Override - public int getMaxFluidAmountToSplitShare() { - return this.tank.getFluidAmount(); - } - - @Override - public boolean doesShareFluid() { - return !this.isPlacer; - } - - @Override - 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 deleted file mode 100644 index e579674c2..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidPlacer.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * This file ("TileEntityFluidPlacer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -public class TileEntityFluidPlacer extends TileEntityFluidCollector { - - public TileEntityFluidPlacer() { - super("fluidPlacer"); - this.isPlacer = true; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceDouble.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceDouble.java deleted file mode 100644 index 3e55daa21..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceDouble.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * This file ("TileEntityFurnaceDouble.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.blocks.BlockFurnaceDouble; -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.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.FurnaceRecipes; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.energy.IEnergyStorage; - -public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements IButtonReactor { - - public static final int SLOT_INPUT_1 = 0; - public static final int SLOT_OUTPUT_1 = 1; - public static final int SLOT_INPUT_2 = 2; - public static final int SLOT_OUTPUT_2 = 3; - public static final int ENERGY_USE = 25; - private static final int SMELT_TIME = 80; - public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 150, 0); - public int firstSmeltTime; - public int secondSmeltTime; - public boolean isAutoSplit; - private int lastEnergy; - private int lastFirstSmelt; - private int lastSecondSmelt; - private boolean lastAutoSplit; - private boolean lastSmelted; - - public TileEntityFurnaceDouble() { - super(4, "furnaceDouble"); - } - - public static void autoSplit(ItemStackHandlerAA inv, int slot1, int slot2) { - ItemStack first = inv.getStackInSlot(slot1); - ItemStack second = inv.getStackInSlot(slot2); - - if (StackUtil.isValid(first) || StackUtil.isValid(second)) { - ItemStack toSplit = StackUtil.getEmpty(); - if (!StackUtil.isValid(first) && StackUtil.isValid(second) && second.getCount() > 1) { - toSplit = second; - } else if (!StackUtil.isValid(second) && StackUtil.isValid(first) && first.getCount() > 1) { - toSplit = first; - } else if (ItemUtil.canBeStacked(first, second)) { - if (first.getCount() < first.getMaxStackSize() || second.getCount() < second.getMaxStackSize()) { - if (!(first.getCount() <= second.getCount() + 1 && first.getCount() >= second.getCount() - 1 || second.getCount() <= first.getCount() + 1 && second.getCount() >= first.getCount() - 1)) { - toSplit = first; - toSplit.grow(second.getCount()); - } - } - } - - if (StackUtil.isValid(toSplit)) { - ItemStack splitFirst = toSplit.copy(); - ItemStack secondSplit = splitFirst.splitStack(splitFirst.getCount() / 2); - inv.setStackInSlot(slot1, splitFirst); - inv.setStackInSlot(slot2, secondSplit); - } - } - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("FirstSmeltTime", this.firstSmeltTime); - compound.setInteger("SecondSmeltTime", this.secondSmeltTime); - compound.setBoolean("IsAutoSplit", this.isAutoSplit); - } - this.storage.writeToNBT(compound); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - this.firstSmeltTime = compound.getInteger("FirstSmeltTime"); - this.secondSmeltTime = compound.getInteger("SecondSmeltTime"); - this.isAutoSplit = compound.getBoolean("IsAutoSplit"); - } - this.storage.readFromNBT(compound); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - if (this.isAutoSplit) { - autoSplit(this.inv, SLOT_INPUT_1, SLOT_INPUT_2); - } - - boolean smelted = false; - - boolean canSmeltOnFirst = this.canSmeltOn(SLOT_INPUT_1, SLOT_OUTPUT_1); - boolean canSmeltOnSecond = this.canSmeltOn(SLOT_INPUT_2, SLOT_OUTPUT_2); - - if (canSmeltOnFirst) { - if (this.storage.getEnergyStored() >= ENERGY_USE) { - this.firstSmeltTime++; - if (this.firstSmeltTime >= SMELT_TIME) { - this.finishBurning(SLOT_INPUT_1, SLOT_OUTPUT_1); - this.firstSmeltTime = 0; - } - this.storage.extractEnergyInternal(ENERGY_USE, false); - } - smelted = true; - } else { - this.firstSmeltTime = 0; - } - - if (canSmeltOnSecond) { - if (this.storage.getEnergyStored() >= ENERGY_USE) { - this.secondSmeltTime++; - if (this.secondSmeltTime >= SMELT_TIME) { - this.finishBurning(SLOT_INPUT_2, SLOT_OUTPUT_2); - this.secondSmeltTime = 0; - } - this.storage.extractEnergyInternal(ENERGY_USE, false); - } - smelted = true; - } else { - this.secondSmeltTime = 0; - } - - IBlockState currState = this.world.getBlockState(this.pos); - boolean current = currState.getValue(BlockFurnaceDouble.IS_ON); - boolean changeTo = current; - if (lastSmelted != smelted) changeTo = smelted; - if (this.isRedstonePowered) changeTo = true; - if (!smelted && !this.isRedstonePowered) changeTo = false; - - if (changeTo != current) { - world.setBlockState(this.pos, currState.withProperty(BlockFurnaceDouble.IS_ON, changeTo)); - } - - this.lastSmelted = smelted; - - if ((this.lastEnergy != this.storage.getEnergyStored() || this.lastFirstSmelt != this.firstSmeltTime || this.lastSecondSmelt != this.secondSmeltTime || this.isAutoSplit != this.lastAutoSplit) && this.sendUpdateWithInterval()) { - this.lastEnergy = this.storage.getEnergyStored(); - this.lastFirstSmelt = this.firstSmeltTime; - this.lastAutoSplit = this.isAutoSplit; - this.lastSecondSmelt = this.secondSmeltTime; - } - } - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !automation || (slot == SLOT_INPUT_1 || slot == SLOT_INPUT_2) && StackUtil.isValid(FurnaceRecipes.instance().getSmeltingResult(stack)); - } - - @Override - public IRemover getRemover() { - return (slot, automation) -> !automation || slot == SLOT_OUTPUT_1 || slot == SLOT_OUTPUT_2; - } - - public boolean canSmeltOn(int theInput, int theOutput) { - if (StackUtil.isValid(this.inv.getStackInSlot(theInput))) { - ItemStack output = FurnaceRecipes.instance().getSmeltingResult(this.inv.getStackInSlot(theInput)); - if (StackUtil.isValid(output)) { - if (!StackUtil.isValid(this.inv.getStackInSlot(theOutput)) || this.inv.getStackInSlot(theOutput).isItemEqual(output) && this.inv.getStackInSlot(theOutput).getCount() <= this.inv.getStackInSlot(theOutput).getMaxStackSize() - output.getCount()) { return true; } - } - - } - return false; - } - - public void finishBurning(int theInput, int theOutput) { - ItemStack output = FurnaceRecipes.instance().getSmeltingResult(this.inv.getStackInSlot(theInput)); - if (!StackUtil.isValid(this.inv.getStackInSlot(theOutput))) { - this.inv.setStackInSlot(theOutput, output.copy()); - } else if (this.inv.getStackInSlot(theOutput).getItem() == output.getItem()) { - this.inv.getStackInSlot(theOutput).grow(output.getCount()); - } - - this.inv.getStackInSlot(theInput).shrink(1); - } - - public int getFirstTimeToScale(int i) { - return this.firstSmeltTime * i / SMELT_TIME; - } - - public int getSecondTimeToScale(int i) { - return this.secondSmeltTime * i / SMELT_TIME; - } - - @Override - public void onButtonPressed(int buttonID, EntityPlayer player) { - if (buttonID == 0) { - this.isAutoSplit = !this.isAutoSplit; - this.markDirty(); - } - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.storage; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java deleted file mode 100644 index c9d572919..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * This file ("TileEntityFurnaceSolar.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -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 static final int PRODUCE = 8; - public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 0, 100); - private int oldEnergy; - - public TileEntityFurnaceSolar() { - super("solarPanel"); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - this.storage.writeToNBT(compound); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - this.storage.readFromNBT(compound); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - int power = this.getPowerToGenerate(PRODUCE); - 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()) { - 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) { - BlockPos pos = this.pos.up(y); - IBlockState state = this.world.getBlockState(pos); - - if (state.getMaterial().isOpaque()) { - power = 0; - } else if (!state.getBlock().isAir(state, this.world, pos)) { - power--; - } - } else { - break; - } - } - - return power; - } - - @Override - public CustomEnergyStorage getEnergyStorage() { - return this.storage; - } - - @Override - public boolean needsHoldShift() { - return false; - } - - @Override - public int getEnergyToSplitShare() { - return this.storage.getEnergyStored(); - } - - @Override - public boolean doesShareEnergy() { - return true; - } - - @Override - public EnumFacing[] getEnergyShareSides() { - return EnumFacing.values(); - } - - @Override - public boolean canShareTo(TileEntity tile) { - return true; - } - - @Override - 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 deleted file mode 100644 index cd9920b0b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * This file ("TileEntityGiantChest.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.util.AwfulUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.WorldServer; -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 ResourceLocation lootTable; - - public TileEntityGiantChest(int slotAmount, String name) { - super(slotAmount, name); - } - - public TileEntityGiantChest() { - this(9 * 13, "giantChest"); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - - if (this.lootTable != null) { - compound.setString("LootTable", this.lootTable.toString()); - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - - 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) { - GuiHandler.GuiTypes type; - - if (buttonID == 0) { - type = GuiHandler.GuiTypes.GIANT_CHEST; - } else if (buttonID == 1) { - type = GuiHandler.GuiTypes.GIANT_CHEST_PAGE_2; - } else { - type = GuiHandler.GuiTypes.GIANT_CHEST_PAGE_3; - } - - player.openGui(ActuallyAdditions.INSTANCE, type.ordinal(), this.world, this.pos.getX(), this.pos.getY(), this.pos.getZ()); - } - } - - @Override - public ResourceLocation getLootTable() { - return this.lootTable; - } - - 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) { - 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 deleted file mode 100644 index d1107b3bd..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestLarge.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * This file ("TileEntityGiantChestLarge.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -public class TileEntityGiantChestLarge extends TileEntityGiantChest { - - 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 deleted file mode 100644 index 4ee048b31..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGiantChestMedium.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * This file ("TileEntityGiantChestMedium.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -public class TileEntityGiantChestMedium extends TileEntityGiantChest { - - public TileEntityGiantChestMedium() { - super(9 * 13 * 2, "giantChestMedium"); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinder.java deleted file mode 100644 index 22662fec1..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinder.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * This file ("TileEntityGrinder.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; -import de.ellpeck.actuallyadditions.mod.blocks.BlockFurnaceDouble; -import de.ellpeck.actuallyadditions.mod.misc.SoundHandler; -import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; -import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.SoundCategory; -import net.minecraftforge.energy.IEnergyStorage; - -public class TileEntityGrinder extends TileEntityInventoryBase implements IButtonReactor { - - public static final int SLOT_INPUT_1 = 0; - public static final int SLOT_OUTPUT_1_1 = 1; - public static final int SLOT_OUTPUT_1_2 = 2; - public static final int SLOT_INPUT_2 = 3; - public static final int SLOT_OUTPUT_2_1 = 4; - public static final int SLOT_OUTPUT_2_2 = 5; - public static final int ENERGY_USE = 40; - public final CustomEnergyStorage storage = new CustomEnergyStorage(60000, 100, 0); - public int firstCrushTime; - public int secondCrushTime; - public boolean isDouble; - public boolean isAutoSplit; - private int lastEnergy; - private int lastFirstCrush; - private int lastSecondCrush; - private boolean lastAutoSplit; - private boolean lastCrushed; - - public TileEntityGrinder(int slots, String name) { - super(slots, name); - } - - public TileEntityGrinder() { - super(3, "grinder"); - this.isDouble = false; - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("FirstCrushTime", this.firstCrushTime); - compound.setInteger("SecondCrushTime", this.secondCrushTime); - compound.setBoolean("IsAutoSplit", this.isAutoSplit); - } - this.storage.writeToNBT(compound); - super.writeSyncableNBT(compound, type); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - if (type != NBTType.SAVE_BLOCK) { - this.firstCrushTime = compound.getInteger("FirstCrushTime"); - this.secondCrushTime = compound.getInteger("SecondCrushTime"); - this.isAutoSplit = compound.getBoolean("IsAutoSplit"); - } - this.storage.readFromNBT(compound); - super.readSyncableNBT(compound, type); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - if (this.isDouble && this.isAutoSplit) { - TileEntityFurnaceDouble.autoSplit(this.inv, SLOT_INPUT_1, SLOT_INPUT_2); - } - - boolean crushed = false; - - boolean canCrushOnFirst = this.canCrushOn(SLOT_INPUT_1, SLOT_OUTPUT_1_1, SLOT_OUTPUT_1_2); - boolean canCrushOnSecond = false; - if (this.isDouble) { - canCrushOnSecond = this.canCrushOn(SLOT_INPUT_2, SLOT_OUTPUT_2_1, SLOT_OUTPUT_2_2); - } - - boolean shouldPlaySound = false; - - if (canCrushOnFirst) { - if (this.storage.getEnergyStored() >= ENERGY_USE) { - if (this.firstCrushTime % 20 == 0) { - shouldPlaySound = true; - } - this.firstCrushTime++; - if (this.firstCrushTime >= this.getMaxCrushTime()) { - this.finishCrushing(SLOT_INPUT_1, SLOT_OUTPUT_1_1, SLOT_OUTPUT_1_2); - this.firstCrushTime = 0; - } - this.storage.extractEnergyInternal(ENERGY_USE, false); - } - crushed = this.storage.getEnergyStored() >= ENERGY_USE; - } else { - this.firstCrushTime = 0; - } - - if (this.isDouble) { - if (canCrushOnSecond) { - if (this.storage.getEnergyStored() >= ENERGY_USE) { - if (this.secondCrushTime % 20 == 0) { - shouldPlaySound = true; - } - this.secondCrushTime++; - if (this.secondCrushTime >= this.getMaxCrushTime()) { - this.finishCrushing(SLOT_INPUT_2, SLOT_OUTPUT_2_1, SLOT_OUTPUT_2_2); - this.secondCrushTime = 0; - } - this.storage.extractEnergyInternal(ENERGY_USE, false); - } - crushed = this.storage.getEnergyStored() >= ENERGY_USE; - } else { - this.secondCrushTime = 0; - } - } - - IBlockState currState = this.world.getBlockState(this.pos); - boolean current = currState.getValue(BlockFurnaceDouble.IS_ON); - boolean changeTo = current; - if (lastCrushed != crushed) changeTo = crushed; - if (this.isRedstonePowered) changeTo = true; - if (!crushed && !this.isRedstonePowered) changeTo = false; - - if (changeTo != current) { - world.setBlockState(this.pos, currState.withProperty(BlockFurnaceDouble.IS_ON, changeTo)); - } - - this.lastCrushed = crushed; - - if ((this.lastEnergy != this.storage.getEnergyStored() || this.lastFirstCrush != this.firstCrushTime || this.lastSecondCrush != this.secondCrushTime || this.isAutoSplit != this.lastAutoSplit) && this.sendUpdateWithInterval()) { - this.lastEnergy = this.storage.getEnergyStored(); - this.lastFirstCrush = this.firstCrushTime; - this.lastSecondCrush = this.secondCrushTime; - this.lastAutoSplit = this.isAutoSplit; - } - - if (shouldPlaySound) { - this.world.playSound(null, this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), SoundHandler.crusher, SoundCategory.BLOCKS, 0.025F, 1.0F); - } - } - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !automation || (slot == SLOT_INPUT_1 || slot == SLOT_INPUT_2) && CrusherRecipeRegistry.getRecipeFromInput(stack) != null; - } - - @Override - public IRemover getRemover() { - return (slot, automation) -> !automation || slot == SLOT_OUTPUT_1_1 || slot == SLOT_OUTPUT_1_2 || slot == SLOT_OUTPUT_2_1 || slot == SLOT_OUTPUT_2_2; - } - - public boolean canCrushOn(int theInput, int theFirstOutput, int theSecondOutput) { - if (StackUtil.isValid(this.inv.getStackInSlot(theInput))) { - CrusherRecipe recipe = CrusherRecipeRegistry.getRecipeFromInput(this.inv.getStackInSlot(theInput)); - if (recipe == null) return false; - ItemStack outputOne = recipe.getOutputOne(); - ItemStack outputTwo = recipe.getOutputTwo(); - if (StackUtil.isValid(outputOne)) { - if (outputOne.getItemDamage() == Util.WILDCARD) { - outputOne.setItemDamage(0); - } - if (StackUtil.isValid(outputTwo) && outputTwo.getItemDamage() == Util.WILDCARD) { - outputTwo.setItemDamage(0); - } - if ((!StackUtil.isValid(this.inv.getStackInSlot(theFirstOutput)) || this.inv.getStackInSlot(theFirstOutput).isItemEqual(outputOne) && this.inv.getStackInSlot(theFirstOutput).getCount() <= this.inv.getStackInSlot(theFirstOutput).getMaxStackSize() - outputOne.getCount()) && (!StackUtil.isValid(outputTwo) || !StackUtil.isValid(this.inv.getStackInSlot(theSecondOutput)) || this.inv.getStackInSlot(theSecondOutput).isItemEqual(outputTwo) && this.inv.getStackInSlot(theSecondOutput).getCount() <= this.inv.getStackInSlot(theSecondOutput).getMaxStackSize() - outputTwo.getCount())) { return true; } - } - } - return false; - } - - private int getMaxCrushTime() { - return this.isDouble ? 150 : 100; - } - - public void finishCrushing(int theInput, int theFirstOutput, int theSecondOutput) { - CrusherRecipe recipe = CrusherRecipeRegistry.getRecipeFromInput(this.inv.getStackInSlot(theInput)); - if (recipe == null) return; - ItemStack outputOne = recipe.getOutputOne(); - if (StackUtil.isValid(outputOne)) { - if (outputOne.getItemDamage() == Util.WILDCARD) { - outputOne.setItemDamage(0); - } - if (!StackUtil.isValid(this.inv.getStackInSlot(theFirstOutput))) { - this.inv.setStackInSlot(theFirstOutput, outputOne.copy()); - } else if (this.inv.getStackInSlot(theFirstOutput).getItem() == outputOne.getItem()) { - this.inv.setStackInSlot(theFirstOutput, StackUtil.grow(this.inv.getStackInSlot(theFirstOutput), outputOne.getCount())); - } - } - - ItemStack outputTwo = recipe.getOutputTwo(); - if (StackUtil.isValid(outputTwo)) { - if (outputTwo.getItemDamage() == Util.WILDCARD) { - outputTwo.setItemDamage(0); - } - int rand = this.world.rand.nextInt(100) + 1; - if (rand <= recipe.getSecondChance()) { - if (!StackUtil.isValid(this.inv.getStackInSlot(theSecondOutput))) { - this.inv.setStackInSlot(theSecondOutput, outputTwo.copy()); - } else if (this.inv.getStackInSlot(theSecondOutput).getItem() == outputTwo.getItem()) { - this.inv.setStackInSlot(theSecondOutput, StackUtil.grow(this.inv.getStackInSlot(theSecondOutput), outputTwo.getCount())); - } - } - } - - this.inv.getStackInSlot(theInput).shrink(1); - } - - public int getEnergyScaled(int i) { - return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored(); - } - - public int getFirstTimeToScale(int i) { - return this.firstCrushTime * i / this.getMaxCrushTime(); - } - - public int getSecondTimeToScale(int i) { - return this.secondCrushTime * i / this.getMaxCrushTime(); - } - - @Override - public void onButtonPressed(int buttonID, EntityPlayer player) { - if (buttonID == 0) { - this.isAutoSplit = !this.isAutoSplit; - this.markDirty(); - } - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.storage; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinderDouble.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinderDouble.java deleted file mode 100644 index f44310209..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinderDouble.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * This file ("TileEntityGrinderDouble.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -public class TileEntityGrinderDouble extends TileEntityGrinder { - - 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 deleted file mode 100644 index 2374fc118..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * This file ("TileEntityHeatCollector.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.energy.IEnergyStorage; - -public class TileEntityHeatCollector extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay { - - public static final int ENERGY_PRODUCE = 40; - public static final int BLOCKS_NEEDED = 4; - public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 0, 80); - private int oldEnergy; - private int disappearTime; - - public TileEntityHeatCollector() { - super("heatCollector"); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - - this.storage.writeToNBT(compound); - if (type == NBTType.SAVE_TILE) { - compound.setInteger("DisappearTime", this.disappearTime); - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - - this.storage.readFromNBT(compound); - if (type == NBTType.SAVE_TILE) { - this.disappearTime = compound.getInteger("DisappearTime"); - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - ArrayList blocksAround = new ArrayList<>(); - 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) { - blocksAround.add(i); - } - } - - if (blocksAround.size() >= BLOCKS_NEEDED) { - this.storage.receiveEnergyInternal(ENERGY_PRODUCE, false); - this.markDirty(); - - this.disappearTime++; - if (this.disappearTime >= 1000) { - this.disappearTime = 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))); - } - } - } - } - - if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { - this.oldEnergy = this.storage.getEnergyStored(); - } - } - } - - @Override - public CustomEnergyStorage getEnergyStorage() { - return this.storage; - } - - @Override - public boolean needsHoldShift() { - return false; - } - - @Override - public int getEnergyToSplitShare() { - return this.storage.getEnergyStored(); - } - - @Override - public boolean doesShareEnergy() { - return true; - } - - @Override - public EnumFacing[] getEnergyShareSides() { - return EnumFacing.values(); - } - - @Override - public boolean canShareTo(TileEntity tile) { - return true; - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.storage; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java deleted file mode 100644 index 795adc1b3..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * This file ("TileEntityInputter.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; -import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityFurnace; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.items.CapabilityItemHandler; -import net.minecraftforge.items.IItemHandler; - -public class TileEntityInputter extends TileEntityInventoryBase implements IButtonReactor, INumberReactor { - - public static final int OKAY_BUTTON_ID = 133; - private final SlotlessableItemHandlerWrapper wrapper = new SlotlessableItemHandlerWrapper(this.inv, null); - public int sideToPut = -1; - public int slotToPutStart; - public int slotToPutEnd; - public Map placeToPut = new ConcurrentHashMap<>(); - public int sideToPull = -1; - public int slotToPullStart; - public int slotToPullEnd; - public Map placeToPull = new ConcurrentHashMap<>(); - public boolean isAdvanced; - public FilterSettings leftFilter = new FilterSettings(12, true, true, false, false, 0, -1000); - public FilterSettings rightFilter = new FilterSettings(12, true, true, false, false, 0, -2000); - private int lastPutSide; - private int lastPutStart; - private int lastPutEnd; - private int lastPullSide; - private int lastPullStart; - private int lastPullEnd; - - public TileEntityInputter(int slots, String name) { - super(slots, name); - } - - public TileEntityInputter() { - super(1, "inputter"); - this.isAdvanced = false; - } - - @Override - public void onNumberReceived(double number, int textID, EntityPlayer player) { - int text = (int) number; - - if (text != -1) { - if (textID == 0) { - this.slotToPutStart = Math.max(text, 0); - } - if (textID == 1) { - this.slotToPutEnd = Math.max(text, 0); - } - - if (textID == 2) { - this.slotToPullStart = Math.max(text, 0); - } - if (textID == 3) { - this.slotToPullEnd = Math.max(text, 0); - } - } - this.markDirty(); - } - - private boolean newPulling() { - for (EnumFacing side : this.placeToPull.keySet()) { - WorldUtil.doItemInteraction(this.placeToPull.get(side), this.wrapper, Integer.MAX_VALUE, this.slotToPullStart, this.slotToPullEnd, 0, 1, !this.isAdvanced ? null : this.leftFilter); - - if (this.placeToPull instanceof TileEntityItemViewer) { - break; - } - } - return false; - } - - private boolean newPutting() { - if (!this.isAdvanced || this.rightFilter.check(this.inv.getStackInSlot(0))) { - for (EnumFacing side : this.placeToPut.keySet()) { - WorldUtil.doItemInteraction(this.wrapper, this.placeToPut.get(side), Integer.MAX_VALUE, 0, 1, this.slotToPutStart, this.slotToPutEnd, null); - - if (this.placeToPut instanceof TileEntityItemViewer) { - break; - } - } - } - return false; - } - - @Override - public boolean shouldSaveDataOnChangeOrWorldStart() { - return true; - } - - /** - * Sets all of the relevant variables - */ - @Override - public void saveDataOnChangeOrWorldStart() { - this.placeToPull.clear(); - this.placeToPut.clear(); - - if (this.sideToPull != -1) { - EnumFacing side = WorldUtil.getDirectionBySidesInOrder(this.sideToPull); - BlockPos offset = this.pos.offset(side); - - if (this.world.isBlockLoaded(offset)) { - TileEntity tile = this.world.getTileEntity(offset); - - if (tile != null) { - for (EnumFacing facing : EnumFacing.values()) { - IItemHandler normal = null; - if (tile.getClass() == TileEntityFurnace.class) normal = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - else if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)) { - normal = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing); - } - - Object slotless = null; - if (ActuallyAdditions.commonCapsLoaded) { - if (tile.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, facing)) { - slotless = tile.getCapability(SlotlessItemHandlerConfig.CAPABILITY, facing); - } - } - - this.placeToPull.put(facing.getOpposite(), new SlotlessableItemHandlerWrapper(normal, slotless)); - } - - if (this.slotToPullEnd <= 0) { - if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) { - IItemHandler cap = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - if (cap != null) { - this.slotToPullEnd = cap.getSlots(); - } - } - } - } - } - } - - if (this.sideToPut != -1) { - EnumFacing side = WorldUtil.getDirectionBySidesInOrder(this.sideToPut); - BlockPos offset = this.pos.offset(side); - - if (this.world.isBlockLoaded(offset)) { - TileEntity tile = this.world.getTileEntity(offset); - - if (tile != null) { - for (EnumFacing facing : EnumFacing.values()) { - IItemHandler normal = null; - if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)) { - normal = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing); - } - - Object slotless = null; - if (ActuallyAdditions.commonCapsLoaded) { - if (tile.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, facing)) { - slotless = tile.getCapability(SlotlessItemHandlerConfig.CAPABILITY, facing); - } - } - - this.placeToPut.put(facing.getOpposite(), new SlotlessableItemHandlerWrapper(normal, slotless)); - } - - if (this.slotToPutEnd <= 0) { - if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) { - IItemHandler cap = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - if (cap != null) { - this.slotToPutEnd = cap.getSlots(); - } - } - } - } - } - } - } - - @Override - public void onButtonPressed(int buttonID, EntityPlayer player) { - this.leftFilter.onButtonPressed(buttonID); - this.rightFilter.onButtonPressed(buttonID); - - //Reset the Slots - if (buttonID == 0 || buttonID == 1) { - this.slotToPutStart = 0; - this.slotToPutEnd = 0; - } - if (buttonID == 2 || buttonID == 3) { - this.slotToPullStart = 0; - this.slotToPullEnd = 0; - } - - if (buttonID == 0) { - this.sideToPut++; - } - if (buttonID == 1) { - this.sideToPut--; - } - - if (buttonID == 2) { - this.sideToPull++; - } - if (buttonID == 3) { - this.sideToPull--; - } - - if (this.sideToPut >= 6) { - this.sideToPut = -1; - } else if (this.sideToPut < -1) { - this.sideToPut = 5; - } else if (this.sideToPull >= 6) { - this.sideToPull = -1; - } else if (this.sideToPull < -1) { - this.sideToPull = 5; - } - - this.markDirty(); - this.saveDataOnChangeOrWorldStart(); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("SideToPut", this.sideToPut); - compound.setInteger("SlotToPut", this.slotToPutStart); - compound.setInteger("SlotToPutEnd", this.slotToPutEnd); - compound.setInteger("SideToPull", this.sideToPull); - compound.setInteger("SlotToPull", this.slotToPullStart); - compound.setInteger("SlotToPullEnd", this.slotToPullEnd); - } - - this.leftFilter.writeToNBT(compound, "LeftFilter"); - this.rightFilter.writeToNBT(compound, "RightFilter"); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - if (type != NBTType.SAVE_BLOCK) { - this.sideToPut = compound.getInteger("SideToPut"); - this.slotToPutStart = compound.getInteger("SlotToPut"); - this.slotToPutEnd = compound.getInteger("SlotToPutEnd"); - this.sideToPull = compound.getInteger("SideToPull"); - this.slotToPullStart = compound.getInteger("SlotToPull"); - this.slotToPullEnd = compound.getInteger("SlotToPullEnd"); - } - - this.leftFilter.readFromNBT(compound, "LeftFilter"); - this.rightFilter.readFromNBT(compound, "RightFilter"); - - super.readSyncableNBT(compound, type); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - - //Is Block not powered by Redstone? - if (!this.isRedstonePowered) { - if (this.ticksElapsed % 30 == 0) { - if (!(this.sideToPull == this.sideToPut && this.slotToPullStart == this.slotToPutStart && this.slotToPullEnd == this.slotToPutEnd)) { - if (!StackUtil.isValid(this.inv.getStackInSlot(0)) && this.sideToPull != -1 && this.placeToPull != null) { - this.newPulling(); - } - - if (StackUtil.isValid(this.inv.getStackInSlot(0)) && this.sideToPut != -1 && this.placeToPut != null) { - this.newPutting(); - } - } - } - } - - //Update the Client - if ((this.sideToPut != this.lastPutSide || this.sideToPull != this.lastPullSide || this.slotToPullStart != this.lastPullStart || this.slotToPullEnd != this.lastPullEnd || this.slotToPutStart != this.lastPutStart || this.slotToPutEnd != this.lastPutEnd || this.leftFilter.needsUpdateSend() || this.rightFilter.needsUpdateSend()) && this.sendUpdateWithInterval()) { - this.lastPutSide = this.sideToPut; - this.lastPullSide = this.sideToPull; - this.lastPullStart = this.slotToPullStart; - this.lastPullEnd = this.slotToPullEnd; - this.lastPutStart = this.slotToPutStart; - this.lastPutEnd = this.slotToPutEnd; - this.leftFilter.updateLasts(); - this.rightFilter.updateLasts(); - } - } - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !automation || slot == 0; - } - - @Override - public IRemover getRemover() { - return (slot, automation) -> !automation || slot == 0; - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputterAdvanced.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputterAdvanced.java deleted file mode 100644 index fc334bd2c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputterAdvanced.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * This file ("TileEntityInputterAdvanced.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -public class TileEntityInputterAdvanced extends TileEntityInputter { - - public TileEntityInputterAdvanced() { - super(1, "inputterAdvanced"); - this.isAdvanced = true; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java deleted file mode 100644 index 730b3defc..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * This file ("TileEntityInventoryBase.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -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.StackUtil; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.items.IItemHandler; -import net.minecraftforge.items.IItemHandlerModifiable; -import net.minecraftforge.items.ItemHandlerHelper; - -public abstract class TileEntityInventoryBase extends TileEntityBase { - - public final ItemStackHandlerAA inv; - - public TileEntityInventoryBase(int slots, String name) { - super(name); - this.inv = new TileStackHandler(slots); - } - - public static void saveSlots(IItemHandler slots, NBTTagCompound compound) { - if (slots != null && slots.getSlots() > 0) { - NBTTagList tagList = new NBTTagList(); - for (int i = 0; i < slots.getSlots(); i++) { - ItemStack slot = slots.getStackInSlot(i); - NBTTagCompound tagCompound = new NBTTagCompound(); - if (StackUtil.isValid(slot)) { - slot.writeToNBT(tagCompound); - } - tagList.appendTag(tagCompound); - } - compound.setTag("Items", tagList); - } - } - - public static void loadSlots(IItemHandlerModifiable slots, NBTTagCompound compound) { - if (slots != null && slots.getSlots() > 0) { - NBTTagList tagList = compound.getTagList("Items", 10); - for (int i = 0; i < slots.getSlots(); i++) { - NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); - slots.setStackInSlot(i, tagCompound != null && tagCompound.hasKey("id") ? new ItemStack(tagCompound) : StackUtil.getEmpty()); - } - } - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - if (type == NBTType.SAVE_TILE || type == NBTType.SYNC && this.shouldSyncSlots()) { - saveSlots(this.inv, compound); - } - } - - @Override - public IItemHandler getItemHandler(EnumFacing facing) { - return this.inv; - } - - public IAcceptor getAcceptor() { - return ItemStackHandlerAA.ACCEPT_TRUE; - } - - public IRemover getRemover() { - return ItemStackHandlerAA.REMOVE_TRUE; - } - - public int getMaxStackSize(int slot) { - return 64; - } - - public boolean shouldSyncSlots() { - return false; - } - - @Override - public void markDirty() { - super.markDirty(); - - if (this.shouldSyncSlots()) { - this.sendUpdate(); - } - } - - @Override - public int getComparatorStrength() { - return ItemHandlerHelper.calcRedstoneFromInventory(this.inv); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - if (type == NBTType.SAVE_TILE || type == NBTType.SYNC && this.shouldSyncSlots()) { - loadSlots(this.inv, compound); - } - } - - protected class TileStackHandler extends ItemStackHandlerAA { - - protected TileStackHandler(int slots) { - super(slots); - } - - @Override - public IAcceptor getAcceptor() { - return TileEntityInventoryBase.this.getAcceptor(); - } - - @Override - public IRemover getRemover() { - return TileEntityInventoryBase.this.getRemover(); - } - - @Override - public int getSlotLimit(int slot) { - return TileEntityInventoryBase.this.getMaxStackSize(slot); - } - - @Override - protected void onContentsChanged(int slot) { - super.onContentsChanged(slot); - TileEntityInventoryBase.this.markDirty(); - } - }; -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java deleted file mode 100644 index a879289aa..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * This file ("TileEntityItemRepairer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.tuple.Pair; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.fml.common.registry.ForgeRegistries; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class TileEntityItemRepairer extends TileEntityInventoryBase { - - public static final int SLOT_INPUT = 0; - public static final int SLOT_OUTPUT = 1; - public static final int ENERGY_USE = 2500; - public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 6000, 0); - public int nextRepairTick; - private int lastEnergy; - - public TileEntityItemRepairer() { - super(2, "repairer"); - } - - public static boolean canBeRepaired(ItemStack stack) { - if (StackUtil.isValid(stack)) { - Item item = stack.getItem(); - if (item != null) { - if (item.isRepairable() && item.getMaxDamage(stack) > 0) { - return true; - } else { - String reg = item.getRegistryName().toString(); - if (reg != null) { - for (String strg : ConfigStringListValues.REPAIRER_EXTRA_WHITELIST.getValue()) { - if (reg.equals(strg)) { return true; } - } - } - } - } - } - return false; - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("NextRepairTick", this.nextRepairTick); - } - super.writeSyncableNBT(compound, type); - this.storage.writeToNBT(compound); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - if (type != NBTType.SAVE_BLOCK) { - this.nextRepairTick = compound.getInteger("NextRepairTick"); - } - super.readSyncableNBT(compound, type); - this.storage.readFromNBT(compound); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - ItemStack input = this.inv.getStackInSlot(SLOT_INPUT); - if (!StackUtil.isValid(this.inv.getStackInSlot(SLOT_OUTPUT)) && canBeRepaired(input)) { - if (input.getItemDamage() <= 0) { - this.inv.setStackInSlot(SLOT_OUTPUT, input.copy()); - this.inv.setStackInSlot(SLOT_INPUT, StackUtil.getEmpty()); - this.nextRepairTick = 0; - } else { - if (this.storage.getEnergyStored() >= ENERGY_USE) { - this.nextRepairTick++; - this.storage.extractEnergyInternal(ENERGY_USE, false); - if (this.nextRepairTick >= 4) { - this.nextRepairTick = 0; - input.setItemDamage(input.getItemDamage() - 1); - - if (input.hasTagCompound()) { - //TiCon un-break tools - if ("tconstruct".equalsIgnoreCase(input.getItem().getRegistryName().getNamespace())) { - NBTTagCompound stats = input.getTagCompound().getCompoundTag("Stats"); - stats.removeTag("Broken"); - } - } - } - } - } - } else { - this.nextRepairTick = 0; - } - - if (this.lastEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { - this.lastEnergy = this.storage.getEnergyStored(); - } - } - } - - @SideOnly(Side.CLIENT) - public int getEnergyScaled(int i) { - return this.storage.getEnergyStored() * i / this.storage.getMaxEnergyStored(); - } - - public int getItemDamageToScale(int i) { - if (StackUtil.isValid(this.inv.getStackInSlot(SLOT_INPUT))) { return (this.inv.getStackInSlot(SLOT_INPUT).getMaxDamage() - this.inv.getStackInSlot(SLOT_INPUT).getItemDamage()) * i / this.inv.getStackInSlot(SLOT_INPUT).getMaxDamage(); } - return 0; - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.storage; - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !isBlacklisted(stack) && (!automation || slot == SLOT_INPUT); - } - - @Override - public IRemover getRemover() { - return (slot, automation) -> !automation || slot == SLOT_OUTPUT; - } - - private static final List> BLACKLIST = new ArrayList<>(); - - private static boolean runOnce = false; - - public static boolean isBlacklisted(ItemStack stack) { - if (!runOnce) { - runOnce = true; - for (String s : ConfigStringListValues.REPAIR_BLACKLIST.getValue()) { - String[] split = s.split("@"); - Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(split[0])); - if (item == null) { - ActuallyAdditions.LOGGER.error("Invalid item in repair blacklist: " + s); - continue; - } - if (split.length == 1) BLACKLIST.add(Pair.of(item, 0)); - else if (split.length == 2) { - BLACKLIST.add(Pair.of(item, Integer.parseInt(split[1]))); - } - } - } - return BLACKLIST.contains(Pair.of(stack.getItem(), stack.getMetadata())); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java deleted file mode 100644 index f862c6158..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * This file ("TileEntityItemViewer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import de.ellpeck.actuallyadditions.mod.util.compat.CommonCapsUtil; -import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.items.IItemHandler; - -public class TileEntityItemViewer extends TileEntityBase { - - public final List genericInfos = new ArrayList<>(); - public final Map itemHandlerInfos = new HashMap<>(); - public final List slotlessInfos = new ArrayList<>(); - protected final SlotlessableItemHandlerWrapper itemHandler; - public TileEntityLaserRelayItem connectedRelay; - private int lastNetworkChangeAmount = -1; - - public TileEntityItemViewer(String name) { - super(name); - - IItemHandler normalHandler = new IItemHandler() { - @Override - 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) { - IItemHandler normalHandler = handler.getNormalHandler(); - if (normalHandler != null) { - size += normalHandler.getSlots(); - } - } - } - } - } - return size; - } - - @Override - public ItemStack getStackInSlot(int slot) { - IItemHandlerInfo handler = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); - if (handler != null && handler.isLoaded()) { return handler.handler.getStackInSlot(handler.switchedIndex); } - return StackUtil.getEmpty(); - } - - @Override - 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)) { - ItemStack remain = info.handler.insertItem(info.switchedIndex, stack, simulate); - if (!ItemStack.areItemStacksEqual(remain, stack) && !simulate) { - TileEntityItemViewer.this.markDirty(); - TileEntityItemViewer.this.doItemParticle(stack, info.relayInQuestion.getPos(), TileEntityItemViewer.this.connectedRelay.getPos()); - } - return remain; - } - return stack; - } - - @Override - public ItemStack extractItem(int slot, int amount, boolean simulate) { - ItemStack stackIn = this.getStackInSlot(slot); - if (StackUtil.isValid(stackIn)) { - IItemHandlerInfo info = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); - 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) { - TileEntityItemViewer.this.markDirty(); - TileEntityItemViewer.this.doItemParticle(extracted, TileEntityItemViewer.this.connectedRelay.getPos(), info.relayInQuestion.getPos()); - } - return extracted; - } - } - return StackUtil.getEmpty(); - } - - @Override - public int getSlotLimit(int slot) { - IItemHandlerInfo info = TileEntityItemViewer.this.getSwitchedIndexHandler(slot); - if (info != null && info.isLoaded()) { - return info.handler.getSlotLimit(info.switchedIndex); - } else { - return 0; - } - } - }; - - Object slotlessHandler = null; - if (ActuallyAdditions.commonCapsLoaded) { - slotlessHandler = CommonCapsUtil.createSlotlessItemViewerHandler(this, normalHandler); - } - - this.itemHandler = new SlotlessableItemHandlerWrapper(normalHandler, slotlessHandler); - } - - public TileEntityItemViewer() { - this("itemViewer"); - } - - @Override - 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) { - Object handler = this.itemHandler.getSlotlessHandler(); - if (handler != null) { return (T) handler; } - } - } - return super.getCapability(capability, facing); - } - - private List getItemHandlerInfos() { - this.queryAndSaveData(); - return this.genericInfos; - } - - public void doItemParticle(ItemStack stack, BlockPos input, BlockPos output) { - if (!this.world.isRemote) { - NBTTagCompound compound = new NBTTagCompound(); - stack.writeToNBT(compound); - - compound.setDouble("InX", input.getX()); - compound.setDouble("InY", input.getY()); - compound.setDouble("InZ", input.getZ()); - - compound.setDouble("OutX", output.getX()); - 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); - } - } - } - } - } - - private void queryAndSaveData() { - if (this.connectedRelay != null) { - Network network = this.connectedRelay.getNetwork(); - if (network != null) { - if (this.lastNetworkChangeAmount != network.changeAmount) { - this.clearInfos(); - - this.connectedRelay.getItemHandlersInNetwork(network, this.genericInfos); - if (!this.genericInfos.isEmpty()) { - Collections.sort(this.genericInfos); - - int slotsQueried = 0; - 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++) { - this.itemHandlerInfos.put(slotsQueried, new IItemHandlerInfo(normalHandler, i, info.relayInQuestion)); - slotsQueried++; - } - } - - if (ActuallyAdditions.commonCapsLoaded) { - Object slotlessHandler = handler.getSlotlessHandler(); - if (slotlessHandler instanceof ISlotlessItemHandler) { - this.slotlessInfos.add(new SlotlessItemHandlerInfo(slotlessHandler, info.relayInQuestion)); - } - } - } - } - } - this.lastNetworkChangeAmount = network.changeAmount; - } - - return; - } - } - - this.clearInfos(); - this.lastNetworkChangeAmount = -1; - } - - private void clearInfos() { - if (!this.genericInfos.isEmpty()) { - this.genericInfos.clear(); - } - - if (!this.itemHandlerInfos.isEmpty()) { - this.itemHandlerInfos.clear(); - } - - if (!this.slotlessInfos.isEmpty()) { - this.slotlessInfos.clear(); - } - } - - private IItemHandlerInfo getSwitchedIndexHandler(int i) { - this.queryAndSaveData(); - return this.itemHandlerInfos.get(i); - } - - @Override - public boolean shouldSaveDataOnChangeOrWorldStart() { - return true; - } - - @Override - public void saveDataOnChangeOrWorldStart() { - TileEntityLaserRelayItem tileFound = null; - 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)) { - TileEntity tile = this.world.getTileEntity(pos); - - if (tile instanceof TileEntityLaserRelayItem) { - if (tileFound != null) { - this.connectedRelay = null; - return; - } else { - tileFound = (TileEntityLaserRelayItem) tile; - } - } - } - } - } - this.connectedRelay = tileFound; - } - - 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) { - return whitelisted && connected.isWhitelisted(stack, output); - } else { - return whitelisted; - } - } - - public static class SlotlessItemHandlerInfo extends SpecificItemHandlerInfo { - - public final Object handler; - - public SlotlessItemHandlerInfo(Object handler, TileEntityLaserRelayItem relayInQuestion) { - super(relayInQuestion); - this.handler = handler; - } - } - - private static class IItemHandlerInfo extends SpecificItemHandlerInfo { - - public final IItemHandler handler; - public final int switchedIndex; - - public IItemHandlerInfo(IItemHandler handler, int switchedIndex, TileEntityLaserRelayItem relayInQuestion) { - super(relayInQuestion); - this.handler = handler; - this.switchedIndex = switchedIndex; - } - } - - private static class SpecificItemHandlerInfo { - - public final TileEntityLaserRelayItem relayInQuestion; - - public SpecificItemHandlerInfo(TileEntityLaserRelayItem relayInQuestion) { - this.relayInQuestion = relayInQuestion; - } - - public boolean isLoaded() { - return this.relayInQuestion.hasWorld() && this.relayInQuestion.getWorld().isBlockLoaded(this.relayInQuestion.getPos()); - } - } - - public static class GenericItemHandlerInfo implements Comparable { - - public final List handlers = new ArrayList<>(); - public final TileEntityLaserRelayItem relayInQuestion; - - public GenericItemHandlerInfo(TileEntityLaserRelayItem relayInQuestion) { - this.relayInQuestion = relayInQuestion; - } - - public boolean isLoaded() { - return this.relayInQuestion.hasWorld() && this.relayInQuestion.getWorld().isBlockLoaded(this.relayInQuestion.getPos()); - } - - @Override - public int compareTo(GenericItemHandlerInfo other) { - int thisPrio = this.relayInQuestion.getPriority(); - int otherPrio = other.relayInQuestion.getPriority(); - - if (thisPrio == otherPrio) { - return 0; - } else if (thisPrio > otherPrio) { - return -1; - } 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 deleted file mode 100644 index db6bfc7ce..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewerHopping.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * This file ("TileEntityItemViewerHopping.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; -import net.minecraft.block.BlockHopper; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.items.CapabilityItemHandler; -import net.minecraftforge.items.IItemHandler; - -public class TileEntityItemViewerHopping extends TileEntityItemViewer { - - private SlotlessableItemHandlerWrapper handlerToPullFrom; - private SlotlessableItemHandlerWrapper handlerToPushTo; - - public TileEntityItemViewerHopping() { - super("itemViewerHopping"); - } - - @Override - public void updateEntity() { - super.updateEntity(); - - 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) { - Object slotless = this.itemHandler.getSlotlessHandler(); - if (slotless instanceof ISlotlessItemHandler) { - ItemStack left = ((ISlotlessItemHandler) slotless).insertItem(item.getItem(), false); - item.setItem(left); - - if (!StackUtil.isValid(left)) { - item.setDead(); - continue; - } - } - } - - IItemHandler handler = this.itemHandler.getNormalHandler(); - 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)) { - item.setDead(); - break; - } - } - } - } - } - } - } - } - - if (this.handlerToPushTo != null) { - WorldUtil.doItemInteraction(this.itemHandler, this.handlerToPushTo, 4); - } - } - } - - @Override - 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)) { - IItemHandler normal = null; - 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)) { - slotless = from.getCapability(SlotlessItemHandlerConfig.CAPABILITY, EnumFacing.DOWN); - } - } - - this.handlerToPullFrom = new SlotlessableItemHandlerWrapper(normal, slotless); - } - - IBlockState state = this.world.getBlockState(this.pos); - EnumFacing facing = state.getValue(BlockHopper.FACING); - - BlockPos toPos = this.pos.offset(facing); - if (this.world.isBlockLoaded(toPos)) { - TileEntity to = this.world.getTileEntity(toPos); - if (to != null && !(to instanceof TileEntityItemViewer)) { - IItemHandler normal = null; - 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())) { - slotless = to.getCapability(SlotlessItemHandlerConfig.CAPABILITY, facing.getOpposite()); - } - } - - this.handlerToPushTo = new SlotlessableItemHandlerWrapper(normal, slotless); - } - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java deleted file mode 100644 index b79c8d5cf..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * This file ("TileEntityLaserRelay.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.laser.IConnectionPair; -import de.ellpeck.actuallyadditions.api.laser.LaserType; -import de.ellpeck.actuallyadditions.api.laser.Network; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.misc.apiimpl.ConnectionPair; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import io.netty.util.internal.ConcurrentSet; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.items.IItemHandler; - -public abstract class TileEntityLaserRelay extends TileEntityInventoryBase { - - public static final int MAX_DISTANCE = 15; - public static final int MAX_DISTANCE_RANGED = 35; - - public final LaserType type; - - private Network cachedNetwork; - private int changeAmountAtCaching = -1; - private int lastRange; - - public TileEntityLaserRelay(String name, LaserType type) { - super(1, name); - this.type = type; - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - - 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++) { - ConnectionPair pair = new ConnectionPair(); - pair.readFromNBT(list.getCompoundTagAt(i)); - ActuallyAdditionsAPI.connectionHandler.addConnection(pair.getPositions()[0], pair.getPositions()[1], this.type, this.world, pair.doesSuppressRender()); - } - } - } - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - - 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) { - NBTTagCompound tag = new NBTTagCompound(); - pair.writeToNBT(tag); - list.appendTag(tag); - } - } - - compound.setTag("Connections", list); - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - - int range = this.getMaxRange(); - 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) { - ActuallyAdditionsAPI.connectionHandler.removeConnection(this.world, pair.getPositions()[0], pair.getPositions()[1]); - } - } - } - - this.lastRange = range; - } - } - - /*@Override - public void updateEntity(){ - super.updateEntity(); - if(this.world.isRemote){ - this.renderParticles(); - } - } - - @SideOnly(Side.CLIENT) - public void renderParticles(){ - if(this.world.rand.nextInt(8) == 0){ - EntityPlayer player = Minecraft.getMinecraft().player; - if(player != null){ - PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player); - WrenchMode mode = WrenchMode.values()[data.theCompound.getInteger("LaserWrenchMode")]; - if(mode != WrenchMode.NO_PARTICLES){ - ItemStack stack = player.getHeldItemMainhand(); - if(mode == WrenchMode.ALWAYS_PARTICLES || (StackUtil.isValid(stack) && stack.getItem() instanceof ItemLaserWrench)){ - Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(this.pos, this.world); - if(network != null){ - for(IConnectionPair aPair : network.connections){ - if(!aPair.doesSuppressRender() && aPair.contains(this.pos) && this.pos.equals(aPair.getPositions()[0])){ - AssetUtil.renderParticlesFromAToB(aPair.getPositions()[0].getX(), aPair.getPositions()[0].getY(), aPair.getPositions()[0].getZ(), aPair.getPositions()[1].getX(), aPair.getPositions()[1].getY(), aPair.getPositions()[1].getZ(), this.world.rand.nextInt(3)+1, 0.8F, this.type == LaserType.ITEM ? COLOR_ITEM : (this.type == LaserType.FLUID ? COLOR_FLUIDS : COLOR), 1F); - } - } - } - } - } - } - } - }*/ - - 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) { - this.changeAmountAtCaching = this.cachedNetwork.changeAmount; - } else { - this.changeAmountAtCaching = -1; - } - } - - return this.cachedNetwork; - } - - @Override - @SideOnly(Side.CLIENT) - public AxisAlignedBB getRenderBoundingBox() { - return INFINITE_EXTENT_AABB; - } - - @Override - public boolean shouldSyncSlots() { - return true; - } - - @Override - public IItemHandler getItemHandler(EnumFacing facing) { - return null; - } - - public int getMaxRange() { - ItemStack upgrade = this.inv.getStackInSlot(0); - if (StackUtil.isValid(upgrade) && upgrade.getItem() == InitItems.itemLaserUpgradeRange) { - return MAX_DISTANCE_RANGED; - } else { - return MAX_DISTANCE; - } - } - - @SideOnly(Side.CLIENT) - public abstract String getExtraDisplayString(); - - @SideOnly(Side.CLIENT) - public abstract String getCompassDisplayString(); - - public abstract void onCompassAction(EntityPlayer player); -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java deleted file mode 100644 index 0d95f4dc4..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java +++ /dev/null @@ -1,300 +0,0 @@ -/* - * This file ("TileEntityLaserRelayEnergy.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import java.util.HashMap; -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; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.energy.CapabilityEnergy; -import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -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) { - super(name, LaserType.ENERGY); - - for (int i = 0; i < this.energyStorages.length; i++) { - final EnumFacing facing = EnumFacing.values()[i]; - this.energyStorages[i] = new IEnergyStorage() { - - @Override - public int receiveEnergy(int amount, boolean simulate) { - return TileEntityLaserRelayEnergy.this.transmitEnergy(facing, amount, simulate); - } - - @Override - public int extractEnergy(int maxExtract, boolean simulate) { - return 0; - } - - @Override - public int getEnergyStored() { - return 0; - } - - @Override - public int getMaxEnergyStored() { - return TileEntityLaserRelayEnergy.this.getEnergyCap(); - } - - @Override - public boolean canExtract() { - return false; - } - - @Override - public boolean canReceive() { - return true; - } - }; - } - } - - public TileEntityLaserRelayEnergy() { - this("laserRelay"); - } - - private int transmitEnergy(EnumFacing from, int maxTransmit, boolean simulate) { - int transmitted = 0; - if (maxTransmit > 0 && this.mode != Mode.OUTPUT_ONLY) { - Network network = this.getNetwork(); - if (network != null) { - transmitted = this.transferEnergyToReceiverInNeed(from, network, maxTransmit, simulate); - } - } - return transmitted; - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.energyStorages[facing == null ? 0 : facing.ordinal()]; - } - - @Override - public boolean shouldSaveDataOnChangeOrWorldStart() { - return true; - } - - @Override - public void saveDataOnChangeOrWorldStart() { - Map old = new HashMap<>(this.receiversAround); - boolean change = false; - - this.receiversAround.clear(); - for (EnumFacing side : EnumFacing.values()) { - BlockPos pos = this.getPos().offset(side); - if (this.world.isBlockLoaded(pos)) { - TileEntity tile = this.world.getTileEntity(pos); - 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)) { - change = true; - } - } - } - } - } - - if (change || old.size() != this.receiversAround.size()) { - Network network = this.getNetwork(); - if (network != null) { - network.changeAmount++; - } - } - } - - 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<>(); - - 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)) { - alreadyChecked.add(relay); - TileEntity relayTile = this.world.getTileEntity(relay); - 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) { - TileEntity tile = theRelay.receiversAround.get(facing); - - EnumFacing opp = facing.getOpposite(); - if (tile != null) { - if (tile.hasCapability(CapabilityEnergy.ENERGY, opp)) { - IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, opp); - if (cap != null && cap.receiveEnergy(maxTransfer, true) > 0) { - totalReceiverAmount++; - workedOnce = true; - } - } - } - } - } - - if (workedOnce) { - relaysThatWork.add(theRelay); - } - } - } - } - } - } - - if (totalReceiverAmount > 0 && !relaysThatWork.isEmpty()) { - int amountPer = maxTransfer / totalReceiverAmount; - if (amountPer <= 0) { - amountPer = maxTransfer; - } - - 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) { - EnumFacing side = receiver.getKey(); - EnumFacing opp = side.getOpposite(); - TileEntity tile = receiver.getValue(); - if (!alreadyChecked.contains(tile.getPos())) { - alreadyChecked.add(tile.getPos()); - if (theRelay != this || side != from) { - if (tile.hasCapability(CapabilityEnergy.ENERGY, opp)) { - IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, opp); - if (cap != null) { - int theoreticalReceived = cap.receiveEnergy(Math.min(amountPer, lowestCap), true); - if (theoreticalReceived > 0) { - int deduct = this.calcDeduction(theoreticalReceived, highestLoss); - if (deduct >= theoreticalReceived) { //Happens with small numbers - deduct = 0; - } - - transmitted += cap.receiveEnergy(theoreticalReceived - deduct, simulate); - transmitted += deduct; - } - } - } - - //If everything that could be transmitted was transmitted - if (transmitted >= maxTransfer) { return transmitted; } - } - } - } - } - } - } - - return transmitted; - } - - private int calcDeduction(int theoreticalReceived, double highestLoss) { - return ConfigBoolValues.LASER_RELAY_LOSS.isEnabled() ? MathHelper.ceil(theoreticalReceived * (highestLoss / 100)) : 0; - } - - public int getEnergyCap() { - return CAP; - } - - 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; - } - - @Override - @SideOnly(Side.CLIENT) - public String getCompassDisplayString() { - return TextFormatting.GREEN + StringUtil.localize("info." + ActuallyAdditions.MODID + ".laserRelay.energy.display"); - } - - @Override - public void onCompassAction(EntityPlayer player) { - this.mode = this.mode.getNext(); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - - if (type != NBTType.SAVE_BLOCK) { - compound.setString("Mode", this.mode.toString()); - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - - if (type != NBTType.SAVE_BLOCK) { - String modeStrg = compound.getString("Mode"); - 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 final String name; - - Mode(String name) { - this.name = name; - } - - public Mode getNext() { - int ordinal = this.ordinal() + 1; - - if (ordinal >= values().length) { - ordinal = 0; - } - - return values()[ordinal]; - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyAdvanced.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyAdvanced.java deleted file mode 100644 index e3f601fbf..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyAdvanced.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file ("TileEntityLaserRelayEnergyAdvanced.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -public class TileEntityLaserRelayEnergyAdvanced extends TileEntityLaserRelayEnergy { - - public static final int CAP = 10000; - - public TileEntityLaserRelayEnergyAdvanced() { - super("laserRelayAdvanced"); - } - - @Override - public int getEnergyCap() { - return CAP; - } - - @Override - 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 deleted file mode 100644 index 951207f92..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyExtreme.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file ("TileEntityLaserRelayEnergyExtreme.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -public class TileEntityLaserRelayEnergyExtreme extends TileEntityLaserRelayEnergy { - - public static final int CAP = 100000; - - public TileEntityLaserRelayEnergyExtreme() { - super("laserRelayExtreme"); - } - - @Override - public int getEnergyCap() { - return CAP; - } - - @Override - 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 deleted file mode 100644 index b3c82c6da..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java +++ /dev/null @@ -1,254 +0,0 @@ -/* - * This file ("TileEntityLaserRelayFluids.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergy.Mode; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.capability.CapabilityFluidHandler; -import net.minecraftforge.fluids.capability.IFluidHandler; -import net.minecraftforge.fluids.capability.IFluidTankProperties; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -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() { - super("laserRelayFluids", LaserType.FLUID); - - for (int i = 0; i < this.fluidHandlers.length; i++) { - final EnumFacing facing = EnumFacing.values()[i]; - this.fluidHandlers[i] = new IFluidHandler() { - @Override - public IFluidTankProperties[] getTankProperties() { - return new IFluidTankProperties[0]; - } - - @Override - public int fill(FluidStack resource, boolean doFill) { - return TileEntityLaserRelayFluids.this.transmitFluid(facing, resource, doFill); - } - - @Override - public FluidStack drain(FluidStack resource, boolean doDrain) { - return null; - } - - @Override - public FluidStack drain(int maxDrain, boolean doDrain) { - return null; - } - }; - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - - 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); - } - } - } - } - - @Override - public boolean shouldSaveDataOnChangeOrWorldStart() { - return true; - } - - @Override - public void saveDataOnChangeOrWorldStart() { - Map old = new HashMap<>(this.handlersAround); - boolean change = false; - - this.handlersAround.clear(); - for (EnumFacing side : EnumFacing.values()) { - BlockPos pos = this.getPos().offset(side); - 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())) { - this.handlersAround.put(side, tile); - - TileEntity oldTile = old.get(side); - if (oldTile == null || !tile.equals(oldTile)) { - change = true; - } - } - } - } - } - - if (change || old.size() != this.handlersAround.size()) { - Network network = this.getNetwork(); - if (network != null) { - network.changeAmount++; - } - } - } - - @Override - public IFluidHandler getFluidHandler(EnumFacing facing) { - return this.fluidHandlers[facing == null ? 0 : facing.ordinal()]; - } - - private int transmitFluid(EnumFacing from, FluidStack stack, boolean doFill) { - int transmitted = 0; - if (stack != null && this.mode != Mode.OUTPUT_ONLY) { - Network network = this.getNetwork(); - if (network != null) { - transmitted = this.transferFluidToReceiverInNeed(from, network, stack, doFill); - } - } - return transmitted; - } - - 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<>(); - - 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)) { - alreadyChecked.add(relay); - TileEntity relayTile = this.world.getTileEntity(relay); - 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) { - TileEntity tile = theRelay.handlersAround.get(facing); - - EnumFacing opp = facing.getOpposite(); - 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) { - totalReceiverAmount++; - workedOnce = true; - } - } - } - } - - if (workedOnce) { - relaysThatWork.add(theRelay); - } - } - } - } - } - } - - 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) { - EnumFacing side = receiver.getKey(); - EnumFacing opp = side.getOpposite(); - TileEntity tile = receiver.getValue(); - if (!alreadyChecked.contains(tile.getPos())) { - alreadyChecked.add(tile.getPos()); - 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) { - FluidStack copy = stack.copy(); - copy.amount = amountPer; - transmitted += cap.fill(copy, doFill); - } - } - - //If everything that could be transmitted was transmitted - if (transmitted >= stack.amount) { return transmitted; } - } - } - } - } - } - } - - return transmitted; - } - - @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; - } - - @Override - @SideOnly(Side.CLIENT) - public String getCompassDisplayString() { - return TextFormatting.GREEN + StringUtil.localize("info." + ActuallyAdditions.MODID + ".laserRelay.energy.display"); - } - - @Override - public void onCompassAction(EntityPlayer player) { - this.mode = this.mode.getNext(); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - - if (type != NBTType.SAVE_BLOCK) { - compound.setString("Mode", this.mode.toString()); - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - - if (type != NBTType.SAVE_BLOCK) { - String modeStrg = compound.getString("Mode"); - 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 deleted file mode 100644 index 1e5e8dc68..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * This file ("TileEntityLaserRelayItem.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer.GenericItemHandlerInfo; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.items.CapabilityItemHandler; -import net.minecraftforge.items.IItemHandler; - -public class TileEntityLaserRelayItem extends TileEntityLaserRelay { - - public final Map handlersAround = new ConcurrentHashMap<>(); - public int priority; - - public TileEntityLaserRelayItem(String name) { - super(name, LaserType.ITEM); - } - - public TileEntityLaserRelayItem() { - this("laserRelayItem"); - } - - public int getPriority() { - return this.priority; - } - - public boolean isWhitelisted(ItemStack stack, boolean output) { - return true; - } - - @Override - public boolean shouldSaveDataOnChangeOrWorldStart() { - return true; - } - - @Override - public void saveDataOnChangeOrWorldStart() { - Map old = new HashMap<>(this.handlersAround); - boolean change = false; - - this.handlersAround.clear(); - for (int i = 0; i <= 5; i++) { - EnumFacing side = WorldUtil.getDirectionBySidesInOrder(i); - BlockPos pos = this.getPos().offset(side); - if (this.world.isBlockLoaded(pos)) { - TileEntity tile = this.world.getTileEntity(pos); - if (tile != null && !(tile instanceof TileEntityItemViewer) && !(tile instanceof TileEntityLaserRelay)) { - IItemHandler itemHandler = null; - 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())) { - slotlessHandler = tile.getCapability(SlotlessItemHandlerConfig.CAPABILITY, side.getOpposite()); - } - } - - 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)) { - change = true; - } - } - } - } - } - - if (change || old.size() != this.handlersAround.size()) { - Network network = this.getNetwork(); - if (network != null) { - network.changeAmount++; - } - } - } - - 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)) { - alreadyChecked.add(relay); - TileEntity aRelayTile = this.world.getTileEntity(relay); - 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())) { - alreadyChecked.add(handler.getKey()); - - info.handlers.add(handler.getValue()); - } - } - - storeList.add(info); - } - } - } - } - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - 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; - } - - @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"); - } - - @Override - public void onCompassAction(EntityPlayer player) { - if (player.isSneaking()) { - this.priority--; - } else { - this.priority++; - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - 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 deleted file mode 100644 index 26400564b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * This file ("TileEntityLaserRelayItemWhitelist.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.inventory.ContainerFilter; -import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter; -import de.ellpeck.actuallyadditions.mod.items.ItemDrill; -import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.items.IItemHandler; - -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() { - super("laserRelayItemWhitelist"); - } - - @Override - public int getPriority() { - return super.getPriority() + 10; - } - - @Override - 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) { - super.writeSyncableNBT(compound, type); - - this.leftFilter.writeToNBT(compound, "LeftFilter"); - this.rightFilter.writeToNBT(compound, "RightFilter"); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - - this.leftFilter.readFromNBT(compound, "LeftFilter"); - this.rightFilter.readFromNBT(compound, "RightFilter"); - } - - @Override - public void onButtonPressed(int buttonID, EntityPlayer player) { - this.leftFilter.onButtonPressed(buttonID); - this.rightFilter.onButtonPressed(buttonID); - if (buttonID == 2) { - this.addWhitelistSmart(false); - } else if (buttonID == 3) { - this.addWhitelistSmart(true); - } - } - - 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++) { - ItemStack stack = itemHandler.getStackInSlot(i); - if (StackUtil.isValid(stack)) { - this.addWhitelistSmart(output, 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++) { - ItemStack slot = usedSettings.filterInventory.getStackInSlot(k); - 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))) { - inv.setStackInSlot(j, copy); - did = true; - break; - } - } - - if (did) { - ItemDrill.writeSlotsToNBT(inv, slot); - break; - } - } - } else { - usedSettings.filterInventory.setStackInSlot(k, copy); - break; - } - } - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - - 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 deleted file mode 100644 index 9ddf1b666..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLavaFactoryController.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This file ("TileEntityLavaFactoryController.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.energy.IEnergyStorage; - -public class TileEntityLavaFactoryController extends TileEntityBase implements IEnergyDisplay { - - public static final int NOT_MULTI = 0; - public static final int HAS_LAVA = 1; - public static final int HAS_AIR = 2; - public static final int ENERGY_USE = 150000; - public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 2000, 0); - private int currentWorkTime; - private int oldEnergy; - - public TileEntityLavaFactoryController() { - super("lavaFactory"); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - this.storage.writeToNBT(compound); - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("WorkTime", this.currentWorkTime); - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - this.storage.readFromNBT(compound); - if (type != NBTType.SAVE_BLOCK) { - this.currentWorkTime = compound.getInteger("WorkTime"); - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - if (this.storage.getEnergyStored() >= ENERGY_USE && this.isMultiblock() == HAS_AIR) { - this.currentWorkTime++; - if (this.currentWorkTime >= 200) { - this.currentWorkTime = 0; - this.world.setBlockState(this.pos.up(), Blocks.LAVA.getDefaultState(), 2); - this.storage.extractEnergyInternal(ENERGY_USE, false); - } - } else { - this.currentWorkTime = 0; - } - - if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { - this.oldEnergy = this.storage.getEnergyStored(); - } - } - } - - 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) }; - - 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; } - } - return NOT_MULTI; - } - - @Override - public CustomEnergyStorage getEnergyStorage() { - return this.storage; - } - - @Override - public boolean needsHoldShift() { - return false; - } - - @Override - 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 deleted file mode 100644 index f748ca7cb..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * This file ("TileEntityLeafGenerator.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.energy.IEnergyStorage; - -public class TileEntityLeafGenerator extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay { - - public static final int RANGE = 7; - public static final int ENERGY_PRODUCED = 300; - public final CustomEnergyStorage storage = new CustomEnergyStorage(35000, 0, 450); - private int nextUseCounter; - private int oldEnergy; - - public TileEntityLeafGenerator() { - super("leafGenerator"); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - this.storage.writeToNBT(compound); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - this.storage.readFromNBT(compound); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - if (!this.isRedstonePowered) { - - if (this.nextUseCounter >= 5) { - this.nextUseCounter = 0; - - 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++) { - 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)) { - breakPositions.add(pos); - } - } - } - } - - if (!breakPositions.isEmpty()) { - Collections.shuffle(breakPositions); - BlockPos theCoord = breakPositions.get(0); - - this.world.playEvent(2001, theCoord, Block.getStateId(this.world.getBlockState(theCoord))); - - this.world.setBlockToAir(theCoord); - - 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); - } - } - } else { - this.nextUseCounter++; - } - } - - if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { - this.oldEnergy = this.storage.getEnergyStored(); - } - } - } - - @Override - public CustomEnergyStorage getEnergyStorage() { - return this.storage; - } - - @Override - public boolean needsHoldShift() { - return false; - } - - @Override - public int getEnergyToSplitShare() { - return this.storage.getEnergyStored(); - } - - @Override - public boolean doesShareEnergy() { - return true; - } - - @Override - public EnumFacing[] getEnergyShareSides() { - return EnumFacing.values(); - } - - @Override - public boolean canShareTo(TileEntity tile) { - return true; - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.storage; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityMiner.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityMiner.java deleted file mode 100644 index 17249b6fe..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityMiner.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * This file ("TileEntityMiner.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; -import de.ellpeck.actuallyadditions.mod.items.ItemDrill; -import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; -import de.ellpeck.actuallyadditions.mod.util.AssetUtil; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import net.minecraft.block.Block; -import net.minecraft.block.BlockLiquid; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.RayTraceResult.Type; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.WorldServer; -import net.minecraftforge.common.util.FakePlayerFactory; -import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.fluids.IFluidBlock; -import net.minecraftforge.oredict.OreDictionary; - -public class TileEntityMiner extends TileEntityInventoryBase implements IButtonReactor, IEnergyDisplay { - - public static final int ENERGY_USE_PER_BLOCK = 650; - public static final int DEFAULT_RANGE = 2; - public final CustomEnergyStorage storage = new CustomEnergyStorage(200000, 2000, 0); - - public boolean onlyMineOres; - public int checkX; - public int checkY = -1; - public int checkZ; - private int oldEnergy; - private int oldCheckX; - private int oldCheckY; - private int oldCheckZ; - - public TileEntityMiner() { - super(9, "miner"); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - this.storage.writeToNBT(compound); - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("CheckX", this.checkX); - compound.setInteger("CheckY", this.checkY); - compound.setInteger("CheckZ", this.checkZ); - } - if (type != NBTType.SAVE_BLOCK || this.onlyMineOres) { - compound.setBoolean("OnlyOres", this.onlyMineOres); - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - this.storage.readFromNBT(compound); - if (type != NBTType.SAVE_BLOCK) { - this.checkX = compound.getInteger("CheckX"); - this.checkY = compound.getInteger("CheckY"); - this.checkZ = compound.getInteger("CheckZ"); - } - this.onlyMineOres = compound.getBoolean("OnlyOres"); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - - if (!this.isRedstonePowered && this.ticksElapsed % 5 == 0) { - if (this.checkY != 0) { - int range = TileEntityPhantomface.upgradeRange(DEFAULT_RANGE, this.world, this.pos); - if (this.checkY < 0) { - this.checkY = this.pos.getY() - 1; - this.checkX = -range; - this.checkZ = -range; - } - - if (this.checkY > 0) { - if (this.mine()) { - this.checkX++; - if (this.checkX > range) { - this.checkX = -range; - this.checkZ++; - if (this.checkZ > range) { - this.checkZ = -range; - this.checkY--; - } - } - } - } - } - } - - if ((this.oldEnergy != this.storage.getEnergyStored() || this.oldCheckX != this.checkX || this.oldCheckY != this.checkY || this.oldCheckZ != this.checkZ) && this.sendUpdateWithInterval()) { - this.oldEnergy = this.storage.getEnergyStored(); - this.oldCheckX = this.checkX; - this.oldCheckY = this.checkY; - this.oldCheckZ = this.checkZ; - } - } - } - - private boolean mine() { - int actualUse = ENERGY_USE_PER_BLOCK * (this.onlyMineOres ? 3 : 1); - if (this.storage.getEnergyStored() >= actualUse) { - BlockPos pos = new BlockPos(this.pos.getX() + this.checkX, this.checkY, this.pos.getZ() + this.checkZ); - - IBlockState state = this.world.getBlockState(pos); - Block block = state.getBlock(); - ItemStack stack = block.getPickBlock(state, new RayTraceResult(Type.BLOCK, new Vec3d(0, 0, 0), EnumFacing.DOWN, pos), this.world, pos, FakePlayerFactory.getMinecraft((WorldServer) this.world)); - if (!block.isAir(this.world.getBlockState(pos), this.world, pos)) { - if (block.getHarvestLevel(this.world.getBlockState(pos)) <= ItemDrill.HARVEST_LEVEL && state.getBlockHardness(this.world, pos) >= 0F && !(block instanceof BlockLiquid) && !(block instanceof IFluidBlock) && this.isMinable(block, stack)) { - NonNullList drops = NonNullList.create(); - block.getDrops(drops, this.world, pos, state, 0); - float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.world, pos); - - if (chance > 0 && this.world.rand.nextFloat() <= chance) { - if (StackUtil.canAddAll(this.inv, drops, false)) { - this.world.playEvent(2001, pos, Block.getStateId(this.world.getBlockState(pos))); - this.world.setBlockToAir(pos); - - StackUtil.addAll(this.inv, drops, false); - this.markDirty(); - - this.storage.extractEnergyInternal(actualUse, false); - this.shootParticles(pos.getX(), pos.getY(), pos.getZ()); - } else { - return false; - } - } - } - } - return true; - } - return false; - } - - private boolean isMinable(Block block, ItemStack stack) { - if (block != null) { - if (!this.isBlacklisted(block)) { - if (!this.onlyMineOres) { - return true; - } else { - if (StackUtil.isValid(stack)) { - int[] ids = OreDictionary.getOreIDs(stack); - for (int id : ids) { - String name = OreDictionary.getOreName(id); - if (name.startsWith("ore") || name.startsWith("denseore")) { return true; } - } - - String reg = block.getRegistryName().toString(); - if (!reg.isEmpty()) { - for (String string : ConfigStringListValues.MINER_EXTRA_WHITELIST.getValue()) { - if (reg.equals(string)) { return true; } - } - } - } - } - } - } - - return false; - } - - private void shootParticles(int endX, int endY, int endZ) { - AssetUtil.spawnLaserWithTimeServer(this.world, this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), endX, endY, endZ, new float[] { 65F / 255F, 150F / 255F, 2F / 255F }, 10, 120, 0.1F, 0.8F); - } - - private boolean isBlacklisted(Block block) { - String reg = block.getRegistryName().toString(); - if (!reg.isEmpty()) { - for (String string : ConfigStringListValues.MINER_BLACKLIST.getValue()) { - if (reg.equals(string)) { return true; } - } - } - return false; - } - - @Override - public IAcceptor getAcceptor() { - return (stack, slot, automation) -> !automation; - } - - @Override - public void onButtonPressed(int buttonID, EntityPlayer player) { - if (buttonID == 0) { - this.onlyMineOres = !this.onlyMineOres; - this.sendUpdate(); - } else if (buttonID == 1) { - this.checkX = 0; - this.checkY = -1; - this.checkZ = 0; - } - } - - @Override - public CustomEnergyStorage getEnergyStorage() { - return this.storage; - } - - @Override - public boolean needsHoldShift() { - return false; - } - - @Override - 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 deleted file mode 100644 index efa538591..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * This file ("TileEntityOilGenerator.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.recipe.OilGenRecipe; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntListValues; -import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; -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 { - - 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) { - @Override - public boolean canDrain() { - return false; - } - - @Override - public boolean canFillFluidType(FluidStack stack) { - Fluid fluid = stack == null ? null : stack.getFluid(); - return fluid != null && getRecipeForFluid(fluid.getName()) != null; - } - }; - public int currentEnergyProduce; - public int currentBurnTime; - public int maxBurnTime; - private int lastEnergy; - private int lastTank; - private int lastBurnTime; - private int lastMaxBurnTime; - private int lastEnergyProduce; - private int lastCompare; - - 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; } - } - } - return null; - } - - @SideOnly(Side.CLIENT) - public int getBurningScaled(int i) { - return this.currentBurnTime * i / this.maxBurnTime; - } - - private OilGenRecipe getRecipeForCurrentFluid() { - FluidStack stack = this.tank.getFluid(); - if (stack != null) { - Fluid fluid = stack.getFluid(); - if (fluid != null) { return getRecipeForFluid(fluid.getName()); } - } - return null; - } - - @Override - 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); - } - this.storage.writeToNBT(compound); - this.tank.writeToNBT(compound); - super.writeSyncableNBT(compound, type); - } - - @Override - 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"); - } - this.storage.readFromNBT(compound); - this.tank.readFromNBT(compound); - super.readSyncableNBT(compound, type); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - boolean flag = this.currentBurnTime > 0; - - if (this.currentBurnTime > 0 && this.currentEnergyProduce > 0) { - this.currentBurnTime--; - - this.storage.receiveEnergyInternal(this.currentEnergyProduce, false); - } else if (!this.isRedstonePowered) { - int fuelUsed = 50; - - OilGenRecipe recipe = this.getRecipeForCurrentFluid(); - 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 { - this.currentEnergyProduce = 0; - this.currentBurnTime = 0; - this.maxBurnTime = 0; - } - } - - 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()) { - this.lastEnergy = this.storage.getEnergyStored(); - this.lastTank = this.tank.getFluidAmount(); - this.lastBurnTime = this.currentBurnTime; - this.lastEnergyProduce = this.currentEnergyProduce; - this.lastMaxBurnTime = this.maxBurnTime; - } - } - } - - @Override - public int getComparatorStrength() { - float calc = (float) this.storage.getEnergyStored() / (float) this.storage.getMaxEnergyStored() * 15F; - return (int) calc; - } - - @Override - public IFluidHandler getFluidHandler(EnumFacing facing) { - return this.tank; - } - - @Override - public int getMaxFluidAmountToSplitShare() { - return 0; - } - - @Override - public boolean doesShareFluid() { - return false; - } - - @Override - public EnumFacing[] getFluidShareSides() { - return null; - } - - @Override - public int getEnergyToSplitShare() { - return this.storage.getEnergyStored(); - } - - @Override - public boolean doesShareEnergy() { - return true; - } - - @Override - public EnumFacing[] getEnergyShareSides() { - return EnumFacing.values(); - } - - @Override - public boolean canShareTo(TileEntity tile) { - return true; - } - - @Override - 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 deleted file mode 100644 index 66866f48e..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomBooster.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * This file ("TileEntityPhantomBooster.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -public class TileEntityPhantomBooster extends TileEntityBase { - - public TileEntityPhantomBooster() { - super("phantomBooster"); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomBreaker.java deleted file mode 100644 index 5aa079c2f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomBreaker.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file ("TileEntityPhantomBreaker.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; - -public class TileEntityPhantomBreaker extends TileEntityPhantomPlacer { - - public TileEntityPhantomBreaker() { - super(9, "phantomBreaker"); - this.isBreaker = true; - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !automation; - } - - @Override - public IRemover getRemover() { - return ItemStackHandlerAA.REMOVE_TRUE; - } - -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomEnergyface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomEnergyface.java deleted file mode 100644 index 951a4cd68..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomEnergyface.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file ("TileEntityPhantomEnergyface.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.energy.CapabilityEnergy; - -public class TileEntityPhantomEnergyface extends TileEntityPhantomface implements ISharingEnergyProvider { - - public TileEntityPhantomEnergyface() { - super("energyface"); - this.type = BlockPhantom.Type.ENERGYFACE; - } - - @Override - 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; } - } - } - } - return false; - } - - @Override - protected boolean isCapabilitySupported(Capability capability) { - return capability == CapabilityEnergy.ENERGY; - } - - @Override - public int getEnergyToSplitShare() { - return Integer.MAX_VALUE; - } - - @Override - public boolean doesShareEnergy() { - return true; - } - - @Override - public EnumFacing[] getEnergyShareSides() { - return EnumFacing.values(); - } - - @Override - public boolean canShareTo(TileEntity tile) { - return true; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomItemface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomItemface.java deleted file mode 100644 index 5357d5763..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomItemface.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file ("TileEntityPhantomItemface.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.items.CapabilityItemHandler; - -public class TileEntityPhantomItemface extends TileEntityPhantomface { - - public TileEntityPhantomItemface() { - super("phantomface"); - this.type = BlockPhantom.Type.FACE; - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !automation || this.isBoundThingInRange(); - } - - @Override - public boolean isBoundThingInRange() { - if (super.isBoundThingInRange()) { - TileEntity tile = this.world.getTileEntity(this.getBoundPosition()); - if (tile != null) { - for (EnumFacing facing : EnumFacing.values()) { - if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)) { return true; } - } - } - } - return false; - } - - @Override - protected boolean isCapabilitySupported(Capability capability) { - return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY; - } - - @Override - public IRemover getRemover() { - return (slot, automation) -> !automation || this.isBoundThingInRange(); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomLiquiface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomLiquiface.java deleted file mode 100644 index 013efe8ed..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomLiquiface.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file ("TileEntityPhantomLiquiface.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom; -import net.minecraft.tileentity.TileEntity; -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 TileEntityPhantomLiquiface() { - super("liquiface"); - this.type = BlockPhantom.Type.LIQUIFACE; - } - - @Override - 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; } - } - } - } - return false; - } - - @Override - protected boolean isCapabilitySupported(Capability capability) { - return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY; - } - - @Override - public int getMaxFluidAmountToSplitShare() { - return Integer.MAX_VALUE; - } - - @Override - public boolean doesShareFluid() { - return true; - } - - @Override - 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 deleted file mode 100644 index 50a9547e6..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * This file ("TileEntityPhantomPlacer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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.StackUtil; -import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumParticleTypes; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; - -public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements IPhantomTile, IButtonReactor { - - public static final int RANGE = 3; - public BlockPos boundPosition; - public int currentTime; - public int range; - public boolean isBreaker; - public int side; - private int oldRange; - - public TileEntityPhantomPlacer(int slots, String name) { - super(slots, name); - } - - public TileEntityPhantomPlacer() { - super(9, "phantomPlacer"); - this.isBreaker = false; - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("Range", this.range); - if (this.boundPosition != null) { - compound.setInteger("xOfTileStored", this.boundPosition.getX()); - compound.setInteger("yOfTileStored", this.boundPosition.getY()); - compound.setInteger("zOfTileStored", this.boundPosition.getZ()); - } - if (!this.isBreaker) { - compound.setInteger("Side", this.side); - } - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - 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)) { - this.boundPosition = new BlockPos(x, y, z); - this.markDirty(); - } - if (!this.isBreaker) { - this.side = compound.getInteger("Side"); - } - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - this.range = TileEntityPhantomface.upgradeRange(RANGE, this.world, this.pos); - - if (!this.hasBoundPosition()) { - this.boundPosition = null; - } - - if (this.isBoundThingInRange()) { - if (!this.isRedstonePowered && !this.isPulseMode) { - if (this.currentTime > 0) { - this.currentTime--; - if (this.currentTime <= 0) { - this.doWork(); - } - } else { - this.currentTime = 30; - } - } - } - - if (this.oldRange != this.range) { - this.oldRange = this.range; - - this.sendUpdate(); - } - } else { - if (this.boundPosition != null) { - this.renderParticles(); - } - } - } - - @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() && this.world.provider.getDimension() == this.world.provider.getDimension()) { - this.boundPosition = null; - return false; - } - return this.world.provider.getDimension() == this.world.provider.getDimension(); - } - return false; - } - - private void doWork() { - if (this.isBoundThingInRange()) { - if (this.isBreaker) { - Block blockToBreak = this.world.getBlockState(this.boundPosition).getBlock(); - if (blockToBreak != null && this.world.getBlockState(this.boundPosition).getBlockHardness(this.world, this.boundPosition) > -1.0F) { - NonNullList drops = NonNullList.create(); - blockToBreak.getDrops(drops, this.world, this.pos, this.world.getBlockState(this.boundPosition), 0); - - if (StackUtil.canAddAll(this.inv, drops, false)) { - this.world.playEvent(2001, this.boundPosition, Block.getStateId(this.world.getBlockState(this.boundPosition))); - this.world.setBlockToAir(this.boundPosition); - StackUtil.addAll(this.inv, drops, false); - this.markDirty(); - } - } - } else { - int theSlot = StackUtil.findFirstFilled(this.inv); - if (theSlot == -1) return; - this.inv.setStackInSlot(theSlot, WorldUtil.useItemAtSide(WorldUtil.getDirectionBySidesInOrder(this.side), this.world, this.boundPosition, this.inv.getStackInSlot(theSlot))); - } - } - } - - 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.pos) <= this.range * this.range; - } - - @Override - public BlockPos getBoundPosition() { - return this.boundPosition; - } - - @Override - public void setBoundPosition(BlockPos pos) { - this.boundPosition = pos; - } - - @Override - public int getGuiID() { - return GuiHandler.GuiTypes.PHANTOM_PLACER.ordinal(); - } - - @Override - public int getRange() { - return this.range; - } - - @Override - public IAcceptor getAcceptor() { - return ItemStackHandlerAA.ACCEPT_TRUE; - } - - @Override - public IRemover getRemover() { - return (slot, automation) -> !automation; - } - - @Override - public boolean isRedstoneToggle() { - return true; - } - - @Override - public void activateOnPulse() { - this.doWork(); - } - - @Override - public void onButtonPressed(int buttonID, EntityPlayer player) { - if (this.side + 1 >= EnumFacing.values().length) { - this.side = 0; - } else { - this.side++; - } - - this.sendUpdate(); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomRedstoneface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomRedstoneface.java deleted file mode 100644 index f4a2c1257..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomRedstoneface.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file ("TileEntityPhantomRedstoneface.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; - -public class TileEntityPhantomRedstoneface extends TileEntityPhantomface { - - public final int[] providesStrong = new int[EnumFacing.values().length]; - public final int[] providesWeak = new int[EnumFacing.values().length]; - - private final int[] lastProvidesStrong = new int[this.providesStrong.length]; - private final int[] lastProvidesWeak = new int[this.providesWeak.length]; - - public TileEntityPhantomRedstoneface() { - super("redstoneface"); - } - - @Override - public void updateEntity() { - if (!this.world.isRemote) { - if (this.isBoundThingInRange()) { - IBlockState boundState = this.world.getBlockState(this.boundPosition); - if (boundState != null) { - Block boundBlock = boundState.getBlock(); - 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); - } - } - } - } - } - - super.updateEntity(); - } - - @Override - protected boolean doesNeedUpdateSend() { - return super.doesNeedUpdateSend() || !Arrays.equals(this.providesStrong, this.lastProvidesStrong) || !Arrays.equals(this.providesWeak, this.lastProvidesWeak); - } - - @Override - 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); - - super.onUpdateSent(); - } - - @Override - 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 deleted file mode 100644 index 619406ded..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * This file ("TileEntityPhantomface.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.api.tile.IPhantomTile; -import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom; -import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumParticleTypes; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -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 static final int RANGE = 16; - public BlockPos boundPosition; - public BlockPhantom.Type type; - public int range; - private int rangeBefore; - private BlockPos boundPosBefore; - private Block boundBlockBefore; - private int lastStrength; - - public TileEntityPhantomface(String name) { - super(0, name); - } - - 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 { - break; - } - } - return newRange; - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("Range", this.range); - if (this.boundPosition != null) { - compound.setInteger("xOfTileStored", this.boundPosition.getX()); - compound.setInteger("yOfTileStored", this.boundPosition.getY()); - compound.setInteger("zOfTileStored", this.boundPosition.getZ()); - } - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - 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)) { - this.boundPosition = new BlockPos(x, y, z); - this.markDirty(); - } - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - this.range = upgradeRange(RANGE, this.world, this.getPos()); - - if (!this.hasBoundPosition()) { - this.boundPosition = null; - } - - if (this.doesNeedUpdateSend()) { - this.onUpdateSent(); - } - - int strength = this.getComparatorStrength(); - if (this.lastStrength != strength) { - this.lastStrength = strength; - - this.markDirty(); - } - } else { - if (this.boundPosition != null) { - this.renderParticles(); - } - } - } - - 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() { - this.rangeBefore = this.range; - this.boundPosBefore = this.boundPosition; - this.boundBlockBefore = this.boundPosition == null ? null : this.world.getBlockState(this.boundPosition).getBlock(); - - if (this.boundPosition != null) { - this.world.notifyNeighborsOfStateChange(this.pos, this.world.getBlockState(this.boundPosition).getBlock(), false); - } - - this.sendUpdate(); - this.markDirty(); - } - - @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()) { - this.boundPosition = null; - return false; - } - return true; - } - return false; - } - - @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; - 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; - } - - @Override - public BlockPos getBoundPosition() { - return this.boundPosition; - } - - @Override - public void setBoundPosition(BlockPos pos) { - this.boundPosition = pos; - } - - @Override - public int getGuiID() { - return -1; - } - - @Override - 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)) { - TileEntity tile = this.world.getTileEntity(this.getBoundPosition()); - 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)) { - TileEntity tile = this.world.getTileEntity(this.getBoundPosition()); - if (tile != null) { return tile.getCapability(capability, facing); } - } - return super.getCapability(capability, facing); - } - - @Override - 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); } - } - return 0; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlacer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlacer.java deleted file mode 100644 index bb22c0b10..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlacer.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file ("TileEntityPlacer.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; - -public class TileEntityPlacer extends TileEntityBreaker { - - public TileEntityPlacer() { - super(9, "placer"); - this.isPlacer = true; - } - - @Override - public IAcceptor getAcceptor() { - return ItemStackHandlerAA.ACCEPT_TRUE; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java deleted file mode 100644 index cfba2d526..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * This file ("TileEntityPlayerInterface.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import java.util.UUID; - -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.energy.CapabilityEnergy; -import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.items.IItemHandler; -import net.minecraftforge.items.wrapper.PlayerInvWrapper; - -public class TileEntityPlayerInterface extends TileEntityBase implements IEnergyDisplay { - - public static final int DEFAULT_RANGE = 32; - private final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 50, 0); - public UUID connectedPlayer; - public String playerName; - private IItemHandler playerHandler; - private EntityPlayer oldPlayer; - private int oldEnergy; - private int range; - - public TileEntityPlayerInterface() { - super("playerInterface"); - } - - 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; } - } - } - return null; - } - - @Override - public IItemHandler getItemHandler(EnumFacing facing) { - EntityPlayer player = this.getPlayer(); - - if (this.oldPlayer != player) { - this.oldPlayer = player; - - this.playerHandler = player == null ? null : new PlayerInvWrapper(player.inventory); - } - - return this.playerHandler; - } - - @Override - public void updateEntity() { - super.updateEntity(); - 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) { - ItemStack slot = player.inventory.getStackInSlot(i); - if (StackUtil.isValid(slot) && slot.getCount() == 1) { - - int received = 0; - if (slot.hasCapability(CapabilityEnergy.ENERGY, null)) { - IEnergyStorage cap = slot.getCapability(CapabilityEnergy.ENERGY, null); - if (cap != null) { - received = cap.receiveEnergy(this.storage.getEnergyStored(), false); - } - } - - if (received > 0) { - this.storage.extractEnergyInternal(received, false); - } - } - } else { - break; - } - } - } - - if (changed) { - this.markDirty(); - this.sendUpdate(); - } - - if (this.storage.getEnergyStored() != this.oldEnergy && this.sendUpdateWithInterval()) { - this.oldEnergy = this.storage.getEnergyStored(); - } - } - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - - this.storage.writeToNBT(compound); - 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) { - super.readSyncableNBT(compound, type); - - this.storage.readFromNBT(compound); - if (compound.hasKey("PlayerLeast") && type != NBTType.SAVE_BLOCK) { - this.connectedPlayer = compound.getUniqueId("Player"); - this.playerName = compound.getString("PlayerName"); - } - } - - @Override - public CustomEnergyStorage getEnergyStorage() { - return this.storage; - } - - @Override - public boolean needsHoldShift() { - return false; - } - - @Override - public IEnergyStorage getEnergyStorage(EnumFacing facing) { - return this.storage; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java deleted file mode 100644 index a510eaf4f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file ("TileEntityRangedCollector.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import java.util.ArrayList; -import java.util.List; - -import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumParticleTypes; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.world.WorldServer; - -public class TileEntityRangedCollector extends TileEntityInventoryBase implements IButtonReactor { - - public static final int RANGE = 6; - public FilterSettings filter = new FilterSettings(12, true, true, false, false, 0, -1000); - - public TileEntityRangedCollector() { - super(6, "rangedCollector"); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - - this.filter.writeToNBT(compound, "Filter"); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - - this.filter.readFromNBT(compound, "Filter"); - } - - @Override - public boolean isRedstoneToggle() { - return true; - } - - @Override - public void activateOnPulse() { - List items = this.world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(this.pos.getX() - RANGE, this.pos.getY() - RANGE, this.pos.getZ() - RANGE, this.pos.getX() + RANGE, this.pos.getY() + RANGE, this.pos.getZ() + RANGE)); - if (!items.isEmpty()) { - for (EntityItem item : items) { - if (!item.isDead && !item.cannotPickup() && StackUtil.isValid(item.getItem())) { - ItemStack toAdd = item.getItem().copy(); - if (this.filter.check(toAdd)) { - ArrayList checkList = new ArrayList<>(); - checkList.add(toAdd); - if (StackUtil.canAddAll(this.inv, checkList, false)) { - StackUtil.addAll(this.inv, checkList, false); - ((WorldServer) this.world).spawnParticle(EnumParticleTypes.CLOUD, false, item.posX, item.posY + 0.45F, item.posZ, 5, 0, 0, 0, 0.03D); - item.setDead(); - } - } - } - } - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - if (!this.isRedstonePowered && !this.isPulseMode) { - this.activateOnPulse(); - } - - if (this.filter.needsUpdateSend() && this.sendUpdateWithInterval()) { - this.filter.updateLasts(); - } - } - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !automation; - } - - @Override - public void onButtonPressed(int buttonID, EntityPlayer player) { - this.filter.onButtonPressed(buttonID); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityShockSuppressor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityShockSuppressor.java deleted file mode 100644 index e5445b14f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityShockSuppressor.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This file ("TileEntityShockSuppressor.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; - -public class TileEntityShockSuppressor extends TileEntityBase implements IEnergyDisplay { - - public static final List SUPPRESSORS = new ArrayList<>(); - - public static final int USE_PER = 300; - public static final int RANGE = 5; - - public CustomEnergyStorage storage = new CustomEnergyStorage(300000, 400, 0); - private int oldEnergy; - - public TileEntityShockSuppressor() { - super("shockSuppressor"); - } - - @Override - public void onChunkUnload() { - super.onChunkUnload(); - - if (!this.world.isRemote) { - SUPPRESSORS.remove(this); - } - } - - @Override - public void invalidate() { - super.invalidate(); - - if (!this.world.isRemote) { - SUPPRESSORS.remove(this); - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - - if (!this.world.isRemote) { - if (!this.isInvalid() && !SUPPRESSORS.contains(this)) { - SUPPRESSORS.add(this); - } - - if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { - this.oldEnergy = this.storage.getEnergyStored(); - } - } - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - this.storage.writeToNBT(compound); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - this.storage.readFromNBT(compound); - } - - @Override - public CustomEnergyStorage getEnergyStorage() { - return this.storage; - } - - @Override - public boolean needsHoldShift() { - return false; - } - - @Override - 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 deleted file mode 100644 index d12a69b4e..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file ("TileEntitySmileyCloud.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -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 String name; - private String nameBefore; - - public TileEntitySmileyCloud() { - super("smileyCloud"); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - if (this.name != null && type != NBTType.SAVE_BLOCK) { - compound.setString("Name", this.name); - } - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - this.name = compound.getString("Name"); - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - boolean nameChanged = this.name != null ? !this.name.equals(this.nameBefore) : this.nameBefore != null; - if (nameChanged && this.sendUpdateWithInterval()) { - this.nameBefore = this.name; - this.markDirty(); - } - } - } - - @Override - public void onTextReceived(String text, int textID, EntityPlayer player) { - this.name = text; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java deleted file mode 100644 index 193c62fe9..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * This file ("TileEntityXPSolidifier.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import java.util.List; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.ItemSolidifiedExperience; -import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.item.EntityXPOrb; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.MathHelper; - -public class TileEntityXPSolidifier extends TileEntityInventoryBase implements IButtonReactor { - - private static final int[] XP_MAP = new int[256]; - - static { - for (int i = 0; i < XP_MAP.length; i++) { - XP_MAP[i] = getExperienceForLevelImpl(i); - } - } - - private final int[] buttonAmounts = new int[] { 1, 5, 10, 20, 30, 40, 50, 64, -999 }; - public int amount; - private int lastAmount; - private int singlePointAmount; - - public TileEntityXPSolidifier() { - super(2, "xpSolidifier"); - } - - /* - * The below methods were excerpted from EnderIO by SleepyTrousers with permission, thanks! - */ - - public static int getExperienceForLevel(int level) { - if (level >= 0 && level < XP_MAP.length) { return XP_MAP[level]; } - if (level >= 21863) { return Integer.MAX_VALUE; } - return getExperienceForLevelImpl(level); - } - - private static int getExperienceForLevelImpl(int level) { - int res = 0; - for (int i = 0; i < level; i++) { - res += getXpBarCapacity(i); - if (res < 0) { return Integer.MAX_VALUE; } - } - return res; - } - - public static int getXpBarCapacity(int level) { - if (level >= 30) { - return 112 + (level - 30) * 9; - } else if (level >= 15) { return 37 + (level - 15) * 5; } - return 7 + level * 2; - } - - public static int getLevelForExperience(int experience) { - for (int i = 0; i < XP_MAP.length; i++) { - if (XP_MAP[i] > experience) { return i - 1; } - } - int i = XP_MAP.length; - while (getExperienceForLevel(i) <= experience) { - i++; - } - return i - 1; - } - - public static int getPlayerXP(EntityPlayer player) { - return (int) (getExperienceForLevel(player.experienceLevel) + player.experience * player.xpBarCap()); - } - - public static void addPlayerXP(EntityPlayer player, int amount) { - int experience = Math.max(0, getPlayerXP(player) + amount); - player.experienceTotal = experience; - player.experienceLevel = getLevelForExperience(experience); - int expForLevel = getExperienceForLevel(player.experienceLevel); - player.experience = (float) (experience - expForLevel) / (float) player.xpBarCap(); - } - - @Override - public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { - super.writeSyncableNBT(compound, type); - compound.setInteger("Amount", this.amount); - compound.setInteger("SinglePointAmount", this.singlePointAmount); - } - - @Override - public void readSyncableNBT(NBTTagCompound compound, NBTType type) { - super.readSyncableNBT(compound, type); - this.amount = compound.getInteger("Amount"); - this.singlePointAmount = compound.getInteger("SinglePointAmount"); - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - if (this.amount > 0) { - ItemStack stack = this.inv.getStackInSlot(0); - if (stack.isEmpty()) { - int toSet = this.amount > 64 ? 64 : this.amount; - this.inv.setStackInSlot(0, new ItemStack(InitItems.itemSolidifiedExperience, toSet)); - this.amount -= toSet; - this.markDirty(); - } else if (stack.getCount() < 64) { - int needed = 64 - stack.getCount(); - int toAdd = Math.min(needed, this.amount); - stack.grow(toAdd); - this.amount -= toAdd; - this.markDirty(); - } - } - - if (!this.isRedstonePowered) { - int range = 5; - List orbs = this.world.getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(this.pos.getX() - range, this.pos.getY() - range, this.pos.getZ() - range, this.pos.getX() + 1 + range, this.pos.getY() + 1 + range, this.pos.getZ() + 1 + range)); - if (orbs != null && !orbs.isEmpty()) { - for (EntityXPOrb orb : orbs) { - if (orb != null && !orb.isDead && !orb.getEntityData().getBoolean(ActuallyAdditions.MODID + "FromSolidified")) { - this.singlePointAmount += orb.getXpValue(); - orb.setDead(); - - if (this.singlePointAmount >= ItemSolidifiedExperience.SOLID_XP_AMOUNT) { - this.amount += this.singlePointAmount / ItemSolidifiedExperience.SOLID_XP_AMOUNT; - this.singlePointAmount = 0; - this.markDirty(); - } - } - } - } - } - - ItemStack stack = this.inv.getStackInSlot(1); - if (StackUtil.isValid(stack) && stack.getItem() instanceof ItemSolidifiedExperience) { - int remainingSpace = MathHelper.clamp(Integer.MAX_VALUE - this.amount, 0, stack.getCount()); - if (stack.getCount() >= remainingSpace && remainingSpace != 0) { - this.amount += remainingSpace; - stack.shrink(remainingSpace); - this.markDirty(); - } - } - - if (this.lastAmount != this.amount && this.sendUpdateWithInterval()) { - this.lastAmount = this.amount; - } - } - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> slot == 1 && stack.getItem() == InitItems.itemSolidifiedExperience; - } - - @Override - public void markDirty() { - if (this.amount < 0) this.amount = Integer.MAX_VALUE; //don't u go negative on me weird number - super.markDirty(); - } - - @Override - public void onButtonPressed(int buttonID, EntityPlayer player) { - if (buttonID < this.buttonAmounts.length) { - int playerXP = getPlayerXP(player); - if (playerXP > 0) { - int xp = this.buttonAmounts[buttonID] == -999 ? playerXP / ItemSolidifiedExperience.SOLID_XP_AMOUNT : this.buttonAmounts[buttonID]; - if (this.amount < Integer.MAX_VALUE - xp && playerXP >= ItemSolidifiedExperience.SOLID_XP_AMOUNT * xp) { - addPlayerXP(player, -(ItemSolidifiedExperience.SOLID_XP_AMOUNT * xp)); - if (!this.world.isRemote) { - this.amount += xp; - } - } - } - } - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/update/ThreadUpdateChecker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/update/ThreadUpdateChecker.java deleted file mode 100644 index 31c77b900..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/update/ThreadUpdateChecker.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file ("ThreadUpdateChecker.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.update; - -import java.io.InputStreamReader; -import java.net.URL; -import java.util.Properties; - -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 ThreadUpdateChecker() { - this.setName(ActuallyAdditions.NAME + " Update Checker"); - this.setDaemon(true); - this.start(); - } - - @Override - public void run() { - ActuallyAdditions.LOGGER.info("Starting Update Check..."); - 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()) { - String newestVersionProp = updateProperties.getProperty(currentMcVersion); - - UpdateChecker.updateVersionInt = Integer.parseInt(newestVersionProp); - UpdateChecker.updateVersionString = currentMcVersion + "-r" + newestVersionProp; - } else { - int highest = 0; - String highestString = ""; - - for (String updateMC : updateProperties.stringPropertyNames()) { - String updateVersion = updateProperties.getProperty(updateMC); - int update = Integer.parseInt(updateVersion); - if (highest < update) { - highest = update; - highestString = updateMC + "-r" + updateVersion; - } - } - - UpdateChecker.updateVersionInt = highest; - UpdateChecker.updateVersionString = highestString; - } - - String clientVersionString = Util.getMajorModVersion(); - int clientVersion = Integer.parseInt(clientVersionString.contains("_") ? clientVersionString.substring(0, clientVersionString.indexOf("_")) : clientVersionString); - if (UpdateChecker.updateVersionInt > clientVersion) { - UpdateChecker.needsUpdateNotify = true; - } - - ActuallyAdditions.LOGGER.info("Update Check done!"); - } 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!"); - } - } - - UpdateChecker.threadFinished = true; - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java deleted file mode 100644 index 609f2edfc..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file ("UpdateChecker.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.update; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; -import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import de.ellpeck.actuallyadditions.mod.util.Util; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class UpdateChecker { - - public static final String DOWNLOAD_LINK = "http://ellpeck.de/actadddownload"; - public static final String CHANGELOG_LINK = "http://ellpeck.de/actaddchangelog"; - public static boolean checkFailed; - public static boolean needsUpdateNotify; - public static int updateVersionInt; - public static String updateVersionString; - public static boolean threadFinished = false; - - public UpdateChecker() { - if (ConfigBoolValues.DO_UPDATE_CHECK.isEnabled() && !Util.isDevVersion()) { - ActuallyAdditions.LOGGER.info("Initializing Update Checker..."); - new ThreadUpdateChecker(); - MinecraftForge.EVENT_BUS.register(this); - } - } - - @SideOnly(Side.CLIENT) - @SubscribeEvent(receiveCanceled = true) - 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"))); - } 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); - } - } -} \ 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 deleted file mode 100644 index 75a6103de..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java +++ /dev/null @@ -1,376 +0,0 @@ -/* - * This file ("AssetUtil.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.util; - -import org.lwjgl.opengl.GL11; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.network.PacketHandler; -import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient; -import de.ellpeck.actuallyadditions.mod.particle.ParticleBeam; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.particle.Particle; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.GlStateManager.DestFactor; -import net.minecraft.client.renderer.GlStateManager.SourceFactor; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.RenderItem; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.block.model.IBakedModel; -import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.client.ForgeHooksClient; -import net.minecraftforge.fml.common.network.NetworkRegistry; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -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 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); - } - - @SideOnly(Side.CLIENT) - 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) { - renderItemInWorld(new ItemStack(block, 1, meta)); - } - - @SideOnly(Side.CLIENT) - public static void renderItemInWorld(ItemStack stack) { - if (StackUtil.isValid(stack)) { - GlStateManager.pushMatrix(); - GlStateManager.disableLighting(); - GlStateManager.pushAttrib(); - RenderHelper.enableStandardItemLighting(); - Minecraft.getMinecraft().getRenderItem().renderItem(stack, TransformType.FIXED); - RenderHelper.disableStandardItemLighting(); - GlStateManager.popAttrib(); - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); - } - } - - @SideOnly(Side.CLIENT) - 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); - int i = Minecraft.getMinecraft().getBlockColors().colorMultiplier(state, world, pos, 0); - - float r = (i >> 16 & 255) / 255F; - float g = (i >> 8 & 255) / 255F; - float b = (i & 255) / 255F; - - Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(state, model, brightness, r, g, b); - } - - @SideOnly(Side.CLIENT) - public static void renderItemWithoutScrewingWithColors(ItemStack stack) { - if (StackUtil.isValid(stack)) { - Minecraft mc = Minecraft.getMinecraft(); - RenderItem renderer = mc.getRenderItem(); - TextureManager manager = mc.getTextureManager(); - - IBakedModel model = renderer.getItemModelWithOverrides(stack, null, null); - - manager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); - manager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false); - GlStateManager.enableRescaleNormal(); - GlStateManager.enableBlend(); - GlStateManager.pushMatrix(); - model = ForgeHooksClient.handleCameraTransforms(model, TransformType.FIXED, false); - renderer.renderItem(stack, model); - GlStateManager.cullFace(GlStateManager.CullFace.BACK); - GlStateManager.popMatrix(); - GlStateManager.disableRescaleNormal(); - GlStateManager.disableBlend(); - manager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); - manager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap(); - } - } - - @SideOnly(Side.CLIENT) - 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); - RenderHelper.enableGUIStandardItemLighting(); - GlStateManager.enableDepth(); - GlStateManager.enableRescaleNormal(); - GlStateManager.translate(x, y, 0); - GlStateManager.scale(scale, scale, scale); - - Minecraft mc = Minecraft.getMinecraft(); - boolean flagBefore = mc.fontRenderer.getUnicodeFlag(); - mc.fontRenderer.setUnicodeFlag(false); - Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(stack, 0, 0); - Minecraft.getMinecraft().getRenderItem().renderItemOverlayIntoGUI(mc.fontRenderer, stack, 0, 0, null); - mc.fontRenderer.setUnicodeFlag(flagBefore); - - RenderHelper.disableStandardItemLighting(); - GlStateManager.popMatrix(); - } - - //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; - GlStateManager.disableTexture2D(); - GlStateManager.enableBlend(); - GlStateManager.disableAlpha(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.shadeModel(7425); - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder renderer = tessellator.getBuffer(); - renderer.begin(7, DefaultVertexFormats.POSITION_COLOR); - renderer.pos(left, top, zLevel).color(f1, f2, f3, f).endVertex(); - renderer.pos(left, bottom, zLevel).color(f1, f2, f3, f).endVertex(); - renderer.pos(right, bottom, zLevel).color(f5, f6, f7, f4).endVertex(); - renderer.pos(right, top, zLevel).color(f5, f6, f7, f4).endVertex(); - tessellator.draw(); - GlStateManager.shadeModel(7424); - GlStateManager.disableBlend(); - GlStateManager.enableAlpha(); - GlStateManager.enableTexture2D(); - } - - @SideOnly(Side.CLIENT) - 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; - GlStateManager.pushMatrix(); - GlStateManager.translate(x, y, z); - GL11.glNormal3f(0.0F, 1.0F, 0.0F); - GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); - GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F); - GlStateManager.scale(-f1, -f1, f1); - GlStateManager.disableLighting(); - GlStateManager.depthMask(false); - GlStateManager.disableDepth(); - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder renderer = tessellator.getBuffer(); - int i = 0; - 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(); - tessellator.draw(); - GlStateManager.enableTexture2D(); - fontrenderer.drawString(tag, -fontrenderer.getStringWidth(tag) / 2, i, 553648127); - GlStateManager.enableDepth(); - GlStateManager.depthMask(true); - 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) { - NBTTagCompound data = new NBTTagCompound(); - data.setDouble("StartX", startX); - data.setDouble("StartY", startY); - data.setDouble("StartZ", startZ); - data.setDouble("EndX", endX); - data.setDouble("EndY", endY); - data.setDouble("EndZ", endZ); - data.setFloat("Color1", color[0]); - data.setFloat("Color2", color[1]); - data.setFloat("Color3", color[2]); - data.setDouble("RotationTime", rotationTime); - data.setFloat("Size", size); - data.setInteger("MaxAge", maxAge); - data.setFloat("Alpha", alpha); - PacketHandler.theNetwork.sendToAllAround(new PacketServerToClient(data, PacketHandler.LASER_HANDLER), new NetworkRegistry.TargetPoint(world.provider.getDimension(), startX, startY, startZ, 96)); - } - } - - @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) { - Minecraft mc = Minecraft.getMinecraft(); - - 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); - } - } - - //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) { - Tessellator tessy = Tessellator.getInstance(); - BufferBuilder render = tessy.getBuffer(); - World world = Minecraft.getMinecraft().world; - - float r = color[0]; - float g = color[1]; - float b = color[2]; - - Vec3d vec1 = new Vec3d(firstX, firstY, firstZ); - 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 yaw = Math.atan2(-combinedVec.z, combinedVec.x); - - double length = combinedVec.length(); - - GlStateManager.pushMatrix(); - - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE); - 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); - - /*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(); - render.pos(0, -beamWidth, -beamWidth).tex(0, 0).color(r2, g2, b2, alpha).endVertex(); - tessy.draw(); - } - 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); - 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(); - render.pos(length, -width, width).tex(0, 0).lightmap(MAX_LIGHT_X, MAX_LIGHT_Y).color(r, g, b, alpha).endVertex(); - - 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(); - render.pos(length, width, -width).tex(0, 0).lightmap(MAX_LIGHT_X, MAX_LIGHT_Y).color(r, g, b, alpha).endVertex(); - - 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(); - render.pos(length, width, width).tex(0, 0).lightmap(MAX_LIGHT_X, MAX_LIGHT_Y).color(r, g, b, alpha).endVertex(); - - 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(); - render.pos(length, -width, -width).tex(0, 0).lightmap(MAX_LIGHT_X, MAX_LIGHT_Y).color(r, g, b, alpha).endVertex(); - } - tessy.draw(); - - GlStateManager.enableTexture2D(); - //} - - GlStateManager.alphaFunc(func, ref); - GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); - GlStateManager.disableBlend(); - GlStateManager.enableLighting(); - 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 }; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AwfulUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AwfulUtil.java deleted file mode 100644 index e3958d31b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AwfulUtil.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * This file ("AwfulUtil.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import net.minecraft.world.storage.loot.LootTable; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.items.IItemHandlerModifiable; - -//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 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); - } - } - } - - private static void shuffleItems(List stacks, int someInt, Random rand) { - List list = Lists.newArrayList(); - Iterator iterator = stacks.iterator(); - - while (iterator.hasNext()) { - ItemStack itemstack = iterator.next(); - - if (itemstack.isEmpty()) { - iterator.remove(); - } else if (itemstack.getCount() > 1) { - list.add(itemstack); - iterator.remove(); - } - } - - 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); - ItemStack itemstack1 = itemstack2.splitStack(i); - - if (itemstack2.getCount() > 1 && rand.nextBoolean()) { - list.add(itemstack2); - } else { - stacks.add(itemstack2); - } - - if (itemstack1.getCount() > 1 && rand.nextBoolean()) { - list.add(itemstack1); - } else { - stacks.add(itemstack1); - } - } - - stacks.addAll(list); - Collections.shuffle(stacks, 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()) { - list.add(i); - } - } - - Collections.shuffle(list, rand); - return list; - } - - 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) { - error += "\n" + i++ + ": " + (k == null ? "null" : k.getClass().getSimpleName() + " <- CLASS | INSTANCE -> " + k.toString() + ", "); - } - error += "\n" + "The current side is: " + FMLCommonHandler.instance().getEffectiveSide(); - error += "\n" + "Report this to https://github.com/Ellpeck/ActuallyAdditions/issues"; - throw new IllegalStateException(error); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/FluidStateMapper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/FluidStateMapper.java deleted file mode 100644 index 9d1a79549..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/FluidStateMapper.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file ("FluidStateMapper.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.util; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.ItemMeshDefinition; -import net.minecraft.client.renderer.block.model.ModelResourceLocation; -import net.minecraft.client.renderer.block.statemap.StateMapperBase; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fml.relauncher.Side; -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 final Fluid fluid; - public final ModelResourceLocation location; - - public FluidStateMapper(Fluid fluid) { - this.fluid = fluid; - - this.location = new ModelResourceLocation(new ResourceLocation(ActuallyAdditions.MODID, "fluids"), fluid.getName()); - } - - @Override - protected ModelResourceLocation getModelResourceLocation(IBlockState state) { - return this.location; - } - - @Override - 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 deleted file mode 100644 index 40543780d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingBlock.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * This file ("IColorProvidingBlock.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.util; - -import net.minecraft.client.renderer.color.IBlockColor; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -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 deleted file mode 100644 index 33562842d..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingItem.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * This file ("IColorProvidingItem.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.util; - -import net.minecraft.client.renderer.color.IItemColor; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public interface IColorProvidingItem { - - @SideOnly(Side.CLIENT) - IItemColor getItemColor(); - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemStackHandlerAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemStackHandlerAA.java deleted file mode 100644 index 4d747a86f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemStackHandlerAA.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file ("ItemStackHandlerAA.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.util; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraftforge.items.ItemStackHandler; - -/** - * The Actually Additions variant of ItemStackHandler. Provides methods to disallow add/removal based on automation context. Defaults to thinking operations are performed by automation. - * @author Shadows - */ -public class ItemStackHandlerAA extends ItemStackHandler { - - public static final IAcceptor ACCEPT_TRUE = (a, b, c) -> true; - public static final IRemover REMOVE_TRUE = (a, b) -> true; - public static final IAcceptor ACCEPT_FALSE = (a, b, c) -> false; - public static final IRemover REMOVE_FALSE = (a, b) -> false; - - IAcceptor acceptor; - IRemover remover; - - public ItemStackHandlerAA(NonNullList stacks, IAcceptor acceptor, IRemover remover) { - super(stacks); - this.acceptor = acceptor; - this.remover = remover; - } - - public ItemStackHandlerAA(int slots, IAcceptor acceptor, IRemover remover) { - super(slots); - this.acceptor = acceptor; - this.remover = remover; - } - - public ItemStackHandlerAA(NonNullList stacks) { - this(stacks, ACCEPT_TRUE, REMOVE_TRUE); - } - - public ItemStackHandlerAA(int slots) { - this(slots, ACCEPT_TRUE, REMOVE_TRUE); - } - - public NonNullList getItems() { - return this.stacks; - } - - @Override - public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { - return this.insertItem(slot, stack, simulate, true); - } - - public ItemStack insertItem(int slot, ItemStack stack, boolean simulate, boolean fromAutomation) { - if (!this.canAccept(slot, stack, fromAutomation)) return stack; - return super.insertItem(slot, stack, simulate); - } - - @Override - public ItemStack extractItem(int slot, int amount, boolean simulate) { - return this.extractItem(slot, amount, simulate, true); - } - - public ItemStack extractItem(int slot, int amount, boolean simulate, boolean byAutomation) { - if (!this.canRemove(slot, byAutomation)) return ItemStack.EMPTY; - return super.extractItem(slot, amount, simulate); - } - - public final boolean canAccept(int slot, ItemStack stack, boolean automation) { - return this.getAcceptor().canAccept(slot, stack, automation); - } - - public final boolean canRemove(int slot, boolean automation) { - return this.getRemover().canRemove(slot, automation); - } - - public IAcceptor getAcceptor() { - return this.acceptor; - } - - public IRemover getRemover() { - return this.remover; - } - - public static interface IAcceptor { - boolean canAccept(int slot, ItemStack stack, boolean automation); - } - - public static interface IRemover { - boolean canRemove(int slot, boolean automation); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java deleted file mode 100644 index e4f877184..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * This file ("ItemUtil.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.mod.creative.CreativeTab; -import de.ellpeck.actuallyadditions.mod.util.compat.IMCHandler; -import net.minecraft.block.Block; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.EnumHand; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.registry.ForgeRegistries; - -public final class ItemUtil { - - 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); - - block.setRegistryName(ActuallyAdditions.MODID, name); - RegistryHandler.BLOCKS_TO_REGISTER.add(block); - - itemBlock.setRegistryName(block.getRegistryName()); - RegistryHandler.ITEMS_TO_REGISTER.add(itemBlock); - - block.setCreativeTab(addTab ? CreativeTab.INSTANCE : null); - - IMCHandler.doBlockIMC(block); - - if (block instanceof IColorProvidingBlock) { - ActuallyAdditions.PROXY.addColoredBlock(block); - } - } - - 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); - - item.setCreativeTab(addTab ? CreativeTab.INSTANCE : null); - - IMCHandler.doItemIMC(item); - - if (item instanceof IColorProvidingItem) { - ActuallyAdditions.PROXY.addColoredItem(item); - } - } - - 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) { - 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; } - } - } - return -1; - } - - 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) { - return !(list == null || list.isEmpty()) && getPlaceAt(list, stack, checkWildcard) != -1; - } - - 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) { - NBTTagList ench = stack.getEnchantmentTagList(); - 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; } - } - } - return false; - } - - public static void removeEnchantment(ItemStack stack, Enchantment e) { - NBTTagList ench = stack.getEnchantmentTagList(); - if (ench != null) { - for (int i = 0; i < ench.tagCount(); i++) { - short id = ench.getCompoundTagAt(i).getShort("id"); - if (id == Enchantment.getEnchantmentID(e)) { - ench.removeTag(i); - } - } - if (ench.isEmpty() && stack.hasTagCompound()) { - stack.getTagCompound().removeTag("ench"); - } - } - } - - public static boolean canBeStacked(ItemStack stack1, ItemStack stack2) { - return ItemStack.areItemsEqual(stack1, stack2) && ItemStack.areItemStackTagsEqual(stack1, stack2); - } - - public static boolean isEnabled(ItemStack stack) { - return stack.hasTagCompound() && stack.getTagCompound().getBoolean("IsEnabled"); - } - - public static void changeEnabled(EntityPlayer player, EnumHand hand) { - changeEnabled(player.getHeldItem(hand)); - } - - public static void changeEnabled(ItemStack stack) { - if (!stack.hasTagCompound()) { - stack.setTagCompound(new NBTTagCompound()); - } - - boolean isEnabled = isEnabled(stack); - stack.getTagCompound().setBoolean("IsEnabled", !isEnabled); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/NetHandlerSpaghettiServer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/NetHandlerSpaghettiServer.java deleted file mode 100644 index 651d67554..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/NetHandlerSpaghettiServer.java +++ /dev/null @@ -1,190 +0,0 @@ -package de.ellpeck.actuallyadditions.mod.util; - -import java.util.Set; - -import net.minecraft.network.EnumPacketDirection; -import net.minecraft.network.NetHandlerPlayServer; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.Packet; -import net.minecraft.network.play.client.CPacketAnimation; -import net.minecraft.network.play.client.CPacketChatMessage; -import net.minecraft.network.play.client.CPacketClickWindow; -import net.minecraft.network.play.client.CPacketClientSettings; -import net.minecraft.network.play.client.CPacketClientStatus; -import net.minecraft.network.play.client.CPacketCloseWindow; -import net.minecraft.network.play.client.CPacketConfirmTeleport; -import net.minecraft.network.play.client.CPacketConfirmTransaction; -import net.minecraft.network.play.client.CPacketCreativeInventoryAction; -import net.minecraft.network.play.client.CPacketCustomPayload; -import net.minecraft.network.play.client.CPacketEnchantItem; -import net.minecraft.network.play.client.CPacketEntityAction; -import net.minecraft.network.play.client.CPacketHeldItemChange; -import net.minecraft.network.play.client.CPacketInput; -import net.minecraft.network.play.client.CPacketKeepAlive; -import net.minecraft.network.play.client.CPacketPlaceRecipe; -import net.minecraft.network.play.client.CPacketPlayer; -import net.minecraft.network.play.client.CPacketPlayerAbilities; -import net.minecraft.network.play.client.CPacketPlayerDigging; -import net.minecraft.network.play.client.CPacketPlayerTryUseItem; -import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock; -import net.minecraft.network.play.client.CPacketRecipeInfo; -import net.minecraft.network.play.client.CPacketResourcePackStatus; -import net.minecraft.network.play.client.CPacketSeenAdvancements; -import net.minecraft.network.play.client.CPacketSpectate; -import net.minecraft.network.play.client.CPacketSteerBoat; -import net.minecraft.network.play.client.CPacketTabComplete; -import net.minecraft.network.play.client.CPacketUpdateSign; -import net.minecraft.network.play.client.CPacketUseEntity; -import net.minecraft.network.play.client.CPacketVehicleMove; -import net.minecraft.network.play.server.SPacketPlayerPosLook.EnumFlags; -import net.minecraft.util.text.ITextComponent; -import net.minecraftforge.common.util.FakePlayer; - -public class NetHandlerSpaghettiServer extends NetHandlerPlayServer { - - public NetHandlerSpaghettiServer(FakePlayer player) { - super(null, new NetworkManager(EnumPacketDirection.CLIENTBOUND), player); - } - - @Override - public void disconnect(ITextComponent textComponent) { - } - - @Override - public void func_194308_a(CPacketPlaceRecipe p_194308_1_) { - } - - @Override - public void handleAnimation(CPacketAnimation packetIn) { - } - - @Override - public void handleRecipeBookUpdate(CPacketRecipeInfo p_191984_1_) { - } - - @Override - public void handleResourcePackStatus(CPacketResourcePackStatus packetIn) { - } - - @Override - public void handleSeenAdvancements(CPacketSeenAdvancements p_194027_1_) { - } - - @Override - public void handleSpectate(CPacketSpectate packetIn) { - } - - @Override - public void onDisconnect(ITextComponent reason) { - } - - @Override - public void processChatMessage(CPacketChatMessage packetIn) { - } - - @Override - public void processClickWindow(CPacketClickWindow packetIn) { - } - - @Override - public void processClientSettings(CPacketClientSettings packetIn) { - } - - @Override - public void processClientStatus(CPacketClientStatus packetIn) { - } - - @Override - public void processCloseWindow(CPacketCloseWindow packetIn) { - } - - @Override - public void processConfirmTeleport(CPacketConfirmTeleport packetIn) { - } - - @Override - public void processConfirmTransaction(CPacketConfirmTransaction packetIn) { - } - - @Override - public void processCreativeInventoryAction(CPacketCreativeInventoryAction packetIn) { - } - - @Override - public void processCustomPayload(CPacketCustomPayload packetIn) { - } - - @Override - public void processEnchantItem(CPacketEnchantItem packetIn) { - } - - @Override - public void processEntityAction(CPacketEntityAction packetIn) { - } - - @Override - public void processHeldItemChange(CPacketHeldItemChange packetIn) { - } - - @Override - public void processInput(CPacketInput packetIn) { - } - - @Override - public void processKeepAlive(CPacketKeepAlive packetIn) { - } - - @Override - public void processPlayer(CPacketPlayer packetIn) { - } - - @Override - public void processPlayerAbilities(CPacketPlayerAbilities packetIn) { - } - - @Override - public void processPlayerDigging(CPacketPlayerDigging packetIn) { - } - - @Override - public void processSteerBoat(CPacketSteerBoat packetIn) { - } - - @Override - public void processTabComplete(CPacketTabComplete packetIn) { - } - - @Override - public void processTryUseItem(CPacketPlayerTryUseItem packetIn) { - } - - @Override - public void processTryUseItemOnBlock(CPacketPlayerTryUseItemOnBlock packetIn) { - } - - @Override - public void processUpdateSign(CPacketUpdateSign packetIn) { - } - - @Override - public void processUseEntity(CPacketUseEntity packetIn) { - } - - @Override - public void processVehicleMove(CPacketVehicleMove packetIn) { - } - - @Override - public void sendPacket(Packet packetIn) { - } - - @Override - public void setPlayerLocation(double x, double y, double z, float yaw, float pitch) { - } - - @Override - public void setPlayerLocation(double x, double y, double z, float yaw, float pitch, Set relativeSet) { - - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/Rarity.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/Rarity.java deleted file mode 100644 index 2b0b2e38b..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/Rarity.java +++ /dev/null @@ -1,26 +0,0 @@ -package de.ellpeck.actuallyadditions.mod.util; - -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.common.IRarity; - -public class Rarity implements IRarity { - - TextFormatting color; - String name; - - public Rarity(TextFormatting color, String name) { - this.color = color; - this.name = name; - } - - @Override - public TextFormatting getColor() { - return color; - } - - @Override - public String getName() { - return name; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/RecipeUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/RecipeUtil.java deleted file mode 100644 index be8d227db..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/RecipeUtil.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file ("RecipeUtil.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; -import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; -import de.ellpeck.actuallyadditions.mod.util.crafting.RecipeHandler; -import net.minecraft.item.crafting.IRecipe; - -public final class RecipeUtil { - - public static LensConversionRecipe lastReconstructorRecipe() { - List list = ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES; - return list.get(list.size() - 1); - } - - public static CrusherRecipe lastCrusherRecipe() { - List list = ActuallyAdditionsAPI.CRUSHER_RECIPES; - return list.get(list.size() - 1); - } - - public static IRecipe lastIRecipe() { - return RecipeHandler.lastRecipe; - } - - public static EmpowererRecipe lastEmpowererRecipe() { - List list = ActuallyAdditionsAPI.EMPOWERER_RECIPES; - 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 deleted file mode 100644 index f25841218..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/RefHelp.java +++ /dev/null @@ -1,231 +0,0 @@ -package de.ellpeck.actuallyadditions.mod.util; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.StringJoiner; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import org.apache.commons.lang3.StringUtils; - -import com.google.common.base.MoreObjects; -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; - - public UnableToFindMethodException(String[] methodNames, Exception failed) { - super(failed); - } - - public UnableToFindMethodException(Throwable failed) { - super(failed); - } - } - - public static class UnableToFindClassException extends RuntimeException { - private static final long serialVersionUID = 1L; - - public UnableToFindClassException(String[] classNames, @Nullable Exception err) { - super(err); - } - } - - public static class UnableToAccessFieldException extends RuntimeException { - private static final long serialVersionUID = 1L; - - public UnableToAccessFieldException(String[] fieldNames, Exception e) { - super(e); - } - - public UnableToAccessFieldException(Exception e) { - super(e); - } - } - - public static class UnableToFindFieldException extends RuntimeException { - private static final long serialVersionUID = 1L; - - public UnableToFindFieldException(String[] fieldNameList, Exception e) { - super(e); - } - - public UnableToFindFieldException(Exception e) { - super(e); - } - } - - public static class UnknownConstructorException extends RuntimeException { - public UnknownConstructorException(final String message) { - super(message); - } - } - - public static Field findField(Class clazz, String... fieldNames) { - Exception failed = null; - for (String fieldName : fieldNames) { - try { - Field f = clazz.getDeclaredField(fieldName); - f.setAccessible(true); - return f; - } catch (Exception e) { - failed = e; - } - } - throw new UnableToFindFieldException(fieldNames, failed); - } - - @Nonnull - public static Field findField(@Nonnull Class clazz, @Nonnull String fieldName, @Nullable String fieldObfName) { - Preconditions.checkNotNull(clazz); - Preconditions.checkArgument(StringUtils.isNotEmpty(fieldName), "Field name cannot be empty"); - - String nameToFind = FMLLaunchHandler.isDeobfuscatedEnvironment() ? fieldName : MoreObjects.firstNonNull(fieldObfName, fieldName); - - try { - Field f = clazz.getDeclaredField(nameToFind); - f.setAccessible(true); - return f; - } catch (Exception e) { - throw new UnableToFindFieldException(e); - } - } - - @SuppressWarnings("unchecked") - public static T getPrivateValue(Class classToAccess, @Nullable E instance, int fieldIndex) { - try { - Field f = classToAccess.getDeclaredFields()[fieldIndex]; - f.setAccessible(true); - return (T) f.get(instance); - } catch (Exception e) { - throw new UnableToAccessFieldException(e); - } - } - - @SuppressWarnings("unchecked") - public static T getPrivateValue(Class classToAccess, E instance, String... fieldNames) { - try { - return (T) findField(classToAccess, fieldNames).get(instance); - } catch (Exception e) { - throw new UnableToAccessFieldException(fieldNames, e); - } - } - - @SuppressWarnings("unchecked") - public static T getPrivateValue(Class classToAccess, @Nullable E instance, String fieldName, @Nullable String fieldObfName) { - try { - return (T) findField(classToAccess, fieldName, fieldObfName).get(instance); - } catch (Exception e) { - throw new UnableToAccessFieldException(e); - } - } - - public static void setPrivateValue(Class classToAccess, T instance, E value, int fieldIndex) { - try { - Field f = classToAccess.getDeclaredFields()[fieldIndex]; - f.setAccessible(true); - f.set(instance, value); - } catch (Exception e) { - throw new UnableToAccessFieldException(e); - } - } - - public static void setPrivateValue(Class classToAccess, T instance, E value, String... fieldNames) { - try { - findField(classToAccess, fieldNames).set(instance, value); - } catch (Exception e) { - throw new UnableToAccessFieldException(fieldNames, e); - } - } - - public static void setPrivateValue(Class classToAccess, @Nullable T instance, @Nullable E value, String fieldName, @Nullable String fieldObfName) { - try { - findField(classToAccess, fieldName, fieldObfName).set(instance, value); - } catch (Exception e) { - throw new UnableToAccessFieldException(e); - } - } - - @SuppressWarnings("unchecked") - public static Class getClass(ClassLoader loader, String... classNames) { - Exception err = null; - for (String className : classNames) { - try { - return (Class) Class.forName(className, false, loader); - } catch (Exception e) { - err = e; - } - } - - throw new UnableToFindClassException(classNames, err); - } - - /** - * Finds a method with the specified name and parameters in the given class and makes it accessible. - * Note: for performance, store the returned value and avoid calling this repeatedly. - *

- * Throws an exception if the method is not found. - * - * @param clazz The class to find the method on. - * @param methodName The name of the method to find (used in developer environments, i.e. "getWorldTime"). - * @param methodObfName The obfuscated name of the method to find (used in obfuscated environments, i.e. "getWorldTime"). - * If the name you are looking for is on a class that is never obfuscated, this should be null. - * @param parameterTypes The parameter types of the method to find. - * @return The method with the specified name and parameters in the given class. - */ - @Nonnull - public static Method findMethod(@Nonnull Class clazz, @Nonnull String methodName, @Nullable String methodObfName, Class... parameterTypes) { - Preconditions.checkNotNull(clazz); - Preconditions.checkArgument(StringUtils.isNotEmpty(methodName), "Method name cannot be empty"); - - String nameToFind = FMLLaunchHandler.isDeobfuscatedEnvironment() ? methodName : MoreObjects.firstNonNull(methodObfName, methodName); - - try { - Method m = clazz.getDeclaredMethod(nameToFind, parameterTypes); - m.setAccessible(true); - return m; - } catch (Exception e) { - throw new UnableToFindMethodException(e); - } - } - - /** - * Finds a constructor in the specified class that has matching parameter types. - * - * @param klass The class to find the constructor in - * @param parameterTypes The parameter types of the constructor. - * @param The type - * @return The constructor - * @throws NullPointerException if {@code klass} is null - * @throws NullPointerException if {@code parameterTypes} is null - * @throws UnknownConstructorException if the constructor could not be found - */ - @Nonnull - public static Constructor findConstructor(@Nonnull final Class klass, @Nonnull final Class... parameterTypes) { - Preconditions.checkNotNull(klass, "class"); - Preconditions.checkNotNull(parameterTypes, "parameter types"); - - try { - Constructor constructor = klass.getDeclaredConstructor(parameterTypes); - constructor.setAccessible(true); - return constructor; - } catch (final NoSuchMethodException e) { - final StringBuilder desc = new StringBuilder(); - desc.append(klass.getSimpleName()); - - StringJoiner joiner = new StringJoiner(", ", "(", ")"); - for (Class type : parameterTypes) { - joiner.add(type.getSimpleName()); - } - desc.append(joiner); - - throw new UnknownConstructorException("Could not find constructor '" + desc.toString() + "' in " + klass); - } - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/StackUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/StackUtil.java deleted file mode 100644 index c9ae2ed82..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/StackUtil.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * This file ("StackUtil.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.util; - -import java.util.Collection; -import java.util.List; - -import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler; - -import de.ellpeck.actuallyadditions.api.misc.IDisableableItem; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraftforge.items.IItemHandler; - -public final class StackUtil { - - /** - * Pretty much just a check for {@link ItemStack#isEmpty()} but exists in case Mojang does some more refactoring. - * @param stack The stack - * @return If the stack is not empty, or if it's an IDisableableItem, if its enabled. - */ - public static boolean isValid(ItemStack stack) { - if (stack == null) AwfulUtil.callTheFuckinPolice("Null ItemStack detected", stack); - Item i = stack.getItem(); - if (i instanceof IDisableableItem) return !((IDisableableItem) i).isDisabled(); - return !stack.isEmpty(); - } - - /** - * @return The empty itemstack instance. - */ - public static ItemStack getEmpty() { - return ItemStack.EMPTY; - } - - /** - * A helper method to make NonNullLists with empty fill. - * @param size How big the list will be. - * @return A {@link NonNullList} with the same size as provided. - */ - public static NonNullList makeList(int size) { - return NonNullList.withSize(size, getEmpty()); - } - - /** - * Checks if a collection of stacks are empty, as {@link Collection#isEmpty()} does not care about empty stacks. - * @param stacks Some ItemStacks - * @return If all stacks in the collection return true for {@link ItemStack#isEmpty()} - */ - public static boolean isEmpty(Collection stacks) { - if (stacks.isEmpty()) return true; - for (ItemStack s : stacks) - if (!s.isEmpty()) return false; - return true; - } - - /** - * Checks if all provided itemstacks will fit in the AA handler. Use addAll below to actually add the stacks. This is strictly a check function. - * @param inv The AA Item handler - * @param stacks The stacks to add - * @param fromAutomation If these stacks are coming from a pipe or other external source, or internally, like from the TE's update() method. - * @return If all stacks fit fully. If even one item would not fit, the method returns false. - */ - public static boolean canAddAll(ItemStackHandlerAA inv, List stacks, boolean fromAutomation) { - int counter = 0; - ItemStackHandlerAA dummy = testDummy(inv, 0, inv.getSlots()); - for (ItemStack s : stacks) { - for (int i = 0; i < dummy.getSlots(); i++) { - s = dummy.insertItem(i, s, false, fromAutomation); - if (s.isEmpty()) break; - } - if (s.isEmpty()) counter++; - } - return counter == stacks.size(); - } - - /** - * Adds all itemstacks in a list to an AA item handler. Must be an AA item handler to support the automation bool. - * @param inv The AA Item handler - * @param stacks The stacks to add - * @param fromAutomation If these stacks are coming from a pipe or other external source, or internally, like from the TE's update() method. - */ - public static void addAll(ItemStackHandlerAA inv, List stacks, boolean fromAutomation) { - int slotMax = inv.getSlots(); - for (ItemStack s : stacks) { - for (int i = 0; i < slotMax; i++) { - s = inv.insertItem(i, s, false, fromAutomation); - if (s.isEmpty()) break; - } - } - } - - /** - * Checks if all provided itemstacks will fit in the AA handler. Use addAll below to actually add the stacks. This is strictly a check function. - * @param inv The AA Item handler - * @param stacks The stacks to add - * @param slot The starting slot. - * @param endSlot The ending slot, exclusive. - * @param fromAutomation If these stacks are coming from a pipe or other external source, or internally, like from the TE's update() method. - * @return If all stacks fit fully. If even one item would not fit, the method returns false. - */ - public static boolean canAddAll(ItemStackHandlerAA inv, List stacks, int slot, int endSlot, boolean fromAutomation) { - int counter = 0; - ItemStackHandlerAA dummy = testDummy(inv, slot, endSlot); - for (ItemStack s : stacks) { - for (int i = 0; i < dummy.getSlots(); i++) { - s = dummy.insertItem(i, s, false, fromAutomation); - if (s.isEmpty()) break; - } - if (s.isEmpty()) counter++; - } - return counter == stacks.size(); - } - - /** - * Adds all itemstacks in a list to an AA item handler. Must be an AA item handler to support the automation bool. - * @param inv The AA Item handler - * @param stacks The stacks to add - * @param slot The starting slot. - * @param endSlot The ending slot, exclusive. - * @param fromAutomation If these stacks are coming from a pipe or other external source, or internally, like from the TE's update() method. - */ - public static void addAll(ItemStackHandlerAA inv, List stacks, int slot, int endSlot, boolean fromAutomation) { - for (ItemStack s : stacks) { - for (int i = slot; i < endSlot; i++) { - s = inv.insertItem(i, s, false, fromAutomation); - if (s.isEmpty()) break; - } - } - } - - /** - * Util method to find the first filled item in a handler. Searches from slot 0 to the end. - * @param inv The IItemHandler to search. - * @return The first filled slot, or -1 if all slots are empty. - */ - public static int findFirstFilled(IItemHandler inv) { - for (int i = 0; i < inv.getSlots(); i++) { - if (!inv.getStackInSlot(i).isEmpty()) return i; - } - return -1; - } - - /** - * Helper method to add stack size and return the stack. - */ - public static ItemStack grow(ItemStack s, int i) { - s.grow(i); - return s; - } - - /** - * Helper method to remove stack size and return the stack. - */ - public static ItemStack shrink(ItemStack s, int i) { - s.shrink(i); - return s; - } - - /** - * Helper method to remove stack size and return the stack. - */ - public static ItemStack shrinkForContainer(ItemStack s, int i) { - ItemStack sc = s.copy(); - s.shrink(i); - if (s.isEmpty()) return sc.getItem().getContainerItem(sc); - return s; - } - - /** - * Interaction method for working with Common Capabilities. - * @param wrapper The wrapper holding at least one instance - * @param stack The stack to insert. Should not be empty. - * @param simulate If this is a simulation - * @param slotStart Start range - * @param slotEnd End range - * @return The remainder that was not inserted. - */ - public static ItemStack insertItem(SlotlessableItemHandlerWrapper wrapper, ItemStack stack, boolean simulate, int slotStart, int slotEnd) { - if (stack.isEmpty()) return stack; - ItemStack remain = stack.copy(); - - if (ActuallyAdditions.commonCapsLoaded) { - Object handler = wrapper.getSlotlessHandler(); - if (handler instanceof ISlotlessItemHandler) { - remain = ((ISlotlessItemHandler) handler).insertItem(remain, simulate); - if (!ItemStack.areItemStacksEqual(remain, stack)) return remain; - } - } - - IItemHandler handler = wrapper.getNormalHandler(); - if (handler != null) { - for (int i = Math.max(0, slotStart); i < Math.min(slotEnd, handler.getSlots()); i++) { - remain = handler.insertItem(i, remain, simulate); - } - } - - return remain; - } - - /** - * Constructs a clone of the given item handler, from the given slots. The new item handler will have the provided slot as slot 0. - * This is used for testing the ability to add all itemstacks, and should not be used for anything else. - */ - public static ItemStackHandlerAA testDummy(ItemStackHandlerAA inv, int slot, int endSlot) { - NonNullList stacks = NonNullList.withSize(endSlot - slot, getEmpty()); - for (int i = slot; i < endSlot; i++) - stacks.set(i - slot, inv.getStackInSlot(i).copy()); - return new ItemStackHandlerAA(stacks, inv.getAcceptor(), inv.getRemover()); - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/StringUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/StringUtil.java deleted file mode 100644 index 0ab74e0e4..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/StringUtil.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * This file ("StringUtil.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.util; - -import java.io.InputStream; -import java.lang.reflect.Method; -import java.util.List; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.util.text.translation.LanguageMap; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -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"; - - /** - * Localizes a given String - */ - @SideOnly(Side.CLIENT) - public static String localize(String text) { - return I18n.format(text); - } - - /** - * Localizes a given formatted String with the given Replacements - */ - @SideOnly(Side.CLIENT) - 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 - 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) { - List list = renderer.listFormattedStringToWidth(strg, width); - for (int i = 0; i < list.size(); i++) { - String s1 = list.get(i); - 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) { - GlStateManager.pushMatrix(); - GlStateManager.scale(scale, scale, scale); - boolean oldUnicode = font.getUnicodeFlag(); - font.setUnicodeFlag(false); - - 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); - } - } - - //TODO: Remove - static LanguageMap cancerino; - - static void setupLangMap() { - try { - Method m = LanguageMap.class.getDeclaredMethod("inject", LanguageMap.class, InputStream.class); - m.setAccessible(true); - m.invoke(null, cancerino = new LanguageMap(), ActuallyAdditions.class.getResourceAsStream("/assets/actuallyadditions/lang/en_US.lang")); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException("Actually Additions failed to access LanguageMap.inject. Report this!"); - } - } - - public static String badTranslate(String someUnlocAAItemName) { - if (cancerino == null) { - cancerino = new LanguageMap(); - setupLangMap(); - } - return cancerino.translateKey("item.actuallyadditions." + someUnlocAAItemName + ".name"); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/Util.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/Util.java deleted file mode 100644 index bb5ef3453..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/Util.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file ("Util.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.util; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.common.IRarity; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.oredict.OreDictionary; - -public final class Util { - - public static final int WILDCARD = OreDictionary.WILDCARD_VALUE; - public static final int BUCKET = Fluid.BUCKET_VOLUME; - - public static final IRarity CRYSTAL_RED_RARITY = addRarity("crystalRed", TextFormatting.DARK_RED, ActuallyAdditions.NAME + " Red Crystal"); - public static final IRarity CRYSTAL_BLUE_RARITY = addRarity("crystalBlue", TextFormatting.DARK_BLUE, ActuallyAdditions.NAME + " Blue Crystal"); - public static final IRarity CRYSTAL_LIGHT_BLUE_RARITY = addRarity("crystalLightBlue", TextFormatting.BLUE, ActuallyAdditions.NAME + " Light Blue Crystal"); - public static final IRarity CRYSTAL_BLACK_RARITY = addRarity("crystalBlack", TextFormatting.DARK_GRAY, ActuallyAdditions.NAME + " Black Crystal"); - public static final IRarity CRYSTAL_GREEN_RARITY = addRarity("crystalGreen", TextFormatting.DARK_GREEN, ActuallyAdditions.NAME + " Green Crystal"); - public static final IRarity CRYSTAL_WHITE_RARITY = addRarity("crystalWhite", TextFormatting.GRAY, ActuallyAdditions.NAME + " White Crystal"); - - public static final IRarity FALLBACK_RARITY = addRarity("fallback", TextFormatting.STRIKETHROUGH, ActuallyAdditions.NAME + " Fallback"); - - private static IRarity addRarity(String name, TextFormatting color, String displayName) { - return new Rarity(color, displayName); - } - - public static boolean isDevVersion() { - return ActuallyAdditions.VERSION.equals("@VERSION@"); - } - - public static boolean isClient() { - return FMLCommonHandler.instance().getEffectiveSide().isClient(); - } - - private static String[] splitVersion() { - return ActuallyAdditions.VERSION.split("-"); - } - - public static String getMcVersion() { - return splitVersion()[0]; - } - - public static String getMajorModVersion() { - return splitVersion()[1].substring(1); - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/VanillaPacketDispatcher.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/VanillaPacketDispatcher.java deleted file mode 100644 index 2bc923da9..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/VanillaPacketDispatcher.java +++ /dev/null @@ -1,28 +0,0 @@ -package de.ellpeck.actuallyadditions.mod.util; - -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.server.management.PlayerChunkMapEntry; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraft.world.WorldServer; - -public final class VanillaPacketDispatcher { - - //Don't call from the client. - public static void dispatchTEToNearbyPlayers(TileEntity tile) { - WorldServer world = (WorldServer) tile.getWorld(); - PlayerChunkMapEntry entry = world.getPlayerChunkMap().getEntry(tile.getPos().getX() >> 4, tile.getPos().getZ() >> 4); - - if (entry == null) return; - - for (EntityPlayerMP player : entry.getWatchingPlayers()) - player.connection.sendPacket(tile.getUpdatePacket()); - - } - - public static void dispatchTEToNearbyPlayers(World world, BlockPos pos) { - TileEntity tile = world.getTileEntity(pos); - if (tile != null) dispatchTEToNearbyPlayers(tile); - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java deleted file mode 100644 index fe033f8ab..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java +++ /dev/null @@ -1,361 +0,0 @@ -/* - * This file ("WorldUtil.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.util; - -import java.util.ArrayList; - -import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.tile.FilterSettings; -import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; -import net.minecraft.block.Block; -import net.minecraft.block.BlockDirectional; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.network.play.server.SPacketBlockChange; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; -import net.minecraft.world.WorldServer; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.IPlantable; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.util.FakePlayer; -import net.minecraftforge.common.util.FakePlayerFactory; -import net.minecraftforge.energy.CapabilityEnergy; -import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.event.ForgeEventFactory; -import net.minecraftforge.event.world.BlockEvent.BreakEvent; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.capability.CapabilityFluidHandler; -import net.minecraftforge.fluids.capability.IFluidHandler; -import net.minecraftforge.items.IItemHandler; - -public final class WorldUtil { - - public static boolean doItemInteraction(SlotlessableItemHandlerWrapper extractWrapper, SlotlessableItemHandlerWrapper insertWrapper, int maxExtract) { - return doItemInteraction(extractWrapper, insertWrapper, maxExtract, null); - } - - public static boolean doItemInteraction(SlotlessableItemHandlerWrapper extractWrapper, SlotlessableItemHandlerWrapper insertWrapper, int maxExtract, FilterSettings filter) { - return doItemInteraction(extractWrapper, insertWrapper, maxExtract, 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, filter); - } - - public static boolean doItemInteraction(SlotlessableItemHandlerWrapper extractWrapper, SlotlessableItemHandlerWrapper insertWrapper, int maxExtract, int extractSlotStart, int extractSlotEnd, int insertSlotStart, int insertSlotEnd, FilterSettings filter) { - ItemStack theoreticalExtract = extractItem(extractWrapper, maxExtract, true, extractSlotStart, extractSlotEnd, filter); - if (StackUtil.isValid(theoreticalExtract)) { - ItemStack remaining = StackUtil.insertItem(insertWrapper, theoreticalExtract, false, insertSlotStart, insertSlotEnd); - if (!ItemStack.areItemStacksEqual(remaining, theoreticalExtract)) { - int toExtract = theoreticalExtract.getCount() - remaining.getCount(); - extractItem(extractWrapper, toExtract, false, extractSlotStart, extractSlotEnd, filter); - return true; - } - } - return false; - } - - public static ItemStack extractItem(SlotlessableItemHandlerWrapper extractWrapper, int maxExtract, boolean simulate, int slotStart, int slotEnd, FilterSettings filter) { - ItemStack extracted = StackUtil.getEmpty(); - - if (ActuallyAdditions.commonCapsLoaded) { - Object handler = extractWrapper.getSlotlessHandler(); - if (handler instanceof ISlotlessItemHandler) { - ISlotlessItemHandler slotless = (ISlotlessItemHandler) handler; - - if (filter == null || !filter.needsCheck()) { - extracted = slotless.extractItem(maxExtract, simulate); - return extracted; - } else { - ItemStack would = slotless.extractItem(maxExtract, true); - if (filter.check(would)) { - if (simulate) { - extracted = would; - } else { - extracted = slotless.extractItem(maxExtract, false); - } - } - //Leave the possibility to fall back to vanilla when there is a filter - } - } - } - - if (!StackUtil.isValid(extracted)) { - IItemHandler handler = extractWrapper.getNormalHandler(); - if (handler != null) { - for (int i = Math.max(0, slotStart); i < Math.min(slotEnd, handler.getSlots()); i++) { - if (filter == null || !filter.needsCheck() || filter.check(handler.getStackInSlot(i))) { - extracted = handler.extractItem(i, maxExtract, simulate); - - if (StackUtil.isValid(extracted)) { - break; - } - } - } - } - } - - return extracted; - } - - public static void doEnergyInteraction(TileEntity tileFrom, TileEntity tileTo, EnumFacing sideTo, int maxTransfer) { - if (maxTransfer > 0) { - EnumFacing opp = sideTo == null ? null : sideTo.getOpposite(); - IEnergyStorage handlerFrom = tileFrom.getCapability(CapabilityEnergy.ENERGY, sideTo); - IEnergyStorage handlerTo = tileTo.getCapability(CapabilityEnergy.ENERGY, opp); - if (handlerFrom != null && handlerTo != null) { - int drain = handlerFrom.extractEnergy(maxTransfer, true); - if (drain > 0) { - int filled = handlerTo.receiveEnergy(drain, false); - handlerFrom.extractEnergy(filled, false); - return; - } - } - } - } - - public static void doFluidInteraction(TileEntity tileFrom, TileEntity tileTo, EnumFacing sideTo, int maxTransfer) { - if (maxTransfer > 0) { - if (tileFrom.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, sideTo) && tileTo.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, sideTo.getOpposite())) { - IFluidHandler handlerFrom = tileFrom.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, sideTo); - IFluidHandler handlerTo = tileTo.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, sideTo.getOpposite()); - FluidStack drain = handlerFrom.drain(maxTransfer, false); - if (drain != null) { - int filled = handlerTo.fill(drain.copy(), true); - handlerFrom.drain(filled, true); - } - } - } - } - - /** - * Checks if a given Block with a given Meta is present in given Positions - * - * @param positions The Positions, an array of {x, y, z} arrays containing Positions - * @param block The Block - * @param meta The Meta - * @param world The World - * @return Is every block present? - */ - public static boolean hasBlocksInPlacesGiven(BlockPos[] positions, Block block, int meta, World world) { - for (BlockPos pos : positions) { - IBlockState state = world.getBlockState(pos); - if (!(state.getBlock() == block && block.getMetaFromState(state) == meta)) { return false; } - } - return true; - } - - public static ItemStack useItemAtSide(EnumFacing side, World world, BlockPos pos, ItemStack stack) { - if (world instanceof WorldServer && StackUtil.isValid(stack) && pos != null) { - BlockPos offsetPos = pos.offset(side); - IBlockState state = world.getBlockState(offsetPos); - Block block = state.getBlock(); - boolean replaceable = block.isReplaceable(world, offsetPos); - - //Redstone - if (replaceable && stack.getItem() == Items.REDSTONE) { - world.setBlockState(offsetPos, Blocks.REDSTONE_WIRE.getDefaultState(), 2); - return StackUtil.shrink(stack, 1); - } - - //Plants - if (replaceable && stack.getItem() instanceof IPlantable) { - if (((IPlantable) stack.getItem()).getPlant(world, offsetPos).getBlock().canPlaceBlockAt(world, offsetPos)) { - if (world.setBlockState(offsetPos, ((IPlantable) stack.getItem()).getPlant(world, offsetPos), 2)) return StackUtil.shrink(stack, 1); - } - } - - //Everything else - try { - FakePlayer fake = FakePlayerFactory.getMinecraft((WorldServer) world); - if (fake.connection == null) fake.connection = new NetHandlerSpaghettiServer(fake); - ItemStack heldBefore = fake.getHeldItemMainhand(); - setHandItemWithoutAnnoyingSound(fake, EnumHand.MAIN_HAND, stack.copy()); - fake.interactionManager.processRightClickBlock(fake, world, fake.getHeldItemMainhand(), EnumHand.MAIN_HAND, offsetPos, side.getOpposite(), 0.5F, 0.5F, 0.5F); - ItemStack result = fake.getHeldItem(EnumHand.MAIN_HAND); - setHandItemWithoutAnnoyingSound(fake, EnumHand.MAIN_HAND, heldBefore); - return result; - } catch (Exception e) { - ActuallyAdditions.LOGGER.error("Something that places Blocks at " + offsetPos.getX() + ", " + offsetPos.getY() + ", " + offsetPos.getZ() + " in World " + world.provider.getDimension() + " threw an Exception! Don't let that happen again!", e); - } - } - return stack; - } - - public static boolean dropItemAtSide(EnumFacing side, World world, BlockPos pos, ItemStack stack) { - BlockPos coords = pos.offset(side); - if (world.isBlockLoaded(coords)) { - EntityItem item = new EntityItem(world, coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5, stack); - item.motionX = 0; - item.motionY = 0; - item.motionZ = 0; - - return world.spawnEntity(item); - } - return false; - } - - public static EnumFacing getDirectionBySidesInOrder(int side) { - switch (side) { - case 0: - return EnumFacing.UP; - case 1: - return EnumFacing.DOWN; - case 2: - return EnumFacing.NORTH; - case 3: - return EnumFacing.EAST; - case 4: - return EnumFacing.SOUTH; - default: - return EnumFacing.WEST; - } - } - - public static EnumFacing getDirectionByPistonRotation(IBlockState state) { - return state.getValue(BlockDirectional.FACING); - } - - public static ArrayList getMaterialsAround(World world, BlockPos pos) { - ArrayList blocks = new ArrayList<>(); - blocks.add(world.getBlockState(pos.offset(EnumFacing.NORTH)).getMaterial()); - blocks.add(world.getBlockState(pos.offset(EnumFacing.EAST)).getMaterial()); - blocks.add(world.getBlockState(pos.offset(EnumFacing.SOUTH)).getMaterial()); - blocks.add(world.getBlockState(pos.offset(EnumFacing.WEST)).getMaterial()); - return blocks; - } - - public static RayTraceResult getNearestPositionWithAir(World world, EntityPlayer player, int reach) { - return getMovingObjectPosWithReachDistance(world, player, reach, false, false, true); - } - - private static RayTraceResult getMovingObjectPosWithReachDistance(World world, EntityPlayer player, double distance, boolean p1, boolean p2, boolean p3) { - float f = player.rotationPitch; - float f1 = player.rotationYaw; - double d0 = player.posX; - double d1 = player.posY + player.getEyeHeight(); - double d2 = player.posZ; - Vec3d vec3 = new Vec3d(d0, d1, d2); - float f2 = MathHelper.cos(-f1 * 0.017453292F - (float) Math.PI); - float f3 = MathHelper.sin(-f1 * 0.017453292F - (float) Math.PI); - float f4 = -MathHelper.cos(-f * 0.017453292F); - float f5 = MathHelper.sin(-f * 0.017453292F); - float f6 = f3 * f4; - float f7 = f2 * f4; - Vec3d vec31 = vec3.add(f6 * distance, f5 * distance, f7 * distance); - return world.rayTraceBlocks(vec3, vec31, p1, p2, p3); - } - - public static RayTraceResult getNearestBlockWithDefaultReachDistance(World world, EntityPlayer player) { - return getNearestBlockWithDefaultReachDistance(world, player, false, true, false); - } - - public static RayTraceResult getNearestBlockWithDefaultReachDistance(World world, EntityPlayer player, boolean stopOnLiquids, boolean ignoreBlockWithoutBoundingBox, boolean returnLastUncollidableBlock) { - return getMovingObjectPosWithReachDistance(world, player, player.getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue(), stopOnLiquids, ignoreBlockWithoutBoundingBox, returnLastUncollidableBlock); - } - - public static void setHandItemWithoutAnnoyingSound(EntityPlayer player, EnumHand hand, ItemStack stack) { - if (hand == EnumHand.MAIN_HAND) { - player.inventory.mainInventory.set(player.inventory.currentItem, stack); - } else if (hand == EnumHand.OFF_HAND) { - player.inventory.offHandInventory.set(0, stack); - } - } - - //I think something is up with this, but I'm not entirely certain what. - public static float fireFakeHarvestEventsForDropChance(TileEntity caller, NonNullList drops, World world, BlockPos pos) { - if (world instanceof WorldServer) { - FakePlayer fake = FakePlayerFactory.getMinecraft((WorldServer) world); - BlockPos tePos = caller.getPos(); - fake.setPosition(tePos.getX() + 0.5, tePos.getY() + 0.5, tePos.getZ() + 0.5); - IBlockState state = world.getBlockState(pos); - - BreakEvent event = new BreakEvent(world, pos, state, fake); - if (!MinecraftForge.EVENT_BUS.post(event)) { return ForgeEventFactory.fireBlockHarvesting(drops, world, pos, state, 0, 1, false, fake); } - } - return 0F; - } - - /** - * Tries to break a block as if this player had broken it. This is a complex operation. - * @param stack The player's current held stack, main hand. - * @param world The player's world. - * @param player The player that is breaking this block. - * @param pos The pos to break. - * @return If the break was successful. - */ - public static boolean breakExtraBlock(ItemStack stack, World world, EntityPlayer player, BlockPos pos) { - IBlockState state = world.getBlockState(pos); - Block block = state.getBlock(); - - if (player.capabilities.isCreativeMode) { - if (block.removedByPlayer(state, world, pos, player, false)) { - block.onPlayerDestroy(world, pos, state); - } - - // send update to client - if (!world.isRemote) { - ((EntityPlayerMP) player).connection.sendPacket(new SPacketBlockChange(world, pos)); - } - return true; - } - - // callback to the tool the player uses. Called on both sides. This damages the tool n stuff. - stack.onBlockDestroyed(world, state, pos, player); - - // server sided handling - if (!world.isRemote) { - // send the blockbreak event - int xp = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP) player).interactionManager.getGameType(), (EntityPlayerMP) player, pos); - if (xp == -1) return false; - - TileEntity tileEntity = world.getTileEntity(pos); - if (block.removedByPlayer(state, world, pos, player, true)) { // boolean is if block can be harvested, checked above - block.onPlayerDestroy(world, pos, state); - block.harvestBlock(world, player, pos, state, tileEntity, stack); - block.dropXpOnBlockBreak(world, pos, xp); - } - - // always send block update to client - ((EntityPlayerMP) player).connection.sendPacket(new SPacketBlockChange(world, pos)); - return true; - } - // client sided handling - else { - // clientside we do a "this block has been clicked on long enough to be broken" call. This should not send any new packets - // the code above, executed on the server, sends a block-updates that give us the correct state of the block we destroy. - - // following code can be found in PlayerControllerMP.onPlayerDestroyBlock - world.playEvent(2001, pos, Block.getStateId(state)); - if (block.removedByPlayer(state, world, pos, player, true)) { - block.onPlayerDestroy(world, pos, state); - } - // callback to the tool - stack.onBlockDestroyed(world, state, pos, player); - - // send an update to the server, so we get an update back - ActuallyAdditions.PROXY.sendBreakPacket(pos); - return true; - } - } -} 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 deleted file mode 100644 index 5991614c6..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CommonCapsUtil.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This file ("CommonCapsUtil.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -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; - -public final class CommonCapsUtil { - - public static ISlotlessItemHandler createSlotlessItemViewerHandler(final TileEntityItemViewer tile, IItemHandler normalHandler) { - return new DefaultSlotlessItemHandlerWrapper(normalHandler) { - @Override - 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); - - if (!ItemStack.areItemStacksEqual(remain, stack) && !simulate) { - tile.markDirty(); - tile.doItemParticle(stack, handler.relayInQuestion.getPos(), tile.connectedRelay.getPos()); - } - - if (!StackUtil.isValid(remain)) { return StackUtil.getEmpty(); } - } - } - } - return super.insertItem(remain, simulate); - } - - @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; - - ItemStack would = slotless.extractItem(amount, true); - if (StackUtil.isValid(would)) { - if (tile.isWhitelisted(handler, would, true)) { - ItemStack has; - if (simulate) { - has = would; - } else { - has = slotless.extractItem(amount, false); - } - - if (StackUtil.isValid(has) && !simulate) { - tile.markDirty(); - tile.doItemParticle(has, tile.connectedRelay.getPos(), handler.relayInQuestion.getPos()); - } - - return has; - } - } - } - } - } - return super.extractItem(amount, simulate); - } - - @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; - - ItemStack would = slotless.extractItem(matchStack, matchFlags, true); - if (StackUtil.isValid(would)) { - if (tile.isWhitelisted(handler, would, true)) { - if (simulate) { - return would; - } else { - return slotless.extractItem(matchStack, matchFlags, false); - } - } - } - } - } - } - return super.extractItem(matchStack, matchFlags, simulate); - } - }; - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CompatFastBench.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CompatFastBench.java deleted file mode 100644 index f1f0db33f..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CompatFastBench.java +++ /dev/null @@ -1,29 +0,0 @@ -package de.ellpeck.actuallyadditions.mod.util.compat; - -import net.minecraft.client.gui.Gui; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import shadows.fastbench.gui.ContainerFastBench; -import shadows.fastbench.gui.GuiFastBench; - -public class CompatFastBench { - - public static Container getFastBenchContainer(EntityPlayer p, World world) { - return new ContainerFastBench(p, world, BlockPos.ORIGIN) { - @Override - public boolean canInteractWith(EntityPlayer playerIn) { - return true; - } - }; - } - - @SideOnly(Side.CLIENT) - public static Gui getFastBenchGui(EntityPlayer p, World world) { - return new GuiFastBench(p.inventory, world, BlockPos.ORIGIN); - } - -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CompatUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CompatUtil.java deleted file mode 100644 index fa72ad19a..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CompatUtil.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file ("CompatUtil.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.util.compat; - -import net.minecraft.client.gui.inventory.GuiCrafting; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ContainerWorkbench; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.event.FMLInterModComms; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public final class CompatUtil { - - static boolean fb = Loader.isModLoaded("fastbench"); - - @SideOnly(Side.CLIENT) - public static Object getCrafterGuiElement(EntityPlayer player, World world, int x, int y, int z) { - if (fb) return CompatFastBench.getFastBenchGui(player, world); - return new GuiCrafting(player.inventory, world, new BlockPos(x, y, z)); - } - - public static Object getCrafterContainerElement(EntityPlayer player, World world, int x, int y, int z) { - if (fb) return CompatFastBench.getFastBenchContainer(player, world); - return new ContainerWorkbench(player.inventory, world, new BlockPos(x, y, z)) { - @Override - public boolean canInteractWith(EntityPlayer playerIn) { - return true; - } - }; - } - - public static void registerCraftingTweaks() { - NBTTagCompound t = new NBTTagCompound(); - if (fb) t.setString("ContainerClass", "de.ellpeck.actuallyadditions.mod.util.compat.CompatFastBench$1"); - else t.setString("ContainerClass", "de.ellpeck.actuallyadditions.mod.util.compat.CompatUtil$1"); - FMLInterModComms.sendMessage("craftingtweaks", "RegisterProvider", t); - } -} 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 deleted file mode 100644 index f5b9b6e18..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/IMCHandler.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file ("IMCHandler.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.util.compat; - -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; - -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 }; - - public static void doBlockIMC(Block block) { - boolean allow = !ArrayUtils.contains(NO_CARRYING, block.getClass()); - FMLInterModComms.sendMessage("charset", (allow ? "add" : "remove") + "Carry", block.getRegistryName()); - } - - 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 deleted file mode 100644 index 04e64fa3c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/SlotlessableItemHandlerWrapper.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file ("SlotlessableItemHandlerWrapper.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.util.compat; - -import net.minecraftforge.items.IItemHandler; - -public class SlotlessableItemHandlerWrapper { - - private final IItemHandler normalHandler; - private final Object slotlessHandler; - - public SlotlessableItemHandlerWrapper(IItemHandler normalHandler, Object slotlessHandler) { - this.normalHandler = normalHandler; - this.slotlessHandler = slotlessHandler; - } - - public IItemHandler getNormalHandler() { - return this.normalHandler; - } - - 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 deleted file mode 100644 index e8f3ea081..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/BlankRecipe.java +++ /dev/null @@ -1,31 +0,0 @@ -package de.ellpeck.actuallyadditions.mod.util.crafting; - -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.world.World; -import net.minecraftforge.registries.IForgeRegistryEntry; - -public class BlankRecipe extends IForgeRegistryEntry.Impl implements IRecipe { - - @Override - public boolean matches(InventoryCrafting inv, World worldIn) { - return false; - } - - @Override - public ItemStack getCraftingResult(InventoryCrafting inv) { - return ItemStack.EMPTY; - } - - @Override - public boolean canFit(int width, int height) { - return false; - } - - @Override - public ItemStack getRecipeOutput() { - return ItemStack.EMPTY; - } - -} 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 deleted file mode 100644 index edd42a94c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/IRecipeGrouped.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * This file ("IRecipeGrouped.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.util.crafting; - -public interface IRecipeGrouped { - - String getRecipeGroup(); - -} \ No newline at end of file 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 deleted file mode 100644 index a853282d7..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/RecipeHandler.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright 2014-2017, the Biomes O' Plenty Team - - This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License. - - To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/. - - Original: https://github.com/Glitchfiend/BiomesOPlenty/blob/0f8be0526e01d918cf8f22d4904a3b74981dee6f/src/main/java/biomesoplenty/common/util/inventory/CraftingUtil.java - (edited to work with multiple mods) - */ -package de.ellpeck.actuallyadditions.mod.util.crafting; - -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; - -public final class RecipeHandler { - - public static IRecipe lastRecipe; - - public static void addOreDictRecipe(ItemStack output, Object... inputs) { - addShapedRecipe(output, inputs); - } - - public static void addShapelessOreDictRecipe(ItemStack output, Object... inputs) { - addShapelessRecipe(output, inputs); - } - - public static void addShapelessRecipe(ItemStack output, Object... inputs) { - RecipeHelper.addOldShapeless(output, inputs); - } - - public static void addShapedRecipe(ItemStack output, Object... inputs) { - RecipeHelper.addOldShaped(output, inputs); - } - -} \ No newline at end of file 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 deleted file mode 100644 index 3f3fab225..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/crafting/RecipeHelper.java +++ /dev/null @@ -1,232 +0,0 @@ -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; -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.item.crafting.ShapedRecipes; -import net.minecraft.item.crafting.ShapelessRecipes; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.crafting.CraftingHelper; -import net.minecraftforge.common.crafting.CraftingHelper.ShapedPrimer; -import net.minecraftforge.oredict.OreIngredient; - -//This class created by Shadows_of_Fire -//MIT License -public final class RecipeHelper { - - private static int j = 0; - private static final String MODID = ActuallyAdditions.MODID; - private static final String MODNAME = ActuallyAdditions.NAME; - public static final List RECIPE_LIST = RegistryHandler.RECIPES_TO_REGISTER; - - /* - * This adds the recipe to the list of crafting recipes. Since who cares about names, it adds it as recipesX, where X is the current recipe you are adding. - */ - public static void addRecipe(int j, IRecipe rec) { - addRecipe("recipes" + j, rec); - } - - /* - * This adds the recipe to the list of crafting recipes. Cares about names. - */ - public static void addRecipe(String name, IRecipe rec) { - Item i = rec.getRecipeOutput().getItem(); - if (i instanceof IDisableableItem && ((IDisableableItem) i).isDisabled()) rec = new BlankRecipe(); - if (rec.getRegistryName() == null) { - RECIPE_LIST.add(rec.setRegistryName(new ResourceLocation(MODID, name))); - } else { - RECIPE_LIST.add(rec); - } - RecipeHandler.lastRecipe = rec; - } - - /* - * This adds a shaped recipe to the list of crafting recipes, using the forge format. - */ - public static void addOldShaped(ItemStack output, Object... input) { - ShapedPrimer primer = CraftingHelper.parseShaped(input); - addRecipe(j++, new ShapedRecipes(new ResourceLocation(MODID, "recipes" + j).toString(), primer.width, primer.height, primer.input, output)); - } - - /* - * This adds a shaped recipe to the list of crafting recipes, using the forge format, with a custom group. - */ - public static void addOldShaped(String group, ItemStack output, Object... input) { - ShapedPrimer primer = CraftingHelper.parseShaped(input); - addRecipe(j++, new ShapedRecipes(new ResourceLocation(MODID, group).toString(), primer.width, primer.height, primer.input, output)); - } - - /* - * This adds a shaped recipe to the list of crafting recipes, using the forge format, with a custom group. - */ - public static void addOldShaped(String name, String group, ItemStack output, Object... input) { - ShapedPrimer primer = CraftingHelper.parseShaped(input); - addRecipe(j++, new ShapedRecipes(new ResourceLocation(MODID, group).toString(), primer.width, primer.height, primer.input, output).setRegistryName(MODID, name)); - } - - /* - * This adds a shapeless recipe to the list of crafting recipes, using the forge format. - */ - public static void addOldShapeless(ItemStack output, Object... input) { - addRecipe(j++, new ShapelessRecipes(new ResourceLocation(MODID, "recipes" + j).toString(), output, createInput(input))); - } - - /* - * This adds a shapeless recipe to the list of crafting recipes, using the forge format, with a custom group. - */ - public static void addOldShapeless(String group, ItemStack output, Object... input) { - addRecipe(j++, new ShapelessRecipes(new ResourceLocation(MODID, group).toString(), output, createInput(input))); - } - - public static void addOldShapeless(String name, String group, ItemStack output, Object... input) { - addRecipe(j++, new ShapelessRecipes(new ResourceLocation(MODID, group).toString(), output, createInput(input)).setRegistryName(MODID, name)); - } - - /* - * Adds a shapeless recipe with X output using an array of inputs. Use Strings for OreDictionary support. This array is not ordered. - */ - public static void addShapeless(ItemStack output, Object... inputs) { - addRecipe(j++, new ShapelessRecipes(MODID + ":" + j, output, createInput(inputs))); - } - - public static void addShapeless(Item output, Object... inputs) { - addShapeless(new ItemStack(output), inputs); - } - - public static void addShapeless(Block output, Object... inputs) { - addShapeless(new ItemStack(output), inputs); - } - - /* - * Adds a shapeless recipe with X output using an array of inputs. Use Strings for OreDictionary support. This array is not ordered. This has a custom group. - */ - public static void addShapeless(String group, ItemStack output, Object... inputs) { - addRecipe(j++, new ShapelessRecipes(MODID + ":" + group, output, createInput(inputs))); - } - - public static void addShapeless(String group, Item output, Object... inputs) { - addShapeless(group, new ItemStack(output), inputs); - } - - public static void addShapeless(String group, Block output, Object... inputs) { - addShapeless(group, new ItemStack(output), inputs); - } - - /* - * Adds a shapeless recipe with X output on a crafting grid that is W x H, using an array of inputs. Use null for nothing, use Strings for OreDictionary support, this array must have a length of width * height. - * This array is ordered, and items must follow from left to right, top to bottom of the crafting grid. - */ - public static void addShaped(ItemStack output, int width, int height, Object... input) { - addRecipe(j++, genShaped(output, width, height, input)); - } - - public static void addShaped(Item output, int width, int height, Object... input) { - addShaped(new ItemStack(output), width, height, input); - } - - public static void addShaped(Block output, int width, int height, Object... input) { - addShaped(new ItemStack(output), width, height, input); - } - - /* - * Adds a shapeless recipe with X output on a crafting grid that is W x H, using an array of inputs. Use null for nothing, use Strings for OreDictionary support, this array must have a length of width * height. - * This array is ordered, and items must follow from left to right, top to bottom of the crafting grid. This has a custom group. - */ - public static void addShaped(String group, ItemStack output, int width, int height, Object... input) { - addRecipe(j++, genShaped(MODID + ":" + group, output, width, height, input)); - } - - public static void addShaped(String group, Item output, int width, int height, Object... input) { - addShaped(group, new ItemStack(output), width, height, input); - } - - public static void addShaped(String group, Block output, int width, int height, Object... input) { - addShaped(group, new ItemStack(output), width, height, input); - } - - public static ShapedRecipes genShaped(ItemStack output, int l, int w, Object[] input) { - if (input[0] instanceof Object[]) { - input = (Object[]) input[0]; - } - if (l * w != input.length) { throw new UnsupportedOperationException("Attempted to add invalid shaped recipe. Complain to the author of " + MODNAME); } - NonNullList inputL = NonNullList.create(); - for (int i = 0; i < input.length; i++) { - Object k = input[i]; - if (k instanceof String) { - inputL.add(i, new OreIngredient((String) k)); - } else if (k instanceof ItemStack && !((ItemStack) k).isEmpty()) { - inputL.add(i, Ingredient.fromStacks((ItemStack) k)); - } else if (k instanceof Item) { - inputL.add(i, Ingredient.fromStacks(new ItemStack((Item) k))); - } else if (k instanceof Block) { - inputL.add(i, Ingredient.fromStacks(new ItemStack((Block) k))); - } else { - inputL.add(i, Ingredient.EMPTY); - } - } - - return new ShapedRecipes(MODID + ":" + j, l, w, inputL, output); - } - - public static ShapedRecipes genShaped(String group, ItemStack output, int l, int w, Object[] input) { - if (input[0] instanceof List) { - input = ((List) input[0]).toArray(); - } else if (input[0] instanceof Object[]) { - input = (Object[]) input[0]; - } - if (l * w != input.length) { throw new UnsupportedOperationException("Attempted to add invalid shaped recipe. Complain to the author of " + MODNAME); } - NonNullList inputL = NonNullList.create(); - for (int i = 0; i < input.length; i++) { - Object k = input[i]; - if (k instanceof String) { - inputL.add(i, new OreIngredient((String) k)); - } else if (k instanceof ItemStack && !((ItemStack) k).isEmpty()) { - inputL.add(i, Ingredient.fromStacks((ItemStack) k)); - } else if (k instanceof Item) { - inputL.add(i, Ingredient.fromStacks(new ItemStack((Item) k))); - } else if (k instanceof Block) { - inputL.add(i, Ingredient.fromStacks(new ItemStack((Block) k))); - } else if (k instanceof Ingredient) { - inputL.add(i, (Ingredient) k); - } else { - inputL.add(i, Ingredient.EMPTY); - } - } - - return new ShapedRecipes(group, l, w, inputL, output); - } - - public static NonNullList createInput(Object[] input) { - if (input[0] instanceof List) { - input = ((List) input[0]).toArray(); - } else if (input[0] instanceof Object[]) { - input = (Object[]) input[0]; - } - NonNullList inputL = NonNullList.create(); - for (int i = 0; i < input.length; i++) { - Object k = input[i]; - if (k instanceof String) { - inputL.add(i, new OreIngredient((String) k)); - } else if (k instanceof ItemStack) { - inputL.add(i, Ingredient.fromStacks((ItemStack) k)); - } else if (k instanceof Item) { - inputL.add(i, Ingredient.fromStacks(new ItemStack((Item) k))); - } else if (k instanceof Block) { - inputL.add(i, Ingredient.fromStacks(new ItemStack((Block) k))); - } else if (k instanceof Ingredient) { - inputL.add(i, (Ingredient) k); - } else { - throw new UnsupportedOperationException("Attempted to add invalid shapeless recipe. Complain to the author of " + MODNAME); - } - } - return inputL; - } -} \ No newline at end of file diff --git a/src/main/java/invtweaks/api/container/ChestContainer.java b/src/main/java/invtweaks/api/container/ChestContainer.java deleted file mode 100644 index 9fa7dab7c..000000000 --- a/src/main/java/invtweaks/api/container/ChestContainer.java +++ /dev/null @@ -1,38 +0,0 @@ -package invtweaks.api.container; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * A marker for containers that have a chest-like persistent storage component. Enables the Inventory Tweaks sorting - * buttons for this container. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface ChestContainer { - // Set to true if the Inventory Tweaks sorting buttons should be shown for this container. - boolean showButtons() default true; - - // Size of a chest row - int rowSize() default 9; - - // Uses 'large chest' mode for sorting buttons - // (Renders buttons vertically down the right side of the GUI) - boolean isLargeChest() default false; - - // Annotation for method to get size of a chest row if it is not a fixed size for this container class - // Signature int func() - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - @interface RowSizeCallback { - } - - // Annotation for method to get size of a chest row if it is not a fixed size for this container class - // Signature int func() - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - @interface IsLargeCallback { - } -} diff --git a/src/main/java/invtweaks/api/container/InventoryContainer.java b/src/main/java/invtweaks/api/container/InventoryContainer.java deleted file mode 100644 index b3614d278..000000000 --- a/src/main/java/invtweaks/api/container/InventoryContainer.java +++ /dev/null @@ -1,20 +0,0 @@ -package invtweaks.api.container; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * A marker for containers that need special treatment, such as crafting inputs or alternate player inventory positions, - * but do not have a chest-like component. - *

- * Does not enable the Inventory Tweaks sorting buttons for this container. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface InventoryContainer { - // Set to true if the Inventory Tweaks options button should be shown for this container. - // (For instance, if you are replacing a vanilla container such as the player's inventory) - boolean showOptions() default true; -} diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 2f1282c19..2a42c54c7 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -4,7 +4,7 @@ issueTrackerURL="http://github.com/Ellpeck/ActuallyAdditions/issues" displayURL="http://github.com/Ellpeck/ActuallyAdditions" logoFile="logo.png" credits="Author: Ellpeck; Textures and Models: BootyToast, GlenthorLP, canitzp" -authors="Ellpeck" +authors="Ellpeck, Shadows_of_Fire" [[mods]] modId="actuallyadditions"