Merge remote-tracking branch 'origin/1.16' into 1.16

This commit is contained in:
Flanks255 2021-08-07 08:54:58 -05:00
commit 11db8c8324
10 changed files with 544 additions and 545 deletions

View file

@ -24,7 +24,7 @@ import net.minecraftforge.registries.ForgeRegistries;
public final class ActuallyBlocks { public final class ActuallyBlocks {
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, ActuallyAdditions.MODID); public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, ActuallyAdditions.MODID);
public static final AbstractBlock.Properties miscBlockProperties = AbstractBlock.Properties.create(Material.ROCK).harvestLevel(1).harvestTool(ToolType.PICKAXE).hardnessAndResistance(1.5f,10f); public static final AbstractBlock.Properties miscBlockProperties = AbstractBlock.Properties.create(Material.ROCK).harvestLevel(1).harvestTool(ToolType.PICKAXE).hardnessAndResistance(1.5f, 10f);
@Deprecated @Deprecated
public static final RegistryObject<Block> blockMisc = BLOCKS.register("misc", () -> new Block(miscBlockProperties)); // TODO this isnt a real block? public static final RegistryObject<Block> blockMisc = BLOCKS.register("misc", () -> new Block(miscBlockProperties)); // TODO this isnt a real block?
public static final RegistryObject<Block> WOOD_CASING = BLOCKS.register("wood_casing", () -> new Block(miscBlockProperties)); public static final RegistryObject<Block> WOOD_CASING = BLOCKS.register("wood_casing", () -> new Block(miscBlockProperties));
@ -36,7 +36,6 @@ public final class ActuallyBlocks {
public static final RegistryObject<Block> GRINDER = BLOCKS.register("grinder", () -> new BlockGrinder(false)); public static final RegistryObject<Block> GRINDER = BLOCKS.register("grinder", () -> new BlockGrinder(false));
public static final RegistryObject<Block> GRINDER_DOUBLE = BLOCKS.register("grinder_double", () -> new BlockGrinder(true)); public static final RegistryObject<Block> GRINDER_DOUBLE = BLOCKS.register("grinder_double", () -> new BlockGrinder(true));
public static final RegistryObject<Block> CRYSTAL_CLUSTER_REDSTONE = BLOCKS.register("crystal_cluster_redstone", () -> new BlockCrystalCluster(TheCrystals.REDSTONE)); public static final RegistryObject<Block> CRYSTAL_CLUSTER_REDSTONE = BLOCKS.register("crystal_cluster_redstone", () -> new BlockCrystalCluster(TheCrystals.REDSTONE));
public static final RegistryObject<Block> CRYSTAL_CLUSTER_LAPIS = BLOCKS.register("crystal_cluster_lapis", () -> new BlockCrystalCluster(TheCrystals.LAPIS)); public static final RegistryObject<Block> CRYSTAL_CLUSTER_LAPIS = BLOCKS.register("crystal_cluster_lapis", () -> new BlockCrystalCluster(TheCrystals.LAPIS));
public static final RegistryObject<Block> CRYSTAL_CLUSTER_DIAMOND = BLOCKS.register("crystal_cluster_diamond", () -> new BlockCrystalCluster(TheCrystals.DIAMOND)); public static final RegistryObject<Block> CRYSTAL_CLUSTER_DIAMOND = BLOCKS.register("crystal_cluster_diamond", () -> new BlockCrystalCluster(TheCrystals.DIAMOND));

View file

@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.misc.DispenserHandlerFertilize; import de.ellpeck.actuallyadditions.mod.misc.DispenserHandlerFertilize;
import net.minecraft.block.BlockDispenser; import net.minecraft.block.DispenserBlock;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemDye; import net.minecraft.item.ItemDye;
@ -28,7 +28,7 @@ public class ItemFertilizer extends ItemBase {
public ItemFertilizer() { public ItemFertilizer() {
super(name); super(name);
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, new DispenserHandlerFertilize()); DispenserBlock.registerDispenseBehavior(this, new DispenserHandlerFertilize());
} }
@Override @Override

View file

@ -1,102 +1,102 @@
/* ///*
* This file ("CommonCapsUtil.java") is part of the Actually Additions mod for Minecraft. // * This file ("CommonCapsUtil.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed // * It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at // * under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense // * http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions // * View the source code at https://github.com/Ellpeck/ActuallyAdditions
* // *
* © 2015-2017 Ellpeck // * © 2015-2017 Ellpeck
*/ // */
//
package de.ellpeck.actuallyadditions.mod.util.compat; //package de.ellpeck.actuallyadditions.mod.util.compat;
//
import org.cyclops.commoncapabilities.api.capability.itemhandler.DefaultSlotlessItemHandlerWrapper; //import org.cyclops.commoncapabilities.api.capability.itemhandler.DefaultSlotlessItemHandlerWrapper;
import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler; //import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler;
//
import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer; //import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer.SlotlessItemHandlerInfo; //import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer.SlotlessItemHandlerInfo;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; //import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.item.ItemStack; //import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler; //import net.minecraftforge.items.IItemHandler;
//
public final class CommonCapsUtil { //public final class CommonCapsUtil {
//
public static ISlotlessItemHandler createSlotlessItemViewerHandler(final TileEntityItemViewer tile, IItemHandler normalHandler) { // public static ISlotlessItemHandler createSlotlessItemViewerHandler(final TileEntityItemViewer tile, IItemHandler normalHandler) {
return new DefaultSlotlessItemHandlerWrapper(normalHandler) { // return new DefaultSlotlessItemHandlerWrapper(normalHandler) {
@Override // @Override
public ItemStack insertItem(ItemStack stack, boolean simulate) { // public ItemStack insertItem(ItemStack stack, boolean simulate) {
ItemStack remain = stack.copy(); // ItemStack remain = stack.copy();
for (SlotlessItemHandlerInfo handler : tile.slotlessInfos) { // for (SlotlessItemHandlerInfo handler : tile.slotlessInfos) {
if (handler.isLoaded() && tile.isWhitelisted(handler, stack, false)) { // if (handler.isLoaded() && tile.isWhitelisted(handler, stack, false)) {
if (handler.handler instanceof ISlotlessItemHandler) { // if (handler.handler instanceof ISlotlessItemHandler) {
remain = ((ISlotlessItemHandler) handler.handler).insertItem(stack, simulate); // remain = ((ISlotlessItemHandler) handler.handler).insertItem(stack, simulate);
//
if (!ItemStack.areItemStacksEqual(remain, stack) && !simulate) { // if (!ItemStack.areItemStacksEqual(remain, stack) && !simulate) {
tile.markDirty(); // tile.markDirty();
tile.doItemParticle(stack, handler.relayInQuestion.getPos(), tile.connectedRelay.getPos()); // tile.doItemParticle(stack, handler.relayInQuestion.getPos(), tile.connectedRelay.getPos());
} // }
//
if (!StackUtil.isValid(remain)) { return StackUtil.getEmpty(); } // if (!StackUtil.isValid(remain)) { return StackUtil.getEmpty(); }
} // }
} // }
} // }
return super.insertItem(remain, simulate); // return super.insertItem(remain, simulate);
} // }
//
@Override // @Override
public ItemStack extractItem(int amount, boolean simulate) { // public ItemStack extractItem(int amount, boolean simulate) {
for (SlotlessItemHandlerInfo handler : tile.slotlessInfos) { // for (SlotlessItemHandlerInfo handler : tile.slotlessInfos) {
if (handler.isLoaded()) { // if (handler.isLoaded()) {
if (handler.handler instanceof ISlotlessItemHandler) { // if (handler.handler instanceof ISlotlessItemHandler) {
ISlotlessItemHandler slotless = (ISlotlessItemHandler) handler.handler; // ISlotlessItemHandler slotless = (ISlotlessItemHandler) handler.handler;
//
ItemStack would = slotless.extractItem(amount, true); // ItemStack would = slotless.extractItem(amount, true);
if (StackUtil.isValid(would)) { // if (StackUtil.isValid(would)) {
if (tile.isWhitelisted(handler, would, true)) { // if (tile.isWhitelisted(handler, would, true)) {
ItemStack has; // ItemStack has;
if (simulate) { // if (simulate) {
has = would; // has = would;
} else { // } else {
has = slotless.extractItem(amount, false); // has = slotless.extractItem(amount, false);
} // }
//
if (StackUtil.isValid(has) && !simulate) { // if (StackUtil.isValid(has) && !simulate) {
tile.markDirty(); // tile.markDirty();
tile.doItemParticle(has, tile.connectedRelay.getPos(), handler.relayInQuestion.getPos()); // tile.doItemParticle(has, tile.connectedRelay.getPos(), handler.relayInQuestion.getPos());
} // }
//
return has; // return has;
} // }
} // }
} // }
} // }
} // }
return super.extractItem(amount, simulate); // return super.extractItem(amount, simulate);
} // }
//
@Override // @Override
public ItemStack extractItem(ItemStack matchStack, int matchFlags, boolean simulate) { // public ItemStack extractItem(ItemStack matchStack, int matchFlags, boolean simulate) {
for (SlotlessItemHandlerInfo handler : tile.slotlessInfos) { // for (SlotlessItemHandlerInfo handler : tile.slotlessInfos) {
if (handler.isLoaded()) { // if (handler.isLoaded()) {
if (handler.handler instanceof ISlotlessItemHandler) { // if (handler.handler instanceof ISlotlessItemHandler) {
ISlotlessItemHandler slotless = (ISlotlessItemHandler) handler.handler; // ISlotlessItemHandler slotless = (ISlotlessItemHandler) handler.handler;
//
ItemStack would = slotless.extractItem(matchStack, matchFlags, true); // ItemStack would = slotless.extractItem(matchStack, matchFlags, true);
if (StackUtil.isValid(would)) { // if (StackUtil.isValid(would)) {
if (tile.isWhitelisted(handler, would, true)) { // if (tile.isWhitelisted(handler, would, true)) {
if (simulate) { // if (simulate) {
return would; // return would;
} else { // } else {
return slotless.extractItem(matchStack, matchFlags, false); // return slotless.extractItem(matchStack, matchFlags, false);
} // }
} // }
} // }
} // }
} // }
} // }
return super.extractItem(matchStack, matchFlags, simulate); // return super.extractItem(matchStack, matchFlags, simulate);
} // }
}; // };
} // }
//
} //}

View file

@ -1,27 +1,27 @@
package de.ellpeck.actuallyadditions.mod.util.compat; //package de.ellpeck.actuallyadditions.mod.util.compat;
//
import net.minecraft.client.gui.Gui; //import net.minecraft.client.gui.Gui;
import net.minecraft.entity.player.PlayerEntity; //import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.Container; //import net.minecraft.inventory.container.Container;
import net.minecraft.util.math.BlockPos; //import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; //import net.minecraft.world.World;
import shadows.fastbench.gui.ContainerFastBench; //import shadows.fastbench.gui.ContainerFastBench;
import shadows.fastbench.gui.GuiFastBench; //import shadows.fastbench.gui.GuiFastBench;
//
public class CompatFastBench { //public class CompatFastBench {
//
public static Container getFastBenchContainer(PlayerEntity p, World world) { // public static Container getFastBenchContainer(PlayerEntity p, World world) {
return new ContainerFastBench(p, world, BlockPos.ORIGIN) { // return new ContainerFastBench(p, world, BlockPos.ORIGIN) {
@Override // @Override
public boolean canInteractWith(PlayerEntity playerIn) { // public boolean canInteractWith(PlayerEntity playerIn) {
return true; // return true;
} // }
}; // };
} // }
//
@OnlyIn(Dist.CLIENT) // @OnlyIn(Dist.CLIENT)
public static Gui getFastBenchGui(PlayerEntity p, World world) { // public static Gui getFastBenchGui(PlayerEntity p, World world) {
return new GuiFastBench(p.inventory, world, BlockPos.ORIGIN); // return new GuiFastBench(p.inventory, world, BlockPos.ORIGIN);
} // }
//
} //}

View file

@ -1,56 +1,56 @@
/* ///*
* This file ("CompatUtil.java") is part of the Actually Additions mod for Minecraft. // * This file ("CompatUtil.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed // * It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at // * under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense // * http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions // * View the source code at https://github.com/Ellpeck/ActuallyAdditions
* // *
* © 2015-2017 Ellpeck // * © 2015-2017 Ellpeck
*/ // */
//
package de.ellpeck.actuallyadditions.mod.util.compat; //package de.ellpeck.actuallyadditions.mod.util.compat;
//
import net.minecraft.client.gui.inventory.GuiCrafting; //import net.minecraft.client.gui.inventory.GuiCrafting;
import net.minecraft.entity.player.PlayerEntity; //import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.ContainerWorkbench; //import net.minecraft.inventory.ContainerWorkbench;
import net.minecraft.nbt.CompoundNBT; //import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.BlockPos; //import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; //import net.minecraft.world.World;
import net.minecraftforge.fml.common.Loader; //import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInterModComms; //import net.minecraftforge.fml.common.event.FMLInterModComms;
//
//
public final class CompatUtil { //public final class CompatUtil {
//
static boolean fb = Loader.isModLoaded("fastbench"); // static boolean fb = Loader.isModLoaded("fastbench");
//
@OnlyIn(Dist.CLIENT) // @OnlyIn(Dist.CLIENT)
public static Object getCrafterGuiElement(PlayerEntity player, World world, int x, int y, int z) { // public static Object getCrafterGuiElement(PlayerEntity player, World world, int x, int y, int z) {
if (fb) { // if (fb) {
return CompatFastBench.getFastBenchGui(player, world); // return CompatFastBench.getFastBenchGui(player, world);
} // }
return new GuiCrafting(player.inventory, world, new BlockPos(x, y, z)); // return new GuiCrafting(player.inventory, world, new BlockPos(x, y, z));
} // }
//
public static Object getCrafterContainerElement(PlayerEntity player, World world, int x, int y, int z) { // public static Object getCrafterContainerElement(PlayerEntity player, World world, int x, int y, int z) {
if (fb) { // if (fb) {
return CompatFastBench.getFastBenchContainer(player, world); // return CompatFastBench.getFastBenchContainer(player, world);
} // }
return new ContainerWorkbench(player.inventory, world, new BlockPos(x, y, z)) { // return new ContainerWorkbench(player.inventory, world, new BlockPos(x, y, z)) {
@Override // @Override
public boolean canInteractWith(PlayerEntity playerIn) { // public boolean canInteractWith(PlayerEntity playerIn) {
return true; // return true;
} // }
}; // };
} // }
//
public static void registerCraftingTweaks() { // public static void registerCraftingTweaks() {
CompoundNBT t = new CompoundNBT(); // CompoundNBT t = new CompoundNBT();
if (fb) { // if (fb) {
t.setString("ContainerClass", "de.ellpeck.actuallyadditions.mod.util.compat.CompatFastBench$1"); // t.setString("ContainerClass", "de.ellpeck.actuallyadditions.mod.util.compat.CompatFastBench$1");
} else { // } else {
t.setString("ContainerClass", "de.ellpeck.actuallyadditions.mod.util.compat.CompatUtil$1"); // t.setString("ContainerClass", "de.ellpeck.actuallyadditions.mod.util.compat.CompatUtil$1");
} // }
FMLInterModComms.sendMessage("craftingtweaks", "RegisterProvider", t); // FMLInterModComms.sendMessage("craftingtweaks", "RegisterProvider", t);
} // }
} //}

View file

@ -1,39 +1,39 @@
/* ///*
* This file ("IMCHandler.java") is part of the Actually Additions mod for Minecraft. // * This file ("IMCHandler.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed // * It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at // * under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense // * http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions // * View the source code at https://github.com/Ellpeck/ActuallyAdditions
* // *
* © 2015-2017 Ellpeck // * © 2015-2017 Ellpeck
*/ // */
//
package de.ellpeck.actuallyadditions.mod.util.compat; //package de.ellpeck.actuallyadditions.mod.util.compat;
//
import org.apache.commons.lang3.ArrayUtils; //import org.apache.commons.lang3.ArrayUtils;
//
import de.ellpeck.actuallyadditions.mod.blocks.BlockGiantChest; //import de.ellpeck.actuallyadditions.mod.blocks.BlockGiantChest;
import de.ellpeck.actuallyadditions.mod.blocks.BlockItemViewer; //import de.ellpeck.actuallyadditions.mod.blocks.BlockItemViewer;
import de.ellpeck.actuallyadditions.mod.blocks.BlockItemViewerHopping; //import de.ellpeck.actuallyadditions.mod.blocks.BlockItemViewerHopping;
import de.ellpeck.actuallyadditions.mod.blocks.BlockLaserRelay; //import de.ellpeck.actuallyadditions.mod.blocks.BlockLaserRelay;
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom; //import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
import de.ellpeck.actuallyadditions.mod.blocks.BlockTinyTorch; //import de.ellpeck.actuallyadditions.mod.blocks.BlockTinyTorch;
import de.ellpeck.actuallyadditions.mod.blocks.BlockWildPlant; //import de.ellpeck.actuallyadditions.mod.blocks.BlockWildPlant;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant; //import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant;
import net.minecraft.block.Block; //import net.minecraft.block.Block;
import net.minecraft.item.Item; //import net.minecraft.item.Item;
import net.minecraftforge.fml.common.event.FMLInterModComms; //import net.minecraftforge.fml.common.event.FMLInterModComms;
//
public final class IMCHandler { //public final class IMCHandler {
//
private static final Class<?>[] NO_CARRYING = new Class<?>[] { BlockGiantChest.class, BlockWildPlant.class, BlockPlant.class, BlockPhantom.class, BlockTinyTorch.class, BlockItemViewer.class, BlockItemViewerHopping.class, BlockLaserRelay.class }; // private static final Class<?>[] NO_CARRYING = new Class<?>[] { BlockGiantChest.class, BlockWildPlant.class, BlockPlant.class, BlockPhantom.class, BlockTinyTorch.class, BlockItemViewer.class, BlockItemViewerHopping.class, BlockLaserRelay.class };
//
public static void doBlockIMC(Block block) { // public static void doBlockIMC(Block block) {
boolean allow = !ArrayUtils.contains(NO_CARRYING, block.getClass()); // boolean allow = !ArrayUtils.contains(NO_CARRYING, block.getClass());
FMLInterModComms.sendMessage("charset", (allow ? "add" : "remove") + "Carry", block.getRegistryName()); // FMLInterModComms.sendMessage("charset", (allow ? "add" : "remove") + "Carry", block.getRegistryName());
} // }
//
public static void doItemIMC(Item item) { // public static void doItemIMC(Item item) {
//
} // }
} //}

View file

@ -1,31 +1,31 @@
package de.ellpeck.actuallyadditions.mod.util.crafting; //package de.ellpeck.actuallyadditions.mod.util.crafting;
//
import net.minecraft.inventory.InventoryCrafting; //import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack; //import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; //import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World; //import net.minecraft.world.World;
import net.minecraftforge.registries.IForgeRegistryEntry; //import net.minecraftforge.registries.IForgeRegistryEntry;
//
public class BlankRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe { //public class BlankRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
//
@Override // @Override
public boolean matches(InventoryCrafting inv, World worldIn) { // public boolean matches(InventoryCrafting inv, World worldIn) {
return false; // return false;
} // }
//
@Override // @Override
public ItemStack getCraftingResult(InventoryCrafting inv) { // public ItemStack getCraftingResult(InventoryCrafting inv) {
return ItemStack.EMPTY; // return ItemStack.EMPTY;
} // }
//
@Override // @Override
public boolean canFit(int width, int height) { // public boolean canFit(int width, int height) {
return false; // return false;
} // }
//
@Override // @Override
public ItemStack getRecipeOutput() { // public ItemStack getRecipeOutput() {
return ItemStack.EMPTY; // return ItemStack.EMPTY;
} // }
//
} //}

View file

@ -1,17 +1,17 @@
/* ///*
* This file ("IRecipeGrouped.java") is part of the Actually Additions mod for Minecraft. // * This file ("IRecipeGrouped.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed // * It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at // * under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense // * http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions // * View the source code at https://github.com/Ellpeck/ActuallyAdditions
* // *
* © 2015-2017 Ellpeck // * © 2015-2017 Ellpeck
*/ // */
//
package de.ellpeck.actuallyadditions.mod.util.crafting; //package de.ellpeck.actuallyadditions.mod.util.crafting;
//
public interface IRecipeGrouped { //public interface IRecipeGrouped {
//
String getRecipeGroup(); // String getRecipeGroup();
//
} //}

View file

@ -1,36 +1,36 @@
/* ///*
Copyright 2014-2017, the Biomes O' Plenty Team // Copyright 2014-2017, the Biomes O' Plenty Team
//
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License. // 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/. // 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 // Original: https://github.com/Glitchfiend/BiomesOPlenty/blob/0f8be0526e01d918cf8f22d4904a3b74981dee6f/src/main/java/biomesoplenty/common/util/inventory/CraftingUtil.java
(edited to work with multiple mods) // (edited to work with multiple mods)
*/ // */
package de.ellpeck.actuallyadditions.mod.util.crafting; //package de.ellpeck.actuallyadditions.mod.util.crafting;
//
import net.minecraft.item.ItemStack; //import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; //import net.minecraft.item.crafting.IRecipe;
//
public final class RecipeHandler { //public final class RecipeHandler {
//
public static IRecipe lastRecipe; // public static IRecipe lastRecipe;
//
public static void addOreDictRecipe(ItemStack output, Object... inputs) { // public static void addOreDictRecipe(ItemStack output, Object... inputs) {
addShapedRecipe(output, inputs); // addShapedRecipe(output, inputs);
} // }
//
public static void addShapelessOreDictRecipe(ItemStack output, Object... inputs) { // public static void addShapelessOreDictRecipe(ItemStack output, Object... inputs) {
addShapelessRecipe(output, inputs); // addShapelessRecipe(output, inputs);
} // }
//
public static void addShapelessRecipe(ItemStack output, Object... inputs) { // public static void addShapelessRecipe(ItemStack output, Object... inputs) {
RecipeHelper.addOldShapeless(output, inputs); // RecipeHelper.addOldShapeless(output, inputs);
} // }
//
public static void addShapedRecipe(ItemStack output, Object... inputs) { // public static void addShapedRecipe(ItemStack output, Object... inputs) {
RecipeHelper.addOldShaped(output, inputs); // RecipeHelper.addOldShaped(output, inputs);
} // }
//
} //}

View file

@ -1,232 +1,232 @@
package de.ellpeck.actuallyadditions.mod.util.crafting; //package de.ellpeck.actuallyadditions.mod.util.crafting;
//
import java.util.List; //import java.util.List;
//
import de.ellpeck.actuallyadditions.api.misc.IDisableableItem; //import de.ellpeck.actuallyadditions.api.misc.IDisableableItem;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; //import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.RegistryHandler; //import de.ellpeck.actuallyadditions.mod.RegistryHandler;
import net.minecraft.block.Block; //import net.minecraft.block.Block;
import net.minecraft.item.Item; //import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; //import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; //import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient; //import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.ShapedRecipes; //import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes; //import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.util.NonNullList; //import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation; //import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.crafting.CraftingHelper; //import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.common.crafting.CraftingHelper.ShapedPrimer; //import net.minecraftforge.common.crafting.CraftingHelper.ShapedPrimer;
import net.minecraftforge.oredict.OreIngredient; //import net.minecraftforge.oredict.OreIngredient;
//
//This class created by Shadows_of_Fire ////This class created by Shadows_of_Fire
//MIT License ////MIT License
public final class RecipeHelper { //public final class RecipeHelper {
//
private static int j = 0; // private static int j = 0;
private static final String MODID = ActuallyAdditions.MODID; // private static final String MODID = ActuallyAdditions.MODID;
private static final String MODNAME = ActuallyAdditions.NAME; // private static final String MODNAME = ActuallyAdditions.NAME;
public static final List<IRecipe> RECIPE_LIST = RegistryHandler.RECIPES_TO_REGISTER; // public static final List<IRecipe> 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. // * 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) { // public static void addRecipe(int j, IRecipe rec) {
addRecipe("recipes" + j, rec); // addRecipe("recipes" + j, rec);
} // }
//
/* // /*
* This adds the recipe to the list of crafting recipes. Cares about names. // * This adds the recipe to the list of crafting recipes. Cares about names.
*/ // */
public static void addRecipe(String name, IRecipe rec) { // public static void addRecipe(String name, IRecipe rec) {
Item i = rec.getRecipeOutput().getItem(); // Item i = rec.getRecipeOutput().getItem();
if (i instanceof IDisableableItem && ((IDisableableItem) i).isDisabled()) rec = new BlankRecipe(); // if (i instanceof IDisableableItem && ((IDisableableItem) i).isDisabled()) rec = new BlankRecipe();
if (rec.getRegistryName() == null) { // if (rec.getRegistryName() == null) {
RECIPE_LIST.add(rec.setRegistryName(new ResourceLocation(MODID, name))); // RECIPE_LIST.add(rec.setRegistryName(new ResourceLocation(MODID, name)));
} else { // } else {
RECIPE_LIST.add(rec); // RECIPE_LIST.add(rec);
} // }
RecipeHandler.lastRecipe = rec; // RecipeHandler.lastRecipe = rec;
} // }
//
/* // /*
* This adds a shaped recipe to the list of crafting recipes, using the forge format. // * This adds a shaped recipe to the list of crafting recipes, using the forge format.
*/ // */
public static void addOldShaped(ItemStack output, Object... input) { // public static void addOldShaped(ItemStack output, Object... input) {
ShapedPrimer primer = CraftingHelper.parseShaped(input); // ShapedPrimer primer = CraftingHelper.parseShaped(input);
addRecipe(j++, new ShapedRecipes(new ResourceLocation(MODID, "recipes" + j).toString(), primer.width, primer.height, primer.input, output)); // 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. // * 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) { // public static void addOldShaped(String group, ItemStack output, Object... input) {
ShapedPrimer primer = CraftingHelper.parseShaped(input); // ShapedPrimer primer = CraftingHelper.parseShaped(input);
addRecipe(j++, new ShapedRecipes(new ResourceLocation(MODID, group).toString(), primer.width, primer.height, primer.input, output)); // 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. // * 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) { // public static void addOldShaped(String name, String group, ItemStack output, Object... input) {
ShapedPrimer primer = CraftingHelper.parseShaped(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)); // 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. // * This adds a shapeless recipe to the list of crafting recipes, using the forge format.
*/ // */
public static void addOldShapeless(ItemStack output, Object... input) { // public static void addOldShapeless(ItemStack output, Object... input) {
addRecipe(j++, new ShapelessRecipes(new ResourceLocation(MODID, "recipes" + j).toString(), output, createInput(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. // * 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) { // public static void addOldShapeless(String group, ItemStack output, Object... input) {
addRecipe(j++, new ShapelessRecipes(new ResourceLocation(MODID, group).toString(), output, createInput(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) { // 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)); // 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. // * 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) { // public static void addShapeless(ItemStack output, Object... inputs) {
addRecipe(j++, new ShapelessRecipes(MODID + ":" + j, output, createInput(inputs))); // addRecipe(j++, new ShapelessRecipes(MODID + ":" + j, output, createInput(inputs)));
} // }
//
public static void addShapeless(Item output, Object... inputs) { // public static void addShapeless(Item output, Object... inputs) {
addShapeless(new ItemStack(output), inputs); // addShapeless(new ItemStack(output), inputs);
} // }
//
public static void addShapeless(Block output, Object... inputs) { // public static void addShapeless(Block output, Object... inputs) {
addShapeless(new ItemStack(output), 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. // * 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) { // public static void addShapeless(String group, ItemStack output, Object... inputs) {
addRecipe(j++, new ShapelessRecipes(MODID + ":" + group, output, createInput(inputs))); // addRecipe(j++, new ShapelessRecipes(MODID + ":" + group, output, createInput(inputs)));
} // }
//
public static void addShapeless(String group, Item output, Object... inputs) { // public static void addShapeless(String group, Item output, Object... inputs) {
addShapeless(group, new ItemStack(output), inputs); // addShapeless(group, new ItemStack(output), inputs);
} // }
//
public static void addShapeless(String group, Block output, Object... inputs) { // public static void addShapeless(String group, Block output, Object... inputs) {
addShapeless(group, new ItemStack(output), 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. // * 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 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) { // public static void addShaped(ItemStack output, int width, int height, Object... input) {
addRecipe(j++, genShaped(output, width, height, input)); // addRecipe(j++, genShaped(output, width, height, input));
} // }
//
public static void addShaped(Item output, int width, int height, Object... input) { // public static void addShaped(Item output, int width, int height, Object... input) {
addShaped(new ItemStack(output), width, height, input); // addShaped(new ItemStack(output), width, height, input);
} // }
//
public static void addShaped(Block output, int width, int height, Object... input) { // public static void addShaped(Block output, int width, int height, Object... input) {
addShaped(new ItemStack(output), width, height, 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. // * 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. // * 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) { // public static void addShaped(String group, ItemStack output, int width, int height, Object... input) {
addRecipe(j++, genShaped(MODID + ":" + group, output, width, height, input)); // addRecipe(j++, genShaped(MODID + ":" + group, output, width, height, input));
} // }
//
public static void addShaped(String group, Item output, int width, int height, Object... input) { // public static void addShaped(String group, Item output, int width, int height, Object... input) {
addShaped(group, new ItemStack(output), width, height, input); // addShaped(group, new ItemStack(output), width, height, input);
} // }
//
public static void addShaped(String group, Block output, int width, int height, Object... input) { // public static void addShaped(String group, Block output, int width, int height, Object... input) {
addShaped(group, new ItemStack(output), width, height, input); // addShaped(group, new ItemStack(output), width, height, input);
} // }
//
public static ShapedRecipes genShaped(ItemStack output, int l, int w, Object[] input) { // public static ShapedRecipes genShaped(ItemStack output, int l, int w, Object[] input) {
if (input[0] instanceof Object[]) { // if (input[0] instanceof Object[]) {
input = (Object[]) input[0]; // input = (Object[]) input[0];
} // }
if (l * w != input.length) { throw new UnsupportedOperationException("Attempted to add invalid shaped recipe. Complain to the author of " + MODNAME); } // if (l * w != input.length) { throw new UnsupportedOperationException("Attempted to add invalid shaped recipe. Complain to the author of " + MODNAME); }
NonNullList<Ingredient> inputL = NonNullList.create(); // NonNullList<Ingredient> inputL = NonNullList.create();
for (int i = 0; i < input.length; i++) { // for (int i = 0; i < input.length; i++) {
Object k = input[i]; // Object k = input[i];
if (k instanceof String) { // if (k instanceof String) {
inputL.add(i, new OreIngredient((String) k)); // inputL.add(i, new OreIngredient((String) k));
} else if (k instanceof ItemStack && !((ItemStack) k).isEmpty()) { // } else if (k instanceof ItemStack && !((ItemStack) k).isEmpty()) {
inputL.add(i, Ingredient.fromStacks((ItemStack) k)); // inputL.add(i, Ingredient.fromStacks((ItemStack) k));
} else if (k instanceof Item) { // } else if (k instanceof Item) {
inputL.add(i, Ingredient.fromStacks(new ItemStack((Item) k))); // inputL.add(i, Ingredient.fromStacks(new ItemStack((Item) k)));
} else if (k instanceof Block) { // } else if (k instanceof Block) {
inputL.add(i, Ingredient.fromStacks(new ItemStack((Block) k))); // inputL.add(i, Ingredient.fromStacks(new ItemStack((Block) k)));
} else { // } else {
inputL.add(i, Ingredient.EMPTY); // inputL.add(i, Ingredient.EMPTY);
} // }
} // }
//
return new ShapedRecipes(MODID + ":" + j, l, w, inputL, output); // return new ShapedRecipes(MODID + ":" + j, l, w, inputL, output);
} // }
//
public static ShapedRecipes genShaped(String group, ItemStack output, int l, int w, Object[] input) { // public static ShapedRecipes genShaped(String group, ItemStack output, int l, int w, Object[] input) {
if (input[0] instanceof List) { // if (input[0] instanceof List) {
input = ((List<?>) input[0]).toArray(); // input = ((List<?>) input[0]).toArray();
} else if (input[0] instanceof Object[]) { // } else if (input[0] instanceof Object[]) {
input = (Object[]) input[0]; // input = (Object[]) input[0];
} // }
if (l * w != input.length) { throw new UnsupportedOperationException("Attempted to add invalid shaped recipe. Complain to the author of " + MODNAME); } // if (l * w != input.length) { throw new UnsupportedOperationException("Attempted to add invalid shaped recipe. Complain to the author of " + MODNAME); }
NonNullList<Ingredient> inputL = NonNullList.create(); // NonNullList<Ingredient> inputL = NonNullList.create();
for (int i = 0; i < input.length; i++) { // for (int i = 0; i < input.length; i++) {
Object k = input[i]; // Object k = input[i];
if (k instanceof String) { // if (k instanceof String) {
inputL.add(i, new OreIngredient((String) k)); // inputL.add(i, new OreIngredient((String) k));
} else if (k instanceof ItemStack && !((ItemStack) k).isEmpty()) { // } else if (k instanceof ItemStack && !((ItemStack) k).isEmpty()) {
inputL.add(i, Ingredient.fromStacks((ItemStack) k)); // inputL.add(i, Ingredient.fromStacks((ItemStack) k));
} else if (k instanceof Item) { // } else if (k instanceof Item) {
inputL.add(i, Ingredient.fromStacks(new ItemStack((Item) k))); // inputL.add(i, Ingredient.fromStacks(new ItemStack((Item) k)));
} else if (k instanceof Block) { // } else if (k instanceof Block) {
inputL.add(i, Ingredient.fromStacks(new ItemStack((Block) k))); // inputL.add(i, Ingredient.fromStacks(new ItemStack((Block) k)));
} else if (k instanceof Ingredient) { // } else if (k instanceof Ingredient) {
inputL.add(i, (Ingredient) k); // inputL.add(i, (Ingredient) k);
} else { // } else {
inputL.add(i, Ingredient.EMPTY); // inputL.add(i, Ingredient.EMPTY);
} // }
} // }
//
return new ShapedRecipes(group, l, w, inputL, output); // return new ShapedRecipes(group, l, w, inputL, output);
} // }
//
public static NonNullList<Ingredient> createInput(Object[] input) { // public static NonNullList<Ingredient> createInput(Object[] input) {
if (input[0] instanceof List) { // if (input[0] instanceof List) {
input = ((List<?>) input[0]).toArray(); // input = ((List<?>) input[0]).toArray();
} else if (input[0] instanceof Object[]) { // } else if (input[0] instanceof Object[]) {
input = (Object[]) input[0]; // input = (Object[]) input[0];
} // }
NonNullList<Ingredient> inputL = NonNullList.create(); // NonNullList<Ingredient> inputL = NonNullList.create();
for (int i = 0; i < input.length; i++) { // for (int i = 0; i < input.length; i++) {
Object k = input[i]; // Object k = input[i];
if (k instanceof String) { // if (k instanceof String) {
inputL.add(i, new OreIngredient((String) k)); // inputL.add(i, new OreIngredient((String) k));
} else if (k instanceof ItemStack) { // } else if (k instanceof ItemStack) {
inputL.add(i, Ingredient.fromStacks((ItemStack) k)); // inputL.add(i, Ingredient.fromStacks((ItemStack) k));
} else if (k instanceof Item) { // } else if (k instanceof Item) {
inputL.add(i, Ingredient.fromStacks(new ItemStack((Item) k))); // inputL.add(i, Ingredient.fromStacks(new ItemStack((Item) k)));
} else if (k instanceof Block) { // } else if (k instanceof Block) {
inputL.add(i, Ingredient.fromStacks(new ItemStack((Block) k))); // inputL.add(i, Ingredient.fromStacks(new ItemStack((Block) k)));
} else if (k instanceof Ingredient) { // } else if (k instanceof Ingredient) {
inputL.add(i, (Ingredient) k); // inputL.add(i, (Ingredient) k);
} else { // } else {
throw new UnsupportedOperationException("Attempted to add invalid shapeless recipe. Complain to the author of " + MODNAME); // throw new UnsupportedOperationException("Attempted to add invalid shapeless recipe. Complain to the author of " + MODNAME);
} // }
} // }
return inputL; // return inputL;
} // }
} //}