mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-20 12:20:05 +00:00
Drawers, compacting drawers, and controller will all save a custom inventory name
This commit is contained in:
1 parent
534e040fe8
commit
94c2e91cd9
7 files changed
+54
-11
No files matched your search
@@ -1,8 +1,11 @@
|
||||
itemGroup.storageDrawers=Storage Drawers
|
||||
itemGroup.storageDrawersSorting=Storage Drawers - Sorting
|
||||
|
||||
container.drawers=Drawers
|
||||
storageDrawers.container.drawers=Drawers
|
||||
storageDrawers.container.compDrawers=Compacting Drawers
|
||||
storageDrawers.container.upgrades=Upgrades
|
||||
storageDrawers.container.controller=Drawer Controller
|
||||
storageDrawers.container.unboundSlave=Unbound Slave
|
||||
|
||||
storagedrawers.msg.maxUpgrades=This drawer cannot accept any more upgrades.
|
||||
|
||||
|
||||
@@ -90,6 +90,9 @@ public class BlockController extends BlockContainer implements INetworked
|
||||
break;
|
||||
}
|
||||
|
||||
if (itemStack.hasDisplayName())
|
||||
tile.setInventoryName(itemStack.getDisplayName());
|
||||
|
||||
if (world.isRemote) {
|
||||
tile.invalidate();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
|
||||
@@ -190,6 +190,9 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
|
||||
break;
|
||||
}
|
||||
|
||||
if (itemStack.hasDisplayName())
|
||||
tile.setInventoryName(itemStack.getDisplayName());
|
||||
|
||||
if (world.isRemote) {
|
||||
tile.invalidate();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
|
||||
@@ -18,6 +18,7 @@ import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.*;
|
||||
@@ -71,6 +72,8 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IS
|
||||
private long lastClickTime;
|
||||
private UUID lastClickUUID;
|
||||
|
||||
private String customName;
|
||||
|
||||
public TileEntityController () {
|
||||
invSlotList.add(new SlotRecord(null, 0));
|
||||
inventorySlots = new int[] { 0 };
|
||||
@@ -493,6 +496,9 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IS
|
||||
|
||||
setDirection(tag.getByte("Dir"));
|
||||
|
||||
if (tag.hasKey("CustomName", Constants.NBT.TAG_STRING))
|
||||
customName = tag.getString("CustomName");
|
||||
|
||||
if (worldObj != null && !worldObj.isRemote)
|
||||
updateCache();
|
||||
}
|
||||
@@ -502,6 +508,9 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IS
|
||||
super.writeToNBT(tag);
|
||||
|
||||
tag.setByte("Dir", (byte)direction);
|
||||
|
||||
if (hasCustomInventoryName())
|
||||
tag.setString("CustomName", customName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -643,16 +652,18 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IS
|
||||
inventory.markDirty();
|
||||
}
|
||||
|
||||
public void setInventoryName (String name) {
|
||||
customName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName () {
|
||||
// TODO
|
||||
return null;
|
||||
return hasCustomInventoryName() ? customName : "storageDrawers.container.controller";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName () {
|
||||
// TODO
|
||||
return false;
|
||||
return customName != null && customName.length() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,6 +52,8 @@ public abstract class TileEntityDrawers extends TileEntity implements IDrawerGro
|
||||
private long lastClickTime;
|
||||
private UUID lastClickUUID;
|
||||
|
||||
private String customName;
|
||||
|
||||
private NBTTagCompound failureSnapshot;
|
||||
|
||||
protected TileEntityDrawers (int drawerCount) {
|
||||
@@ -415,6 +417,9 @@ public abstract class TileEntityDrawers extends TileEntity implements IDrawerGro
|
||||
}
|
||||
|
||||
inventory = new StorageInventory(this, getSideManager(), this);
|
||||
|
||||
if (tag.hasKey("CustomName", Constants.NBT.TAG_STRING))
|
||||
customName = tag.getString("CustomName");
|
||||
}
|
||||
catch (Throwable t) {
|
||||
trapLoadFailure(t, tag);
|
||||
@@ -461,6 +466,9 @@ public abstract class TileEntityDrawers extends TileEntity implements IDrawerGro
|
||||
}
|
||||
|
||||
tag.setTag("Slots", slots);
|
||||
|
||||
if (hasCustomInventoryName())
|
||||
tag.setString("CustomName", customName);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
FMLLog.log(StorageDrawers.MOD_ID, Level.ERROR, t, "Tile Save Failure.");
|
||||
@@ -587,14 +595,18 @@ public abstract class TileEntityDrawers extends TileEntity implements IDrawerGro
|
||||
inventory.setInventorySlotContents(slot, stack);
|
||||
}
|
||||
|
||||
public void setInventoryName (String name) {
|
||||
customName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName () {
|
||||
return "container.drawers";
|
||||
return hasCustomInventoryName() ? customName : "storageDrawers.container.drawers";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName () {
|
||||
return inventory.hasCustomInventoryName();
|
||||
return customName != null && customName.length() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -154,6 +154,11 @@ public class TileEntityDrawersComp extends TileEntityDrawers
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName () {
|
||||
return hasCustomInventoryName() ? super.getInventoryName() : "storageDrawers.container.compDrawers";
|
||||
}
|
||||
|
||||
private void populateSlots (ItemStack stack) {
|
||||
int index = 0;
|
||||
|
||||
|
||||
@@ -164,14 +164,20 @@ public class TileEntitySlave extends TileEntity implements IDrawerGroup, ISidedI
|
||||
|
||||
@Override
|
||||
public String getInventoryName () {
|
||||
// TODO
|
||||
return null;
|
||||
TileEntityController controller = getController();
|
||||
if (controller == null || !controller.isValidSlave(selfCoord))
|
||||
return "storageDrawers.container.unboundSlave";
|
||||
|
||||
return controller.getInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName () {
|
||||
// TODO
|
||||
return false;
|
||||
TileEntityController controller = getController();
|
||||
if (controller == null || !controller.isValidSlave(selfCoord))
|
||||
return false;
|
||||
|
||||
return controller.hasCustomInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user