mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-22 13:09:53 +00:00
infinite loop fix & tool localization optimization (#167)
This commit is contained in:
1 parent
d6d7a699fd
commit
2a7e9b350a
5 files changed
+39
-58
No files matched your search
@@ -268,12 +268,7 @@ public class ToolBuilder {
|
||||
|
||||
if (name != null && !name.equals("")) {
|
||||
compound.setTag("display", new NBTTagCompound());
|
||||
compound.getCompoundTag("display").setString("Name", "\u00A7f" + name);
|
||||
}
|
||||
// set a nice default name
|
||||
else {
|
||||
compound.setTag("display", new NBTTagCompound());
|
||||
compound.getCompoundTag("display").setString("Name", "\u00A7f" + defaultToolName(headMat, item));
|
||||
compound.getCompoundTag("display").setString("Name", name);
|
||||
}
|
||||
|
||||
ToolCraftEvent.NormalTool event = new ToolCraftEvent.NormalTool(
|
||||
|
||||
@@ -822,4 +822,10 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IEq
|
||||
return curTags.equals(prevTags);
|
||||
}
|
||||
// end of TE support section
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
String name = ToolBuilder.defaultToolName(stack);
|
||||
return name != null ? name : super.getItemStackDisplayName(stack);
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,10 @@ import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.crafting.ModifyBuilder;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.modifier.IModifyable;
|
||||
import tconstruct.tools.inventory.ToolForgeContainer;
|
||||
import tconstruct.util.network.ToolStationPacket;
|
||||
|
||||
/*
|
||||
* Simple class for storing items in the block
|
||||
@@ -67,15 +65,5 @@ public class ToolForgeLogic extends ToolStationLogic implements ISidedInventory
|
||||
output = tryRenameTool(output, name);
|
||||
}
|
||||
inventory[0] = output;
|
||||
if (output != null && output.hasDisplayName()) {
|
||||
TConstruct.packetPipeline
|
||||
.sendToServer(new ToolStationPacket(xCoord, yCoord, zCoord, output.getDisplayName()));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* public void buildTool (String name) { toolName = name; ItemStack tool =
|
||||
* ToolBuilder.instance.buildTool(inventory[1], inventory[2], inventory[3], inventory[4], name); if (inventory[0] ==
|
||||
* null) inventory[0] = tool; else { NBTTagCompound tags = inventory[0].getTagCompound(); if
|
||||
* (!tags.getCompoundTag("InfiTool").hasKey("Built")) { inventory[0] = tool; } } }
|
||||
*/
|
||||
}
|
||||
@@ -9,12 +9,10 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.crafting.ModifyBuilder;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import tconstruct.library.modifier.IModifyable;
|
||||
import tconstruct.tools.inventory.ToolStationContainer;
|
||||
import tconstruct.util.network.ToolStationPacket;
|
||||
|
||||
/*
|
||||
* Simple class for storing items in the block
|
||||
@@ -55,9 +53,25 @@ public class ToolStationLogic extends InventoryLogic implements ISidedInventory
|
||||
return new ToolStationContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
super.setInventorySlotContents(slot, stack);
|
||||
if (slot != 0) {
|
||||
buildTool(toolName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
ItemStack itemstack = super.decrStackSize(slot, amount);
|
||||
if (slot != 0) {
|
||||
buildTool(toolName);
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
buildTool(toolName);
|
||||
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);
|
||||
@@ -91,10 +105,6 @@ public class ToolStationLogic extends InventoryLogic implements ISidedInventory
|
||||
output = tryRenameTool(output, name);
|
||||
}
|
||||
inventory[0] = output;
|
||||
if (output != null && output.hasDisplayName()) {
|
||||
TConstruct.packetPipeline
|
||||
.sendToServer(new ToolStationPacket(xCoord, yCoord, zCoord, output.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
public void setToolname(String name) {
|
||||
@@ -107,10 +117,6 @@ public class ToolStationLogic extends InventoryLogic implements ISidedInventory
|
||||
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) {
|
||||
tags = new NBTTagCompound();
|
||||
@@ -118,17 +124,16 @@ public class ToolStationLogic extends InventoryLogic implements ISidedInventory
|
||||
}
|
||||
|
||||
NBTTagCompound display = null;
|
||||
if (!(tags.hasKey("display"))) display = new NBTTagCompound();
|
||||
else if (tags.getCompoundTag("display").hasKey("Name")) display = tags.getCompoundTag("display");
|
||||
|
||||
if (display == null) return output;
|
||||
if (tags.hasKey("display") && tags.getCompoundTag("display").hasKey("Name"))
|
||||
display = tags.getCompoundTag("display");
|
||||
|
||||
boolean doRename = false;
|
||||
if (canRename(display, temp)) {
|
||||
if (display == null) {
|
||||
display = new NBTTagCompound();
|
||||
doRename = true;
|
||||
}
|
||||
// we only allow renaming with a nametag otherwise
|
||||
else if (!("\u00A7f" + name).equals(display.getString("Name")) && !name.equals(display.getString("Name"))) {
|
||||
else if (!name.equals(display.getString("Name"))) {
|
||||
int nametagCount = 0;
|
||||
for (ItemStack itemStack : inventory)
|
||||
if (itemStack != null && itemStack.getItem() == Items.name_tag) nametagCount++;
|
||||
@@ -138,8 +143,7 @@ public class ToolStationLogic extends InventoryLogic implements ISidedInventory
|
||||
|
||||
if (!doRename) return output;
|
||||
|
||||
String dName = temp.getItem() instanceof IModifyable ? "\u00A7f" + name : name;
|
||||
display.setString("Name", dName);
|
||||
display.setString("Name", name);
|
||||
tags.setTag("display", display);
|
||||
temp.setRepairCost(2);
|
||||
output = temp;
|
||||
|
||||
Reference in new issue
Block a user