mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-17 19:15:24 +00:00
Add Lumbermill JEI recipes
This commit is contained in:
1 parent
88ad994a8c
commit
b6f91fe870
23 files changed
+634
-366
No files matched your search
@@ -4,7 +4,7 @@ import binnie.Binnie;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.util.UniqueItemStackSet;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.machines.Lumbermill;
|
||||
import binnie.extratrees.machines.lumbermill.LumbermillRecipes;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.arboriculture.EnumTreeChromosome;
|
||||
@@ -221,7 +221,7 @@ public class TreeBreedingSystem extends BreedingSystem {
|
||||
ITreeGenome genome = TreeManager.treeRoot.templateAsGenome(TreeManager.treeRoot.getTemplate(tSpecies.getUID()));
|
||||
IAlleleTreeSpecies treeSpecies = genome.getPrimary();
|
||||
final ItemStack woodStack = treeSpecies.getWoodProvider().getWoodStack();
|
||||
if (Lumbermill.getPlankProduct(woodStack) != null && fruit.isItemEqual(Lumbermill.getPlankProduct(woodStack))) {
|
||||
if (LumbermillRecipes.getPlankProduct(woodStack) != null && fruit.isItemEqual(LumbermillRecipes.getPlankProduct(woodStack))) {
|
||||
found.add(species);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package binnie.core.util;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.profiler.Profiler;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldProvider;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.EmptyChunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.storage.ISaveHandler;
|
||||
import net.minecraft.world.storage.SaveDataMemoryStorage;
|
||||
import net.minecraft.world.storage.SaveHandlerMP;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class FakeCraftingWorld extends World {
|
||||
private static final WorldSettings worldSettings = new WorldSettings(0, GameType.SURVIVAL, false, false, WorldType.DEFAULT);
|
||||
private static final WorldInfo worldInfo = new WorldInfo(worldSettings, "fake");
|
||||
private static final ISaveHandler saveHandler = new SaveHandlerMP();
|
||||
private static final WorldProvider worldProvider = new WorldProvider() {
|
||||
@Override
|
||||
public DimensionType getDimensionType() {
|
||||
return DimensionType.OVERWORLD;
|
||||
}
|
||||
};
|
||||
@Nullable
|
||||
private static FakeCraftingWorld INSTANCE;
|
||||
|
||||
public static FakeCraftingWorld getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new FakeCraftingWorld();
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private FakeCraftingWorld() {
|
||||
super(saveHandler, worldInfo, worldProvider, new Profiler(), true);
|
||||
this.provider.registerWorld(this);
|
||||
this.mapStorage = new SaveDataMemoryStorage();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public BlockPos getSpawnPoint() {
|
||||
return new BlockPos(0, 0, 0);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBlockState getBlockState(BlockPos pos) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected IChunkProvider createChunkProvider() {
|
||||
return new IChunkProvider() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Chunk getLoadedChunk(int x, int z) {
|
||||
return new EmptyChunk(FakeCraftingWorld.this, x, z);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Chunk provideChunk(int x, int z) {
|
||||
return new EmptyChunk(FakeCraftingWorld.this, x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unloadQueuedChunks() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String makeString() {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isChunkLoaded(int x, int z, boolean allowEmpty) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,9 @@ import binnie.craftgui.resource.Texture;
|
||||
import binnie.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.craftgui.window.Panel;
|
||||
import binnie.extratrees.core.ExtraTreeTexture;
|
||||
import binnie.extratrees.machines.Lumbermill;
|
||||
import binnie.extratrees.machines.lumbermill.LumbermillMachine;
|
||||
import binnie.extratrees.machines.lumbermill.LumbermillRecipes;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -37,7 +39,7 @@ public class ControlLumbermillProgress extends ControlProgressBase {
|
||||
GL11.glDisable(2896);
|
||||
final int sawX = (int) (63.0f * this.progress);
|
||||
CraftGUI.Render.texture(ControlLumbermillProgress.Saw, new IPoint(sawX, -8.0f + 6.0f * (float) Math.sin(this.animation)));
|
||||
final ItemStack item = Window.get(this).getInventory().getStackInSlot(Lumbermill.slotWood);
|
||||
final ItemStack item = Window.get(this).getInventory().getStackInSlot(LumbermillMachine.SLOT_LOG);
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
@@ -54,7 +56,7 @@ public class ControlLumbermillProgress extends ControlProgressBase {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
//CraftGUI.Render.iconBlock(new IPoint(1 + i * 16, 1.0f), icon);
|
||||
}
|
||||
final ItemStack result = Lumbermill.getPlankProduct(item);
|
||||
final ItemStack result = LumbermillRecipes.getPlankProduct(item);
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import binnie.craftgui.minecraft.control.ControlLiquidTank;
|
||||
import binnie.craftgui.minecraft.control.ControlPlayerInventory;
|
||||
import binnie.craftgui.minecraft.control.ControlSlot;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.machines.Lumbermill;
|
||||
import binnie.extratrees.machines.lumbermill.LumbermillMachine;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -33,10 +33,10 @@ public class WindowLumbermill extends Window {
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName());
|
||||
new ControlSlot(this, 42.0f, 43.0f).assign(Lumbermill.slotWood);
|
||||
new ControlSlot(this, 148.0f, 43.0f).assign(Lumbermill.slotPlanks);
|
||||
new ControlSlot(this, 172.0f, 28.0f).assign(Lumbermill.slotBark);
|
||||
new ControlSlot(this, 172.0f, 58.0f).assign(Lumbermill.slotSawdust);
|
||||
new ControlSlot(this, 42.0f, 43.0f).assign(LumbermillMachine.SLOT_LOG);
|
||||
new ControlSlot(this, 148.0f, 43.0f).assign(LumbermillMachine.SLOT_PLANKS);
|
||||
new ControlSlot(this, 172.0f, 28.0f).assign(LumbermillMachine.SLOT_BARK);
|
||||
new ControlSlot(this, 172.0f, 58.0f).assign(LumbermillMachine.SLOT_SAWDUST);
|
||||
new ControlLumbermillProgress(this, 70.0f, 43.0f);
|
||||
new ControlLiquidTank(this, 16, 32);
|
||||
new ControlEnergyBar(this, 8, 112, 16, 60, Position.Bottom);
|
||||
|
||||
@@ -4,6 +4,7 @@ import binnie.Constants;
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.gui.IBinnieGUID;
|
||||
import binnie.core.item.ItemMisc;
|
||||
import binnie.core.models.DoublePassBakedModel;
|
||||
import binnie.core.network.BinniePacketHandler;
|
||||
import binnie.core.proxy.IProxyCore;
|
||||
@@ -57,7 +58,7 @@ public class ExtraTrees extends AbstractMod {
|
||||
public static Proxy proxy;
|
||||
public static Item itemDictionary;
|
||||
public static Item itemDictionaryLepi;
|
||||
public static Item itemMisc;
|
||||
public static ItemMisc itemMisc;
|
||||
public static Item itemFood;
|
||||
public static List<BlockETLog> logs;
|
||||
public static List<BlockETLog> logsFireproof;
|
||||
|
||||
@@ -60,9 +60,11 @@ public class ModuleBlocks implements IInitializable {
|
||||
ExtraTrees.proxy.registerBlock(block, new ItemETLog(block));
|
||||
registerOreDictWildcard(OreDictUtil.LOG_WOOD, block);
|
||||
}
|
||||
|
||||
WoodAccess.registerLogs(ExtraTrees.logs);
|
||||
WoodAccess.registerLogs(ExtraTrees.logsFireproof);
|
||||
|
||||
WoodAccess woodAccess = WoodAccess.getInstance();
|
||||
|
||||
woodAccess.registerLogs(ExtraTrees.logs);
|
||||
woodAccess.registerLogs(ExtraTrees.logsFireproof);
|
||||
|
||||
ExtraTrees.planks = BlockETPlank.create(false);
|
||||
for (BlockETPlank block : ExtraTrees.planks) {
|
||||
@@ -75,9 +77,9 @@ public class ModuleBlocks implements IInitializable {
|
||||
ExtraTrees.proxy.registerBlock(block, new ItemETPlank(block));
|
||||
registerOreDictWildcard(OreDictUtil.PLANK_WOOD, block);
|
||||
}
|
||||
|
||||
WoodAccess.registerPlanks(ExtraTrees.planks);
|
||||
WoodAccess.registerPlanks(ExtraTrees.planksFireproof);
|
||||
|
||||
woodAccess.registerPlanks(ExtraTrees.planks);
|
||||
woodAccess.registerPlanks(ExtraTrees.planksFireproof);
|
||||
|
||||
ExtraTrees.slabs = BlockETSlab.create(false, false);
|
||||
ExtraTrees.slabsDouble = BlockETSlab.create(false, true);
|
||||
@@ -98,8 +100,8 @@ public class ModuleBlocks implements IInitializable {
|
||||
ExtraTrees.proxy.registerBlock(slabDouble, new ItemETSlab(slabDouble, slab, slabDouble));
|
||||
registerOreDictWildcard(OreDictUtil.SLAB_WOOD, slab);
|
||||
}
|
||||
WoodAccess.registerSlabs(ExtraTrees.slabs);
|
||||
WoodAccess.registerSlabs(ExtraTrees.slabsFireproof);
|
||||
woodAccess.registerSlabs(ExtraTrees.slabs);
|
||||
woodAccess.registerSlabs(ExtraTrees.slabsFireproof);
|
||||
|
||||
ExtraTrees.stairs = new ArrayList<>();
|
||||
for (BlockETPlank plank : ExtraTrees.planks) {
|
||||
@@ -132,9 +134,9 @@ public class ModuleBlocks implements IInitializable {
|
||||
registerOreDictWildcard(OreDictUtil.STAIR_WOOD, stair);
|
||||
}
|
||||
}
|
||||
|
||||
WoodAccess.registerStairs(ExtraTrees.stairs);
|
||||
WoodAccess.registerStairs(ExtraTrees.stairsFireproof);
|
||||
|
||||
woodAccess.registerStairs(ExtraTrees.stairs);
|
||||
woodAccess.registerStairs(ExtraTrees.stairsFireproof);
|
||||
|
||||
ExtraTrees.blockFence = new BlockFence("fence");
|
||||
ExtraTrees.blockGate = new BlockGate();
|
||||
@@ -184,17 +186,24 @@ public class ModuleBlocks implements IInitializable {
|
||||
IWoodAccess woodAccess = TreeManager.woodAccess;
|
||||
for(EnumExtraTreeLog woodType : EnumExtraTreeLog.VALUES){
|
||||
for(boolean fireproof : new boolean[]{false, true}){
|
||||
ItemStack logs = woodAccess.getStack(woodType, WoodBlockKind.LOG, fireproof);
|
||||
ItemStack planks = woodAccess.getStack(woodType, WoodBlockKind.PLANKS, fireproof);
|
||||
ItemStack slabs = woodAccess.getStack(woodType, WoodBlockKind.SLAB, fireproof);
|
||||
ItemStack stairs = woodAccess.getStack(woodType, WoodBlockKind.STAIRS, fireproof);
|
||||
|
||||
stairs.stackSize = 4;
|
||||
RecipeUtil.addPriorityRecipe(stairs.copy(),
|
||||
"# ",
|
||||
"## ",
|
||||
"###",
|
||||
'#', planks.copy());
|
||||
|
||||
slabs.stackSize = 6;
|
||||
RecipeUtil.addPriorityRecipe(slabs.copy(), "###", '#', planks.copy());
|
||||
|
||||
ItemStack craftedPlanks = planks.copy();
|
||||
craftedPlanks.stackSize = 4;
|
||||
RecipeUtil.addShapelessRecipe(craftedPlanks, logs.copy());
|
||||
}
|
||||
}
|
||||
GameRegistry.addRecipe(new MultiFenceRecipeSize());
|
||||
|
||||
@@ -6,11 +6,11 @@ import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.api.CarpentryManager;
|
||||
import com.google.common.base.Optional;
|
||||
import forestry.api.arboriculture.EnumForestryWoodType;
|
||||
import forestry.api.arboriculture.EnumVanillaWoodType;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
@@ -33,48 +33,50 @@ public class PlankType {
|
||||
}
|
||||
|
||||
public enum ExtraTreePlanks implements IPlankType, IFenceProvider, IStringSerializable {
|
||||
Fir(12815444),
|
||||
Cedar(14181940),
|
||||
Hemlock(13088108),
|
||||
Cypress(16169052),
|
||||
Fig(13142058),
|
||||
Beech(14784849),
|
||||
Alder(12092755),
|
||||
Hazel(13480341),
|
||||
Hornbeam(12818528),
|
||||
Box(16511430),
|
||||
Butternut(15510138),
|
||||
Hickory(14333070),
|
||||
Whitebeam(13222585),
|
||||
Elm(15772004),
|
||||
Apple(6305064),
|
||||
Yew(14722426),
|
||||
Pear(12093805),
|
||||
Hawthorn(13402978),
|
||||
Rowan(13610394),
|
||||
Elder(12489337),
|
||||
Maclura(15970862),
|
||||
Syzgium(15123393),
|
||||
Brazilwood(7487063),
|
||||
Logwood(10762028),
|
||||
Iroko(7681024),
|
||||
Locust(12816736),
|
||||
Eucalyptus(16165771),
|
||||
Purpleheart(5970991),
|
||||
Ash(16107368),
|
||||
Holly(16512743),
|
||||
Olive(11578760),
|
||||
Sweetgum(13997656),
|
||||
Rosewood(7738624),
|
||||
Gingko(16050106),
|
||||
PinkIvory(15502496),
|
||||
Banana(0);
|
||||
Fir(12815444, EnumExtraTreeLog.Fir),
|
||||
Cedar(14181940, EnumExtraTreeLog.Cedar),
|
||||
Hemlock(13088108, EnumExtraTreeLog.Hemlock),
|
||||
Cypress(16169052, EnumExtraTreeLog.Cypress),
|
||||
Fig(13142058, EnumExtraTreeLog.Fig),
|
||||
Beech(14784849, EnumExtraTreeLog.Beech),
|
||||
Alder(12092755, EnumExtraTreeLog.Alder),
|
||||
Hazel(13480341, EnumExtraTreeLog.Hazel),
|
||||
Hornbeam(12818528, EnumExtraTreeLog.Hornbeam),
|
||||
Box(16511430, EnumExtraTreeLog.Box),
|
||||
Butternut(15510138, EnumExtraTreeLog.Butternut),
|
||||
Hickory(14333070, EnumExtraTreeLog.Hickory),
|
||||
Whitebeam(13222585, EnumExtraTreeLog.Whitebeam),
|
||||
Elm(15772004, EnumExtraTreeLog.Elm),
|
||||
Apple(6305064, EnumExtraTreeLog.Apple),
|
||||
Yew(14722426, EnumExtraTreeLog.Yew),
|
||||
Pear(12093805, EnumExtraTreeLog.Pear),
|
||||
Hawthorn(13402978, EnumExtraTreeLog.Hawthorn),
|
||||
Rowan(13610394, EnumExtraTreeLog.Rowan),
|
||||
Elder(12489337, EnumExtraTreeLog.Elder),
|
||||
Maclura(15970862, EnumExtraTreeLog.Maclura),
|
||||
Syzgium(15123393, EnumExtraTreeLog.Syzgium),
|
||||
Brazilwood(7487063, EnumExtraTreeLog.Brazilwood),
|
||||
Logwood(10762028, EnumExtraTreeLog.Logwood),
|
||||
Iroko(7681024, EnumExtraTreeLog.Iroko),
|
||||
Locust(12816736, EnumExtraTreeLog.Locust),
|
||||
Eucalyptus(16165771, EnumExtraTreeLog.Eucalyptus),
|
||||
Purpleheart(5970991, EnumExtraTreeLog.Purpleheart),
|
||||
Ash(16107368, EnumExtraTreeLog.Ash),
|
||||
Holly(16512743, EnumExtraTreeLog.Holly),
|
||||
Olive(11578760, EnumExtraTreeLog.Olive),
|
||||
Sweetgum(13997656, EnumExtraTreeLog.Sweetgum),
|
||||
Rosewood(7738624, EnumExtraTreeLog.Rosewood),
|
||||
Gingko(16050106, EnumExtraTreeLog.Gingko),
|
||||
PinkIvory(15502496, EnumExtraTreeLog.PinkIvory),
|
||||
Banana(0, EnumExtraTreeLog.Banana);
|
||||
|
||||
int color;
|
||||
private final IWoodType woodType;
|
||||
private int color;
|
||||
//IIcon icon;
|
||||
|
||||
ExtraTreePlanks(final int color) {
|
||||
ExtraTreePlanks(final int color, IWoodType woodType) {
|
||||
this.color = color;
|
||||
this.woodType = woodType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,6 +101,7 @@ public class PlankType {
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
// TODO get stack
|
||||
return null; //TileEntityMetadata.getItemStack(ExtraTrees.blockPlanks, this.ordinal());
|
||||
}
|
||||
|
||||
@@ -118,17 +121,19 @@ public class PlankType {
|
||||
}
|
||||
|
||||
public enum VanillaPlanks implements IPlankType {
|
||||
OAK(11833434),
|
||||
SPRUCE(8412726),
|
||||
BIRCH(14139781),
|
||||
JUNGLE(11632732),
|
||||
ACACIA(12215095),
|
||||
BIG_OAK(4599061);
|
||||
OAK(11833434, EnumVanillaWoodType.OAK),
|
||||
SPRUCE(8412726, EnumVanillaWoodType.SPRUCE),
|
||||
BIRCH(14139781, EnumVanillaWoodType.BIRCH),
|
||||
JUNGLE(11632732, EnumVanillaWoodType.JUNGLE),
|
||||
ACACIA(12215095, EnumVanillaWoodType.ACACIA),
|
||||
BIG_OAK(4599061, EnumVanillaWoodType.DARK_OAK);
|
||||
|
||||
int color;
|
||||
private final IWoodType woodType;
|
||||
private int color;
|
||||
|
||||
VanillaPlanks(final int color) {
|
||||
VanillaPlanks(final int color, IWoodType woodType) {
|
||||
this.color = color;
|
||||
this.woodType = woodType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,7 +158,7 @@ public class PlankType {
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return new ItemStack(Blocks.PLANKS, 1, this.ordinal());
|
||||
return TreeManager.woodAccess.getStack(woodType, WoodBlockKind.PLANKS, false);
|
||||
}
|
||||
|
||||
// @Override
|
||||
|
||||
@@ -41,7 +41,7 @@ public class TreeGenerator implements ITreeGenerator {
|
||||
if (woodType != null) {
|
||||
AlleleBoolean fireproofAllele = (AlleleBoolean) genome.getActiveAllele(EnumTreeChromosome.FIREPROOF);
|
||||
boolean fireproof = fireproofAllele.getValue();
|
||||
return world.setBlockState(pos, WoodAccess.getInstance().getBlock(woodType, WoodBlockKind.LOG, fireproof), 2);
|
||||
return world.setBlockState(pos, TreeManager.woodAccess.getBlock(woodType, WoodBlockKind.LOG, fireproof), 2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
package binnie.extratrees.genetics;
|
||||
|
||||
import binnie.extratrees.block.EnumExtraTreeLog;
|
||||
import forestry.api.arboriculture.IWoodAccess;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class WoodAccess implements IWoodAccess {
|
||||
private WoodHolder wood = new WoodHolder();
|
||||
private WoodHolder woodFireproof= new WoodHolder();
|
||||
|
||||
private static final WoodAccess instance = new WoodAccess();
|
||||
|
||||
public static WoodAccess getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public <T extends Block, V extends Enum<V> & IWoodType> void registerWithVariants(T woodTyped, WoodBlockKind woodBlockKind, PropertyEnum<V> property, boolean fireproof) {
|
||||
for (V value : property.getAllowedValues()) {
|
||||
IBlockState blockState = woodTyped.getDefaultState().withProperty(property, value);
|
||||
if(fireproof) {
|
||||
woodFireproof.addWood(value, woodBlockKind, blockState);
|
||||
}else {
|
||||
wood.addWood(value, woodBlockKind, blockState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerWithBlockState(IBlockState blockState, WoodBlockKind woodBlockKind, EnumExtraTreeLog log, boolean fireproof) {
|
||||
if(fireproof) {
|
||||
woodFireproof.addWood(log, woodBlockKind, blockState);
|
||||
}else {
|
||||
wood.addWood(log, woodBlockKind, blockState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack(IWoodType woodType, WoodBlockKind kind, boolean fireproof) {
|
||||
IBlockState state = fireproof?woodFireproof.getWood(woodType, kind) : wood.getWood(woodType, kind);
|
||||
if(state != null) {
|
||||
int metadata = state.getBlock().getMetaFromState(state);
|
||||
return new ItemStack(state.getBlock(), 1, metadata);
|
||||
} else {
|
||||
return TreeManager.woodAccess.getStack(woodType, kind, fireproof);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getBlock(IWoodType woodType, WoodBlockKind kind, boolean fireproof) {
|
||||
IBlockState state = fireproof?woodFireproof.getWood(woodType, kind) : wood.getWood(woodType, kind);
|
||||
return state==null? TreeManager.woodAccess.getBlock(woodType, kind, fireproof) : state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IWoodType> getRegisteredWoodTypes() {
|
||||
throw new NotImplementedException("");
|
||||
}
|
||||
|
||||
private class WoodHolder{
|
||||
private Map<WoodBlockKind, Map<IWoodType, IBlockState>> woodMap = new HashMap<>();
|
||||
|
||||
public void addWood(IWoodType woodType, WoodBlockKind kind, IBlockState state){
|
||||
Map<IWoodType, IBlockState> woodTypes = woodMap.get(kind);
|
||||
if (woodTypes == null){
|
||||
woodTypes = new HashMap<>();
|
||||
woodMap.put(kind, woodTypes);
|
||||
}
|
||||
woodTypes.put(woodType, state);
|
||||
}
|
||||
|
||||
public IBlockState getWood(IWoodType woodType, WoodBlockKind kind){
|
||||
Map<IWoodType, IBlockState> woodTypes = woodMap.get(kind);
|
||||
return woodTypes!=null ? woodTypes.get(woodType) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package binnie.extratrees.integration.jei;
|
||||
|
||||
import binnie.core.integration.jei.Drawables;
|
||||
import binnie.core.integration.jei.SimpleRecipeHandler;
|
||||
import binnie.extratrees.integration.jei.lumbermill.LumbermillRecipeCategory;
|
||||
import binnie.extratrees.integration.jei.lumbermill.LumbermillRecipeMaker;
|
||||
import binnie.extratrees.integration.jei.lumbermill.LumbermillRecipeWrapper;
|
||||
import binnie.extratrees.machines.ExtraTreeMachine;
|
||||
import mezz.jei.api.BlankModPlugin;
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.ISubtypeRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
|
||||
@JEIPlugin
|
||||
public class ExtraTreesJeiPlugin extends BlankModPlugin {
|
||||
public static IJeiHelpers jeiHelpers;
|
||||
public static IGuiHelper guiHelper;
|
||||
public static Drawables drawables;
|
||||
|
||||
@Override
|
||||
public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(IModRegistry registry) {
|
||||
ExtraTreesJeiPlugin.jeiHelpers = registry.getJeiHelpers();
|
||||
ExtraTreesJeiPlugin.guiHelper = jeiHelpers.getGuiHelper();
|
||||
ExtraTreesJeiPlugin.drawables = Drawables.getDrawables(guiHelper);
|
||||
|
||||
registry.addRecipeCategories(
|
||||
new LumbermillRecipeCategory()
|
||||
);
|
||||
|
||||
registry.addRecipeHandlers(
|
||||
new SimpleRecipeHandler<>(LumbermillRecipeWrapper.class, RecipeUids.LUMBERMILL)
|
||||
);
|
||||
|
||||
registry.addRecipeCategoryCraftingItem(ExtraTreeMachine.Lumbermill.get(1), RecipeUids.LUMBERMILL);
|
||||
|
||||
registry.addRecipes(LumbermillRecipeMaker.create());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package binnie.extratrees.integration.jei;
|
||||
|
||||
public class RecipeUids {
|
||||
public static final String LUMBERMILL = "binnie.extratrees.lumbermill";
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package binnie.extratrees.integration.jei.lumbermill;
|
||||
|
||||
|
||||
import binnie.extratrees.integration.jei.ExtraTreesJeiPlugin;
|
||||
import binnie.extratrees.integration.jei.RecipeUids;
|
||||
import binnie.extratrees.machines.lumbermill.LumbermillMachine;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IDrawableAnimated;
|
||||
import mezz.jei.api.gui.IGuiFluidStackGroup;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.BlankRecipeCategory;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class LumbermillRecipeCategory extends BlankRecipeCategory<LumbermillRecipeWrapper> {
|
||||
private final IDrawableAnimated arrowAnimated;
|
||||
|
||||
public LumbermillRecipeCategory() {
|
||||
this.arrowAnimated = ExtraTreesJeiPlugin.drawables.createArrowAnimated(56);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return RecipeUids.LUMBERMILL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Lumbermill";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return ExtraTreesJeiPlugin.guiHelper.createBlankDrawable(130, 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
IDrawable tank = ExtraTreesJeiPlugin.drawables.getTank();
|
||||
tank.draw(minecraft, 0, 0);
|
||||
|
||||
IDrawable arrow = ExtraTreesJeiPlugin.drawables.getArrow();
|
||||
arrow.draw(minecraft, 69, 25);
|
||||
arrowAnimated.draw(minecraft, 69, 25);
|
||||
|
||||
IDrawable slot = ExtraTreesJeiPlugin.guiHelper.getSlotDrawable();
|
||||
|
||||
slot.draw(minecraft, 42, 21);
|
||||
|
||||
slot.draw(minecraft, 112, 0);
|
||||
slot.draw(minecraft, 92, 21);
|
||||
slot.draw(minecraft, 112, 42);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, LumbermillRecipeWrapper recipeWrapper, IIngredients ingredients) {
|
||||
IDrawable tankOverlay = ExtraTreesJeiPlugin.drawables.getTankOverlay();
|
||||
IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
|
||||
fluidStacks.init(LumbermillMachine.TANK_WATER, true, 1, 1, 16, 58, LumbermillMachine.TANK_WATER_CAPACITY, false, tankOverlay);
|
||||
fluidStacks.set(ingredients);
|
||||
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
itemStacks.init(0, true, 42, 21);
|
||||
|
||||
itemStacks.init(1, false, 112, 0);
|
||||
itemStacks.init(2, false, 92, 21);
|
||||
itemStacks.init(3, false, 112, 42);
|
||||
itemStacks.set(ingredients);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package binnie.extratrees.integration.jei.lumbermill;
|
||||
|
||||
import binnie.extratrees.machines.lumbermill.LumbermillRecipes;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class LumbermillRecipeMaker {
|
||||
public static List<LumbermillRecipeWrapper> create() {
|
||||
List<LumbermillRecipeWrapper> recipes = new ArrayList<>();
|
||||
|
||||
Collection<Pair<ItemStack, ItemStack>> recipePairs = LumbermillRecipes.getRecipes();
|
||||
for (Pair<ItemStack, ItemStack> pair : recipePairs) {
|
||||
ItemStack logInput = pair.getKey();
|
||||
ItemStack plankOutput = pair.getValue();
|
||||
recipes.add(new LumbermillRecipeWrapper(logInput, plankOutput));
|
||||
}
|
||||
|
||||
return recipes;
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package binnie.extratrees.integration.jei.lumbermill;
|
||||
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.item.ExtraTreeItems;
|
||||
import binnie.extratrees.machines.lumbermill.LumbermillLogic;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.BlankRecipeWrapper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class LumbermillRecipeWrapper extends BlankRecipeWrapper {
|
||||
private static final FluidStack WATER = new FluidStack(FluidRegistry.WATER, LumbermillLogic.WATER_PER_TICK * LumbermillLogic.PROCESS_LENGTH);
|
||||
|
||||
private final ItemStack inputLog;
|
||||
private final ItemStack outputPlanks;
|
||||
|
||||
public LumbermillRecipeWrapper(ItemStack inputLog, ItemStack outputPlanks) {
|
||||
this.inputLog = inputLog;
|
||||
this.outputPlanks = outputPlanks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
ingredients.setInput(ItemStack.class, inputLog);
|
||||
ingredients.setInput(FluidStack.class, WATER);
|
||||
|
||||
ingredients.setOutputs(ItemStack.class, Arrays.asList(
|
||||
ExtraTrees.itemMisc.getStack(ExtraTreeItems.Bark, 1),
|
||||
outputPlanks,
|
||||
ExtraTrees.itemMisc.getStack(ExtraTreeItems.Sawdust, 1)
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package binnie.extratrees.integration.jei.lumbermill;
|
||||
|
||||
import binnie.core.util.FieldsAreNonnullByDefault;
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -0,0 +1,9 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package binnie.extratrees.integration.jei;
|
||||
|
||||
import binnie.core.util.FieldsAreNonnullByDefault;
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -12,6 +12,7 @@ import binnie.core.resource.BinnieResource;
|
||||
import binnie.core.resource.ResourceType;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.core.ExtraTreesGUID;
|
||||
import binnie.extratrees.machines.lumbermill.LumbermillMachine;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -19,7 +20,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public enum ExtraTreeMachine implements IMachineType {
|
||||
Lumbermill(Lumbermill.PackageLumbermill.class),
|
||||
Lumbermill(LumbermillMachine.class),
|
||||
Woodworker(Designer.PackageWoodworker.class),
|
||||
Panelworker(Designer.PackagePanelworker.class),
|
||||
Nursery(Nursery.PackageNursery.class),
|
||||
|
||||
@@ -1,207 +0,0 @@
|
||||
package binnie.extratrees.machines;
|
||||
|
||||
import binnie.core.item.ItemMisc;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.inventory.TankValidator;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.block.IPlankType;
|
||||
import binnie.extratrees.block.WoodManager;
|
||||
import binnie.extratrees.core.ExtraTreeTexture;
|
||||
import binnie.extratrees.core.ExtraTreesGUID;
|
||||
import binnie.extratrees.item.ExtraTreeItems;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Lumbermill {
|
||||
public static int slotWood = 0;
|
||||
public static int slotPlanks = 1;
|
||||
public static int slotBark = 2;
|
||||
public static int slotSawdust = 3;
|
||||
public static int tankWater = 0;
|
||||
static Map<ItemStack, ItemStack> recipes = new HashMap<>();
|
||||
|
||||
public static ItemStack getPlankProduct(final ItemStack item) {
|
||||
ItemStack stack = null;
|
||||
if (Lumbermill.recipes.isEmpty()) {
|
||||
calculateLumbermillProducts();
|
||||
}
|
||||
for (final Map.Entry<ItemStack, ItemStack> entry : Lumbermill.recipes.entrySet()) {
|
||||
if (entry.getKey().isItemEqual(item)) {
|
||||
stack = entry.getValue().copy();
|
||||
break;
|
||||
}
|
||||
}
|
||||
stack.stackSize = 6;
|
||||
return stack;
|
||||
}
|
||||
|
||||
private static void calculateLumbermillProducts() {
|
||||
for (final IPlankType type : WoodManager.getAllPlankTypes()) {
|
||||
for (final ItemStack wood : getRecipeResult(type.getStack())) {
|
||||
Lumbermill.recipes.put(wood, type.getStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Collection<ItemStack> getRecipeResult(final ItemStack output) {
|
||||
final List<ItemStack> list = new ArrayList<>();
|
||||
for (final Object recipeO : CraftingManager.getInstance().getRecipeList()) {
|
||||
if (recipeO instanceof ShapelessRecipes) {
|
||||
final ShapelessRecipes recipe = (ShapelessRecipes) recipeO;
|
||||
if (recipe.recipeItems.size() != 1) {
|
||||
continue;
|
||||
}
|
||||
if (!(recipe.recipeItems.get(0) != null)) {
|
||||
continue;
|
||||
}
|
||||
final ItemStack input = recipe.recipeItems.get(0);
|
||||
if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().isItemEqual(output)) {
|
||||
list.add(input);
|
||||
}
|
||||
}
|
||||
if (recipeO instanceof ShapedRecipes) {
|
||||
final ShapedRecipes recipe2 = (ShapedRecipes) recipeO;
|
||||
if (recipe2.recipeItems.length != 1) {
|
||||
continue;
|
||||
}
|
||||
final ItemStack input = recipe2.recipeItems[0];
|
||||
if (recipe2.getRecipeOutput() != null && recipe2.getRecipeOutput().isItemEqual(output)) {
|
||||
list.add(input);
|
||||
}
|
||||
}
|
||||
if (recipeO instanceof ShapelessOreRecipe) {
|
||||
final ShapelessOreRecipe recipe3 = (ShapelessOreRecipe) recipeO;
|
||||
if (recipe3.getInput().size() != 1) {
|
||||
continue;
|
||||
}
|
||||
if (!(recipe3.getInput().get(0) instanceof ItemStack)) {
|
||||
continue;
|
||||
}
|
||||
final ItemStack input = (ItemStack) recipe3.getInput().get(0);
|
||||
if (recipe3.getRecipeOutput() == null || !recipe3.getRecipeOutput().isItemEqual(output)) {
|
||||
continue;
|
||||
}
|
||||
list.add(input);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static class PackageLumbermill extends ExtraTreeMachine.PackageExtraTreeMachine implements IMachineInformation {
|
||||
public PackageLumbermill() {
|
||||
super("lumbermill", ExtraTreeTexture.lumbermillTexture, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ExtraTreeMachine.ComponentExtraTreeGUI(machine, ExtraTreesGUID.Lumbermill);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(Lumbermill.slotWood, "input");
|
||||
inventory.getSlot(Lumbermill.slotWood).setValidator(new SlotValidatorLog());
|
||||
inventory.getSlot(Lumbermill.slotWood).forbidExtraction();
|
||||
inventory.addSlot(Lumbermill.slotPlanks, "output");
|
||||
inventory.addSlot(Lumbermill.slotBark, "byproduct");
|
||||
inventory.addSlot(Lumbermill.slotSawdust, "byproduct");
|
||||
inventory.getSlot(Lumbermill.slotPlanks).setReadOnly();
|
||||
inventory.getSlot(Lumbermill.slotBark).setReadOnly();
|
||||
inventory.getSlot(Lumbermill.slotSawdust).setReadOnly();
|
||||
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(Lumbermill.tankWater, "input", 10000);
|
||||
tanks.getTankSlot(Lumbermill.tankWater).setValidator(new TankValidator.Basic("water"));
|
||||
new ComponentPowerReceptor(machine);
|
||||
new ComponentLumbermillLogic(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentLumbermillLogic extends ComponentProcessSetCost implements IProcess {
|
||||
public ComponentLumbermillLogic(final Machine machine) {
|
||||
super(machine, 900, 30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(Lumbermill.slotWood)) {
|
||||
return new ErrorState.NoItem("No Wood", Lumbermill.slotWood);
|
||||
}
|
||||
final ItemStack result = Lumbermill.getPlankProduct(this.getUtil().getStack(Lumbermill.slotWood));
|
||||
if (!this.getUtil().isSlotEmpty(Lumbermill.slotPlanks) && result != null) {
|
||||
final ItemStack currentPlank = this.getUtil().getStack(Lumbermill.slotPlanks);
|
||||
if (!result.isItemEqual(currentPlank) || result.stackSize + currentPlank.stackSize > currentPlank.getMaxStackSize()) {
|
||||
return new ErrorState.NoSpace("No room for new planks", new int[]{Lumbermill.slotPlanks});
|
||||
}
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!this.getUtil().liquidInTank(Lumbermill.tankWater, 5)) {
|
||||
return new ErrorState.InsufficientLiquid("Not Enough Water", Lumbermill.tankWater);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
final ItemStack result = Lumbermill.getPlankProduct(this.getUtil().getStack(Lumbermill.slotWood));
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
this.getUtil().addStack(Lumbermill.slotPlanks, result);
|
||||
this.getUtil().addStack(Lumbermill.slotSawdust, ((ItemMisc) ExtraTrees.itemMisc).getStack(ExtraTreeItems.Sawdust, 1));
|
||||
this.getUtil().addStack(Lumbermill.slotBark, ((ItemMisc) ExtraTrees.itemMisc).getStack(ExtraTreeItems.Bark, 1));
|
||||
this.getUtil().decreaseStack(Lumbermill.slotWood, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.getUtil().drainTank(Lumbermill.tankWater, 10);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotValidatorLog extends SlotValidator {
|
||||
public SlotValidatorLog() {
|
||||
super(SlotValidator.IconBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
final String name = OreDictionary.getOreName(OreDictionary.getOreIDs(itemStack)[0]);
|
||||
return name.contains("logWood") && Lumbermill.getPlankProduct(itemStack) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Logs";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package binnie.extratrees.machines.lumbermill;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.item.ExtraTreeItems;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class LumbermillLogic extends ComponentProcessSetCost implements IProcess {
|
||||
public static final int PROCESS_ENERGY = 900;
|
||||
public static final int PROCESS_LENGTH = 30;
|
||||
public static final int WATER_PER_TICK = 10;
|
||||
|
||||
public LumbermillLogic(final Machine machine) {
|
||||
super(machine, PROCESS_ENERGY, PROCESS_LENGTH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(LumbermillMachine.SLOT_LOG)) {
|
||||
return new ErrorState.NoItem("No Wood", LumbermillMachine.SLOT_LOG);
|
||||
}
|
||||
ItemStack logStack = this.getUtil().getStack(LumbermillMachine.SLOT_LOG);
|
||||
final ItemStack plankResult = LumbermillRecipes.getPlankProduct(logStack);
|
||||
if (!this.getUtil().isSlotEmpty(LumbermillMachine.SLOT_PLANKS) && plankResult != null) {
|
||||
final ItemStack currentPlank = this.getUtil().getStack(LumbermillMachine.SLOT_PLANKS);
|
||||
if (!plankResult.isItemEqual(currentPlank) || plankResult.stackSize + currentPlank.stackSize > currentPlank.getMaxStackSize()) {
|
||||
return new ErrorState.NoSpace("No room for new planks", new int[]{LumbermillMachine.SLOT_PLANKS});
|
||||
}
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!this.getUtil().liquidInTank(LumbermillMachine.TANK_WATER, 5)) {
|
||||
return new ErrorState.InsufficientLiquid("Not Enough Water", LumbermillMachine.TANK_WATER);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
final ItemStack logStack = this.getUtil().getStack(LumbermillMachine.SLOT_LOG);
|
||||
final ItemStack result = LumbermillRecipes.getPlankProduct(logStack);
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
this.getUtil().addStack(LumbermillMachine.SLOT_PLANKS, result);
|
||||
this.getUtil().addStack(LumbermillMachine.SLOT_SAWDUST, ExtraTrees.itemMisc.getStack(ExtraTreeItems.Sawdust, 1));
|
||||
this.getUtil().addStack(LumbermillMachine.SLOT_BARK, ExtraTrees.itemMisc.getStack(ExtraTreeItems.Bark, 1));
|
||||
this.getUtil().decreaseStack(LumbermillMachine.SLOT_LOG, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
this.getUtil().drainTank(LumbermillMachine.TANK_WATER, WATER_PER_TICK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package binnie.extratrees.machines.lumbermill;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.TankValidator;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.extratrees.core.ExtraTreeTexture;
|
||||
import binnie.extratrees.core.ExtraTreesGUID;
|
||||
import binnie.extratrees.machines.ExtraTreeMachine;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class LumbermillMachine extends ExtraTreeMachine.PackageExtraTreeMachine implements IMachineInformation {
|
||||
public static int SLOT_LOG = 0;
|
||||
public static int SLOT_PLANKS = 1;
|
||||
public static int SLOT_BARK = 2;
|
||||
public static int SLOT_SAWDUST = 3;
|
||||
public static int TANK_WATER = 0;
|
||||
public static int TANK_WATER_CAPACITY = 10000;
|
||||
|
||||
public LumbermillMachine() {
|
||||
super("lumbermill", ExtraTreeTexture.lumbermillTexture, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ExtraTreeMachine.ComponentExtraTreeGUI(machine, ExtraTreesGUID.Lumbermill);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(SLOT_LOG, "input");
|
||||
inventory.getSlot(SLOT_LOG).setValidator(new SlotValidatorLog());
|
||||
inventory.getSlot(SLOT_LOG).forbidExtraction();
|
||||
inventory.addSlot(SLOT_PLANKS, "output");
|
||||
inventory.addSlot(SLOT_BARK, "byproduct");
|
||||
inventory.addSlot(SLOT_SAWDUST, "byproduct");
|
||||
inventory.getSlot(SLOT_PLANKS).setReadOnly();
|
||||
inventory.getSlot(SLOT_BARK).setReadOnly();
|
||||
inventory.getSlot(SLOT_SAWDUST).setReadOnly();
|
||||
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(TANK_WATER, "input", TANK_WATER_CAPACITY);
|
||||
tanks.getTankSlot(TANK_WATER).setValidator(new TankValidator.Basic("water"));
|
||||
new ComponentPowerReceptor(machine);
|
||||
new LumbermillLogic(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package binnie.extratrees.machines.lumbermill;
|
||||
|
||||
import binnie.core.util.FakeCraftingWorld;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import forestry.api.arboriculture.IWoodType;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.arboriculture.WoodBlockKind;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class LumbermillRecipes {
|
||||
// Map<input log item, Pair<input log, output planks>>
|
||||
private static Multimap<Item, Pair<ItemStack, ItemStack>> recipes = ArrayListMultimap.create();
|
||||
|
||||
@Nullable
|
||||
public static ItemStack getPlankProduct(final ItemStack logStack) {
|
||||
if (recipes.isEmpty()) {
|
||||
calculateLumbermillProducts();
|
||||
}
|
||||
|
||||
Item logItem = logStack.getItem();
|
||||
for (final Pair<ItemStack, ItemStack> entry : recipes.get(logItem)) {
|
||||
if (entry.getKey().isItemEqual(logStack)) {
|
||||
return entry.getValue().copy();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Collection<Pair<ItemStack, ItemStack>> getRecipes() {
|
||||
if (recipes.isEmpty()) {
|
||||
calculateLumbermillProducts();
|
||||
}
|
||||
|
||||
return recipes.values();
|
||||
}
|
||||
|
||||
private static void calculateLumbermillProducts() {
|
||||
int plankOreId = OreDictionary.getOreID("plankWood");
|
||||
|
||||
CraftingManager craftingManager = CraftingManager.getInstance();
|
||||
InventoryCrafting fakeCraftingInventory = new InventoryCrafting(new FakeCraftingHandler(), 3, 3);
|
||||
|
||||
List<IWoodType> registeredWoodTypes = TreeManager.woodAccess.getRegisteredWoodTypes();
|
||||
for (IWoodType woodType : registeredWoodTypes) {
|
||||
ItemStack logStack = TreeManager.woodAccess.getStack(woodType, WoodBlockKind.LOG, false);
|
||||
ItemStack logCopy = logStack.copy();
|
||||
logCopy.stackSize = 1;
|
||||
|
||||
fakeCraftingInventory.clear();
|
||||
fakeCraftingInventory.setInventorySlotContents(0, logCopy);
|
||||
|
||||
try {
|
||||
ItemStack recipeOutput = craftingManager.findMatchingRecipe(fakeCraftingInventory, FakeCraftingWorld.getInstance());
|
||||
if (recipeOutput != null) {
|
||||
int[] outputOreIds = OreDictionary.getOreIDs(recipeOutput);
|
||||
if (contains(outputOreIds, plankOreId)) {
|
||||
Item logItem = logCopy.getItem();
|
||||
ItemStack outputCopy = recipeOutput.copy();
|
||||
outputCopy.stackSize = (int) Math.ceil(outputCopy.stackSize * 1.5f); // turns stack of 4 up to 6
|
||||
recipes.put(logItem, Pair.of(logCopy, outputCopy));
|
||||
}
|
||||
}
|
||||
} catch (RuntimeException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean contains(int[] array, int value) {
|
||||
for (int arrayValue : array) {
|
||||
if (arrayValue == value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class FakeCraftingHandler extends Container {
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory inventoryIn) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(@Nonnull EntityPlayer playerIn) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package binnie.extratrees.machines.lumbermill;
|
||||
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class SlotValidatorLog extends SlotValidator {
|
||||
private static final int logWoodId = OreDictionary.getOreID("logWood");
|
||||
|
||||
public SlotValidatorLog() {
|
||||
super(SlotValidator.IconBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
int[] oreIDs = OreDictionary.getOreIDs(itemStack);
|
||||
for (int oreId : oreIDs) {
|
||||
if (oreId == logWoodId && LumbermillRecipes.getPlankProduct(itemStack) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Logs";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user