mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-21 04:32:26 +00:00
Fix JABBA-related issues with crafting station slots (#54)
* Fix shift-merging tools voiding items fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11392> * Change 0-sized ItemStacks into null stacks in crafting station attached slots Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10425> * Update buildscript * spotlessApply
This commit is contained in:
1 parent
18bfeaff32
commit
39be06c23b
571 files changed
+25959
-28223
No files matched your search
@@ -11,86 +11,69 @@ import net.minecraft.world.World;
|
||||
* 0: Battlesign item
|
||||
*/
|
||||
|
||||
public class BattlesignLogic extends EquipLogic
|
||||
{
|
||||
public class BattlesignLogic extends EquipLogic {
|
||||
protected String[] text;
|
||||
|
||||
public BattlesignLogic()
|
||||
{
|
||||
public BattlesignLogic() {
|
||||
super(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
public String getDefaultName() {
|
||||
return "decoration.battlesign";
|
||||
}
|
||||
|
||||
@Override
|
||||
/* NBT */
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tags) {
|
||||
super.readFromNBT(tags);
|
||||
|
||||
text = new String[tags.getInteger("lineCount")];
|
||||
for (int i = 0; i < text.length; i++)
|
||||
{
|
||||
for (int i = 0; i < text.length; i++) {
|
||||
text[i] = tags.getString("line" + i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound tags) {
|
||||
super.writeToNBT(tags);
|
||||
|
||||
if (text == null)
|
||||
{
|
||||
if (text == null) {
|
||||
text = new String[0];
|
||||
}
|
||||
|
||||
tags.setInteger("lineCount", text.length);
|
||||
for (int i = 0; i < text.length; i++)
|
||||
{
|
||||
for (int i = 0; i < text.length; i++) {
|
||||
tags.setString("line" + i, text[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return null; //Not a normal gui block
|
||||
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
|
||||
return null; // Not a normal gui block
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
public String getInventoryName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
public void closeInventory() {}
|
||||
|
||||
public void setText (String[] text)
|
||||
{
|
||||
public void setText(String[] text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public String[] getText ()
|
||||
{
|
||||
public String[] getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public S35PacketUpdateTileEntity getDescriptionPacket ()
|
||||
{
|
||||
public S35PacketUpdateTileEntity getDescriptionPacket() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
this.writeToNBT(compound);
|
||||
|
||||
@@ -99,8 +82,7 @@ public class BattlesignLogic extends EquipLogic
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity pkt)
|
||||
{
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
this.readFromNBT(pkt.func_148857_g());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package tconstruct.tools.logic;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -15,8 +16,6 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tconstruct.tools.inventory.CraftingStationContainer;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class CraftingStationLogic extends InventoryLogic implements ISidedInventory {
|
||||
public ForgeDirection chestDirection = ForgeDirection.UNKNOWN;
|
||||
public int chestSize;
|
||||
@@ -42,8 +41,7 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int quantity) {
|
||||
if (slot == 0) {
|
||||
for (int i = 1; i < getSizeInventory(); i++)
|
||||
decrStackSize(i, 1);
|
||||
for (int i = 1; i < getSizeInventory(); i++) decrStackSize(i, 1);
|
||||
}
|
||||
return super.decrStackSize(slot, quantity);
|
||||
}
|
||||
@@ -67,7 +65,9 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
|
||||
for (final ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
final int xPos = x + dir.offsetX, yPos = y + dir.offsetY, zPos = z + dir.offsetZ;
|
||||
final TileEntity tile = world.getTileEntity(xPos, yPos, zPos);
|
||||
if (!(tile instanceof IInventory) || (tile instanceof CraftingStationLogic) || isBlacklisted(tile.getClass())) continue;
|
||||
if (!(tile instanceof IInventory)
|
||||
|| (tile instanceof CraftingStationLogic)
|
||||
|| isBlacklisted(tile.getClass())) continue;
|
||||
|
||||
final IInventory inv = (IInventory) tile;
|
||||
|
||||
@@ -82,13 +82,22 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
|
||||
continue;
|
||||
}
|
||||
|
||||
if(tile instanceof ISidedInventory && ((ISidedInventory)tile).getAccessibleSlotsFromSide(dir.getOpposite().ordinal()).length == 0) continue;
|
||||
|
||||
if (tile instanceof ISidedInventory
|
||||
&& ((ISidedInventory) tile)
|
||||
.getAccessibleSlotsFromSide(
|
||||
dir.getOpposite().ordinal())
|
||||
.length
|
||||
== 0) continue;
|
||||
|
||||
if (chest == null && inv.isUseableByPlayer(inventoryplayer.player)) {
|
||||
chest = new WeakReference<>(inv);
|
||||
chestDirection = dir;
|
||||
invColumns = 6;
|
||||
chestSize = tile instanceof ISidedInventory ? ((ISidedInventory)tile).getAccessibleSlotsFromSide(dir.getOpposite().ordinal()).length : inv.getSizeInventory();
|
||||
chestSize = tile instanceof ISidedInventory
|
||||
? ((ISidedInventory) tile)
|
||||
.getAccessibleSlotsFromSide(dir.getOpposite().ordinal())
|
||||
.length
|
||||
: inv.getSizeInventory();
|
||||
|
||||
if (tile instanceof TileEntityChest) {
|
||||
checkForChest(world, xPos, yPos, zPos, 1, 0);
|
||||
@@ -98,8 +107,7 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
|
||||
}
|
||||
slotCount = chestSize * (doubleChest != null ? 2 : 1);
|
||||
invRows = (int) Math.ceil((double) slotCount / invColumns);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return new CraftingStationContainer(inventoryplayer, this, x, y, z);
|
||||
@@ -108,7 +116,7 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
|
||||
private boolean isBlacklisted(Class<? extends TileEntity> clazz) {
|
||||
return PHConstruct.craftingStationBlacklist.contains(clazz.getName());
|
||||
}
|
||||
|
||||
|
||||
void checkForChest(World world, int x, int y, int z, int dx, int dz) {
|
||||
TileEntity tile = world.getTileEntity(x + dx, y, z + dz);
|
||||
if (tile instanceof TileEntityChest) {
|
||||
@@ -116,11 +124,11 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
|
||||
doubleFirst = dx + dz < 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isDoubleChest() {
|
||||
return this.doubleChest != null;
|
||||
}
|
||||
|
||||
|
||||
public IInventory getFirstInventory() {
|
||||
if (doubleFirst && doubleChest != null) {
|
||||
return doubleChest.get();
|
||||
@@ -130,7 +138,7 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
|
||||
}
|
||||
|
||||
public IInventory getSecondInventory() {
|
||||
if(!isDoubleChest()) return null;
|
||||
if (!isDoubleChest()) return null;
|
||||
|
||||
if (doubleFirst) {
|
||||
return chest.get();
|
||||
@@ -154,8 +162,7 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
|
||||
for (WeakReference<IInventory> ref : inventories) {
|
||||
if (ref != null) {
|
||||
IInventory inv = ref.get();
|
||||
if (inv != null && !inv.isUseableByPlayer(player))
|
||||
return false;
|
||||
if (inv != null && !inv.isUseableByPlayer(player)) return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,12 +171,12 @@ public class CraftingStationLogic extends InventoryLogic implements ISidedInvent
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public WeakReference[] getInventories() {
|
||||
return new WeakReference[]{this.chest, this.doubleChest, this.patternChest, this.furnace};
|
||||
return new WeakReference[] {this.chest, this.doubleChest, this.patternChest, this.furnace};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int var1) {
|
||||
return new int[]{};
|
||||
return new int[] {};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,57 +12,45 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
* 2-9: Food
|
||||
*/
|
||||
|
||||
public abstract class EquipLogic extends InventoryLogic
|
||||
{
|
||||
public abstract class EquipLogic extends InventoryLogic {
|
||||
|
||||
public EquipLogic(int invSize)
|
||||
{
|
||||
public EquipLogic(int invSize) {
|
||||
super(invSize);
|
||||
}
|
||||
|
||||
public void setEquipmentItem (ItemStack stack)
|
||||
{
|
||||
public void setEquipmentItem(ItemStack stack) {
|
||||
inventory[0] = stack.copy();
|
||||
}
|
||||
|
||||
public boolean hasEquipmentItem ()
|
||||
{
|
||||
public boolean hasEquipmentItem() {
|
||||
return inventory[0] != null;
|
||||
}
|
||||
|
||||
public ItemStack getEquipmentItem ()
|
||||
{
|
||||
public ItemStack getEquipmentItem() {
|
||||
return inventory[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack stack)
|
||||
{
|
||||
if (slot == 0)
|
||||
{
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
if (slot == 0) {
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
super.setInventorySlotContents(slot, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot (int slot)
|
||||
{
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return slot != 0 ? inventory[slot] : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStackInSlot (int slot)
|
||||
{
|
||||
public boolean isStackInSlot(int slot) {
|
||||
return slot != 0 ? inventory[slot] != null : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public S35PacketUpdateTileEntity getDescriptionPacket ()
|
||||
{
|
||||
public S35PacketUpdateTileEntity getDescriptionPacket() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
this.writeToNBT(compound);
|
||||
|
||||
@@ -71,8 +59,7 @@ public abstract class EquipLogic extends InventoryLogic
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity pkt)
|
||||
{
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
this.readFromNBT(pkt.func_148857_g());
|
||||
}
|
||||
}
|
||||
@@ -20,51 +20,42 @@ import tconstruct.tools.inventory.FrypanContainer;
|
||||
* 2-9: Food
|
||||
*/
|
||||
|
||||
public class FrypanLogic extends EquipLogic implements IActiveLogic
|
||||
{
|
||||
public class FrypanLogic extends EquipLogic implements IActiveLogic {
|
||||
boolean active;
|
||||
public int fuel;
|
||||
public int fuelGague;
|
||||
public int progress;
|
||||
|
||||
public FrypanLogic()
|
||||
{
|
||||
public FrypanLogic() {
|
||||
super(10);
|
||||
active = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
public String getDefaultName() {
|
||||
return "crafters.frypan";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive ()
|
||||
{
|
||||
public boolean getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive (boolean flag)
|
||||
{
|
||||
public void setActive(boolean flag) {
|
||||
active = flag;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/* Fuel gauge */
|
||||
public int gaugeProgressScaled (int scale)
|
||||
{
|
||||
public int gaugeProgressScaled(int scale) {
|
||||
return (progress * scale) / 1000;
|
||||
}
|
||||
|
||||
public int gaugeFuelScaled (int scale)
|
||||
{
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
public int gaugeFuelScaled(int scale) {
|
||||
if (fuelGague == 0) {
|
||||
fuelGague = fuel;
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
if (fuelGague == 0) {
|
||||
fuelGague = 1000;
|
||||
}
|
||||
}
|
||||
@@ -73,84 +64,65 @@ public class FrypanLogic extends EquipLogic implements IActiveLogic
|
||||
|
||||
/* Item cooking */
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
public void updateEntity() {
|
||||
boolean burning = isBurning();
|
||||
boolean updateInventory = false;
|
||||
if (fuel <= 0 && canCook())
|
||||
{
|
||||
if (fuel <= 0 && canCook()) {
|
||||
fuel = fuelGague = (int) (getItemBurnTime(inventory[1]) * 2.5);
|
||||
if (fuel > 0)
|
||||
{
|
||||
if (inventory[1].getItem().hasContainerItem(inventory[1])) //Fuel slot
|
||||
if (fuel > 0) {
|
||||
if (inventory[1].getItem().hasContainerItem(inventory[1])) // Fuel slot
|
||||
{
|
||||
inventory[1] = inventory[1].getItem().getContainerItem(inventory[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
inventory[1].stackSize--;
|
||||
}
|
||||
if (inventory[1].stackSize <= 0)
|
||||
{
|
||||
if (inventory[1].stackSize <= 0) {
|
||||
inventory[1] = null;
|
||||
}
|
||||
updateInventory = true;
|
||||
}
|
||||
}
|
||||
if (isBurning() && canCook())
|
||||
{
|
||||
if (isBurning() && canCook()) {
|
||||
progress++;
|
||||
if (progress >= 1000)
|
||||
{
|
||||
if (progress >= 1000) {
|
||||
progress = 0;
|
||||
cookItems();
|
||||
updateInventory = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
progress = 0;
|
||||
}
|
||||
if (fuel > 0)
|
||||
{
|
||||
if (fuel > 0) {
|
||||
fuel--;
|
||||
}
|
||||
if (burning != isBurning())
|
||||
{
|
||||
if (burning != isBurning()) {
|
||||
setActive(isBurning());
|
||||
updateInventory = true;
|
||||
}
|
||||
if (updateInventory)
|
||||
{
|
||||
if (updateInventory) {
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void cookItems ()
|
||||
{
|
||||
if (!canCook())
|
||||
return;
|
||||
public void cookItems() {
|
||||
if (!canCook()) return;
|
||||
|
||||
for (int id = 2; id < 10; id++) //Check every slot
|
||||
for (int id = 2; id < 10; id++) // Check every slot
|
||||
{
|
||||
if (canCook())
|
||||
{
|
||||
if (canCook()) {
|
||||
ItemStack result = getResultFor(inventory[id]);
|
||||
if (result != null)
|
||||
{
|
||||
if (result != null) {
|
||||
int ids = 2;
|
||||
boolean placed = false;
|
||||
while (ids < 10 && !placed) //Try to merge stacks first
|
||||
while (ids < 10 && !placed) // Try to merge stacks first
|
||||
{
|
||||
if (inventory[ids] != null && inventory[ids].isItemEqual(result) && inventory[ids].stackSize < inventory[ids].getMaxStackSize())
|
||||
{
|
||||
if (inventory[ids].stackSize + result.stackSize <= inventory[ids].getMaxStackSize())
|
||||
{
|
||||
if (inventory[ids] != null
|
||||
&& inventory[ids].isItemEqual(result)
|
||||
&& inventory[ids].stackSize < inventory[ids].getMaxStackSize()) {
|
||||
if (inventory[ids].stackSize + result.stackSize <= inventory[ids].getMaxStackSize()) {
|
||||
inventory[ids].stackSize += result.stackSize;
|
||||
placed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
int decrement = inventory[ids].getMaxStackSize() - inventory[ids].stackSize;
|
||||
inventory[ids].stackSize = inventory[ids].getMaxStackSize();
|
||||
result.stackSize -= decrement;
|
||||
@@ -160,127 +132,101 @@ public class FrypanLogic extends EquipLogic implements IActiveLogic
|
||||
}
|
||||
|
||||
ids = 2;
|
||||
while (!placed && ids < 10) //Place remaining in slot
|
||||
while (!placed && ids < 10) // Place remaining in slot
|
||||
{
|
||||
if (inventory[ids] == null)
|
||||
{
|
||||
if (inventory[ids] == null) {
|
||||
inventory[ids] = result;
|
||||
placed = true;
|
||||
}
|
||||
ids++;
|
||||
}
|
||||
|
||||
if (placed)
|
||||
decrStackSize(id, 1);
|
||||
if (placed) decrStackSize(id, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canCook ()
|
||||
{
|
||||
for (int id = 2; id < 10; id++)
|
||||
{
|
||||
if (inventory[id] == null) //Nothing here!
|
||||
continue;
|
||||
public boolean canCook() {
|
||||
for (int id = 2; id < 10; id++) {
|
||||
if (inventory[id] == null) // Nothing here!
|
||||
continue;
|
||||
|
||||
ItemStack result = getResultFor(inventory[id]);
|
||||
if (result == null) //Doesn't cook into anything
|
||||
continue;
|
||||
if (result == null) // Doesn't cook into anything
|
||||
continue;
|
||||
|
||||
for (int slotid = 2; slotid < 10; slotid++)
|
||||
{
|
||||
if (inventory[slotid] == null)
|
||||
return true;
|
||||
|
||||
else if (inventory[slotid].isItemEqual(result) && inventory[slotid].stackSize + result.stackSize <= inventory[slotid].getMaxStackSize())
|
||||
for (int slotid = 2; slotid < 10; slotid++) {
|
||||
if (inventory[slotid] == null) return true;
|
||||
else if (inventory[slotid].isItemEqual(result)
|
||||
&& inventory[slotid].stackSize + result.stackSize <= inventory[slotid].getMaxStackSize())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isBurning ()
|
||||
{
|
||||
public boolean isBurning() {
|
||||
return fuel > 0;
|
||||
}
|
||||
|
||||
public ItemStack getResultFor (ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
public ItemStack getResultFor(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack);
|
||||
if (result != null && result.getItem() instanceof ItemFood) //Only valid for food
|
||||
return result.copy();
|
||||
if (result != null && result.getItem() instanceof ItemFood) // Only valid for food
|
||||
return result.copy();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getItemBurnTime (ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
public static int getItemBurnTime(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (stack.getItem() instanceof ItemBlock && BlockUtils.getBlockFromItem(item) != null)
|
||||
{
|
||||
if (stack.getItem() instanceof ItemBlock && BlockUtils.getBlockFromItem(item) != null) {
|
||||
Block block = BlockUtils.getBlockFromItem(item);
|
||||
|
||||
if (block == Blocks.wooden_slab)
|
||||
{
|
||||
if (block == Blocks.wooden_slab) {
|
||||
return 150;
|
||||
}
|
||||
|
||||
if (block == Blocks.log)
|
||||
{
|
||||
if (block == Blocks.log) {
|
||||
return 2400;
|
||||
}
|
||||
|
||||
if (block.getMaterial() == Material.wood)
|
||||
{
|
||||
if (block.getMaterial() == Material.wood) {
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item == Items.stick)
|
||||
return 100;
|
||||
if (item == Items.coal)
|
||||
return 800;
|
||||
if (item == Items.lava_bucket)
|
||||
return 20000;
|
||||
if (new ItemStack(item).equals(new ItemStack(Blocks.sapling)))
|
||||
return 100;
|
||||
if (item == Items.blaze_rod)
|
||||
return 2400;
|
||||
if (item instanceof ItemTool
|
||||
&& ((ItemTool) item).getToolMaterialName().equals("WOOD")) return 200;
|
||||
if (item instanceof ItemSword
|
||||
&& ((ItemSword) item).getToolMaterialName().equals("WOOD")) return 200;
|
||||
if (item instanceof ItemHoe
|
||||
&& ((ItemHoe) item).getToolMaterialName().equals("WOOD")) return 200;
|
||||
if (item == Items.stick) return 100;
|
||||
if (item == Items.coal) return 800;
|
||||
if (item == Items.lava_bucket) return 20000;
|
||||
if (new ItemStack(item).equals(new ItemStack(Blocks.sapling))) return 100;
|
||||
if (item == Items.blaze_rod) return 2400;
|
||||
return GameRegistry.getFuelValue(stack);
|
||||
}
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tags) {
|
||||
super.readFromNBT(tags);
|
||||
active = tags.getBoolean("Active");
|
||||
fuel = tags.getInteger("Fuel");
|
||||
fuelGague = tags.getInteger("FuelGague");
|
||||
}
|
||||
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound tags) {
|
||||
super.writeToNBT(tags);
|
||||
tags.setBoolean("Active", active);
|
||||
tags.setInteger("Fuel", fuel);
|
||||
@@ -288,30 +234,23 @@ public class FrypanLogic extends EquipLogic implements IActiveLogic
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
|
||||
return new FrypanContainer(inventoryplayer.player, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
public String getInventoryName() {
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
public boolean hasCustomInventoryName() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
}
|
||||
public void closeInventory() {}
|
||||
}
|
||||
@@ -27,55 +27,46 @@ import tconstruct.tools.inventory.FurnaceContainer;
|
||||
* 3-16: Chest
|
||||
*/
|
||||
|
||||
public class FurnaceLogic extends InventoryLogic implements IActiveLogic, IFacingLogic, ISidedInventory
|
||||
{
|
||||
public class FurnaceLogic extends InventoryLogic implements IActiveLogic, IFacingLogic, ISidedInventory {
|
||||
boolean active = false;
|
||||
public int fuel;
|
||||
public int fuelGague;
|
||||
public int progress;
|
||||
public int fuelScale = 200;
|
||||
byte direction;
|
||||
private static final int[] slots_top = new int[] { 0 };
|
||||
private static final int[] slots_bottom = new int[] { 2, 1 };
|
||||
private static final int[] slots_sides = new int[] { 1 };
|
||||
private static final int[] slots_top = new int[] {0};
|
||||
private static final int[] slots_bottom = new int[] {2, 1};
|
||||
private static final int[] slots_sides = new int[] {1};
|
||||
|
||||
public FurnaceLogic()
|
||||
{
|
||||
public FurnaceLogic() {
|
||||
super(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
public String getDefaultName() {
|
||||
return "container.furnace";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive ()
|
||||
{
|
||||
public boolean getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive (boolean flag)
|
||||
{
|
||||
public void setActive(boolean flag) {
|
||||
active = flag;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/* Fuel gauge */
|
||||
public int gaugeProgressScaled (int scale)
|
||||
{
|
||||
public int gaugeProgressScaled(int scale) {
|
||||
return (progress * scale) / fuelScale;
|
||||
}
|
||||
|
||||
public int gaugeFuelScaled (int scale)
|
||||
{
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
public int gaugeFuelScaled(int scale) {
|
||||
if (fuelGague == 0) {
|
||||
fuelGague = fuel;
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
if (fuelGague == 0) {
|
||||
fuelGague = fuelScale;
|
||||
}
|
||||
}
|
||||
@@ -84,175 +75,133 @@ public class FurnaceLogic extends InventoryLogic implements IActiveLogic, IFacin
|
||||
|
||||
/* Item cooking */
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
public void updateEntity() {
|
||||
boolean burning = isBurning();
|
||||
boolean updateInventory = false;
|
||||
if (fuel <= 0 && canSmelt())
|
||||
{
|
||||
if (fuel <= 0 && canSmelt()) {
|
||||
fuel = fuelGague = (int) (getItemBurnTime(inventory[1]));
|
||||
if (fuel > 0)
|
||||
{
|
||||
if (fuel > 0) {
|
||||
if (inventory[1].getItem().hasContainerItem()) // Fuel slot
|
||||
{
|
||||
inventory[1] = new ItemStack(inventory[1].getItem().getContainerItem());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
inventory[1].stackSize--;
|
||||
}
|
||||
if (inventory[1].stackSize <= 0)
|
||||
{
|
||||
if (inventory[1].stackSize <= 0) {
|
||||
inventory[1] = null;
|
||||
}
|
||||
updateInventory = true;
|
||||
}
|
||||
}
|
||||
if (isBurning() && canSmelt())
|
||||
{
|
||||
if (isBurning() && canSmelt()) {
|
||||
progress++;
|
||||
if (progress >= fuelScale)
|
||||
{
|
||||
if (progress >= fuelScale) {
|
||||
progress = 0;
|
||||
cookItems();
|
||||
updateInventory = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
progress = 0;
|
||||
}
|
||||
if (fuel > 0)
|
||||
{
|
||||
if (fuel > 0) {
|
||||
fuel--;
|
||||
}
|
||||
if (burning != isBurning())
|
||||
{
|
||||
if (burning != isBurning()) {
|
||||
setActive(isBurning());
|
||||
updateInventory = true;
|
||||
}
|
||||
if (updateInventory)
|
||||
{
|
||||
if (updateInventory) {
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void cookItems ()
|
||||
{
|
||||
if (this.canSmelt())
|
||||
{
|
||||
public void cookItems() {
|
||||
if (this.canSmelt()) {
|
||||
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]);
|
||||
|
||||
if (this.inventory[2] == null)
|
||||
{
|
||||
if (this.inventory[2] == null) {
|
||||
this.inventory[2] = itemstack.copy();
|
||||
}
|
||||
else if (this.inventory[2].isItemEqual(itemstack))
|
||||
{
|
||||
} else if (this.inventory[2].isItemEqual(itemstack)) {
|
||||
inventory[2].stackSize += itemstack.stackSize;
|
||||
}
|
||||
|
||||
--this.inventory[0].stackSize;
|
||||
|
||||
if (this.inventory[0].stackSize <= 0)
|
||||
{
|
||||
if (this.inventory[0].stackSize <= 0) {
|
||||
this.inventory[0] = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean canSmelt ()
|
||||
{
|
||||
public boolean canSmelt() {
|
||||
if (inventory[0] == null) // Nothing here!
|
||||
return false;
|
||||
else
|
||||
{
|
||||
return false;
|
||||
else {
|
||||
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]);
|
||||
if (itemstack == null)
|
||||
return false;
|
||||
if (this.inventory[2] == null)
|
||||
return true;
|
||||
if (!this.inventory[2].isItemEqual(itemstack))
|
||||
return false;
|
||||
if (itemstack == null) return false;
|
||||
if (this.inventory[2] == null) return true;
|
||||
if (!this.inventory[2].isItemEqual(itemstack)) return false;
|
||||
int result = inventory[2].stackSize + itemstack.stackSize;
|
||||
return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBurning ()
|
||||
{
|
||||
public boolean isBurning() {
|
||||
return fuel > 0;
|
||||
}
|
||||
|
||||
public ItemStack getResultFor (ItemStack stack)
|
||||
{
|
||||
public ItemStack getResultFor(ItemStack stack) {
|
||||
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack);
|
||||
if (result != null) // Only valid for food
|
||||
return result.copy();
|
||||
return result.copy();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getItemBurnTime (ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
public static int getItemBurnTime(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (stack.getItem() instanceof ItemBlock && BlockUtils.getBlockFromItem(item) != null)
|
||||
{
|
||||
if (stack.getItem() instanceof ItemBlock && BlockUtils.getBlockFromItem(item) != null) {
|
||||
Block block = BlockUtils.getBlockFromItem(item);
|
||||
|
||||
if (block == Blocks.wooden_slab)
|
||||
{
|
||||
if (block == Blocks.wooden_slab) {
|
||||
return 150;
|
||||
}
|
||||
|
||||
if (block == Blocks.log)
|
||||
{
|
||||
if (block == Blocks.log) {
|
||||
return 1200;
|
||||
}
|
||||
|
||||
if (block.getMaterial() == Material.wood)
|
||||
{
|
||||
if (block.getMaterial() == Material.wood) {
|
||||
return 300;
|
||||
}
|
||||
|
||||
if (block == Blocks.coal_block)
|
||||
{
|
||||
if (block == Blocks.coal_block) {
|
||||
return 16000;
|
||||
}
|
||||
}
|
||||
|
||||
if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item == Items.stick)
|
||||
return 100;
|
||||
if (item == Items.coal)
|
||||
return 1600;
|
||||
if (item == Items.lava_bucket)
|
||||
return 20000;
|
||||
if (item == new ItemStack(Blocks.sapling).getItem())
|
||||
return 100;
|
||||
if (item == Items.blaze_rod)
|
||||
return 2400;
|
||||
if (item instanceof ItemTool
|
||||
&& ((ItemTool) item).getToolMaterialName().equals("WOOD")) return 200;
|
||||
if (item instanceof ItemSword
|
||||
&& ((ItemSword) item).getToolMaterialName().equals("WOOD")) return 200;
|
||||
if (item instanceof ItemHoe
|
||||
&& ((ItemHoe) item).getToolMaterialName().equals("WOOD")) return 200;
|
||||
if (item == Items.stick) return 100;
|
||||
if (item == Items.coal) return 1600;
|
||||
if (item == Items.lava_bucket) return 20000;
|
||||
if (item == new ItemStack(Blocks.sapling).getItem()) return 100;
|
||||
if (item == Items.blaze_rod) return 2400;
|
||||
return GameRegistry.getFuelValue(stack);
|
||||
}
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tags) {
|
||||
super.readFromNBT(tags);
|
||||
active = tags.getBoolean("Active");
|
||||
fuel = tags.getInteger("Fuel");
|
||||
@@ -261,140 +210,118 @@ public class FurnaceLogic extends InventoryLogic implements IActiveLogic, IFacin
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound tags) {
|
||||
super.writeToNBT(tags);
|
||||
tags.setInteger("Fuel", fuel);
|
||||
tags.setInteger("FuelGague", fuelGague);
|
||||
writeNetworkNBT(tags);
|
||||
}
|
||||
|
||||
public void readNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void readNetworkNBT(NBTTagCompound tags) {
|
||||
active = tags.getBoolean("Active");
|
||||
direction = tags.getByte("Direction");
|
||||
}
|
||||
|
||||
public void writeNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void writeNetworkNBT(NBTTagCompound tags) {
|
||||
tags.setBoolean("Active", active);
|
||||
tags.setByte("Direction", direction);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeNetworkNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
|
||||
readNetworkNBT(packet.func_148857_g());
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
|
||||
return new FurnaceContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getRenderDirection ()
|
||||
{
|
||||
public byte getRenderDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getForgeDirection ()
|
||||
{
|
||||
public ForgeDirection getForgeDirection() {
|
||||
return ForgeDirection.VALID_DIRECTIONS[direction];
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setDirection (int side)
|
||||
{
|
||||
public void setDirection(int side) {
|
||||
// Nope!
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setDirection (float yaw, float pitch, EntityLivingBase player)
|
||||
{
|
||||
public void setDirection(float yaw, float pitch, EntityLivingBase player) {
|
||||
int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3;
|
||||
switch (facing)
|
||||
{
|
||||
case 0:
|
||||
direction = 2;
|
||||
break;
|
||||
switch (facing) {
|
||||
case 0:
|
||||
direction = 2;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
direction = 5;
|
||||
break;
|
||||
case 1:
|
||||
direction = 5;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
direction = 3;
|
||||
break;
|
||||
case 2:
|
||||
direction = 3;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
direction = 4;
|
||||
break;
|
||||
case 3:
|
||||
direction = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
public String getInventoryName() {
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
public void closeInventory() {}
|
||||
|
||||
public static boolean isItemFuel (ItemStack par0ItemStack)
|
||||
{
|
||||
public static boolean isItemFuel(ItemStack par0ItemStack) {
|
||||
return getItemBurnTime(par0ItemStack) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot (int par1, ItemStack par2ItemStack)
|
||||
{
|
||||
public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) {
|
||||
return par1 == 2 ? false : (par1 == 1 ? isItemFuel(par2ItemStack) : true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int par1)
|
||||
{
|
||||
public int[] getAccessibleSlotsFromSide(int par1) {
|
||||
return par1 == 0 ? slots_bottom : (par1 == 1 ? slots_top : slots_sides);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int par1, ItemStack par2ItemStack, int par3)
|
||||
{
|
||||
public boolean canInsertItem(int par1, ItemStack par2ItemStack, int par3) {
|
||||
return this.isItemValidForSlot(par1, par2ItemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int par1, ItemStack par2ItemStack, int par3)
|
||||
{
|
||||
public boolean canExtractItem(int par1, ItemStack par2ItemStack, int par3) {
|
||||
return par3 != 0 || par1 != 1 || par2ItemStack.getItem() == Items.bucket;
|
||||
}
|
||||
}
|
||||
@@ -11,33 +11,26 @@ import tconstruct.library.crafting.PatternBuilder;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import tconstruct.tools.inventory.*;
|
||||
|
||||
public class PartBuilderLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
public class PartBuilderLogic extends InventoryLogic implements ISidedInventory {
|
||||
boolean craftedTop;
|
||||
boolean craftedBottom;
|
||||
|
||||
public PartBuilderLogic()
|
||||
{
|
||||
public PartBuilderLogic() {
|
||||
super(10);
|
||||
craftedTop = false;
|
||||
craftedBottom = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
public String getDefaultName() {
|
||||
return "toolstation.parts";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++)
|
||||
{
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++)
|
||||
{
|
||||
for (int yPos = y - 1; yPos <= y + 1; yPos++)
|
||||
{
|
||||
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++) {
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++) {
|
||||
for (int yPos = y - 1; yPos <= y + 1; yPos++) {
|
||||
TileEntity tile = world.getTileEntity(xPos, yPos, zPos);
|
||||
if (tile != null && tile instanceof PatternChestLogic && (x == xPos || z == zPos))
|
||||
return new PartCrafterChestContainer(inventoryplayer, this, (PatternChestLogic) tile);
|
||||
@@ -48,172 +41,132 @@ public class PartBuilderLogic extends InventoryLogic implements ISidedInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropInventorySlot (int slot)
|
||||
{
|
||||
public boolean canDropInventorySlot(int slot) {
|
||||
return slot <= 3; // 0-3 = only drop input slots
|
||||
}
|
||||
|
||||
//Called when emptying a slot, not when another item is placed in it
|
||||
// Called when emptying a slot, not when another item is placed in it
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slotID, int quantity)
|
||||
{
|
||||
public ItemStack decrStackSize(int slotID, int quantity) {
|
||||
ItemStack returnStack = super.decrStackSize(slotID, quantity);
|
||||
tryBuildPart(slotID);
|
||||
return returnStack;
|
||||
}
|
||||
|
||||
public void tryBuildPart (int slotID)
|
||||
{
|
||||
if (slotID == 4 || slotID == 5)
|
||||
{
|
||||
if (!craftedTop && inventory[0] != null)
|
||||
{
|
||||
public void tryBuildPart(int slotID) {
|
||||
if (slotID == 4 || slotID == 5) {
|
||||
if (!craftedTop && inventory[0] != null) {
|
||||
int value = PatternBuilder.instance.getPartValue(inventory[2]);
|
||||
IPattern item = (IPattern) inventory[0].getItem();
|
||||
int cost = item != null ? item.getPatternCost(inventory[0]) : 0;
|
||||
if (value > 0 && cost > 0)
|
||||
{
|
||||
if (value > 0 && cost > 0) {
|
||||
int decrease = cost / value;
|
||||
if (cost % value != 0)
|
||||
decrease++;
|
||||
super.decrStackSize(2, decrease); //Call super to avoid crafting again
|
||||
if (cost % value != 0) decrease++;
|
||||
super.decrStackSize(2, decrease); // Call super to avoid crafting again
|
||||
}
|
||||
}
|
||||
|
||||
if (inventory[4] != null || inventory[5] != null)
|
||||
craftedTop = true;
|
||||
else
|
||||
craftedTop = false;
|
||||
if (inventory[4] != null || inventory[5] != null) craftedTop = true;
|
||||
else craftedTop = false;
|
||||
}
|
||||
|
||||
if (!craftedTop)
|
||||
buildTopPart();
|
||||
if (!craftedTop) buildTopPart();
|
||||
|
||||
if (slotID == 6 || slotID == 7)
|
||||
{
|
||||
if (!craftedBottom && inventory[1] != null)
|
||||
{
|
||||
if (slotID == 6 || slotID == 7) {
|
||||
if (!craftedBottom && inventory[1] != null) {
|
||||
int value = PatternBuilder.instance.getPartValue(inventory[3]);
|
||||
IPattern item = (IPattern) inventory[1].getItem();
|
||||
int cost = item != null ? item.getPatternCost(inventory[1]) : 0;
|
||||
if (value > 0 && cost > 0)
|
||||
{
|
||||
if (value > 0 && cost > 0) {
|
||||
int decrease = cost / value;
|
||||
if (cost % value != 0)
|
||||
decrease++;
|
||||
super.decrStackSize(3, decrease); //Call super to avoid crafting again
|
||||
if (cost % value != 0) decrease++;
|
||||
super.decrStackSize(3, decrease); // Call super to avoid crafting again
|
||||
}
|
||||
}
|
||||
|
||||
if (inventory[6] != null || inventory[7] != null)
|
||||
craftedBottom = true;
|
||||
else
|
||||
craftedBottom = false;
|
||||
if (inventory[6] != null || inventory[7] != null) craftedBottom = true;
|
||||
else craftedBottom = false;
|
||||
}
|
||||
|
||||
if (!craftedBottom)
|
||||
buildBottomPart();
|
||||
if (!craftedBottom) buildBottomPart();
|
||||
}
|
||||
|
||||
//Called when a slot has something placed into it.
|
||||
// Called when a slot has something placed into it.
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
public void setInventorySlotContents(int slot, ItemStack itemstack) {
|
||||
super.setInventorySlotContents(slot, itemstack);
|
||||
if ((slot == 0 || slot == 2) && !craftedTop)
|
||||
buildTopPart();
|
||||
if ((slot == 1 || slot == 3) && !craftedBottom)
|
||||
buildBottomPart();
|
||||
if ((slot == 0 || slot == 2) && !craftedTop) buildTopPart();
|
||||
if ((slot == 1 || slot == 3) && !craftedBottom) buildBottomPart();
|
||||
}
|
||||
|
||||
void buildTopPart ()
|
||||
{
|
||||
void buildTopPart() {
|
||||
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[2], inventory[0], inventory[1]);
|
||||
if (parts != null)
|
||||
{
|
||||
if (parts != null) {
|
||||
inventory[4] = parts[0];
|
||||
inventory[5] = parts[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
inventory[4] = inventory[5] = null;
|
||||
}
|
||||
}
|
||||
|
||||
void buildBottomPart ()
|
||||
{
|
||||
void buildBottomPart() {
|
||||
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[3], inventory[1], inventory[0]);
|
||||
if (parts != null)
|
||||
{
|
||||
if (parts != null) {
|
||||
inventory[6] = parts[0];
|
||||
inventory[7] = parts[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
inventory[6] = inventory[7] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tags) {
|
||||
super.readFromNBT(tags);
|
||||
craftedTop = tags.getBoolean("CraftedTop");
|
||||
craftedBottom = tags.getBoolean("CraftedBottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound tags) {
|
||||
super.writeToNBT(tags);
|
||||
tags.setBoolean("CraftedTop", craftedTop);
|
||||
tags.setBoolean("CraftedBottom", craftedBottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
public String getInventoryName() {
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
public void closeInventory() {}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,40 +8,33 @@ import net.minecraft.world.World;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import tconstruct.tools.inventory.PatternChestContainer;
|
||||
|
||||
public class PatternChestLogic extends InventoryLogic
|
||||
{
|
||||
public PatternChestLogic()
|
||||
{
|
||||
public class PatternChestLogic extends InventoryLogic {
|
||||
public PatternChestLogic() {
|
||||
super(30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
public String getDefaultName() {
|
||||
return "toolstation.patternholder";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
|
||||
return new PatternChestContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
public String getInventoryName() {
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
public boolean hasCustomInventoryName() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -51,12 +44,8 @@ public class PatternChestLogic extends InventoryLogic
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
}
|
||||
public void closeInventory() {}
|
||||
}
|
||||
@@ -10,30 +10,25 @@ import net.minecraft.world.World;
|
||||
import tconstruct.library.crafting.StencilBuilder;
|
||||
import tconstruct.tools.inventory.PatternShaperContainer;
|
||||
|
||||
public class StencilTableLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
public class StencilTableLogic extends InventoryLogic implements ISidedInventory {
|
||||
private ItemStack selectedStack;
|
||||
|
||||
public StencilTableLogic()
|
||||
{
|
||||
public StencilTableLogic() {
|
||||
super(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
public String getDefaultName() {
|
||||
return "toolstation.PatternShaper";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
|
||||
return new PatternShaperContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@@ -45,67 +40,49 @@ public class StencilTableLogic extends InventoryLogic implements ISidedInventory
|
||||
super.onInventoryChanged();
|
||||
}*/
|
||||
|
||||
public void setSelectedPattern (ItemStack stack)
|
||||
{
|
||||
public void setSelectedPattern(ItemStack stack) {
|
||||
selectedStack = stack;
|
||||
this.setInventorySlotContents(1, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
public void setInventorySlotContents(int slot, ItemStack itemstack) {
|
||||
super.setInventorySlotContents(slot, itemstack);
|
||||
if (slot == 0) {
|
||||
if (itemstack != null && StencilBuilder.isBlank(itemstack))
|
||||
{
|
||||
if (itemstack != null && StencilBuilder.isBlank(itemstack)) {
|
||||
super.setInventorySlotContents(1, selectedStack);
|
||||
}
|
||||
else if (itemstack!=null)
|
||||
{
|
||||
ItemStack cpy=itemstack.copy();
|
||||
cpy.stackSize=1;
|
||||
} else if (itemstack != null) {
|
||||
ItemStack cpy = itemstack.copy();
|
||||
cpy.stackSize = 1;
|
||||
super.setInventorySlotContents(1, cpy);
|
||||
}
|
||||
else
|
||||
{
|
||||
super.setInventorySlotContents(1,null);
|
||||
} else {
|
||||
super.setInventorySlotContents(1, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
if (slot == 1)
|
||||
{
|
||||
public ItemStack decrStackSize(int slot, int quantity) {
|
||||
if (slot == 1) {
|
||||
super.decrStackSize(0, 1);
|
||||
if (inventory[0] == null)
|
||||
return super.decrStackSize(slot, quantity);
|
||||
else
|
||||
return inventory[1].copy();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inventory[0] == null) return super.decrStackSize(slot, quantity);
|
||||
else return inventory[1].copy();
|
||||
} else {
|
||||
ItemStack ret = super.decrStackSize(slot, quantity);
|
||||
if (inventory[0] == null)
|
||||
super.decrStackSize(1, 1);
|
||||
if (inventory[0] == null) super.decrStackSize(1, 1);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public void altDecrStackSize (int slot, int quantity)
|
||||
{
|
||||
if (inventory[slot] != null)
|
||||
{
|
||||
if (inventory[slot].stackSize <= quantity)
|
||||
{
|
||||
public void altDecrStackSize(int slot, int quantity) {
|
||||
if (inventory[slot] != null) {
|
||||
if (inventory[slot].stackSize <= quantity) {
|
||||
ItemStack stack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return;
|
||||
}
|
||||
ItemStack split = inventory[slot].splitStack(quantity);
|
||||
if (inventory[slot].stackSize == 0)
|
||||
{
|
||||
if (inventory[slot].stackSize == 0) {
|
||||
inventory[slot] = null;
|
||||
}
|
||||
return;
|
||||
@@ -113,51 +90,39 @@ public class StencilTableLogic extends InventoryLogic implements ISidedInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropInventorySlot (int slot)
|
||||
{
|
||||
if (slot == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
public boolean canDropInventorySlot(int slot) {
|
||||
if (slot == 0) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
public String getInventoryName() {
|
||||
return StatCollector.translateToLocal("toolstation.PatternShaper");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
public boolean hasCustomInventoryName() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
public void closeInventory() {}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
}
|
||||
public void openInventory() {}
|
||||
}
|
||||
@@ -11,62 +11,53 @@ import tconstruct.tools.inventory.ToolForgeContainer;
|
||||
/* Simple class for storing items in the block
|
||||
*/
|
||||
|
||||
public class ToolForgeLogic extends ToolStationLogic implements ISidedInventory
|
||||
{
|
||||
public class ToolForgeLogic extends ToolStationLogic implements ISidedInventory {
|
||||
ItemStack previousTool;
|
||||
String toolName;
|
||||
|
||||
public ToolForgeLogic()
|
||||
{
|
||||
public ToolForgeLogic() {
|
||||
super(6);
|
||||
toolName = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
public String getDefaultName() {
|
||||
return "crafters.ToolForge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
|
||||
return new ToolForgeContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTool (String name)
|
||||
{
|
||||
public void buildTool(String name) {
|
||||
ItemStack output = null;
|
||||
if (inventory[1] != null)
|
||||
{
|
||||
if (inventory[1].getItem() instanceof IModifyable) //Modify item
|
||||
if (inventory[1] != null) {
|
||||
if (inventory[1].getItem() instanceof IModifyable) // Modify item
|
||||
{
|
||||
if (inventory[2] == null && inventory[3] == null && inventory[4] == null)
|
||||
output = inventory[1].copy();
|
||||
else
|
||||
{
|
||||
output = ModifyBuilder.instance.modifyItem(inventory[1], new ItemStack[] { inventory[2], inventory[3], inventory[4] });
|
||||
if (inventory[2] == null && inventory[3] == null && inventory[4] == null) output = inventory[1].copy();
|
||||
else {
|
||||
output = ModifyBuilder.instance.modifyItem(
|
||||
inventory[1], new ItemStack[] {inventory[2], inventory[3], inventory[4]});
|
||||
}
|
||||
}
|
||||
else
|
||||
//Build new item
|
||||
} else
|
||||
// Build new item
|
||||
{
|
||||
toolName = name;
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(inventory[1], inventory[2], inventory[3], inventory[4], name);
|
||||
if (inventory[0] == null)
|
||||
ItemStack tool =
|
||||
ToolBuilder.instance.buildTool(inventory[1], inventory[2], inventory[3], inventory[4], name);
|
||||
if (inventory[0] == null) output = tool;
|
||||
else if (tool != null) {
|
||||
// NBTTagCompound tags = tool.getTagCompound();
|
||||
// if (!tags.getCompoundTag(((IModifyable) tool.getItem()).getBaseTagName()).hasKey("Built"))
|
||||
// {
|
||||
output = tool;
|
||||
else if (tool != null)
|
||||
{
|
||||
//NBTTagCompound tags = tool.getTagCompound();
|
||||
//if (!tags.getCompoundTag(((IModifyable) tool.getItem()).getBaseTagName()).hasKey("Built"))
|
||||
//{
|
||||
output = tool;
|
||||
//}
|
||||
// }
|
||||
}
|
||||
}
|
||||
if (!name.equals("")) //Name item
|
||||
output = tryRenameTool(output, name);
|
||||
if (!name.equals("")) // Name item
|
||||
output = tryRenameTool(output, name);
|
||||
}
|
||||
inventory[0] = output;
|
||||
}
|
||||
@@ -85,4 +76,4 @@ public class ToolForgeLogic extends ToolStationLogic implements ISidedInventory
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -16,129 +16,105 @@ import tconstruct.tools.inventory.ToolStationContainer;
|
||||
/* Simple class for storing items in the block
|
||||
*/
|
||||
|
||||
public class ToolStationLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
public class ToolStationLogic extends InventoryLogic implements ISidedInventory {
|
||||
public ItemStack previousTool;
|
||||
public String toolName;
|
||||
|
||||
public ToolStationLogic()
|
||||
{
|
||||
public ToolStationLogic() {
|
||||
super(4);
|
||||
toolName = "";
|
||||
}
|
||||
|
||||
public ToolStationLogic(int slots)
|
||||
{
|
||||
public ToolStationLogic(int slots) {
|
||||
super(slots);
|
||||
toolName = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropInventorySlot (int slot)
|
||||
{
|
||||
if (slot == 0)
|
||||
return false;
|
||||
public boolean canDropInventorySlot(int slot) {
|
||||
if (slot == 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing (int var1)
|
||||
{
|
||||
public ItemStack getStackInSlotOnClosing(int var1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
public String getDefaultName() {
|
||||
return "crafters.ToolStation";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
public Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z) {
|
||||
return new ToolStationContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty ()
|
||||
{
|
||||
public void markDirty() {
|
||||
buildTool(toolName);
|
||||
if (this.worldObj != null)
|
||||
{
|
||||
if (this.worldObj != null) {
|
||||
this.blockMetadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
|
||||
this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this);
|
||||
}
|
||||
}
|
||||
|
||||
public void buildTool (String name)
|
||||
{
|
||||
public void buildTool(String name) {
|
||||
ItemStack output = null;
|
||||
if (inventory[1] != null)
|
||||
{
|
||||
if (inventory[1].getItem() instanceof IModifyable) //Modify item
|
||||
if (inventory[1] != null) {
|
||||
if (inventory[1].getItem() instanceof IModifyable) // Modify item
|
||||
{
|
||||
if (inventory[2] == null && inventory[3] == null)
|
||||
output = inventory[1].copy();
|
||||
else
|
||||
{
|
||||
output = ModifyBuilder.instance.modifyItem(inventory[1], new ItemStack[] { inventory[2], inventory[3] });
|
||||
if (inventory[2] == null && inventory[3] == null) output = inventory[1].copy();
|
||||
else {
|
||||
output = ModifyBuilder.instance.modifyItem(
|
||||
inventory[1], new ItemStack[] {inventory[2], inventory[3]});
|
||||
}
|
||||
}
|
||||
else
|
||||
//Build new item
|
||||
} else
|
||||
// Build new item
|
||||
{
|
||||
toolName = name;
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(inventory[1], inventory[2], inventory[3], name);
|
||||
if (inventory[0] == null)
|
||||
output = tool;
|
||||
else if (tool != null)
|
||||
{
|
||||
if (inventory[0] == null) output = tool;
|
||||
else if (tool != null) {
|
||||
NBTTagCompound tags = tool.getTagCompound();
|
||||
if (!tags.getCompoundTag(((IModifyable) tool.getItem()).getBaseTagName()).hasKey("Built"))
|
||||
{
|
||||
if (!tags.getCompoundTag(((IModifyable) tool.getItem()).getBaseTagName())
|
||||
.hasKey("Built")) {
|
||||
output = tool;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!name.equals("")) //Name item
|
||||
output = tryRenameTool(output, name);
|
||||
if (!name.equals("")) // Name item
|
||||
output = tryRenameTool(output, name);
|
||||
}
|
||||
inventory[0] = output;
|
||||
}
|
||||
|
||||
public void setToolname (String name)
|
||||
{
|
||||
public void setToolname(String name) {
|
||||
toolName = name;
|
||||
buildTool(name);
|
||||
}
|
||||
|
||||
protected ItemStack tryRenameTool (ItemStack output, String name)
|
||||
{
|
||||
protected ItemStack tryRenameTool(ItemStack output, String name) {
|
||||
ItemStack temp;
|
||||
if (output != null)
|
||||
temp = output;
|
||||
else
|
||||
temp = inventory[1].copy();
|
||||
if (output != null) temp = output;
|
||||
else temp = inventory[1].copy();
|
||||
|
||||
if (temp == null) {
|
||||
return null; // output is null or not a tool :(
|
||||
}
|
||||
|
||||
NBTTagCompound tags = temp.getTagCompound();
|
||||
if (tags == null)
|
||||
{
|
||||
if (tags == null) {
|
||||
tags = new NBTTagCompound();
|
||||
temp.setTagCompound(tags);
|
||||
}
|
||||
|
||||
NBTTagCompound display = null;
|
||||
if (!(tags.hasKey("display")))
|
||||
display = new NBTTagCompound();
|
||||
else if (tags.getCompoundTag("display").hasKey("Name"))
|
||||
display = tags.getCompoundTag("display");
|
||||
if (!(tags.hasKey("display"))) display = new NBTTagCompound();
|
||||
else if (tags.getCompoundTag("display").hasKey("Name")) display = tags.getCompoundTag("display");
|
||||
|
||||
if (display == null)
|
||||
return output;
|
||||
if (display == null) return output;
|
||||
|
||||
boolean doRename = false;
|
||||
if (canRename(display, temp)) {
|
||||
@@ -147,15 +123,13 @@ public class ToolStationLogic extends InventoryLogic implements ISidedInventory
|
||||
// we only allow renaming with a nametag otherwise
|
||||
else if (!("\u00A7f" + name).equals(display.getString("Name")) && !name.equals(display.getString("Name"))) {
|
||||
int nametagCount = 0;
|
||||
for(int i = 0; i < inventory.length; i++)
|
||||
if(inventory[i] != null && inventory[i].getItem() == Items.name_tag)
|
||||
nametagCount++;
|
||||
for (int i = 0; i < inventory.length; i++)
|
||||
if (inventory[i] != null && inventory[i].getItem() == Items.name_tag) nametagCount++;
|
||||
|
||||
doRename = nametagCount == 1;
|
||||
}
|
||||
|
||||
if(!doRename)
|
||||
return output;
|
||||
if (!doRename) return output;
|
||||
|
||||
String dName = temp.getItem() instanceof IModifyable ? "\u00A7f" + name : name;
|
||||
display.setString("Name", dName);
|
||||
@@ -167,52 +141,42 @@ public class ToolStationLogic extends InventoryLogic implements ISidedInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
public String getInventoryName() {
|
||||
return "null";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
public void closeInventory() {}
|
||||
|
||||
public static boolean canRename(NBTTagCompound tags, ItemStack tool) {
|
||||
return !tags.hasKey("Name") || tags.getString("Name").equals("\u00A7f" + ToolBuilder.defaultToolName(tool));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user