mirror of
https://github.com/GTNewHorizons/WirelessCraftingTerminal.git
synced 2026-11-18 03:15:15 +00:00
move Gui IDs from main mod file to Reference.java
This commit is contained in:
1 parent
d194c95925
commit
fe5999606d
13 files changed
+150
-208
No files matched your search
@@ -12,7 +12,6 @@ import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.widgets.GuiTabButton;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftAmount;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
|
||||
@@ -21,10 +20,9 @@ import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchGuis;
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
|
||||
public class GuiCraftAmount extends WCTBaseGui
|
||||
{
|
||||
public class GuiCraftAmount extends WCTBaseGui {
|
||||
private GuiNumberBox amountToCraft;
|
||||
private GuiTabButton originalGuiBtn;
|
||||
|
||||
@@ -38,89 +36,75 @@ public class GuiCraftAmount extends WCTBaseGui
|
||||
private GuiButton minus10;
|
||||
private GuiButton minus100;
|
||||
private GuiButton minus1000;
|
||||
|
||||
|
||||
private ItemStack myIcon;
|
||||
|
||||
private int originalGui;
|
||||
|
||||
@Reflected
|
||||
public GuiCraftAmount( final InventoryPlayer inventoryPlayer, final ITerminalHost te )
|
||||
{
|
||||
super( new ContainerCraftAmount( inventoryPlayer, te ) );
|
||||
public GuiCraftAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(new ContainerCraftAmount(inventoryPlayer, te));
|
||||
myIcon = RandomUtils.getWirelessTerm(inventoryPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
final int a = AEConfig.instance.craftItemsByStackAmounts( 0 );
|
||||
final int b = AEConfig.instance.craftItemsByStackAmounts( 1 );
|
||||
final int c = AEConfig.instance.craftItemsByStackAmounts( 2 );
|
||||
final int d = AEConfig.instance.craftItemsByStackAmounts( 3 );
|
||||
final int a = AEConfig.instance.craftItemsByStackAmounts(0);
|
||||
final int b = AEConfig.instance.craftItemsByStackAmounts(1);
|
||||
final int c = AEConfig.instance.craftItemsByStackAmounts(2);
|
||||
final int d = AEConfig.instance.craftItemsByStackAmounts(3);
|
||||
|
||||
this.buttonList.add( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a ) );
|
||||
this.buttonList.add( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b ) );
|
||||
this.buttonList.add( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c ) );
|
||||
this.buttonList.add( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d ) );
|
||||
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a));
|
||||
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b));
|
||||
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c));
|
||||
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d));
|
||||
|
||||
this.buttonList.add( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a ) );
|
||||
this.buttonList.add( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b ) );
|
||||
this.buttonList.add( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c ) );
|
||||
this.buttonList.add( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d ) );
|
||||
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a));
|
||||
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b));
|
||||
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c));
|
||||
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d));
|
||||
|
||||
this.buttonList.add( this.next = new GuiButton( 0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal() ) );
|
||||
final Object target = ( (ContainerCraftAmount) this.inventorySlots ).getTarget();
|
||||
this.buttonList.add(this.next = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal()));
|
||||
final Object target = ((ContainerCraftAmount) this.inventorySlots).getTarget();
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
if( target instanceof WirelessTerminalGuiObject )
|
||||
{
|
||||
/*
|
||||
for( final ItemStack wirelessTerminalStack : definitions.items().wirelessTerminal().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
myIcon = wirelessTerminalStack;
|
||||
}
|
||||
*/
|
||||
this.originalGui = WirelessCraftingTerminal.GUI_WCT;
|
||||
if (target instanceof WirelessTerminalGuiObject) {
|
||||
this.originalGui = Reference.GUI_WCT;
|
||||
}
|
||||
|
||||
if( this.originalGui > 0 && myIcon != null )
|
||||
{
|
||||
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop - 4, myIcon, myIcon.getDisplayName(), itemRender ) );
|
||||
if (this.originalGui > 0 && myIcon != null) {
|
||||
this.buttonList.add(this.originalGuiBtn = new GuiTabButton(this.guiLeft + 154, this.guiTop - 4, myIcon, myIcon.getDisplayName(), itemRender));
|
||||
}
|
||||
|
||||
this.amountToCraft = new GuiNumberBox( this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Integer.class );
|
||||
this.amountToCraft.setEnableBackgroundDrawing( false );
|
||||
this.amountToCraft.setMaxStringLength( 16 );
|
||||
this.amountToCraft.setTextColor( 0xFFFFFF );
|
||||
this.amountToCraft.setVisible( true );
|
||||
this.amountToCraft.setFocused( true );
|
||||
this.amountToCraft.setText( "1" );
|
||||
this.amountToCraft = new GuiNumberBox(this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Integer.class);
|
||||
this.amountToCraft.setEnableBackgroundDrawing(false);
|
||||
this.amountToCraft.setMaxStringLength(16);
|
||||
this.amountToCraft.setTextColor(0xFFFFFF);
|
||||
this.amountToCraft.setVisible(true);
|
||||
this.amountToCraft.setFocused(true);
|
||||
this.amountToCraft.setText("1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
this.fontRendererObj.drawString( GuiText.SelectAmount.getLocal(), 8, 6, 4210752 );
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.fontRendererObj.drawString(GuiText.SelectAmount.getLocal(), 8, 6, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
|
||||
{
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.next.displayString = isShiftKeyDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal();
|
||||
|
||||
this.bindTexture( "appliedenergistics2", "guis/craftAmt.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
|
||||
this.bindTexture("appliedenergistics2", "guis/craftAmt.png");
|
||||
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
try
|
||||
{
|
||||
Long.parseLong( this.amountToCraft.getText() );
|
||||
try {
|
||||
Long.parseLong(this.amountToCraft.getText());
|
||||
this.next.enabled = this.amountToCraft.getText().length() > 0;
|
||||
}
|
||||
catch( final NumberFormatException e )
|
||||
{
|
||||
catch (final NumberFormatException e) {
|
||||
this.next.enabled = false;
|
||||
}
|
||||
|
||||
@@ -128,136 +112,110 @@ public class GuiCraftAmount extends WCTBaseGui
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped( final char character, final int key )
|
||||
{
|
||||
if( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if( key == 28 )
|
||||
{
|
||||
this.actionPerformed( this.next );
|
||||
protected void keyTyped(final char character, final int key) {
|
||||
if (!this.checkHotbarKeys(key)) {
|
||||
if (key == 28) {
|
||||
this.actionPerformed(this.next);
|
||||
}
|
||||
if( ( key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ) ) && this.amountToCraft.textboxKeyTyped( character, key ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit(character)) && this.amountToCraft.textboxKeyTyped(character, key)) {
|
||||
try {
|
||||
String out = this.amountToCraft.getText();
|
||||
|
||||
boolean fixed = false;
|
||||
while( out.startsWith( "0" ) && out.length() > 1 )
|
||||
{
|
||||
out = out.substring( 1 );
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
if( fixed )
|
||||
{
|
||||
this.amountToCraft.setText( out );
|
||||
if (fixed) {
|
||||
this.amountToCraft.setText(out);
|
||||
}
|
||||
|
||||
if( out.isEmpty() )
|
||||
{
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
final long result = Long.parseLong( out );
|
||||
if( result < 0 )
|
||||
{
|
||||
this.amountToCraft.setText( "1" );
|
||||
final long result = Long.parseLong(out);
|
||||
if (result < 0) {
|
||||
this.amountToCraft.setText("1");
|
||||
}
|
||||
}
|
||||
catch( final NumberFormatException e )
|
||||
{
|
||||
catch (final NumberFormatException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
else {
|
||||
super.keyTyped(character, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed( final GuiButton btn )
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
|
||||
if( btn == this.originalGuiBtn )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( this.originalGui ) );
|
||||
if (btn == this.originalGuiBtn) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(this.originalGui));
|
||||
}
|
||||
|
||||
if( btn == this.next )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketCraftRequest( Integer.parseInt( this.amountToCraft.getText() ), isShiftKeyDown() ) );
|
||||
if (btn == this.next) {
|
||||
NetworkHandler.instance.sendToServer(new PacketCraftRequest(Integer.parseInt(this.amountToCraft.getText()), isShiftKeyDown()));
|
||||
}
|
||||
}
|
||||
catch( final NumberFormatException e )
|
||||
{
|
||||
catch (final NumberFormatException e) {
|
||||
// nope..
|
||||
this.amountToCraft.setText( "1" );
|
||||
this.amountToCraft.setText("1");
|
||||
}
|
||||
|
||||
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
|
||||
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
|
||||
|
||||
if( isPlus || isMinus )
|
||||
{
|
||||
this.addQty( this.getQty( btn ) );
|
||||
if (isPlus || isMinus) {
|
||||
this.addQty(this.getQty(btn));
|
||||
}
|
||||
}
|
||||
|
||||
private void addQty( final int i )
|
||||
{
|
||||
try
|
||||
{
|
||||
private void addQty(final int i) {
|
||||
try {
|
||||
String out = this.amountToCraft.getText();
|
||||
|
||||
boolean fixed = false;
|
||||
while( out.startsWith( "0" ) && out.length() > 1 )
|
||||
{
|
||||
out = out.substring( 1 );
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
if( fixed )
|
||||
{
|
||||
this.amountToCraft.setText( out );
|
||||
if (fixed) {
|
||||
this.amountToCraft.setText(out);
|
||||
}
|
||||
|
||||
if( out.isEmpty() )
|
||||
{
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
long result = Integer.parseInt( out );
|
||||
long result = Integer.parseInt(out);
|
||||
|
||||
if( result == 1 && i > 1 )
|
||||
{
|
||||
if (result == 1 && i > 1) {
|
||||
result = 0;
|
||||
}
|
||||
|
||||
result += i;
|
||||
if( result < 1 )
|
||||
{
|
||||
if (result < 1) {
|
||||
result = 1;
|
||||
}
|
||||
|
||||
out = Long.toString( result );
|
||||
Integer.parseInt( out );
|
||||
this.amountToCraft.setText( out );
|
||||
out = Long.toString(result);
|
||||
Integer.parseInt(out);
|
||||
this.amountToCraft.setText(out);
|
||||
}
|
||||
catch( final NumberFormatException e )
|
||||
{
|
||||
catch (final NumberFormatException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
protected String getBackground() {
|
||||
return "guis/craftAmt.png";
|
||||
}
|
||||
}
|
||||
@@ -16,13 +16,13 @@ import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.widgets.GuiScrollbar;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftConfirm;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchGuis;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketValueConfig;
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
@@ -64,7 +64,7 @@ public class GuiCraftConfirm extends WCTBaseGui
|
||||
|
||||
if( te instanceof WirelessTerminalGuiObject )
|
||||
{
|
||||
this.OriginalGui = WirelessCraftingTerminal.GUI_WCT;
|
||||
this.OriginalGui = Reference.GUI_WCT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.widgets.GuiTabButton;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftingStatus;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
|
||||
@@ -18,6 +17,7 @@ import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketValueConfig
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
@@ -54,7 +54,7 @@ public class GuiCraftingStatus extends GuiCraftingCPU
|
||||
|
||||
this.myIcon = RandomUtils.getWirelessTerm(inventoryPlayer);
|
||||
|
||||
this.originalGui = WirelessCraftingTerminal.GUI_WCT;
|
||||
this.originalGui = Reference.GUI_WCT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -177,7 +177,7 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
|
||||
{
|
||||
if( btn == this.craftingStatusBtn )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( WirelessCraftingTerminal.GUI_CRAFTING_STATUS ) );
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( Reference.GUI_CRAFTING_STATUS ) );
|
||||
}
|
||||
|
||||
if( btn instanceof GuiImgButton )
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
public class WCTGuiHandler implements IGuiHandler {
|
||||
|
||||
@@ -35,23 +36,23 @@ public class WCTGuiHandler implements IGuiHandler {
|
||||
final WirelessTerminalGuiObject obj = new WirelessTerminalGuiObject(wh, RandomUtils.getWirelessTerm(player.inventory), player, world, x, y, z);
|
||||
final IPortableCell terminal = (IPortableCell) obj;
|
||||
|
||||
if (guiId == WirelessCraftingTerminal.GUI_WCT) {
|
||||
if (guiId == Reference.GUI_WCT) {
|
||||
return new ContainerWirelessCraftingTerminal(player, player.inventory);
|
||||
}
|
||||
|
||||
if (guiId == WirelessCraftingTerminal.GUI_CRAFTING_STATUS) {
|
||||
if (guiId == Reference.GUI_CRAFTING_STATUS) {
|
||||
return new ContainerCraftingStatus(player.inventory, (ITerminalHost) terminal);
|
||||
}
|
||||
|
||||
if (guiId == WirelessCraftingTerminal.GUI_CRAFT_AMOUNT) {
|
||||
if (guiId == Reference.GUI_CRAFT_AMOUNT) {
|
||||
return new ContainerCraftAmount(player.inventory, (ITerminalHost) terminal);
|
||||
}
|
||||
|
||||
if (guiId == WirelessCraftingTerminal.GUI_CRAFT_CONFIRM) {
|
||||
if (guiId == Reference.GUI_CRAFT_CONFIRM) {
|
||||
return new ContainerCraftConfirm(player.inventory, (ITerminalHost) terminal);
|
||||
}
|
||||
|
||||
if (guiId == WirelessCraftingTerminal.GUI_MAGNET) {
|
||||
if (guiId == Reference.GUI_MAGNET) {
|
||||
return new ContainerMagnet(player, player.inventory);
|
||||
}
|
||||
|
||||
@@ -64,23 +65,23 @@ public class WCTGuiHandler implements IGuiHandler {
|
||||
final WirelessTerminalGuiObject obj = new WirelessTerminalGuiObject(wh, RandomUtils.getWirelessTerm(player.inventory), player, world, x, y, z);
|
||||
final IPortableCell terminal = (IPortableCell) obj;
|
||||
|
||||
if (guiId == WirelessCraftingTerminal.GUI_WCT) {
|
||||
if (guiId == Reference.GUI_WCT) {
|
||||
return new GuiWirelessCraftingTerminal((ContainerWirelessCraftingTerminal) new ContainerWirelessCraftingTerminal(player, player.inventory));
|
||||
}
|
||||
|
||||
if (guiId == WirelessCraftingTerminal.GUI_CRAFTING_STATUS) {
|
||||
if (guiId == Reference.GUI_CRAFTING_STATUS) {
|
||||
return new GuiCraftingStatus(player.inventory, (ITerminalHost) terminal);
|
||||
}
|
||||
|
||||
if (guiId == WirelessCraftingTerminal.GUI_CRAFT_AMOUNT) {
|
||||
if (guiId == Reference.GUI_CRAFT_AMOUNT) {
|
||||
return new GuiCraftAmount(player.inventory, (ITerminalHost) terminal);
|
||||
}
|
||||
|
||||
if (guiId == WirelessCraftingTerminal.GUI_CRAFT_CONFIRM) {
|
||||
if (guiId == Reference.GUI_CRAFT_CONFIRM) {
|
||||
return new GuiCraftConfirm(player.inventory, (ITerminalHost) terminal);
|
||||
}
|
||||
|
||||
if (guiId == WirelessCraftingTerminal.GUI_MAGNET) {
|
||||
if (guiId == Reference.GUI_MAGNET) {
|
||||
return new GuiMagnet(new ContainerMagnet(player, player.inventory));
|
||||
}
|
||||
|
||||
|
||||
@@ -43,13 +43,6 @@ public class WirelessCraftingTerminal {
|
||||
@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
|
||||
public static CommonProxy proxy;
|
||||
|
||||
private static int ae2wctGuiIndex = 0;
|
||||
public static final int GUI_WCT = ++ae2wctGuiIndex;
|
||||
public static final int GUI_CRAFTING_STATUS = ++ae2wctGuiIndex;
|
||||
public static final int GUI_CRAFT_AMOUNT = ++ae2wctGuiIndex;
|
||||
public static final int GUI_CRAFT_CONFIRM = ++ae2wctGuiIndex;
|
||||
public static final int GUI_MAGNET = ++ae2wctGuiIndex;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
if (!Loader.isModLoaded("wct-core")) {
|
||||
|
||||
+2
-2
@@ -19,7 +19,6 @@ import net.minecraft.world.World;
|
||||
import net.p455w0rd.wirelesscraftingterminal.api.networking.security.WCTIActionHost;
|
||||
import net.p455w0rd.wirelesscraftingterminal.api.networking.security.WCTPlayerSource;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WCTGuiHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.guisync.GuiSync;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.inventory.WCTInventoryBooster;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
|
||||
@@ -27,6 +26,7 @@ import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchGuis;
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
@@ -306,7 +306,7 @@ public class ContainerCraftConfirm extends WCTBaseContainer
|
||||
final WCTIActionHost ah = this.getActionHost();
|
||||
if( ah instanceof WirelessTerminalGuiObject )
|
||||
{
|
||||
originalGui = WirelessCraftingTerminal.GUI_WCT;
|
||||
originalGui = Reference.GUI_WCT;
|
||||
}
|
||||
|
||||
if( this.result != null && !this.isSimulation() )
|
||||
|
||||
+34
-52
@@ -9,13 +9,13 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WCTGuiHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftAmount;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftConfirm;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerOpenContext;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.WCTPacket;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.INetworkInfo;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
@@ -23,90 +23,72 @@ import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingJob;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class PacketCraftRequest extends WCTPacket
|
||||
{
|
||||
public class PacketCraftRequest extends WCTPacket {
|
||||
|
||||
private final long amount;
|
||||
private final boolean heldShift;
|
||||
|
||||
// automatic.
|
||||
public PacketCraftRequest( final ByteBuf stream )
|
||||
{
|
||||
public PacketCraftRequest(final ByteBuf stream) {
|
||||
this.heldShift = stream.readBoolean();
|
||||
this.amount = stream.readLong();
|
||||
}
|
||||
|
||||
public PacketCraftRequest( final int craftAmt, final boolean shift )
|
||||
{
|
||||
public PacketCraftRequest(final int craftAmt, final boolean shift) {
|
||||
this.amount = craftAmt;
|
||||
this.heldShift = shift;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeBoolean( shift );
|
||||
data.writeLong( this.amount );
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeBoolean(shift);
|
||||
data.writeLong(this.amount);
|
||||
|
||||
this.configureWrite( data );
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final WCTPacket packet, final EntityPlayer player )
|
||||
{
|
||||
if( player.openContainer instanceof ContainerCraftAmount )
|
||||
{
|
||||
public void serverPacketData(final INetworkInfo manager, final WCTPacket packet, final EntityPlayer player) {
|
||||
if (player.openContainer instanceof ContainerCraftAmount) {
|
||||
final ContainerCraftAmount cca = (ContainerCraftAmount) player.openContainer;
|
||||
final Object target = cca.getTarget();
|
||||
if( target instanceof IGridHost )
|
||||
{
|
||||
if (target instanceof IGridHost) {
|
||||
final IGridHost gh = (IGridHost) target;
|
||||
final IGridNode gn = gh.getGridNode( ForgeDirection.UNKNOWN );
|
||||
if( gn == null )
|
||||
{
|
||||
final IGridNode gn = gh.getGridNode(ForgeDirection.UNKNOWN);
|
||||
if (gn == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final IGrid g = gn.getGrid();
|
||||
if( g == null || cca.getItemToCraft() == null )
|
||||
{
|
||||
if (g == null || cca.getItemToCraft() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
cca.getItemToCraft().setStackSize( this.amount );
|
||||
cca.getItemToCraft().setStackSize(this.amount);
|
||||
|
||||
Future<ICraftingJob> futureJob = null;
|
||||
try
|
||||
{
|
||||
final ICraftingGrid cg = g.getCache( ICraftingGrid.class );
|
||||
futureJob = cg.beginCraftingJob( cca.getWorld(), cca.getGrid(), cca.getActionSrc(), cca.getItemToCraft(), null );
|
||||
try {
|
||||
final ICraftingGrid cg = g.getCache(ICraftingGrid.class);
|
||||
futureJob = cg.beginCraftingJob(cca.getWorld(), cca.getGrid(), cca.getActionSrc(), cca.getItemToCraft(), null);
|
||||
|
||||
//final ContainerOpenContext context = cca.getOpenContext();
|
||||
//if( context != null )
|
||||
//{
|
||||
//final TileEntity te = context.getTile();
|
||||
int x = player.serverPosX;
|
||||
int y = player.serverPosY;
|
||||
int z = player.serverPosZ;
|
||||
|
||||
WCTGuiHandler.launchGui(WirelessCraftingTerminal.GUI_CRAFT_CONFIRM, player, player.worldObj, x, y, z);
|
||||
int x = player.serverPosX;
|
||||
int y = player.serverPosY;
|
||||
int z = player.serverPosZ;
|
||||
|
||||
if( player.openContainer instanceof ContainerCraftConfirm )
|
||||
{
|
||||
final ContainerCraftConfirm ccc = (ContainerCraftConfirm) player.openContainer;
|
||||
ccc.setAutoStart( this.heldShift );
|
||||
ccc.setJob( futureJob );
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
//}
|
||||
}
|
||||
catch( final Throwable e )
|
||||
{
|
||||
if( futureJob != null )
|
||||
{
|
||||
futureJob.cancel( true );
|
||||
WCTGuiHandler.launchGui(Reference.GUI_CRAFT_CONFIRM, player, player.worldObj, x, y, z);
|
||||
|
||||
if (player.openContainer instanceof ContainerCraftConfirm) {
|
||||
final ContainerCraftConfirm ccc = (ContainerCraftConfirm) player.openContainer;
|
||||
ccc.setAutoStart(this.heldShift);
|
||||
ccc.setJob(futureJob);
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
WCTLog.debug( e.getMessage() );
|
||||
}
|
||||
catch (final Throwable e) {
|
||||
if (futureJob != null) {
|
||||
futureJob.cancel(true);
|
||||
}
|
||||
WCTLog.debug(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -14,13 +14,13 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WCTGuiHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.WCTBaseContainer;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftAmount;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerOpenContext;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.WCTPacket;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.INetworkInfo;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
public class PacketInventoryAction extends WCTPacket
|
||||
{
|
||||
@@ -126,7 +126,7 @@ public class PacketInventoryAction extends WCTPacket
|
||||
int y = player.serverPosY;
|
||||
int z = player.serverPosZ;
|
||||
|
||||
WCTGuiHandler.launchGui(WirelessCraftingTerminal.GUI_CRAFT_AMOUNT, player, player.worldObj, x, y, z);
|
||||
WCTGuiHandler.launchGui(Reference.GUI_CRAFT_AMOUNT, player, player.worldObj, x, y, z);
|
||||
|
||||
if( sender.openContainer instanceof ContainerCraftAmount )
|
||||
{
|
||||
|
||||
+3
-2
@@ -12,6 +12,7 @@ import net.p455w0rd.wirelesscraftingterminal.api.WCTApi;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.WCTPacket;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.INetworkInfo;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
public class PacketOpenWirelessTerm extends WCTPacket {
|
||||
|
||||
@@ -39,7 +40,7 @@ public class PacketOpenWirelessTerm extends WCTPacket {
|
||||
//WCTGuiHandler.launchGui(WirelessCraftingTerminal.GUI_WCT, player, world, x, y, z);
|
||||
if (player.openContainer instanceof ContainerPlayer) {
|
||||
//WCTApi.instance().interact().openWirelessCraftingTerminalGui(player);
|
||||
player.openGui(WirelessCraftingTerminal.INSTANCE, WirelessCraftingTerminal.GUI_WCT, world, x, y, z);
|
||||
player.openGui(WirelessCraftingTerminal.INSTANCE, Reference.GUI_WCT, world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +52,6 @@ public class PacketOpenWirelessTerm extends WCTPacket {
|
||||
int z = (int) player.posZ;
|
||||
//WCTGuiHandler.launchGui(WirelessCraftingTerminal.GUI_WCT, player, world, x, y, z);
|
||||
//WCTApi.instance().interact().openWirelessCraftingTerminalGui(player);
|
||||
player.openGui(WirelessCraftingTerminal.INSTANCE, WirelessCraftingTerminal.GUI_WCT, world, x, y, z);
|
||||
player.openGui(WirelessCraftingTerminal.INSTANCE, Reference.GUI_WCT, world, x, y, z);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -11,8 +11,8 @@ import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.p455w0rd.wirelesscraftingterminal.api.IWCTInteractionHelper;
|
||||
import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTermHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WCTGuiHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
public class WCTInteractionHelper implements IWCTInteractionHelper {
|
||||
|
||||
@@ -88,7 +88,7 @@ public class WCTInteractionHelper implements IWCTInteractionHelper {
|
||||
// Attempt to launch the gui
|
||||
// NOTE: Range check done in here
|
||||
else {
|
||||
WCTGuiHandler.launchGui(WirelessCraftingTerminal.GUI_WCT, player, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
WCTGuiHandler.launchGui(Reference.GUI_WCT, player, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,7 +45,6 @@ import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTermHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.api.networking.security.WCTIActionHost;
|
||||
import net.p455w0rd.wirelesscraftingterminal.api.networking.security.WCTPlayerSource;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WCTGuiHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
|
||||
import net.p455w0rd.wirelesscraftingterminal.handlers.LocaleHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
@@ -150,7 +149,7 @@ public class ItemMagnet extends Item {
|
||||
int x = (int) player.posX;
|
||||
int y = (int) player.posY;
|
||||
int z = (int) player.posZ;
|
||||
WCTGuiHandler.launchGui(WirelessCraftingTerminal.GUI_MAGNET, player, world, x, y, z);
|
||||
WCTGuiHandler.launchGui(Reference.GUI_MAGNET, player, world, x, y, z);
|
||||
}
|
||||
}
|
||||
return item;
|
||||
|
||||
@@ -13,4 +13,12 @@ public class Reference {
|
||||
public static boolean WCT_BOOSTER_ENABLED = true;
|
||||
public static boolean WCT_EASYMODE_ENABLED = false;
|
||||
public static int WCT_CRAFTMATRIX_Y_OFFSET = 100;
|
||||
|
||||
// Gui IDs
|
||||
private static int ae2wctGuiIndex = 0;
|
||||
public static final int GUI_WCT = ++ae2wctGuiIndex;
|
||||
public static final int GUI_CRAFTING_STATUS = ++ae2wctGuiIndex;
|
||||
public static final int GUI_CRAFT_AMOUNT = ++ae2wctGuiIndex;
|
||||
public static final int GUI_CRAFT_CONFIRM = ++ae2wctGuiIndex;
|
||||
public static final int GUI_MAGNET = ++ae2wctGuiIndex;
|
||||
}
|
||||
Reference in new issue
Block a user