fixed #3 and #9, implemented #8

This commit is contained in:
p455w0rd committed 2016-05-02 00:11:04 -04:00
1 parent b936d6da95
commit 4ed1a04331
13 files changed
+168 -130

No files matched your search

@@ -69,6 +69,7 @@ import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotCraftingM
import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotCraftingTerm;
import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotDisabled;
import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotFake;
import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotFakeCraftingMatrix;
import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotInaccessible;
import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotOutput;
import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotTrash;
@@ -89,7 +90,7 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
private float xSize_lo;
private float ySize_lo;
public static int tick = 0, GUI_HEIGHT = 240, GUI_WIDTH = 198, AE_ROW_HEIGHT = 18, AE_NUM_ROWS = 3,
public static int tick = 0, GUI_HEIGHT = 240, GUI_WIDTH = 198, AE_ROW_HEIGHT = 18, AE_NUM_ROWS = 0,
GUI_UPPER_HEIGHT = 35, GUI_SEARCH_ROW = 35, SEARCH_X = 81, SEARCH_Y = 6, SEARCH_WIDTH = 88,
SEARCH_HEIGHT = 10, SEARCH_MAXCHARS = 15, GUI_LOWER_HEIGHT, AE_TOTAL_ROWS_HEIGHT,
BUTTON_SEARCH_MODE_POS_X = -18, BUTTON_SEARCH_MODE_POS_Y = 68, BUTTON_SIZE = 16, NEI_EXTRA_SPACE = 30,
@@ -131,10 +132,19 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
private boolean isNEIEnabled;
private boolean wasTextboxFocused = false;
private int screenResTicks = 0;
private int reservedSpace = 0;
private int maxRows = Integer.MAX_VALUE;
private int standardSize;
private final int lowerTextureOffset = 0;
private int rows = 0;
public GuiWirelessCraftingTerminal(Container container) {
super(container);
GuiWirelessCraftingTerminal.INSTANCE = this;
this.xSize = GUI_WIDTH;
this.ySize = GUI_HEIGHT;
this.standardSize = this.xSize;
this.setReservedSpace(73);
this.containerWCT = (ContainerWirelessCraftingTerminal) container;
this.scrollBar = new GuiScrollbar();
this.subGui = switchingGuis;
@@ -144,21 +154,23 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
this.configSrc = ((IConfigurableObject) this.inventorySlots).getConfigManager();
this.devicePowered = containerWCT.isPowered();
((ContainerWirelessCraftingTerminal) this.inventorySlots).setGui(this);
this.isNEIEnabled = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
}
public void postUpdate(final List<IAEItemStack> list) {
for (final IAEItemStack is : list) {
this.repo.postUpdate(is);
}
this.repo.updateView();
this.setScrollBar();
}
private void setScrollBar() {
this.getScrollBar().setTop(18).setLeft(174).setHeight((AE_NUM_ROWS + 3) * 18 - 2);
this.getScrollBar().setRange(0, (this.repo.size() + this.perRow - 1) / this.perRow - (AE_NUM_ROWS + 3), Math.max(1, (AE_NUM_ROWS + 3) / 6));
this.getScrollBar().setTop( 18 ).setLeft( 174 ).setHeight( this.rows * 18 - 2 );
this.getScrollBar().setRange( 0, ( this.repo.size() + this.perRow - 1 ) / this.perRow - this.rows, Math.max( 1, this.rows / 6 ) );
}
protected void setScrollBar(final GuiScrollbar myScrollBar) {
this.scrollBar = myScrollBar;
}
@SuppressWarnings("rawtypes")
@@ -255,6 +267,24 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
return this.subGui;
}
int getReservedSpace() {
return this.reservedSpace;
}
void setReservedSpace(final int reservedSpace) {
this.reservedSpace = reservedSpace;
}
public int getStandardSize()
{
return this.standardSize;
}
void setStandardSize( final int standardSize )
{
this.standardSize = standardSize;
}
/**
* Initializes the GUI
*/
@@ -262,13 +292,39 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
@Override
public void initGui() {
Keyboard.enableRepeatEvents(true);
this.maxRows = this.getMaxRows();
this.isNEIEnabled = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
int top = isNEIEnabled ? 22 : 0;
final int magicNumber = 114 + 1;
final int extraSpace = this.height - magicNumber - 0 - top - this.reservedSpace;
this.rows = (int) Math.floor(extraSpace / 18);
if (this.rows > this.maxRows) {
top += (this.rows - this.maxRows) * 18 / 2;
this.rows = this.maxRows;
}
if (isNEIEnabled) {
this.rows--;
}
if (this.rows < 3) {
this.rows = 3;
}
this.getMeSlots().clear();
for (int y = 0; y < AE_NUM_ROWS + 3; y++) {
for (int y = 0; y < this.rows; y++) {
for (int x = 0; x < this.perRow; x++) {
this.getMeSlots().add(new InternalSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18));
}
}
this.xSize = this.standardSize;
super.initGui();
this.ySize = magicNumber + this.rows * 18 + this.reservedSpace;
final int unusedSpace = this.height - this.ySize;
this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
int offset = this.guiTop + 8;
final List<Slot> slots = this.getInventorySlots();
final Iterator<Slot> i = slots.iterator();
while (i.hasNext()) {
@@ -280,11 +336,10 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
for (final InternalSlotME me : this.meSlots) {
slots.add(new SlotME(me));
}
int offset = this.guiTop + 8;
this.buttonList.clear();
this.buttonList.add(this.clearBtn = new GuiImgButton(this.guiLeft + 134, GuiWirelessCraftingTerminal.GUI_HEIGHT - GuiWirelessCraftingTerminal.GUI_LOWER_HEIGHT + 46, Settings.ACTIONS, ActionItems.STASH));
this.buttonList.add(this.trashBtn = new GuiTrashButton(this.guiLeft + 98, GuiWirelessCraftingTerminal.GUI_HEIGHT - GuiWirelessCraftingTerminal.GUI_LOWER_HEIGHT + 103));
this.buttonList.add(this.clearBtn = new GuiImgButton(this.guiLeft + 134, this.guiTop + this.ySize - 160, Settings.ACTIONS, ActionItems.STASH));
this.buttonList.add(this.trashBtn = new GuiTrashButton(this.guiLeft + 98, this.guiTop + this.ySize - 104));
this.clearBtn.setHalfSize(true);
if (this.customSortOrder) {
this.buttonList.add(this.SortByBox = new GuiImgButton(this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting(Settings.SORT_BY)));
@@ -314,7 +369,7 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
final Enum setting = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
this.searchField.setFocused(SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting);
if (this.isSubGui() || this.init) {
if (this.isSubGui()) {
if (this.isSubGui()) {
this.searchField.setText(memoryText);
this.repo.setSearchString(memoryText);
@@ -322,6 +377,25 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
this.repo.updateView();
this.setScrollBar();
}
craftingGridOffsetX = Integer.MAX_VALUE;
craftingGridOffsetY = Integer.MAX_VALUE;
for (final Object s : this.inventorySlots.inventorySlots) {
if (s instanceof AppEngSlot) {
if (((Slot) s).xDisplayPosition < 197) {
this.repositionSlot((AppEngSlot) s);
}
}
if (s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix) {
final Slot g = (Slot) s;
if (g.xDisplayPosition > 0 && g.yDisplayPosition > 0) {
craftingGridOffsetX = Math.min(craftingGridOffsetX, g.xDisplayPosition);
craftingGridOffsetY = Math.min(craftingGridOffsetY, g.yDisplayPosition);
}
}
}
}
@SuppressWarnings("unchecked")
@@ -329,6 +403,14 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
return this.inventorySlots.inventorySlots;
}
int getMaxRows() {
return Integer.MAX_VALUE;
}
protected void repositionSlot(final AppEngSlot s) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
}
/**
* Called every tick. It is used in this instance to detect screen size
* changes to automatically update the gui height.
@@ -342,7 +424,6 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
public void updateScreen() {
this.devicePowered = containerWCT.isPowered();
this.repo.setPower(devicePowered);
//this.repo.setPower( true );
super.updateScreen();
if (this.init) {
@@ -370,7 +451,6 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
this.wasTextboxFocused = false;
this.wasResized = false;
}
containerWCT.updateSlots(slotYOffset);
this.reInit = false;
tick = 0;
}
@@ -382,26 +462,6 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
if (!this.mc.thePlayer.isEntityAlive() || this.mc.thePlayer.isDead) {
this.mc.thePlayer.closeScreen();
}
else {
// this block of variables is used to automatically
// reposition the slots in the container
GUI_HEIGHT = this.mc.displayHeight / 2;
AE_NUM_ROWS = Math.max(0, ((GUI_HEIGHT) - 240) / AE_ROW_HEIGHT);
if (isNEIEnabled && AE_NUM_ROWS >= 2) {
AE_NUM_ROWS -= 2;
GUI_HEIGHT -= AE_ROW_HEIGHT * 2 + 5;
this.clearBtn.yPosition = AE_TOTAL_ROWS_HEIGHT + GUI_SEARCH_ROW + GUI_UPPER_HEIGHT + 32;
this.trashBtn.yPosition = AE_TOTAL_ROWS_HEIGHT + GUI_SEARCH_ROW + GUI_UPPER_HEIGHT + 89;
}
else {
this.clearBtn.yPosition = AE_TOTAL_ROWS_HEIGHT + GUI_SEARCH_ROW + GUI_UPPER_HEIGHT + 13;
this.trashBtn.yPosition = AE_TOTAL_ROWS_HEIGHT + GUI_SEARCH_ROW + GUI_UPPER_HEIGHT + 68;
}
AE_TOTAL_ROWS_HEIGHT = AE_NUM_ROWS * AE_ROW_HEIGHT;
GUI_LOWER_HEIGHT = GUI_HEIGHT - AE_TOTAL_ROWS_HEIGHT - GUI_UPPER_HEIGHT;
slotYOffset = AE_TOTAL_ROWS_HEIGHT;
craftingGridOffsetY = slotYOffset + 83;
}
}
/**
@@ -427,8 +487,6 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
super.drawScreen(mouseX, mouseY, btn);
this.xSize_lo = (float) mouseX;
this.ySize_lo = (float) mouseY;
this.xSize = GUI_WIDTH;
this.ySize = GUI_HEIGHT;
final boolean hasClicked = Mouse.isButtonDown(0);
if (hasClicked && this.scrollBar != null) {
@@ -542,6 +600,7 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
/**
* Draw GUI Labels and item tooltips
*/
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
final int ox = this.guiLeft; // (width - xSize) / 2;
final int oy = this.guiTop; // (height - ySize) / 2;
@@ -556,7 +615,7 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
String s = LocaleHandler.WirelessTermLabel.getLocal();
this.mc.fontRenderer.drawString(s, 7, 5, 4210752);
this.mc.fontRenderer.drawString(I18n.format("container.inventory"), 7, AE_TOTAL_ROWS_HEIGHT + GUI_SEARCH_ROW + GUI_UPPER_HEIGHT + 3, 4210752);
this.mc.fontRenderer.drawString(I18n.format("container.inventory"), 7, this.ySize - 172 + 3, 4210752);
if (this.searchField != null) {
this.searchField.drawTextBox();
}
@@ -565,6 +624,7 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
/**
* Draw and piece together the background texture
*/
@Override
protected void drawGuiContainerBackgroundLayer(final float f, final int x, final int y) {
final int ox = this.guiLeft; // (width - xSize) / 2;
final int oy = this.guiTop; // (height - ySize) / 2;
@@ -592,22 +652,24 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
}
}
public void drawBG(int ox, int oy, int x, int y) {
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture(bgTexturePath);
final int x_width = 199;
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, GUI_WIDTH, GUI_UPPER_HEIGHT);
for (int i = 0; i <= AE_NUM_ROWS; ++i) {
int yPos = this.guiTop + GUI_UPPER_HEIGHT + (i * AE_ROW_HEIGHT);
// Draw the texture
this.drawTexturedModalRect(this.guiLeft, yPos, 0, GUI_SEARCH_ROW, GUI_WIDTH, AE_ROW_HEIGHT);
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 );
for( int x = 0; x < this.rows; x++ )
{
this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18 );
}
this.drawTexturedModalRect( offsetX, offsetY + 16 + this.rows * 18 + this.lowerTextureOffset, 0, 106 - 18 - 18, x_width, 99 + this.reservedSpace - this.lowerTextureOffset );
this.drawTexturedModalRect(this.guiLeft, this.guiTop + GUI_UPPER_HEIGHT + AE_TOTAL_ROWS_HEIGHT, 0, AE_ROW_HEIGHT + 17, GUI_WIDTH, GUI_LOWER_HEIGHT);
if (Reference.WCT_BOOSTER_ENABLED) {
this.drawTexturedModalRect(this.guiLeft + 132, this.guiTop + GUI_UPPER_HEIGHT + AE_TOTAL_ROWS_HEIGHT + 102, 237, 237, 19, 19);
this.drawTexturedModalRect(this.guiLeft + 132, (this.guiTop + this.rows * 18) + 83, 237, 237, 19, 19);
}
GuiInventory.func_147046_a(this.guiLeft + 51, this.guiTop + GUI_UPPER_HEIGHT + AE_TOTAL_ROWS_HEIGHT + 112, 32, (float) (this.guiLeft + 51) - this.xSize_lo, (float) (this.guiTop + 95 + (AE_NUM_ROWS * AE_ROW_HEIGHT)) - this.ySize_lo, this.mc.thePlayer);
GuiInventory.func_147046_a(this.guiLeft + 51, (this.guiTop + this.rows * 18) + 94, 32, (float) (this.guiLeft + 51) - this.xSize_lo, (float) ((this.guiTop + this.rows * 18) + 50) - this.ySize_lo, this.mc.thePlayer);
}
@SuppressWarnings("rawtypes")
@@ -872,7 +934,8 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
@Override
public void onGuiClosed() {
super.onGuiClosed();
this.subGui = true; // in case the gui is reopened later ( i'm looking at you NEI )
this.subGui = true; // in case the gui is reopened later ( i'm looking
// at you NEI )
Keyboard.enableRepeatEvents(false);
if (this.searchField.getText() != null) {
memoryText = this.searchField.getText();
@@ -1127,10 +1190,6 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
return this.scrollBar;
}
protected void setScrollBar(final GuiScrollbar myScrollBar) {
this.scrollBar = myScrollBar;
}
protected List<InternalSlotME> getMeSlots() {
return this.meSlots;
}
@@ -121,14 +121,10 @@ public class ContainerWirelessCraftingTerminal extends Container implements ICon
public ItemStack craftItem;
private World worldObj;
private EntityPlayer player;
@SuppressWarnings("unused")
private static final int HOTBAR_START = 1, HOTBAR_END = HOTBAR_START + 8, INV_START = HOTBAR_END + 1,
INV_END = INV_START + 26, ARMOR_START = INV_END + 1, ARMOR_END = ARMOR_START + 3,
CRAFT_GRID_START = ARMOR_END + 1, CRAFT_GRID_END = CRAFT_GRID_START + 8, CRAFT_RESULT = CRAFT_GRID_END + 1,
BOOSTER_INDEX = 0, MAGNET_INDEX = CRAFT_RESULT + 1, TRASH_INDEX = MAGNET_INDEX + 1;
private int BOOSTER_Y_OFFSET = 139, HOTBAR_Y_OFFSET = 217, INV_Y_OFFSET = 159, ARMOR_Y_OFFSET = 83,
CRAFTMATRIX_Y_OFFSET = 83, CRAFTING_Y_OFFSET = 100, MAGNET_Y_OFFSET = BOOSTER_Y_OFFSET,
TRASH_Y_OFFSET = MAGNET_Y_OFFSET;
BOOSTER_INDEX = 0, MAGNET_INDEX = CRAFT_RESULT + 1;
public static int CRAFTING_SLOT_X_POS = 80, CRAFTING_SLOT_Y_POS = 83;
private SlotBooster boosterSlot;
private SlotMagnet magnetSlot;
@@ -139,8 +135,7 @@ public class ContainerWirelessCraftingTerminal extends Container implements ICon
private SlotCraftingMatrix[] craftMatrixSlot;
private SlotCraftingTerm craftingSlot;
public SlotTrash trashSlot;
@SuppressWarnings("unused")
private int firstCraftingSlotNumber = -1, lastCraftingSlotNumber = -1, craftingSlotNumber = -1;
private int firstCraftingSlotNumber = -1, lastCraftingSlotNumber = -1;
private final WirelessTerminalGuiObject obj;
private boolean isContainerValid = true;
@@ -224,7 +219,7 @@ public class ContainerWirelessCraftingTerminal extends Container implements ICon
}
if (Reference.WCT_BOOSTER_ENABLED) {
boosterSlot = new SlotBooster(this.boosterInventory, 0, 134, BOOSTER_Y_OFFSET);
boosterSlot = new SlotBooster(this.boosterInventory, 0, 134, -20);
this.addSlotToContainer(boosterSlot);
}
else {
@@ -234,7 +229,7 @@ public class ContainerWirelessCraftingTerminal extends Container implements ICon
// Add hotbar slots
for (int i = 0; i < 9; ++i) {
hotbarSlot[i] = new SlotPlayerHotBar(this.inventoryPlayer, i, i * 18 + 8, HOTBAR_Y_OFFSET);
hotbarSlot[i] = new SlotPlayerHotBar(this.inventoryPlayer, i, i * 18 + 8, 58);
this.addSlotToContainer(hotbarSlot[i]);
}
@@ -243,7 +238,7 @@ public class ContainerWirelessCraftingTerminal extends Container implements ICon
// Add player inventory slots
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
inventorySlot[k] = new SlotPlayerInv(this.inventoryPlayer, j + i * 9 + 9, j * 18 + 8, INV_Y_OFFSET + i * 18);
inventorySlot[k] = new SlotPlayerInv(this.inventoryPlayer, j + i * 9 + 9, j * 18 + 8, 0 + i * 18);
this.addSlotToContainer(inventorySlot[k]);
k++;
}
@@ -251,14 +246,14 @@ public class ContainerWirelessCraftingTerminal extends Container implements ICon
// Add armor slots
for (int i = 0; i < 4; ++i) {
armorSlot[i] = new SlotArmor(this.player, this.inventoryPlayer, 39 - i, (int) 8.5, ARMOR_Y_OFFSET + i * 18, i);
armorSlot[i] = new SlotArmor(this.player, this.inventoryPlayer, 39 - i, (int) 8.5, (i * 18) - 76, i);
this.addSlotToContainer(armorSlot[i]);
}
k = 0;
// Add crafting grid slots
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
craftMatrixSlot[k] = new SlotCraftingMatrix(this, this.craftingGrid, j + i * 3, 80 + j * 18, CRAFTMATRIX_Y_OFFSET + i * 18);
craftMatrixSlot[k] = new SlotCraftingMatrix(this, this.craftingGrid, j + i * 3, 80 + j * 18, (i * 18) - 76);
this.addSlotToContainer(craftMatrixSlot[k]);
if (k == 0) {
this.firstCraftingSlotNumber = craftMatrixSlot[k].slotNumber;
@@ -268,15 +263,14 @@ public class ContainerWirelessCraftingTerminal extends Container implements ICon
}
this.lastCraftingSlotNumber = craftMatrixSlot[8].slotNumber;
craftingSlot = new SlotCraftingTerm(this.getPlayerInv().player, this.mySrc, this.getPowerSource(), this.obj, this.craftingGrid, this.craftingGrid, this.output, 174, CRAFTING_Y_OFFSET, this);
this.craftingSlotNumber = this.lastCraftingSlotNumber + 1;
craftingSlot = new SlotCraftingTerm(this.getPlayerInv().player, this.mySrc, this.getPowerSource(), this.obj, this.craftingGrid, this.craftingGrid, this.output, 174, -58, this);
// Add crafting result slot
this.addSlotToContainer(craftingSlot);
magnetSlot = new SlotMagnet(this.magnetInventory, 152, MAGNET_Y_OFFSET);
magnetSlot = new SlotMagnet(this.magnetInventory, 152, -20);
this.addSlotToContainer(magnetSlot);
trashSlot = new SlotTrash(this.trashInventory, 80, TRASH_Y_OFFSET, player);
trashSlot = new SlotTrash(this.trashInventory, 80, -20, player);
trashSlot.setContainer(this);
this.addSlotToContainer(trashSlot);
@@ -685,43 +679,6 @@ public class ContainerWirelessCraftingTerminal extends Container implements ICon
return null;
}
public void updateSlots(int yOffset) {
int i, j, index = 0;
this.getSlot(index).yDisplayPosition = BOOSTER_Y_OFFSET + yOffset;
for (i = 0; i < 9; ++i) {
index++;
this.getSlot(index).yDisplayPosition = HOTBAR_Y_OFFSET + yOffset;
}
for (i = 0; i < 3; ++i) {
for (j = 0; j < 9; ++j) {
index++;
this.getSlot(index).yDisplayPosition = INV_Y_OFFSET + yOffset + (18 * i);
}
}
for (i = 0; i < 4; ++i) {
index++;
this.getSlot(index).yDisplayPosition = ARMOR_Y_OFFSET + yOffset + (18 * i);
}
Reference.WCT_CRAFTMATRIX_Y_OFFSET = CRAFTMATRIX_Y_OFFSET + yOffset;
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
index++;
this.getSlot(index).yDisplayPosition = (CRAFTMATRIX_Y_OFFSET + yOffset) + (18 * i);
}
}
index++;
this.getSlot(index).yDisplayPosition = CRAFTING_Y_OFFSET + yOffset;
index++;
this.getSlot(index).yDisplayPosition = MAGNET_Y_OFFSET + yOffset;
index++;
this.getSlot(index).yDisplayPosition = TRASH_Y_OFFSET + yOffset;
}
private WirelessTerminalGuiObject getGuiObject(final ItemStack it, final EntityPlayer player, final World w, final int x, final int y, final int z) {
if (it != null) {
final IWirelessCraftingTermHandler wh = (IWirelessCraftingTermHandler) AEApi.instance().registries().wireless().getWirelessTerminalHandler(it);
@@ -10,26 +10,29 @@ import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
public class PacketConfigSync extends WCTPacket {
int wirelessTermMaxPower;
int wirelessTermMaxPower, boosterDropChance;
boolean easyMode, boosterEnabled;
public PacketConfigSync(final ByteBuf stream) {
this.wirelessTermMaxPower = stream.readInt();
this.easyMode = stream.readBoolean();
this.boosterEnabled = stream.readBoolean();
this.boosterDropChance = stream.readInt();
}
// api
public PacketConfigSync(int power, boolean mode, boolean booster) {
public PacketConfigSync(int power, boolean mode, boolean booster, int dropChance) {
this.wirelessTermMaxPower = power;
this.easyMode = mode;
this.boosterEnabled = booster;
this.boosterDropChance = dropChance;
final ByteBuf data = Unpooled.buffer();
data.writeInt(this.getPacketID());
data.writeInt(this.wirelessTermMaxPower);
data.writeBoolean(this.easyMode);
data.writeBoolean(this.boosterEnabled);
data.writeInt(this.boosterDropChance);
this.configureWrite(data);
}
@@ -43,6 +46,7 @@ public class PacketConfigSync extends WCTPacket {
Reference.WCT_MAX_POWER = this.wirelessTermMaxPower;
Reference.WCT_EASYMODE_ENABLED = this.easyMode;
Reference.WCT_BOOSTER_ENABLED = this.boosterEnabled;
Reference.WCT_BOOSTER_DROPCHANCE = this.boosterDropChance;
ConfigHandler.removeBooster();
ConfigHandler.removeBoosterIcon();
ConfigHandler.reloadRecipes();
@@ -23,9 +23,10 @@ public class ConfigHandler {
public static boolean enableInfinityBooster;
public static boolean enableEasyMode;
public static int ae2wctMaxPower = Reference.WCT_MAX_POWER;
public static int boosterDropChance = Reference.WCT_BOOSTER_DROPCHANCE;
private static boolean doSave;
public static boolean firstLoad = true;
private static int pwrInCfgFile;
private static int pwrInCfgFile, boosterDropInCfgFile;
public static void init(File configFile) {
if (config == null) {
@@ -46,6 +47,7 @@ public class ConfigHandler {
String pwrDesc = LocaleHandler.MaxPowerDesc.getLocal() + " [default: 1600000, min: 800000, max:6400000]";
String boosterDesc = LocaleHandler.InfinityBoosterCfgDesc.getLocal();
String easyModeDesc = LocaleHandler.EasyModeDesc.getLocal();
String boosterDropDesc = LocaleHandler.BoosterDropChance.getLocal();
enableInfinityBooster = config.getBoolean("enableInfinityBooster", Configuration.CATEGORY_GENERAL, true, boosterDesc);
enableEasyMode = config.getBoolean("enableEasyMode", Configuration.CATEGORY_GENERAL, false, easyModeDesc);
/*
@@ -70,10 +72,29 @@ public class ConfigHandler {
pwrCfgKey.comment = pwrDesc;
doSave = true;
}
Property boosterDropKey = config.get(Configuration.CATEGORY_GENERAL, "boosterDropChance", Reference.WCT_BOOSTER_DROPCHANCE);
boosterDropKey.comment = boosterDropDesc;
boosterDropKey.setDefaultValue(Reference.WCT_BOOSTER_DROPCHANCE);
boosterDropInCfgFile = boosterDropKey.getInt();
boosterDropChance = boosterDropInCfgFile;
if (boosterDropInCfgFile > 100) {
boosterDropChance = 100;
boosterDropKey.setValue(boosterDropChance);
boosterDropKey.comment = boosterDropDesc;
doSave = true;
} else if (boosterDropInCfgFile < 1) {
boosterDropChance = 1;
boosterDropKey.setValue(boosterDropChance);
boosterDropKey.comment = boosterDropDesc;
doSave = true;
}
Reference.WCT_BOOSTER_ENABLED = enableInfinityBooster;
Reference.WCT_EASYMODE_ENABLED = enableEasyMode;
Reference.WCT_MAX_POWER = ae2wctMaxPower;
Reference.WCT_BOOSTER_DROPCHANCE = boosterDropChance;
if (config.hasChanged() || doSave) {
config.save();
@@ -9,7 +9,7 @@ public enum LocaleHandler {
MagnetDesc, MagnetDesc2, PressShift, OnlyWorks, LinkStatus, Installed, NotInstalled, Active, Inactive,
Status, EmptyTrash, EmptyTrashDesc, MagnetFilterTitle, NoNetworkPower("chatmessages.ae2wct"), FilterMode,
Whitelisting, Blacklisting, MagnetMode1("chatmessages.ae2wct"), MagnetMode2("chatmessages.ae2wct"), MagnetMode3("chatmessages.ae2wct"),
MagnetActiveDesc1, MagnetActiveDesc2;
MagnetActiveDesc1, MagnetActiveDesc2, BoosterDropChance("config.ae2wct");
private final String root;
@@ -4,7 +4,10 @@ import java.util.ArrayList;
import appeng.api.implementations.tiles.IWirelessAccessPoint;
import appeng.core.localization.PlayerMessages;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.FakePlayer;
import net.p455w0rd.wirelesscraftingterminal.api.IWCTInteractionHelper;
@@ -19,7 +22,7 @@ public class WCTInteractionHelper implements IWCTInteractionHelper {
@Override
public void openWirelessCraftingTerminalGui(final EntityPlayer player) {
if ((player == null) || (player instanceof FakePlayer) || player.worldObj.isRemote) {
if ((player == null) || (player instanceof FakePlayer) || (player instanceof EntityPlayerMP) || FMLCommonHandler.instance().getSide() == Side.SERVER) {
return;
}
@@ -19,7 +19,6 @@ import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -34,10 +33,8 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTermHandler;
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiWirelessCraftingTerminal;
import net.p455w0rd.wirelesscraftingterminal.api.WCTApi;
import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketOpenGui;
import net.p455w0rd.wirelesscraftingterminal.handlers.LocaleHandler;
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
import net.p455w0rd.wirelesscraftingterminal.integration.IntegrationType;
@@ -116,16 +113,7 @@ public class ItemWirelessCraftingTerminal extends AEBasePoweredItem implements I
public ItemStack onItemRightClick(final ItemStack itemStack, final World world, final EntityPlayer player) {
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
// Open the gui
ItemStack is = RandomUtils.getWirelessTerm(player.inventory);
if (is == null) {
return itemStack;
}
ItemWirelessCraftingTerminal wirelessTerm = (ItemWirelessCraftingTerminal) is.getItem();
if (wirelessTerm != null) {
if (!FMLClientHandler.instance().isGUIOpen(GuiWirelessCraftingTerminal.class)) {
NetworkHandler.instance.sendToServer(new PacketOpenGui(Reference.GUI_WCT));
}
}
WCTApi.instance().interact().openWirelessCraftingTerminalGui(player);
}
return itemStack;
}
@@ -138,7 +138,7 @@ public class CommonProxy {
*/
}
else {
final PacketConfigSync p = new PacketConfigSync(Reference.WCT_MAX_POWER, Reference.WCT_EASYMODE_ENABLED, Reference.WCT_BOOSTER_ENABLED);
final PacketConfigSync p = new PacketConfigSync(Reference.WCT_MAX_POWER, Reference.WCT_EASYMODE_ENABLED, Reference.WCT_BOOSTER_ENABLED, Reference.WCT_BOOSTER_DROPCHANCE);
NetworkHandler.instance.sendTo((WCTPacket) p, (EntityPlayerMP) e.player);
}
}
@@ -146,12 +146,15 @@ public class CommonProxy {
@SubscribeEvent
public void onMobDrop(LivingDropsEvent event) {
if (!Reference.WCT_EASYMODE_ENABLED && Reference.WCT_BOOSTER_ENABLED) {
if (event.entity instanceof EntityWither || event.entity instanceof EntityDragon) {
ItemStack stack = new ItemStack(ItemEnum.BOOSTER_CARD.getItem());
EntityItem drop = new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, stack);
ItemStack stack = new ItemStack(ItemEnum.BOOSTER_CARD.getItem());
EntityItem drop = new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, stack);
if (event.entity instanceof EntityDragon) {
event.drops.add(drop);
}
if (event.entity instanceof EntityWither) {
Random rand = new Random();
int n = rand.nextInt(50) + 1;
if (n == 25) {
int n = rand.nextInt();
if (n <= Reference.WCT_BOOSTER_DROPCHANCE) {
event.drops.add(drop);
}
}
@@ -2,7 +2,7 @@ package net.p455w0rd.wirelesscraftingterminal.reference;
public class Reference {
public static final String MODID = "ae2wct";
public static final String VERSION = "1.7.10-rv3-1.3b";
public static final String VERSION = "1.7.10-rv3-1.4b";
public static final String NAME = "AE2 Wireless Crafting Terminal";
public static final String SERVER_PROXY_CLASS = "net.p455w0rd.wirelesscraftingterminal.proxy.CommonProxy";
public static final String CLIENT_PROXY_CLASS = "net.p455w0rd.wirelesscraftingterminal.proxy.ClientProxy";
@@ -13,6 +13,7 @@ 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;
public static int WCT_BOOSTER_DROPCHANCE = 50;
// Gui IDs
private static int ae2wctGuiIndex = 0;