mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
the ferocious crafter
This commit is contained in:
parent
0535d3c49f
commit
943e243573
@ -33,6 +33,7 @@ public class GUIHandler implements IGuiHandler {
|
||||
if(entity instanceof TileEntityCrateSteel) { return new ContainerCrateSteel(player.inventory, (TileEntityCrateSteel) entity); }
|
||||
if(entity instanceof TileEntityCrateDesh) { return new ContainerCrateDesh(player.inventory, (TileEntityCrateDesh) entity); }
|
||||
if(entity instanceof TileEntityCrateTungsten) { return new ContainerCrateTungsten(player.inventory, (TileEntityCrateTungsten) entity); }
|
||||
if(entity instanceof TileEntitySafe) { return new ContainerSafe(player.inventory, (TileEntitySafe) entity); }
|
||||
if(entity instanceof TileEntityMassStorage) { return new ContainerMassStorage(player.inventory, (TileEntityMassStorage) entity); }
|
||||
|
||||
if(entity instanceof TileEntityMachineAutocrafter) { return new ContainerAutocrafter(player.inventory, (TileEntityMachineAutocrafter) entity); }
|
||||
|
||||
@ -19,7 +19,7 @@ public class ContainerAutocrafter extends Container {
|
||||
/* TEMPLATE */
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 3; j++) {
|
||||
this.addSlotToContainer(new SlotPattern(tedf, j + i * 3, 44 + j * 18, 22 + i * 18).disableHover());
|
||||
this.addSlotToContainer(new SlotPattern(tedf, j + i * 3, 44 + j * 18, 22 + i * 18));
|
||||
}
|
||||
}
|
||||
this.addSlotToContainer(new SlotPattern(tedf, 9, 116, 40));
|
||||
@ -67,8 +67,15 @@ public class ContainerAutocrafter extends Container {
|
||||
ret = slot.getStack().copy();
|
||||
|
||||
//Don't allow any interaction for the template's output
|
||||
if(index == 9)
|
||||
if(index == 9) {
|
||||
|
||||
if(button == 1 && mode == 0 && slot.getHasStack()) {
|
||||
autocrafter.nextTemplate();
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(button == 1 && mode == 0 && slot.getHasStack()) {
|
||||
autocrafter.nextMode(index);
|
||||
|
||||
@ -0,0 +1,57 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerCrateBase extends Container {
|
||||
|
||||
protected IInventory crate;
|
||||
|
||||
public ContainerCrateBase(IInventory tedf) {
|
||||
crate = tedf;
|
||||
crate.openInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) {
|
||||
ItemStack var3 = null;
|
||||
Slot var4 = (Slot) this.inventorySlots.get(par2);
|
||||
|
||||
if(var4 != null && var4.getHasStack()) {
|
||||
ItemStack var5 = var4.getStack();
|
||||
var3 = var5.copy();
|
||||
|
||||
if(par2 <= crate.getSizeInventory() - 1) {
|
||||
if(!this.mergeItemStack(var5, crate.getSizeInventory(), this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
} else if(!this.mergeItemStack(var5, 0, crate.getSizeInventory(), false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(var5.stackSize == 0) {
|
||||
var4.putStack((ItemStack) null);
|
||||
} else {
|
||||
var4.onSlotChanged();
|
||||
}
|
||||
|
||||
var4.onPickupFromSlot(p_82846_1_, var5);
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return crate.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer p_75134_1_) {
|
||||
super.onContainerClosed(p_75134_1_);
|
||||
this.crate.closeInventory();
|
||||
}
|
||||
}
|
||||
@ -1,18 +1,13 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerCrateDesh extends Container {
|
||||
|
||||
private IInventory diFurnace;
|
||||
public class ContainerCrateDesh extends ContainerCrateBase {
|
||||
|
||||
public ContainerCrateDesh(InventoryPlayer invPlayer, IInventory tedf) {
|
||||
diFurnace = tedf;
|
||||
super(tedf);
|
||||
|
||||
for(int i = 0; i < 8; i++) {
|
||||
for(int j = 0; j < 13; j++) {
|
||||
@ -30,38 +25,4 @@ public class ContainerCrateDesh extends Container {
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 44 + i * 18, 232));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) {
|
||||
ItemStack var3 = null;
|
||||
Slot var4 = (Slot) this.inventorySlots.get(par2);
|
||||
|
||||
if(var4 != null && var4.getHasStack()) {
|
||||
ItemStack var5 = var4.getStack();
|
||||
var3 = var5.copy();
|
||||
|
||||
if(par2 <= diFurnace.getSizeInventory() - 1) {
|
||||
if(!this.mergeItemStack(var5, diFurnace.getSizeInventory(), this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
} else if(!this.mergeItemStack(var5, 0, diFurnace.getSizeInventory(), false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(var5.stackSize == 0) {
|
||||
var4.putStack((ItemStack) null);
|
||||
} else {
|
||||
var4.onSlotChanged();
|
||||
}
|
||||
|
||||
var4.onPickupFromSlot(p_82846_1_, var5);
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return diFurnace.isUseableByPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,19 +2,14 @@ package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.tileentity.machine.storage.TileEntityCrateIron;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
//@invtweaks.api.container.ChestContainer
|
||||
public class ContainerCrateIron extends Container {
|
||||
|
||||
private TileEntityCrateIron diFurnace;
|
||||
public class ContainerCrateIron extends ContainerCrateBase {
|
||||
|
||||
public ContainerCrateIron(InventoryPlayer invPlayer, TileEntityCrateIron tedf) {
|
||||
diFurnace = tedf;
|
||||
super(tedf);
|
||||
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
@ -37,44 +32,4 @@ public class ContainerCrateIron extends Container {
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142 + 20));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2)
|
||||
{
|
||||
ItemStack var3 = null;
|
||||
Slot var4 = (Slot) this.inventorySlots.get(par2);
|
||||
|
||||
if (var4 != null && var4.getHasStack())
|
||||
{
|
||||
ItemStack var5 = var4.getStack();
|
||||
var3 = var5.copy();
|
||||
|
||||
if (par2 <= diFurnace.getSizeInventory() - 1) {
|
||||
if (!this.mergeItemStack(var5, diFurnace.getSizeInventory(), this.inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(var5, 0, diFurnace.getSizeInventory(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (var5.stackSize == 0)
|
||||
{
|
||||
var4.putStack((ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var4.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return diFurnace.isUseableByPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,14 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
//@invtweaks.api.container.ChestContainer
|
||||
public class ContainerCrateSteel extends Container {
|
||||
|
||||
private IInventory diFurnace;
|
||||
public class ContainerCrateSteel extends ContainerCrateBase {
|
||||
|
||||
public ContainerCrateSteel(InventoryPlayer invPlayer, IInventory tedf) {
|
||||
diFurnace = tedf;
|
||||
super(tedf);
|
||||
|
||||
for(int i = 0; i < 6; i++) {
|
||||
for(int j = 0; j < 9; j++) {
|
||||
@ -31,38 +26,4 @@ public class ContainerCrateSteel extends Container {
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142 + (18 * 3) + 2));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) {
|
||||
ItemStack var3 = null;
|
||||
Slot var4 = (Slot) this.inventorySlots.get(par2);
|
||||
|
||||
if(var4 != null && var4.getHasStack()) {
|
||||
ItemStack var5 = var4.getStack();
|
||||
var3 = var5.copy();
|
||||
|
||||
if(par2 <= diFurnace.getSizeInventory() - 1) {
|
||||
if(!this.mergeItemStack(var5, diFurnace.getSizeInventory(), this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
} else if(!this.mergeItemStack(var5, 0, diFurnace.getSizeInventory(), false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(var5.stackSize == 0) {
|
||||
var4.putStack((ItemStack) null);
|
||||
} else {
|
||||
var4.onSlotChanged();
|
||||
}
|
||||
|
||||
var4.onPickupFromSlot(p_82846_1_, var5);
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return diFurnace.isUseableByPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,19 +2,14 @@ package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.tileentity.machine.storage.TileEntityCrateTungsten;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
//@invtweaks.api.container.ChestContainer
|
||||
public class ContainerCrateTungsten extends Container {
|
||||
|
||||
private TileEntityCrateTungsten crate;
|
||||
public class ContainerCrateTungsten extends ContainerCrateBase {
|
||||
|
||||
public ContainerCrateTungsten(InventoryPlayer invPlayer, TileEntityCrateTungsten te) {
|
||||
crate = te;
|
||||
super(te);
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 9; j++) {
|
||||
@ -32,38 +27,4 @@ public class ContainerCrateTungsten extends Container {
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 90 + (18 * 3)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) {
|
||||
ItemStack var3 = null;
|
||||
Slot var4 = (Slot) this.inventorySlots.get(par2);
|
||||
|
||||
if(var4 != null && var4.getHasStack()) {
|
||||
ItemStack var5 = var4.getStack();
|
||||
var3 = var5.copy();
|
||||
|
||||
if(par2 <= crate.getSizeInventory() - 1) {
|
||||
if(!this.mergeItemStack(var5, crate.getSizeInventory(), this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
} else if(!this.mergeItemStack(var5, 0, crate.getSizeInventory(), false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(var5.stackSize == 0) {
|
||||
var4.putStack((ItemStack) null);
|
||||
} else {
|
||||
var4.onSlotChanged();
|
||||
}
|
||||
|
||||
var4.onPickupFromSlot(p_82846_1_, var5);
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return crate.isUseableByPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,6 +31,8 @@ public class GUIAutocrafter extends GuiInfoContainer {
|
||||
@Override
|
||||
public void drawScreen(int x, int y, float interp) {
|
||||
super.drawScreen(x, y, interp);
|
||||
|
||||
this.drawElectricityInfo(this, x, y, guiLeft + 17, guiTop + 45, 16, 52, diFurnace.getPower(), diFurnace.getMaxPower());
|
||||
|
||||
if(this.mc.thePlayer.inventory.getItemStack() == null) {
|
||||
for(int i = 0; i < 9; ++i) {
|
||||
@ -49,6 +51,12 @@ public class GUIAutocrafter extends GuiInfoContainer {
|
||||
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", label }), x, y - 30);
|
||||
}
|
||||
}
|
||||
|
||||
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(9);
|
||||
|
||||
if(this.isMouseOverSlot(slot, x, y) && diFurnace.slots[9] != null) {
|
||||
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", EnumChatFormatting.YELLOW + "" + (diFurnace.recipeIndex + 1) + " / " + diFurnace.recipeCount }), x, y - 30);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,6 +73,10 @@ public class GUIAutocrafter extends GuiInfoContainer {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
int i = (int)(diFurnace.getPower() * 52 / diFurnace.getMaxPower());
|
||||
drawTexturedModalRect(guiLeft + 17, guiTop + 97 - i, 176, 52 - i, 16, i);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.hbm.items.tool;
|
||||
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -11,6 +12,7 @@ public class ItemCraftingDegradation extends Item {
|
||||
this.setMaxStackSize(1);
|
||||
this.setMaxDamage(durability);
|
||||
this.setNoRepair();
|
||||
this.setCreativeTab(MainRegistry.controlTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,22 +1,31 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import com.hbm.util.ItemStackUtil;
|
||||
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
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.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class TileEntityMachineAutocrafter extends TileEntityMachineBase {
|
||||
public class TileEntityMachineAutocrafter extends TileEntityMachineBase implements IEnergyUser {
|
||||
|
||||
public static final String MODE_EXACT = "exact";
|
||||
public static final String MODE_WILDCARD = "wildcard";
|
||||
public String[] modes = new String[9];
|
||||
|
||||
public List<IRecipe> recipes = new ArrayList();
|
||||
public int recipeIndex;
|
||||
public int recipeCount;
|
||||
|
||||
public TileEntityMachineAutocrafter() {
|
||||
super(21);
|
||||
@ -24,6 +33,8 @@ public class TileEntityMachineAutocrafter extends TileEntityMachineBase {
|
||||
|
||||
public void initPattern(ItemStack stack, int i) {
|
||||
|
||||
if(worldObj.isRemote) return;
|
||||
|
||||
if(stack == null) {
|
||||
modes[i] = null;
|
||||
return;
|
||||
@ -57,6 +68,9 @@ public class TileEntityMachineAutocrafter extends TileEntityMachineBase {
|
||||
}
|
||||
|
||||
public void nextMode(int i) {
|
||||
|
||||
if(worldObj.isRemote) return;
|
||||
|
||||
ItemStack stack = slots[i];
|
||||
|
||||
if(stack == null) {
|
||||
@ -95,6 +109,22 @@ public class TileEntityMachineAutocrafter extends TileEntityMachineBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void nextTemplate() {
|
||||
|
||||
if(worldObj.isRemote) return;
|
||||
|
||||
this.recipeIndex++;
|
||||
|
||||
if(this.recipeIndex >= this.recipes.size())
|
||||
this.recipeIndex = 0;
|
||||
|
||||
if(!this.recipes.isEmpty()) {
|
||||
slots[9] = this.recipes.get(this.recipeIndex).getCraftingResult(getTemplateGrid());
|
||||
} else {
|
||||
slots[9] = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
@ -108,31 +138,213 @@ public class TileEntityMachineAutocrafter extends TileEntityMachineBase {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
this.craftingInventory.loadIventory(slots, 10);
|
||||
ItemStack stack = CraftingManager.getInstance().findMatchingRecipe(this.craftingInventory, this.worldObj);
|
||||
this.power = Library.chargeTEFromItems(slots, 20, power, maxPower);
|
||||
this.updateStandardConnections(worldObj, this);
|
||||
|
||||
if(stack != null) {
|
||||
slots[19] = stack.copy();
|
||||
if(!this.recipes.isEmpty() && this.power >= this.consumption) {
|
||||
IRecipe recipe = this.recipes.get(recipeIndex);
|
||||
|
||||
for(int i = 10; i < 19; i++) {
|
||||
this.decrStackSize(i, 1);
|
||||
if(recipe.matches(this.getRecipeGrid(), this.worldObj)) {
|
||||
ItemStack stack = recipe.getCraftingResult(this.getRecipeGrid());
|
||||
|
||||
if(stack != null) {
|
||||
|
||||
boolean didCraft = false;
|
||||
|
||||
if(slots[19] == null) {
|
||||
slots[19] = stack.copy();
|
||||
didCraft = true;
|
||||
} else if(slots[19].isItemEqual(stack) && ItemStack.areItemStackTagsEqual(stack, slots[19]) && slots[19].stackSize + stack.stackSize <= slots[19].getMaxStackSize()) {
|
||||
slots[19].stackSize += stack.stackSize;
|
||||
didCraft = true;
|
||||
}
|
||||
|
||||
if(didCraft) {
|
||||
for(int i = 10; i < 19; i++) {
|
||||
|
||||
ItemStack ingredient = this.getStackInSlot(i);
|
||||
|
||||
if(ingredient != null) {
|
||||
this.decrStackSize(i, 1);
|
||||
|
||||
if(ingredient.getItem().hasContainerItem(ingredient)) {
|
||||
ItemStack container = ingredient.getItem().getContainerItem(ingredient);
|
||||
|
||||
if(container != null && container.isItemStackDamageable() && container.getItemDamage() > container.getMaxDamage()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.setInventorySlotContents(i, container);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.power -= this.consumption;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setLong("power", power);
|
||||
for(int i = 0; i < 9; i++) {
|
||||
if(modes[i] != null) {
|
||||
data.setString("mode" + i, modes[i]);
|
||||
}
|
||||
}
|
||||
data.setInteger("count", this.recipeCount);
|
||||
data.setInteger("rec", this.recipeIndex);
|
||||
this.networkPack(data, 15);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void networkUnpack(NBTTagCompound data) {
|
||||
this.power = data.getLong("power");
|
||||
|
||||
modes = new String[9];
|
||||
for(int i = 0; i < 9; i++) {
|
||||
if(data.hasKey("mode" + i)) {
|
||||
modes[i] = data.getString("mode" + i);
|
||||
}
|
||||
}
|
||||
this.recipeCount = data.getInteger("count");
|
||||
this.recipeIndex = data.getInteger("rec");
|
||||
}
|
||||
|
||||
public void updateTemplateGrid() {
|
||||
|
||||
this.craftingInventory.loadIventory(slots, 0);
|
||||
ItemStack temp = CraftingManager.getInstance().findMatchingRecipe(this.craftingInventory, this.worldObj);
|
||||
this.recipes = getMatchingRecipes(this.getTemplateGrid());
|
||||
this.recipeCount = recipes.size();
|
||||
this.recipeIndex = 0;
|
||||
|
||||
if(temp != null) {
|
||||
slots[9] = temp.copy();
|
||||
if(!this.recipes.isEmpty()) {
|
||||
slots[9] = this.recipes.get(this.recipeIndex).getCraftingResult(getTemplateGrid());
|
||||
} else {
|
||||
slots[9] = null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<IRecipe> getMatchingRecipes(InventoryCrafting grid) {
|
||||
List<IRecipe> recipes = new ArrayList();
|
||||
|
||||
for(Object o : CraftingManager.getInstance().getRecipeList()) {
|
||||
IRecipe recipe = (IRecipe) o;
|
||||
|
||||
if(recipe.matches(grid, worldObj)) {
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
return recipes;
|
||||
}
|
||||
|
||||
public int[] access = new int[] { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return access;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack stack, int j) {
|
||||
if(i == 19)
|
||||
return true;
|
||||
|
||||
if(i > 9 && i < 18) {
|
||||
ItemStack filter = slots[i - 10];
|
||||
String mode = modes[i - 10];
|
||||
|
||||
if(filter == null || mode == null || mode.isEmpty()) return true;
|
||||
|
||||
if(isValidForFilter(filter, mode, stack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
|
||||
//only allow insertion for the nine recipe slots
|
||||
if(slot < 10 || slot > 18)
|
||||
return false;
|
||||
|
||||
//is the filter at this space null? no input.
|
||||
if(slots[slot - 10] == null)
|
||||
return false;
|
||||
|
||||
//let's find all slots that this item could potentially go in
|
||||
List<Integer> validSlots = new ArrayList();
|
||||
for(int i = 0; i < 9; i++) {
|
||||
ItemStack filter = slots[i];
|
||||
String mode = modes[i];
|
||||
|
||||
if(filter == null || mode == null || mode.isEmpty()) continue;
|
||||
|
||||
if(isValidForFilter(filter, mode, stack)) {
|
||||
validSlots.add(i + 10);
|
||||
|
||||
//if the current slot is valid and has no item in it, shortcut to true [*]
|
||||
if(i + 10 == slot && slots[slot] == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if the slot we are looking at isn't valid, skip
|
||||
if(!validSlots.contains(slot)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//assumption from [*]: the slot has to be valid by now, and it cannot be null
|
||||
int size = slots[slot].stackSize;
|
||||
|
||||
//now we decide based on stacksize, woohoo
|
||||
for(Integer i : validSlots) {
|
||||
ItemStack valid = slots[i];
|
||||
|
||||
if(valid == null) return false; //null? since slots[slot] is not null by now, this other slot needs the item more
|
||||
if(!(valid.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(valid, stack))) continue; //different item anyway? out with it
|
||||
|
||||
//if there is another slot that actually does need the same item more, cancel
|
||||
if(valid.stackSize < size)
|
||||
return false;
|
||||
}
|
||||
|
||||
//prevent items with containers from stacking
|
||||
if(stack.getItem().hasContainerItem(stack))
|
||||
return false;
|
||||
|
||||
//by now, we either already have filled the slot (if valid by filter and null) or weeded out all other options, which means it is good to go
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isValidForFilter(ItemStack filter, String mode, ItemStack input) {
|
||||
|
||||
switch(mode) {
|
||||
case MODE_EXACT: return input.isItemEqual(filter) && ItemStack.areItemStackTagsEqual(input, filter);
|
||||
case MODE_WILDCARD: return input.getItem() == filter.getItem() && ItemStack.areItemStackTagsEqual(input, filter);
|
||||
default:
|
||||
List<String> keys = ItemStackUtil.getOreDictNames(input);
|
||||
return keys.contains(mode);
|
||||
}
|
||||
}
|
||||
|
||||
public InventoryCrafting getTemplateGrid() {
|
||||
this.craftingInventory.loadIventory(slots, 0);
|
||||
return this.craftingInventory;
|
||||
}
|
||||
|
||||
public InventoryCrafting getRecipeGrid() {
|
||||
this.craftingInventory.loadIventory(slots, 10);
|
||||
return this.craftingInventory;
|
||||
}
|
||||
|
||||
public static class InventoryCraftingAuto extends InventoryCrafting {
|
||||
|
||||
public InventoryCraftingAuto(int width, int height) {
|
||||
@ -147,10 +359,63 @@ public class TileEntityMachineAutocrafter extends TileEntityMachineBase {
|
||||
}
|
||||
|
||||
public static class ContainerBlank extends Container {
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory inventory) { }
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) { return false; }
|
||||
@Override public void onCraftMatrixChanged(IInventory inventory) { }
|
||||
@Override public boolean canInteractWith(EntityPlayer player) { return false; }
|
||||
}
|
||||
}
|
||||
|
||||
public static int consumption = 100;
|
||||
public static long maxPower = consumption * 100;
|
||||
public long power;
|
||||
|
||||
@Override
|
||||
public long getPower() {
|
||||
return power;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxPower() {
|
||||
return maxPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(long power) {
|
||||
this.power = power;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.power = nbt.getLong("power");
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
if(nbt.hasKey("mode" + i)) {
|
||||
modes[i] = nbt.getString("mode" + i);
|
||||
}
|
||||
}
|
||||
|
||||
this.recipes = getMatchingRecipes(this.getTemplateGrid());
|
||||
this.recipeCount = recipes.size();
|
||||
this.recipeIndex = nbt.getInteger("rec");
|
||||
|
||||
if(!this.recipes.isEmpty()) {
|
||||
slots[9] = this.recipes.get(this.recipeIndex).getCraftingResult(getTemplateGrid());
|
||||
} else {
|
||||
slots[9] = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setLong("power", power);
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
if(modes[i] != null) {
|
||||
nbt.setString("mode" + i, modes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
nbt.setInteger("rec", this.recipeIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,13 +69,14 @@ public abstract class TileEntityCrateBase extends TileEntityLockableBase impleme
|
||||
}
|
||||
}
|
||||
|
||||
// You scrubs aren't needed for anything (right now)
|
||||
@Override
|
||||
public void openInventory() {
|
||||
this.worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "hbm:block.crateOpen", 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
this.worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "hbm:block.crateClose", 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -208,6 +208,7 @@ container.anvil=Stufe %s Amboss
|
||||
container.arcFurnace=Lichtbogenofen
|
||||
container.armorTable=Rüstungsmodifikationstisch
|
||||
container.assembler=Fertigungsmaschine
|
||||
container.autocrafter=Automatische Werkbank
|
||||
container.barrel=Fass
|
||||
container.bat9000=Big-Ass Tank 9000
|
||||
container.battery=Energiespeicher
|
||||
@ -215,6 +216,7 @@ container.bombMulti=Mehrzweckbombe
|
||||
container.centrifuge=Zentrifuge
|
||||
container.chemplant=Chemiewerk
|
||||
container.compactLauncher=Kompakt-Startrampe
|
||||
container.crateDesh=Deshkiste
|
||||
container.crateIron=Eisenkiste
|
||||
container.crateSteel=Stahlkiste
|
||||
container.crateTungsten=Wolframkiste
|
||||
@ -3114,6 +3116,7 @@ tile.crashed_bomb.name=Blindgänger
|
||||
tile.crate.name=Vorratskiste
|
||||
tile.crate_ammo.name=Sternenmetallkiste
|
||||
tile.crate_can.name=Konservenkiste
|
||||
tile.crate_desh.name=Deshkiste
|
||||
tile.crate_iron.name=Eisenkiste
|
||||
tile.crate_jungle.name=Enargitkiste
|
||||
tile.crate_lead.name=Gefahrenstoffkiste
|
||||
@ -3302,6 +3305,7 @@ tile.machine_arc_furnace_on.name=Lichtbogenofen
|
||||
tile.machine_armor_table.name=Rüstungsmodifikationstisch
|
||||
tile.machine_assembler.name=Fertigungsmaschine
|
||||
tile.machine_assemfac.name=Fertigungsfabrik
|
||||
tile.machine_autocrafter.name=Automatische Werkbank
|
||||
tile.machine_bat9000.name=Big-Ass Tank 9000
|
||||
tile.machine_battery.name=Energiespeicherblock
|
||||
tile.machine_battery_potato.name=Kartoffelbatterieblock
|
||||
|
||||
@ -384,6 +384,7 @@ container.anvil=Tier %s Anvil
|
||||
container.arcFurnace=Arc Furnace
|
||||
container.armorTable=Armor Modification Table
|
||||
container.assembler=Assembly Machine
|
||||
container.autocrafter=Automatic Crafting Table
|
||||
container.barrel=Barrel
|
||||
container.bat9000=Big-Ass Tank 9000
|
||||
container.battery=Energy Storage
|
||||
@ -391,6 +392,7 @@ container.bombMulti=Multi Purpose Bomb
|
||||
container.centrifuge=Centrifuge
|
||||
container.chemplant=Chemical Plant
|
||||
container.compactLauncher=Compact Launch Pad
|
||||
container.crateDesh=Desh Crate
|
||||
container.crateIron=Iron Crate
|
||||
container.crateSteel=Steel Crate
|
||||
container.crateTungsten=Tungsten Crate
|
||||
@ -3506,6 +3508,7 @@ tile.crashed_bomb.name=Dud
|
||||
tile.crate.name=Supply Crate
|
||||
tile.crate_ammo.name=Starmetal Crate
|
||||
tile.crate_can.name=Conserve Crate
|
||||
tile.crate_desh.name=Desh Crate
|
||||
tile.crate_iron.name=Iron Crate
|
||||
tile.crate_jungle.name=Enargite Crate
|
||||
tile.crate_lead.name=Hazmat Crate
|
||||
@ -3694,6 +3697,7 @@ tile.machine_arc_furnace_on.name=Arc Furnace
|
||||
tile.machine_armor_table.name=Armor Modification Table
|
||||
tile.machine_assembler.name=Assembly Machine
|
||||
tile.machine_assemfac.name=Assembly Factory
|
||||
tile.machine_autocrafter.name=Automatic Crafting Table
|
||||
tile.machine_bat9000.name=Big-Ass Tank 9000
|
||||
tile.machine_battery.name=Energy Storage Block
|
||||
tile.machine_battery_potato.name=Potato Battery Block
|
||||
|
||||
@ -38,6 +38,8 @@
|
||||
"block.rbmk_az5_cover": {"category": "block", "sounds": [{"name": "block/rbmk_az5_cover", "stream": false}]},
|
||||
"block.chungusLever": {"category": "block", "sounds": [{"name": "block/chungusLever", "stream": false}]},
|
||||
"block.bobble": {"category": "block", "sounds": [{"name": "block/bobble", "stream": false}]},
|
||||
"block.crateOpen": {"category": "block", "sounds": [{"name": "block/crateOpen", "stream": false}]},
|
||||
"block.crateClose": {"category": "block", "sounds": [{"name": "block/crateClose", "stream": false}]},
|
||||
|
||||
"door.TransitionSealOpen": {"category": "block", "sounds": [{"name": "block/door/transition_seal_open", "stream": true}]},
|
||||
|
||||
|
||||
BIN
src/main/resources/assets/hbm/sounds/block/crateClose.ogg
Normal file
BIN
src/main/resources/assets/hbm/sounds/block/crateClose.ogg
Normal file
Binary file not shown.
BIN
src/main/resources/assets/hbm/sounds/block/crateOpen.ogg
Normal file
BIN
src/main/resources/assets/hbm/sounds/block/crateOpen.ogg
Normal file
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.3 KiB |
Loading…
x
Reference in New Issue
Block a user