mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-17 19:15:24 +00:00
Added and fix some localization
Some refactoring extratrees machines
This commit is contained in:
1 parent
99998bcfbd
commit
32028dc85e
40 files changed
+632
-601
No files matched your search
@@ -15,6 +15,6 @@ public class ItemPollen extends ItemBotany {
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return I18N.localise("botany.tube.item.pollen.tag.name");
|
||||
return I18N.localise("botany.item.pollen.tag.name");
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,6 @@ public class ItemSeed extends ItemBotany {
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return I18N.localise("botany.tube.item.germling.tag.name");
|
||||
return I18N.localise("botany.item.germling.tag.name");
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public class BlockPlant extends BlockBush {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return I18N.localise("botany.tube.plant." + name);
|
||||
return I18N.localise("botany.plant." + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,12 +37,12 @@ public class ItemSoil extends ItemBlock {
|
||||
|
||||
if (moisture == EnumMoisture.DRY) {
|
||||
info += EnumChatFormatting.YELLOW
|
||||
+ I18N.localise("botany.tube.moisture.dry")
|
||||
+ I18N.localise("botany.moisture.dry")
|
||||
+ EnumChatFormatting.RESET;
|
||||
}
|
||||
if (moisture == EnumMoisture.DAMP) {
|
||||
info += EnumChatFormatting.YELLOW
|
||||
+ I18N.localise("botany.tube.moisture.damp")
|
||||
+ I18N.localise("botany.moisture.damp")
|
||||
+ EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ItemSoil extends ItemBlock {
|
||||
info += ", ";
|
||||
}
|
||||
info += EnumChatFormatting.YELLOW
|
||||
+ I18N.localise("botany.tube.ph.acid")
|
||||
+ I18N.localise("botany.ph.acid")
|
||||
+ EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class ItemSoil extends ItemBlock {
|
||||
info += ", ";
|
||||
}
|
||||
info += EnumChatFormatting.YELLOW
|
||||
+ I18N.localise("botany.tube.ph.alkaline")
|
||||
+ I18N.localise("botany.ph.alkaline")
|
||||
+ EnumChatFormatting.RESET;
|
||||
}
|
||||
|
||||
@@ -69,14 +69,14 @@ public class ItemSoil extends ItemBlock {
|
||||
}
|
||||
|
||||
if (noWeed) {
|
||||
tooltip.add(I18N.localise("botany.tube.soil.weedkiller"));
|
||||
tooltip.add(I18N.localise("botany.soil.weedkiller"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
String soilName = type.name().toLowerCase(Locale.ENGLISH);
|
||||
return I18N.localise("botany.tube.soil." + soilName);
|
||||
return I18N.localise("botany.soil." + soilName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -79,6 +79,6 @@ public class ItemSoilMeter extends Item {
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
return I18N.localise("botany.tube.item.soilMeter.name");
|
||||
return I18N.localise("botany.item.soilMeter.name");
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class AlleleEffectNone implements IAlleleFlowerEffect {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return I18N.localise("botany.tube.allele.none");
|
||||
return I18N.localise("botany.allele.none");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -520,7 +520,7 @@ public enum FlowerSpecies implements IAlleleFlowerSpecies {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return I18N.localise("botany.tube.flower." + name);
|
||||
return I18N.localise("botany.flower." + name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ItemDictionary extends Item {
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
return (stack.getItemDamage() == 0)
|
||||
? I18N.localise("botany.tube.item.botanistDatabase.0.name")
|
||||
: I18N.localise("botany.tube.item.botanistDatabase.1.name");
|
||||
? I18N.localise("botany.item.botanistDatabase.0.name")
|
||||
: I18N.localise("botany.item.botanistDatabase.1.name");
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public enum BotanyItems implements IItemMisc {
|
||||
|
||||
@Override
|
||||
public String getName(ItemStack itemStack) {
|
||||
return I18N.localise("botany.tube.item." + name + ".name");
|
||||
return I18N.localise("botany.item." + name + ".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ItemClay extends Item {
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
return I18N.localise("botany.tube.item.clay.name");
|
||||
return I18N.localise("botany.item.clay.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ItemPigment extends Item {
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
return I18N.localise("botany.tube.item.pigment.name");
|
||||
return I18N.localise("botany.item.pigment.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,17 +39,17 @@ public class PageSpeciesOverview extends PageSpecies {
|
||||
controlInd2.setSpecies(species, EnumDiscoveryState.SHOW);
|
||||
String branchBinomial = (species.getBranch() != null)
|
||||
? species.getBranch().getScientific()
|
||||
: "<Unknown>";
|
||||
: I18N.localise("extratrees.genetics.unknown");
|
||||
|
||||
controlName.setValue(EnumChatFormatting.BOLD + species.getName() + EnumChatFormatting.RESET);
|
||||
controlScientific.setValue(EnumChatFormatting.ITALIC + branchBinomial + " " + species.getBinomial() + EnumChatFormatting.RESET);
|
||||
controlAuthority.setValue(EnumChatFormatting.BOLD + "Discovered by " + species.getAuthority() + EnumChatFormatting.RESET);
|
||||
controlComplexity.setValue("Complexity: " + species.getComplexity());
|
||||
controlAuthority.setValue(EnumChatFormatting.BOLD + I18N.localise("extratrees.genetics.discoveredBy", species.getAuthority()) + EnumChatFormatting.RESET);
|
||||
controlComplexity.setValue(I18N.localise("extratrees.genetics.complexity", species.getComplexity()));
|
||||
String desc = species.getDescription();
|
||||
String descBody = EnumChatFormatting.ITALIC.toString();
|
||||
String descSig = "";
|
||||
|
||||
if (desc.contains(".species.") || desc.contains("for.description.")) {
|
||||
if (desc == null || desc.isEmpty() || desc.contains("for.description.")) {
|
||||
descBody += I18N.localise("binniecore.gui.database.species.noDesc");
|
||||
} else {
|
||||
String[] descStrings = desc.split("\\|");
|
||||
|
||||
@@ -5,7 +5,7 @@ import binnie.core.util.I18N;
|
||||
import binnie.core.util.UniqueItemStackSet;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.FakeWorld;
|
||||
import binnie.extratrees.machines.Lumbermill;
|
||||
import binnie.extratrees.machines.lumbermill.Lumbermill;
|
||||
import binnie.genetics.genetics.AlleleHelper;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
|
||||
@@ -11,7 +11,7 @@ import binnie.core.craftgui.resource.Texture;
|
||||
import binnie.core.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.core.craftgui.window.Panel;
|
||||
import binnie.extratrees.core.ExtraTreeTexture;
|
||||
import binnie.extratrees.machines.Lumbermill;
|
||||
import binnie.extratrees.machines.lumbermill.Lumbermill;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -46,7 +46,7 @@ public class ControlLumbermillProgress extends ControlProgressBase {
|
||||
GL11.glDisable(2896);
|
||||
int sawX = (int) (63.0f * progress);
|
||||
CraftGUI.Render.texture(ControlLumbermillProgress.saw, new IPoint(sawX, -8.0f + 6.0f * (float) Math.sin(animation)));
|
||||
ItemStack item = Window.get(this).getInventory().getStackInSlot(Lumbermill.slotWood);
|
||||
ItemStack item = Window.get(this).getInventory().getStackInSlot(Lumbermill.SLOT_WOOD);
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import binnie.extratrees.api.CarpentryManager;
|
||||
import binnie.extratrees.api.IDesign;
|
||||
import binnie.extratrees.api.IDesignCategory;
|
||||
import binnie.extratrees.carpentry.EnumDesign;
|
||||
import binnie.extratrees.machines.Designer;
|
||||
import binnie.extratrees.machines.designer.WoodworkerRecipeComponent;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ControlTileSelect extends Control implements IControlValue<IDesign>
|
||||
return;
|
||||
}
|
||||
|
||||
Designer.ComponentWoodworkerRecipe recipe = tile.getMachine().getComponent(Designer.ComponentWoodworkerRecipe.class);
|
||||
WoodworkerRecipeComponent recipe = tile.getMachine().getComponent(WoodworkerRecipeComponent.class);
|
||||
setValue(recipe.getDesign());
|
||||
}
|
||||
|
||||
@@ -159,9 +159,9 @@ public class ControlTileSelect extends Control implements IControlValue<IDesign>
|
||||
}
|
||||
|
||||
if (Window.get(this).getMousedOverWidget() == this) {
|
||||
CraftGUI.Render.gradientRect(getArea().inset(1), 1157627903, 1157627903);
|
||||
CraftGUI.Render.gradientRect(getArea().inset(1), 0x44ffffff, 0x44ffffff);
|
||||
} else {
|
||||
CraftGUI.Render.gradientRect(getArea().inset(1), -1433892728, -1433892728);
|
||||
CraftGUI.Render.gradientRect(getArea().inset(1), 0xaa888888, 0xaa888888);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ public class ControlTileSelect extends Control implements IControlValue<IDesign>
|
||||
return;
|
||||
}
|
||||
|
||||
tile.getMachine().getComponent(Designer.ComponentWoodworkerRecipe.class);
|
||||
tile.getMachine().getComponent(WoodworkerRecipeComponent.class);
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setShort("d", (short) CarpentryManager.carpentryInterface.getDesignIndex(getValue()));
|
||||
Window.get(getWidget()).sendClientAction("design", nbt);
|
||||
|
||||
@@ -10,7 +10,7 @@ import binnie.core.craftgui.minecraft.control.ControlPlayerInventory;
|
||||
import binnie.core.craftgui.minecraft.control.ControlSlot;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.machines.Lumbermill;
|
||||
import binnie.extratrees.machines.lumbermill.Lumbermill;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -37,10 +37,10 @@ public class WindowLumbermill extends Window {
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
setTitle(Machine.getMachine(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(Lumbermill.SLOT_WOOD);
|
||||
new ControlSlot(this, 148.0f, 43.0f).assign(Lumbermill.SLOT_PLANKS);
|
||||
new ControlSlot(this, 172.0f, 28.0f).assign(Lumbermill.SLOT_BARK);
|
||||
new ControlSlot(this, 172.0f, 58.0f).assign(Lumbermill.SLOT_SAWDUST);
|
||||
new ControlLumbermillProgress(this, 70.0f, 43.0f);
|
||||
new ControlLiquidTank(this, 16, 32);
|
||||
new ControlEnergyBar(this, 8, 112, 16, 60, Position.BOTTOM);
|
||||
|
||||
@@ -18,8 +18,9 @@ import binnie.core.craftgui.window.Panel;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.machines.Designer;
|
||||
import binnie.extratrees.machines.DesignerType;
|
||||
import binnie.extratrees.machines.designer.Designer;
|
||||
import binnie.extratrees.machines.designer.DesignerType;
|
||||
import binnie.extratrees.machines.designer.WoodworkerRecipeComponent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -55,11 +56,11 @@ public class WindowWoodworker extends Window {
|
||||
|
||||
if (getInventory() != null) {
|
||||
ControlSlot slotWood1 = new ControlSlot(this, 22.0f, 34.0f);
|
||||
slotWood1.assign(Designer.design1Slot);
|
||||
slotWood1.assign(Designer.DESIGN_1_SLOT);
|
||||
ControlSlot slotWood2 = new ControlSlot(this, 62.0f, 34.0f);
|
||||
slotWood2.assign(Designer.design2Slot);
|
||||
slotWood2.assign(Designer.DESIGN_2_SLOT);
|
||||
ControlSlot slotBeeswax = new ControlSlot(this, 42.0f, 64.0f);
|
||||
slotBeeswax.assign(Designer.beeswaxSlot);
|
||||
slotBeeswax.assign(Designer.GLUE_SLOT);
|
||||
new ControlRecipeSlot(this, 112, 34);
|
||||
}
|
||||
}
|
||||
@@ -75,6 +76,6 @@ public class WindowWoodworker extends Window {
|
||||
}
|
||||
|
||||
public DesignerType getDesignerType() {
|
||||
return Machine.getInterface(Designer.ComponentWoodworkerRecipe.class, getInventory()).getDesignerType();
|
||||
return Machine.getInterface(WoodworkerRecipeComponent.class, getInventory()).getDesignerType();
|
||||
}
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
package binnie.extratrees.machines;
|
||||
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.component.ComponentRecipe;
|
||||
import binnie.core.machines.component.IComponentRecipe;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IErrorStateSource;
|
||||
import binnie.extratrees.api.CarpentryManager;
|
||||
import binnie.extratrees.api.IDesign;
|
||||
import binnie.extratrees.api.IDesignMaterial;
|
||||
import binnie.extratrees.carpentry.EnumDesign;
|
||||
import binnie.extratrees.core.ExtraTreesGUID;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class Designer {
|
||||
public static int beeswaxSlot = 0;
|
||||
public static int design1Slot = 1;
|
||||
public static int design2Slot = 2;
|
||||
|
||||
public static class PackageWoodworker extends PackageCarpenter {
|
||||
public PackageWoodworker() {
|
||||
super(DesignerType.Woodworker);
|
||||
}
|
||||
}
|
||||
|
||||
public static class PackagePanelworker extends PackageCarpenter {
|
||||
public PackagePanelworker() {
|
||||
super(DesignerType.Panelworker);
|
||||
}
|
||||
}
|
||||
|
||||
public static class PackageGlassworker extends PackageCarpenter {
|
||||
public PackageGlassworker() {
|
||||
super(DesignerType.GlassWorker);
|
||||
}
|
||||
}
|
||||
|
||||
public static class PackageTileworker extends PackageCarpenter {
|
||||
public PackageTileworker() {
|
||||
super(DesignerType.Tileworker);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class PackageCarpenter extends ExtraTreeMachine.PackageExtraTreeMachine implements IMachineInformation {
|
||||
DesignerType type;
|
||||
|
||||
public PackageCarpenter(DesignerType type) {
|
||||
super(type.name, type.texture, false);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ExtraTreeMachine.ComponentExtraTreeGUI(machine, ExtraTreesGUID.Woodworker);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(Designer.beeswaxSlot, "polish");
|
||||
inventory.addSlot(Designer.design1Slot, "wood");
|
||||
inventory.addSlot(Designer.design2Slot, "wood");
|
||||
inventory.getSlot(Designer.beeswaxSlot).setValidator(new Validators.SlotValidatorBeeswax(type));
|
||||
inventory.getSlot(Designer.design1Slot).setValidator(new Validators.SlotValidatorPlanks(type));
|
||||
inventory.getSlot(Designer.design2Slot).setValidator(new Validators.SlotValidatorPlanks(type));
|
||||
new ComponentWoodworkerRecipe(machine, type);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentWoodworkerRecipe extends ComponentRecipe implements
|
||||
IComponentRecipe,
|
||||
INetwork.GuiNBT,
|
||||
IErrorStateSource {
|
||||
public DesignerType type;
|
||||
|
||||
private IDesign design;
|
||||
|
||||
public ComponentWoodworkerRecipe(Machine machine, DesignerType type) {
|
||||
super(machine);
|
||||
design = EnumDesign.Diamond;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
setDesign(CarpentryManager.carpentryInterface.getDesign(nbttagcompound.getInteger("design")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
nbttagcompound.setInteger("design", CarpentryManager.carpentryInterface.getDesignIndex(design));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipe() {
|
||||
return getProduct() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getProduct() {
|
||||
ItemStack plank1 = getUtil().getStack(Designer.design1Slot);
|
||||
ItemStack plank2 = getUtil().getStack(Designer.design2Slot);
|
||||
if (plank1 == null || plank2 == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IDesignMaterial type1 = type.getSystem().getMaterial(plank1);
|
||||
IDesignMaterial type2 = type.getSystem().getMaterial(plank2);
|
||||
IDesign design = getDesign();
|
||||
ItemStack stack = type.getBlock(type1, type2, design);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack doRecipe(boolean takeItem) {
|
||||
if (!isRecipe() || canWork() != null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack product = getProduct();
|
||||
if (takeItem) {
|
||||
ItemStack a = getUtil().decreaseStack(Designer.design1Slot, 1);
|
||||
if (a == null) {
|
||||
getUtil().decreaseStack(Designer.design2Slot, 1);
|
||||
} else if (design != EnumDesign.Blank) {
|
||||
getUtil().decreaseStack(Designer.design2Slot, 1);
|
||||
}
|
||||
getUtil().decreaseStack(Designer.beeswaxSlot, 1);
|
||||
}
|
||||
return product;
|
||||
}
|
||||
|
||||
public IDesign getDesign() {
|
||||
return design;
|
||||
}
|
||||
|
||||
private void setDesign(IDesign design) {
|
||||
this.design = design;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
|
||||
if (name.equals("recipe")) {
|
||||
InventoryPlayer playerInv = player.inventory;
|
||||
ItemStack recipe = doRecipe(false);
|
||||
if (recipe == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerInv.getItemStack() == null) {
|
||||
playerInv.setItemStack(doRecipe(true));
|
||||
} else if (playerInv.getItemStack().isItemEqual(recipe) && ItemStack.areItemStackTagsEqual(playerInv.getItemStack(), recipe)) {
|
||||
int fit = recipe.getMaxStackSize() - (recipe.stackSize + playerInv.getItemStack().stackSize);
|
||||
if (fit >= 0) {
|
||||
ItemStack doRecipe;
|
||||
ItemStack rec = doRecipe = doRecipe(true);
|
||||
doRecipe.stackSize += playerInv.getItemStack().stackSize;
|
||||
playerInv.setItemStack(rec);
|
||||
}
|
||||
}
|
||||
|
||||
player.openContainer.detectAndSendChanges();
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) player).updateHeldItem();
|
||||
}
|
||||
} else if (name.equals("design")) {
|
||||
setDesign(CarpentryManager.carpentryInterface.getDesign(nbt.getShort("d")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(Designer.beeswaxSlot)) {
|
||||
return new ErrorState.NoItem("Requires Adhesive to Function", Designer.beeswaxSlot);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendGuiNBT(Map<String, NBTTagCompound> nbts) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setShort("d", (short) CarpentryManager.carpentryInterface.getDesignIndex(getDesign()));
|
||||
nbts.put("design", tag);
|
||||
}
|
||||
|
||||
public DesignerType getDesignerType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,11 @@ import binnie.core.resource.BinnieResource;
|
||||
import binnie.core.resource.ResourceType;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.core.ExtraTreesGUID;
|
||||
import binnie.extratrees.machines.designer.GlassworkerPackage;
|
||||
import binnie.extratrees.machines.designer.PanelworkerPackage;
|
||||
import binnie.extratrees.machines.designer.TileworkerPackage;
|
||||
import binnie.extratrees.machines.designer.WoodworkerPackage;
|
||||
import binnie.extratrees.machines.lumbermill.LumbermillPackage;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -19,15 +24,15 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public enum ExtraTreeMachine implements IMachineType {
|
||||
Lumbermill(Lumbermill.PackageLumbermill.class),
|
||||
Woodworker(Designer.PackageWoodworker.class),
|
||||
Panelworker(Designer.PackagePanelworker.class),
|
||||
Lumbermill(LumbermillPackage.class),
|
||||
Woodworker(WoodworkerPackage.class),
|
||||
Panelworker(PanelworkerPackage.class),
|
||||
Nursery(Nursery.PackageNursery.class),
|
||||
Press(Press.PackagePress.class),
|
||||
Brewery(Brewery.PackageBrewery.class),
|
||||
Distillery(Distillery.PackageDistillery.class),
|
||||
Glassworker(Designer.PackageGlassworker.class),
|
||||
Tileworker(Designer.PackageTileworker.class);
|
||||
Glassworker(GlassworkerPackage.class),
|
||||
Tileworker(TileworkerPackage.class);
|
||||
|
||||
protected Class<? extends MachinePackage> cls;
|
||||
|
||||
|
||||
@@ -1,205 +0,0 @@
|
||||
package binnie.extratrees.machines;
|
||||
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
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.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(ItemStack item) {
|
||||
ItemStack stack = null;
|
||||
if (Lumbermill.recipes.isEmpty()) {
|
||||
calculateLumbermillProducts();
|
||||
}
|
||||
|
||||
for (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 (IPlankType type : WoodManager.getAllPlankTypes()) {
|
||||
for (ItemStack wood : getRecipeResult(type.getStack())) {
|
||||
Lumbermill.recipes.put(wood, type.getStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Collection<ItemStack> getRecipeResult(ItemStack output) {
|
||||
List<ItemStack> list = new ArrayList<ItemStack>();
|
||||
for (Object recipeO : CraftingManager.getInstance().getRecipeList()) {
|
||||
if (recipeO instanceof ShapelessRecipes) {
|
||||
ShapelessRecipes recipe = (ShapelessRecipes) recipeO;
|
||||
if (recipe.recipeItems.size() != 1 || !(recipe.recipeItems.get(0) instanceof ItemStack)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack input = (ItemStack) recipe.recipeItems.get(0);
|
||||
if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().isItemEqual(output)) {
|
||||
list.add(input);
|
||||
}
|
||||
}
|
||||
|
||||
if (recipeO instanceof ShapedRecipes) {
|
||||
ShapedRecipes recipe2 = (ShapedRecipes) recipeO;
|
||||
if (recipe2.recipeItems.length != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack input = recipe2.recipeItems[0];
|
||||
if (recipe2.getRecipeOutput() != null && recipe2.getRecipeOutput().isItemEqual(output)) {
|
||||
list.add(input);
|
||||
}
|
||||
}
|
||||
|
||||
if (recipeO instanceof ShapelessOreRecipe) {
|
||||
ShapelessOreRecipe recipe3 = (ShapelessOreRecipe) recipeO;
|
||||
if (recipe3.getInput().size() != 1 || !(recipe3.getInput().get(0) instanceof ItemStack)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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(Machine machine) {
|
||||
new ExtraTreeMachine.ComponentExtraTreeGUI(machine, ExtraTreesGUID.Lumbermill);
|
||||
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();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentLumbermillLogic extends ComponentProcessSetCost implements IProcess {
|
||||
public ComponentLumbermillLogic(Machine machine) {
|
||||
super(machine, 900, 30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(Lumbermill.slotWood)) {
|
||||
return new ErrorState.NoItem("No Wood", Lumbermill.slotWood);
|
||||
}
|
||||
|
||||
ItemStack result = Lumbermill.getPlankProduct(getUtil().getStack(Lumbermill.slotWood));
|
||||
if (!getUtil().isSlotEmpty(Lumbermill.slotPlanks) && result != null) {
|
||||
ItemStack currentPlank = getUtil().getStack(Lumbermill.slotPlanks);
|
||||
if (!result.isItemEqual(currentPlank) || result.stackSize + currentPlank.stackSize > currentPlank.getMaxStackSize()) {
|
||||
return new ErrorState.NoSpace("No room for new planks", Lumbermill.slotPlanks);
|
||||
}
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!getUtil().liquidInTank(Lumbermill.tankWater, 5)) {
|
||||
return new ErrorState.InsufficientLiquid("Not Enough Water", Lumbermill.tankWater);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
ItemStack result = Lumbermill.getPlankProduct(getUtil().getStack(Lumbermill.slotWood));
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
getUtil().addStack(Lumbermill.slotPlanks, result);
|
||||
getUtil().addStack(Lumbermill.slotSawdust, ((ItemMisc) ExtraTrees.itemMisc).getStack(ExtraTreeItems.Sawdust, 1));
|
||||
getUtil().addStack(Lumbermill.slotBark, ((ItemMisc) ExtraTrees.itemMisc).getStack(ExtraTreeItems.Bark, 1));
|
||||
getUtil().decreaseStack(Lumbermill.slotWood, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
getUtil().drainTank(Lumbermill.tankWater, 10);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotValidatorLog extends SlotValidator {
|
||||
public SlotValidatorLog() {
|
||||
super(SlotValidator.IconBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
String name = OreDictionary.getOreName(OreDictionary.getOreID(itemStack));
|
||||
return name.contains("logWood") && Lumbermill.getPlankProduct(itemStack) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Logs";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package binnie.extratrees.machines;
|
||||
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.inventory.ValidatorIcon;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.api.IDesignMaterial;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class Validators {
|
||||
public static class SlotValidatorBeeswax extends SlotValidator {
|
||||
protected DesignerType type;
|
||||
|
||||
public SlotValidatorBeeswax(DesignerType type) {
|
||||
super(new ValidatorIcon(ExtraTrees.instance, "validator/polish.0", "validator/polish.1"));
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
return type.getSystem().getAdhesive().isItemEqual(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return type.getSystem().getAdhesive().getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotValidatorPlanks extends SlotValidator {
|
||||
protected DesignerType type;
|
||||
|
||||
public SlotValidatorPlanks(DesignerType type) {
|
||||
super(SlotValidator.IconBlock);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
IDesignMaterial mat = type.getSystem().getMaterial(itemStack);
|
||||
return itemStack != null && mat != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return type.getMaterialTooltip();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package binnie.extratrees.machines.designer;
|
||||
|
||||
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.extratrees.core.ExtraTreesGUID;
|
||||
import binnie.extratrees.machines.ExtraTreeMachine;
|
||||
|
||||
public abstract class CarpenterPackage extends ExtraTreeMachine.PackageExtraTreeMachine implements IMachineInformation {
|
||||
private DesignerType type;
|
||||
|
||||
public CarpenterPackage(DesignerType type) {
|
||||
super(type.name, type.texture, false);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ExtraTreeMachine.ComponentExtraTreeGUI(machine, ExtraTreesGUID.Woodworker);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
|
||||
inventory.addSlot(Designer.GLUE_SLOT, "polish")
|
||||
.setValidator(new PolishSlotValidator(type));
|
||||
|
||||
inventory.addSlot(Designer.DESIGN_1_SLOT, "wood")
|
||||
.setValidator(new PlanksSlotValidator(type));
|
||||
|
||||
inventory.addSlot(Designer.DESIGN_2_SLOT, "wood")
|
||||
.setValidator(new PlanksSlotValidator(type));
|
||||
|
||||
new WoodworkerRecipeComponent(machine, type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package binnie.extratrees.machines.designer;
|
||||
|
||||
public abstract class Designer {
|
||||
public static final int GLUE_SLOT = 0;
|
||||
public static final int DESIGN_1_SLOT = 1;
|
||||
public static final int DESIGN_2_SLOT = 2;
|
||||
}
|
||||
+23
-20
@@ -1,7 +1,8 @@
|
||||
package binnie.extratrees.machines;
|
||||
package binnie.extratrees.machines.designer;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.ceramic.CeramicDesignSystem;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.api.IDesign;
|
||||
import binnie.extratrees.api.IDesignMaterial;
|
||||
@@ -13,26 +14,28 @@ import binnie.extratrees.carpentry.ModuleCarpentry;
|
||||
import binnie.extratrees.core.ExtraTreeTexture;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum DesignerType {
|
||||
Woodworker("woodworker", ExtraTreeTexture.carpenterTexture),
|
||||
Panelworker("panelworker", ExtraTreeTexture.panelerTexture),
|
||||
GlassWorker("glassworker", ExtraTreeTexture.panelerTexture),
|
||||
Tileworker("tileworker", ExtraTreeTexture.tileworkerTexture);
|
||||
WOODWORKER(ExtraTreeTexture.carpenterTexture),
|
||||
PANELWORKER(ExtraTreeTexture.panelerTexture),
|
||||
GLASSWORKER(ExtraTreeTexture.panelerTexture),
|
||||
TILEWORKER(ExtraTreeTexture.tileworkerTexture);
|
||||
|
||||
public String name;
|
||||
public String texture;
|
||||
|
||||
DesignerType(String name, String texture) {
|
||||
this.name = name;
|
||||
DesignerType(String texture) {
|
||||
this.name = name().toLowerCase(Locale.ENGLISH);
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
public IDesignSystem getSystem() {
|
||||
switch (this) {
|
||||
case GlassWorker: {
|
||||
case GLASSWORKER: {
|
||||
return DesignSystem.Glass;
|
||||
}
|
||||
case Tileworker: {
|
||||
case TILEWORKER: {
|
||||
return CeramicDesignSystem.instance;
|
||||
}
|
||||
default: {
|
||||
@@ -55,13 +58,13 @@ public enum DesignerType {
|
||||
|
||||
private BlockDesign getBlock() {
|
||||
switch (this) {
|
||||
case GlassWorker:
|
||||
case GLASSWORKER:
|
||||
return ExtraTrees.blockStained;
|
||||
|
||||
case Panelworker:
|
||||
case PANELWORKER:
|
||||
return ExtraTrees.blockPanel;
|
||||
|
||||
case Tileworker:
|
||||
case TILEWORKER:
|
||||
return Botany.ceramicTile;
|
||||
}
|
||||
return ExtraTrees.blockCarpentry;
|
||||
@@ -73,17 +76,17 @@ public enum DesignerType {
|
||||
|
||||
public String getMaterialTooltip() {
|
||||
switch (this) {
|
||||
case GlassWorker:
|
||||
return "Glass";
|
||||
case GLASSWORKER:
|
||||
return I18N.localise("extratrees.machine.glassworker.material");
|
||||
|
||||
case Panelworker:
|
||||
return "Wooden Plank";
|
||||
case PANELWORKER:
|
||||
return I18N.localise("extratrees.machine.panelworker.material");
|
||||
|
||||
case Tileworker:
|
||||
return "Ceramic Block";
|
||||
case TILEWORKER:
|
||||
return I18N.localise("extratrees.machine.tileworker.material");
|
||||
|
||||
case Woodworker:
|
||||
return "Wooden Plank";
|
||||
case WOODWORKER:
|
||||
return I18N.localise("extratrees.machine.woodworker.material");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package binnie.extratrees.machines.designer;
|
||||
|
||||
public class GlassworkerPackage extends CarpenterPackage {
|
||||
public GlassworkerPackage() {
|
||||
super(DesignerType.GLASSWORKER);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package binnie.extratrees.machines.designer;
|
||||
|
||||
public class PanelworkerPackage extends CarpenterPackage {
|
||||
public PanelworkerPackage() {
|
||||
super(DesignerType.PANELWORKER);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package binnie.extratrees.machines.designer;
|
||||
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.extratrees.api.IDesignMaterial;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class PlanksSlotValidator extends SlotValidator {
|
||||
protected DesignerType type;
|
||||
|
||||
public PlanksSlotValidator(DesignerType type) {
|
||||
super(SlotValidator.IconBlock);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
IDesignMaterial mat = type.getSystem().getMaterial(itemStack);
|
||||
return itemStack != null && mat != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return type.getMaterialTooltip();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package binnie.extratrees.machines.designer;
|
||||
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.machines.inventory.ValidatorIcon;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class PolishSlotValidator extends SlotValidator {
|
||||
protected DesignerType type;
|
||||
|
||||
public PolishSlotValidator(DesignerType type) {
|
||||
super(new ValidatorIcon(ExtraTrees.instance, "validator/polish.0", "validator/polish.1"));
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
return type.getSystem().getAdhesive().isItemEqual(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return type.getSystem().getAdhesive().getDisplayName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package binnie.extratrees.machines.designer;
|
||||
|
||||
public class TileworkerPackage extends CarpenterPackage {
|
||||
public TileworkerPackage() {
|
||||
super(DesignerType.TILEWORKER);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package binnie.extratrees.machines.designer;
|
||||
|
||||
public class WoodworkerPackage extends CarpenterPackage {
|
||||
public WoodworkerPackage() {
|
||||
super(DesignerType.WOODWORKER);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package binnie.extratrees.machines.designer;
|
||||
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.component.ComponentRecipe;
|
||||
import binnie.core.machines.component.IComponentRecipe;
|
||||
import binnie.core.machines.network.INetwork;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IErrorStateSource;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.extratrees.api.CarpentryManager;
|
||||
import binnie.extratrees.api.IDesign;
|
||||
import binnie.extratrees.api.IDesignMaterial;
|
||||
import binnie.extratrees.carpentry.EnumDesign;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class WoodworkerRecipeComponent extends ComponentRecipe implements
|
||||
IComponentRecipe,
|
||||
INetwork.GuiNBT,
|
||||
IErrorStateSource {
|
||||
public DesignerType type;
|
||||
|
||||
private IDesign design;
|
||||
|
||||
public WoodworkerRecipeComponent(Machine machine, DesignerType type) {
|
||||
super(machine);
|
||||
design = EnumDesign.Diamond;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
setDesign(CarpentryManager.carpentryInterface.getDesign(nbttagcompound.getInteger("design")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
nbttagcompound.setInteger("design", CarpentryManager.carpentryInterface.getDesignIndex(design));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipe() {
|
||||
return getProduct() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getProduct() {
|
||||
ItemStack plank1 = getUtil().getStack(Designer.DESIGN_1_SLOT);
|
||||
ItemStack plank2 = getUtil().getStack(Designer.DESIGN_2_SLOT);
|
||||
if (plank1 == null || plank2 == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IDesignMaterial type1 = type.getSystem().getMaterial(plank1);
|
||||
IDesignMaterial type2 = type.getSystem().getMaterial(plank2);
|
||||
IDesign design = getDesign();
|
||||
ItemStack stack = type.getBlock(type1, type2, design);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack doRecipe(boolean takeItem) {
|
||||
if (!isRecipe() || canWork() != null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack product = getProduct();
|
||||
if (takeItem) {
|
||||
ItemStack a = getUtil().decreaseStack(Designer.DESIGN_1_SLOT, 1);
|
||||
if (a == null) {
|
||||
getUtil().decreaseStack(Designer.DESIGN_2_SLOT, 1);
|
||||
} else if (design != EnumDesign.Blank) {
|
||||
getUtil().decreaseStack(Designer.DESIGN_2_SLOT, 1);
|
||||
}
|
||||
getUtil().decreaseStack(Designer.GLUE_SLOT, 1);
|
||||
}
|
||||
return product;
|
||||
}
|
||||
|
||||
public IDesign getDesign() {
|
||||
return design;
|
||||
}
|
||||
|
||||
private void setDesign(IDesign design) {
|
||||
this.design = design;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recieveGuiNBT(Side side, EntityPlayer player, String name, NBTTagCompound nbt) {
|
||||
if (name.equals("recipe")) {
|
||||
InventoryPlayer playerInv = player.inventory;
|
||||
ItemStack recipe = doRecipe(false);
|
||||
if (recipe == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerInv.getItemStack() == null) {
|
||||
playerInv.setItemStack(doRecipe(true));
|
||||
} else if (playerInv.getItemStack().isItemEqual(recipe) && ItemStack.areItemStackTagsEqual(playerInv.getItemStack(), recipe)) {
|
||||
int fit = recipe.getMaxStackSize() - (recipe.stackSize + playerInv.getItemStack().stackSize);
|
||||
if (fit >= 0) {
|
||||
ItemStack doRecipe;
|
||||
ItemStack rec = doRecipe = doRecipe(true);
|
||||
doRecipe.stackSize += playerInv.getItemStack().stackSize;
|
||||
playerInv.setItemStack(rec);
|
||||
}
|
||||
}
|
||||
|
||||
player.openContainer.detectAndSendChanges();
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) player).updateHeldItem();
|
||||
}
|
||||
} else if (name.equals("design")) {
|
||||
setDesign(CarpentryManager.carpentryInterface.getDesign(nbt.getShort("d")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(Designer.GLUE_SLOT)) {
|
||||
return new ErrorState.NoItem(I18N.localise("extratrees.machine.worker.error.glueRequired"), Designer.GLUE_SLOT);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendGuiNBT(Map<String, NBTTagCompound> nbts) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setShort("d", (short) CarpentryManager.carpentryInterface.getDesignIndex(getDesign()));
|
||||
nbts.put("design", tag);
|
||||
}
|
||||
|
||||
public DesignerType getDesignerType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package binnie.extratrees.machines.lumbermill;
|
||||
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.util.I18N;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class LogSlotValidator extends SlotValidator {
|
||||
public LogSlotValidator() {
|
||||
super(SlotValidator.IconBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack itemStack) {
|
||||
String name = OreDictionary.getOreName(OreDictionary.getOreID(itemStack));
|
||||
return name.contains("logWood") && Lumbermill.getPlankProduct(itemStack) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return I18N.localise("extratrees.machine.lumbermill.logs");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package binnie.extratrees.machines.lumbermill;
|
||||
|
||||
import binnie.extratrees.block.IPlankType;
|
||||
import binnie.extratrees.block.WoodManager;
|
||||
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.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 final int SLOT_WOOD = 0;
|
||||
public static final int SLOT_PLANKS = 1;
|
||||
public static final int SLOT_BARK = 2;
|
||||
public static final int SLOT_SAWDUST = 3;
|
||||
public static final int TANK_WATER = 0;
|
||||
public static final int RF_COST = 900;
|
||||
public static final int TIME_PERIOD = 30;
|
||||
public static final int WATER_PER_TICK = 10;
|
||||
|
||||
public static Map<ItemStack, ItemStack> recipes = new HashMap<>();
|
||||
|
||||
public static ItemStack getPlankProduct(ItemStack item) {
|
||||
ItemStack stack = null;
|
||||
if (Lumbermill.recipes.isEmpty()) {
|
||||
calculateLumbermillProducts();
|
||||
}
|
||||
|
||||
for (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 (IPlankType type : WoodManager.getAllPlankTypes()) {
|
||||
for (ItemStack wood : getRecipeResult(type.getStack())) {
|
||||
Lumbermill.recipes.put(wood, type.getStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Collection<ItemStack> getRecipeResult(ItemStack output) {
|
||||
List<ItemStack> list = new ArrayList<>();
|
||||
for (Object recipeO : CraftingManager.getInstance().getRecipeList()) {
|
||||
if (recipeO instanceof ShapelessRecipes) {
|
||||
ShapelessRecipes recipe = (ShapelessRecipes) recipeO;
|
||||
if (recipe.recipeItems.size() != 1 || !(recipe.recipeItems.get(0) instanceof ItemStack)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack input = (ItemStack) recipe.recipeItems.get(0);
|
||||
if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().isItemEqual(output)) {
|
||||
list.add(input);
|
||||
}
|
||||
}
|
||||
|
||||
if (recipeO instanceof ShapedRecipes) {
|
||||
ShapedRecipes recipe2 = (ShapedRecipes) recipeO;
|
||||
if (recipe2.recipeItems.length != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack input = recipe2.recipeItems[0];
|
||||
if (recipe2.getRecipeOutput() != null && recipe2.getRecipeOutput().isItemEqual(output)) {
|
||||
list.add(input);
|
||||
}
|
||||
}
|
||||
|
||||
if (recipeO instanceof ShapelessOreRecipe) {
|
||||
ShapelessOreRecipe recipe3 = (ShapelessOreRecipe) recipeO;
|
||||
if (recipe3.getInput().size() != 1 || !(recipe3.getInput().get(0) instanceof ItemStack)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack input = (ItemStack) recipe3.getInput().get(0);
|
||||
if (recipe3.getRecipeOutput() == null || !recipe3.getRecipeOutput().isItemEqual(output)) {
|
||||
continue;
|
||||
}
|
||||
list.add(input);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package binnie.extratrees.machines.lumbermill;
|
||||
|
||||
import binnie.core.item.ItemMisc;
|
||||
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.core.util.I18N;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.item.ExtraTreeItems;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class LumbermillComponentLogic extends ComponentProcessSetCost implements IProcess {
|
||||
public LumbermillComponentLogic(Machine machine) {
|
||||
super(machine, Lumbermill.RF_COST, Lumbermill.TIME_PERIOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (getUtil().isSlotEmpty(Lumbermill.SLOT_WOOD)) {
|
||||
return new ErrorState.NoItem(
|
||||
I18N.localise("extratrees.machine.lumbermill.error.noWood"),
|
||||
Lumbermill.SLOT_WOOD
|
||||
);
|
||||
}
|
||||
|
||||
ItemStack result = Lumbermill.getPlankProduct(getUtil().getStack(Lumbermill.SLOT_WOOD));
|
||||
if (!getUtil().isSlotEmpty(Lumbermill.SLOT_PLANKS) && result != null) {
|
||||
ItemStack currentPlank = getUtil().getStack(Lumbermill.SLOT_PLANKS);
|
||||
if (!result.isItemEqual(currentPlank) || result.stackSize + currentPlank.stackSize > currentPlank.getMaxStackSize()) {
|
||||
return new ErrorState.NoSpace(
|
||||
I18N.localise("extratrees.machine.lumbermill.error.noRoom"),
|
||||
Lumbermill.SLOT_PLANKS
|
||||
);
|
||||
}
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!getUtil().liquidInTank(Lumbermill.TANK_WATER, 5)) {
|
||||
return new ErrorState.InsufficientLiquid(
|
||||
I18N.localise("extratrees.machine.lumbermill.error.noWater"),
|
||||
Lumbermill.TANK_WATER
|
||||
);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
ItemStack result = Lumbermill.getPlankProduct(getUtil().getStack(Lumbermill.SLOT_WOOD));
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
getUtil().addStack(Lumbermill.SLOT_PLANKS, result);
|
||||
getUtil().addStack(Lumbermill.SLOT_SAWDUST, ((ItemMisc) ExtraTrees.itemMisc).getStack(ExtraTreeItems.Sawdust, 1));
|
||||
getUtil().addStack(Lumbermill.SLOT_BARK, ((ItemMisc) ExtraTrees.itemMisc).getStack(ExtraTreeItems.Bark, 1));
|
||||
getUtil().decreaseStack(Lumbermill.SLOT_WOOD, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
getUtil().drainTank(Lumbermill.TANK_WATER, Lumbermill.WATER_PER_TICK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package binnie.extratrees.machines.lumbermill;
|
||||
|
||||
import binnie.core.craftgui.minecraft.IMachineInformation;
|
||||
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.InventorySlot;
|
||||
import binnie.core.machines.inventory.TankSlot;
|
||||
import binnie.core.machines.inventory.TankValidator;
|
||||
import binnie.core.machines.power.ComponentPowerReceptor;
|
||||
import binnie.extratrees.core.ExtraTreeTexture;
|
||||
import binnie.extratrees.core.ExtraTreesGUID;
|
||||
import binnie.extratrees.machines.ExtraTreeMachine;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class LumbermillPackage extends ExtraTreeMachine.PackageExtraTreeMachine implements IMachineInformation {
|
||||
public LumbermillPackage() {
|
||||
super("lumbermill", ExtraTreeTexture.lumbermillTexture, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(Machine machine) {
|
||||
new ExtraTreeMachine.ComponentExtraTreeGUI(machine, ExtraTreesGUID.Lumbermill);
|
||||
ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
|
||||
InventorySlot woodSlot = inventory.addSlot(Lumbermill.SLOT_WOOD, "input");
|
||||
woodSlot.setValidator(new LogSlotValidator());
|
||||
woodSlot.forbidExtraction();
|
||||
|
||||
InventorySlot planksSlot = inventory.addSlot(Lumbermill.SLOT_PLANKS, "output");
|
||||
planksSlot.setReadOnly();
|
||||
|
||||
InventorySlot barkSlot = inventory.addSlot(Lumbermill.SLOT_BARK, "byproduct");
|
||||
barkSlot.setReadOnly();
|
||||
|
||||
InventorySlot sawdustSlot = inventory.addSlot(Lumbermill.SLOT_SAWDUST, "byproduct");
|
||||
sawdustSlot.setReadOnly();
|
||||
|
||||
ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
TankSlot tankSlot = tanks.addTank(Lumbermill.TANK_WATER, "input", 10000);
|
||||
tankSlot.setValidator(new TankValidator.Basic("water"));
|
||||
|
||||
new ComponentPowerReceptor(machine);
|
||||
new LumbermillComponentLogic(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user