mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-18 03:25:07 +00:00
Fix several broken ItemStacks and recipes
This commit is contained in:
1 parent
775b4109a9
commit
697ccabf53
5 files changed
+57
-34
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package binnie.core;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -27,7 +28,7 @@ public class Mods {
|
||||
private static Item findItem(final String modId, final String name) {
|
||||
final Item stack = Item.REGISTRY.getObject(new ResourceLocation(modId, name));
|
||||
if (stack == null && Mods.WARN && Objects.equals(modId, "forestry")) {
|
||||
//throw new RuntimeException("Item not found: " + modId + ":" + name);
|
||||
throw new RuntimeException("Item not found: " + modId + ":" + name);
|
||||
}
|
||||
|
||||
return stack;
|
||||
@@ -35,18 +36,18 @@ public class Mods {
|
||||
|
||||
private static ItemStack findItemStack(final String modId, final String name, final int stackSize) {
|
||||
final ItemStack stack = GameRegistry.makeItemStack(modId + ":" + name, 0, stackSize, null);
|
||||
if (stack == null && Mods.WARN && Objects.equals(modId, "forestry")) {
|
||||
//throw new RuntimeException("Stack not found: " + modId + ":" + name);
|
||||
if ((stack == null || stack.getItem() == null) && Mods.WARN && Objects.equals(modId, "forestry")) {
|
||||
throw new RuntimeException("Stack not found: " + modId + ":" + name);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
private static Block findBlock(final String modId, final String name) {
|
||||
final Block stack = Block.REGISTRY.getObject(new ResourceLocation(modId + ":" + name));
|
||||
if (stack == null && Mods.WARN && Objects.equals(modId, "forestry")) {
|
||||
//throw new RuntimeException("Block not found: " + modId + ":" + name);
|
||||
final Block block = Block.REGISTRY.getObject(new ResourceLocation(modId + ":" + name));
|
||||
if (block == Blocks.AIR && Mods.WARN && Objects.equals(modId, "forestry")) {
|
||||
throw new RuntimeException("Block not found: " + modId + ":" + name);
|
||||
}
|
||||
return stack;
|
||||
return block;
|
||||
}
|
||||
|
||||
public static class Mod {
|
||||
|
||||
@@ -5,7 +5,13 @@ import binnie.core.Mods;
|
||||
import binnie.genetics.item.GeneticsItems;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public enum FluidContainer {
|
||||
Capsule,
|
||||
@@ -47,26 +53,42 @@ public enum FluidContainer {
|
||||
public ItemStack getEmpty() {
|
||||
switch (this) {
|
||||
case Can: {
|
||||
return Mods.Forestry.stack("canEmpty");
|
||||
return Mods.Forestry.stack("can");
|
||||
}
|
||||
case Capsule: {
|
||||
return Mods.Forestry.stack("waxCapsule");
|
||||
return Mods.Forestry.stack("capsule");
|
||||
}
|
||||
case Glass: {
|
||||
return new ItemStack(Items.GLASS_BOTTLE, 1, 0);
|
||||
}
|
||||
case Refractory: {
|
||||
return Mods.Forestry.stack("refractoryEmpty");
|
||||
return Mods.Forestry.stack("refractory");
|
||||
}
|
||||
case Cylinder: {
|
||||
return GeneticsItems.Cylinder.get(1);
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
throw new IllegalArgumentException("Unknown container: " + this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getFilled(Fluid fluid) {
|
||||
ItemStack stack = getEmpty();
|
||||
if (stack != null) {
|
||||
stack = stack.copy();
|
||||
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(stack);
|
||||
if (fluidHandler != null) {
|
||||
int fill = fluidHandler.fill(new FluidStack(fluid, Integer.MAX_VALUE), true);
|
||||
if (fill > 0) {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void registerContainerData(final IFluidType fluid) {
|
||||
if (!this.isActive()) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user