added renaming feature with quartz cutting knife

This commit is contained in:
James
2022-09-05 02:51:17 -06:00
committed by PrototypeTrousers
parent 2ea120e614
commit a9c891f69a
15 changed files with 250 additions and 9 deletions
@@ -33,7 +33,7 @@ import appeng.api.AEApi;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.items.contents.QuartzKnifeObj;
import appeng.bootstrap.contents.QuartzKnifeObj;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform;
@@ -0,0 +1,48 @@
package appeng.container.implementations;
import appeng.api.config.SecurityPermissions;
import appeng.api.parts.IPart;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.container.AEBaseContainer;
import appeng.helpers.ICustomNameObject;
import appeng.util.Platform;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ContainerRenamer extends AEBaseContainer {
private final ICustomNameObject namedObject;
@SideOnly(Side.CLIENT)
private MEGuiTextField textField;
public ContainerRenamer(InventoryPlayer ip, ICustomNameObject obj) {
super(ip, obj instanceof TileEntity ? (TileEntity) obj : null, obj instanceof IPart ? (IPart) obj : null);
namedObject = obj;
}
@SideOnly(Side.CLIENT)
public void setTextField(final MEGuiTextField name) {
this.textField = name;
if(getCustomName() != null) textField.setText(getCustomName());
}
public void setNewName(String newValue) {
this.namedObject.setCustomName(newValue);
}
@Override
public void setCustomName(final String customName) {
super.setCustomName(customName);
if(!Platform.isServer() && customName != null) textField.setText(customName);
}
@Override
public void detectAndSendChanges() {
verifyPermissions(SecurityPermissions.BUILD, false);
super.detectAndSendChanges();
if(!Platform.isServer() && getCustomName() != null) textField.setText(getCustomName());
}
}
@@ -45,7 +45,7 @@ import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.OptionalSlotFakeTypeOnly;
import appeng.container.slot.SlotFakeTypeOnly;
import appeng.container.slot.SlotRestrictedInput;
import appeng.items.contents.NetworkToolViewer;
import appeng.bootstrap.contents.NetworkToolViewer;
import appeng.items.tools.ToolNetworkTool;
import appeng.parts.automation.PartExportBus;
import appeng.util.Platform;