mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-27 15:22:57 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa03d733a3 | ||
|
|
8726d0ffab |
No files matched your search
@@ -25,6 +25,8 @@ import forestry.core.network.packets.PacketAccessUpdate;
|
|||||||
import forestry.core.network.packets.PacketErrorUpdate;
|
import forestry.core.network.packets.PacketErrorUpdate;
|
||||||
import forestry.core.network.packets.PacketGuiEnergy;
|
import forestry.core.network.packets.PacketGuiEnergy;
|
||||||
import forestry.core.network.packets.PacketGuiUpdate;
|
import forestry.core.network.packets.PacketGuiUpdate;
|
||||||
|
import forestry.core.network.packets.PacketTileConfiguration;
|
||||||
|
import forestry.core.tiles.IConfigurable;
|
||||||
import forestry.core.tiles.IPowerHandler;
|
import forestry.core.tiles.IPowerHandler;
|
||||||
import forestry.core.tiles.TilePowered;
|
import forestry.core.tiles.TilePowered;
|
||||||
import forestry.core.tiles.TileUtil;
|
import forestry.core.tiles.TileUtil;
|
||||||
@@ -34,6 +36,7 @@ public abstract class ContainerTile<T extends TileEntity> extends ContainerFores
|
|||||||
|
|
||||||
protected final T tile;
|
protected final T tile;
|
||||||
private final IAccessHandler accessHandler;
|
private final IAccessHandler accessHandler;
|
||||||
|
private boolean configurationChanged;
|
||||||
|
|
||||||
protected ContainerTile(T tile) {
|
protected ContainerTile(T tile) {
|
||||||
this.tile = tile;
|
this.tile = tile;
|
||||||
@@ -43,6 +46,10 @@ public abstract class ContainerTile<T extends TileEntity> extends ContainerFores
|
|||||||
} else {
|
} else {
|
||||||
accessHandler = FakeAccessHandler.getInstance();
|
accessHandler = FakeAccessHandler.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tile instanceof IConfigurable) {
|
||||||
|
configurationChanged = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ContainerTile(T tileForestry, InventoryPlayer playerInventory, int xInv, int yInv) {
|
protected ContainerTile(T tileForestry, InventoryPlayer playerInventory, int xInv, int yInv) {
|
||||||
@@ -128,6 +135,15 @@ public abstract class ContainerTile<T extends TileEntity> extends ContainerFores
|
|||||||
sendPacketToCrafters(packet);
|
sendPacketToCrafters(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tile instanceof IConfigurable && configurationChanged) {
|
||||||
|
configurationChanged = false;
|
||||||
|
sendPacketToCrafters(new PacketTileConfiguration(tile));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void markConfigurationDirty() {
|
||||||
|
configurationChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onGuiEnergy(int energyStored) {
|
public void onGuiEnergy(int energyStored) {
|
||||||
|
|||||||
@@ -138,6 +138,10 @@ public abstract class Ledger {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean acceptMouseButton(int mouseButton) {
|
||||||
|
return mouseButton == 0;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean intersectsWith(int mouseX, int mouseY) {
|
public boolean intersectsWith(int mouseX, int mouseY) {
|
||||||
return mouseX >= currentShiftX && mouseX <= currentShiftX + currentWidth
|
return mouseX >= currentShiftX && mouseX <= currentShiftX + currentWidth
|
||||||
&& mouseY >= currentShiftY
|
&& mouseY >= currentShiftY
|
||||||
|
|||||||
@@ -159,29 +159,28 @@ public class LedgerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handleMouseClicked(int x, int y, int mouseButton) {
|
public void handleMouseClicked(int x, int y, int mouseButton) {
|
||||||
|
Ledger ledger = this.getAtPosition(x, y);
|
||||||
|
if (ledger == null || !ledger.acceptMouseButton(mouseButton)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mouseButton == 0) {
|
// Default action only if the mouse click was not handled by the
|
||||||
|
// ledger itself.
|
||||||
|
if (!ledger.handleMouseClicked(x, y, mouseButton)) {
|
||||||
|
|
||||||
Ledger ledger = this.getAtPosition(x, y);
|
List<? extends Ledger> toggleLedgers;
|
||||||
|
if (ledgers.contains(ledger)) {
|
||||||
// Default action only if the mouse click was not handled by the
|
toggleLedgers = ledgers;
|
||||||
// ledger itself.
|
} else {
|
||||||
if (ledger != null && !ledger.handleMouseClicked(x, y, mouseButton)) {
|
toggleLedgers = errorLedgers;
|
||||||
|
|
||||||
List<? extends Ledger> toggleLedgers;
|
|
||||||
if (ledgers.contains(ledger)) {
|
|
||||||
toggleLedgers = ledgers;
|
|
||||||
} else {
|
|
||||||
toggleLedgers = errorLedgers;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Ledger other : toggleLedgers) {
|
|
||||||
if (other != ledger && other.isOpen()) {
|
|
||||||
other.toggleOpen();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ledger.toggleOpen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Ledger other : toggleLedgers) {
|
||||||
|
if (other != ledger && other.isOpen()) {
|
||||||
|
other.toggleOpen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ledger.toggleOpen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package forestry.core.gui.ledgers;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import net.minecraft.util.IIcon;
|
||||||
|
|
||||||
|
import forestry.core.render.TextureManager;
|
||||||
|
import forestry.core.tiles.IIngredientsSearchController;
|
||||||
|
import forestry.core.tiles.IngredientsStorage;
|
||||||
|
import forestry.core.utils.StringUtil;
|
||||||
|
|
||||||
|
public class SearchIngregientsLedger extends Ledger {
|
||||||
|
|
||||||
|
private final IIngredientsSearchController ingredientsSearch;
|
||||||
|
|
||||||
|
public SearchIngregientsLedger(LedgerManager manager, IIngredientsSearchController ingredientsSearch) {
|
||||||
|
super(manager, "search_ingredients");
|
||||||
|
this.ingredientsSearch = ingredientsSearch;
|
||||||
|
this.maxHeight = 36;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isSwitchButton(int mouseX, int mouseY) {
|
||||||
|
int shiftX = currentShiftX + 20;
|
||||||
|
int shiftY = currentShiftY + 8;
|
||||||
|
return mouseX >= shiftX && mouseX <= currentShiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(int x, int y) {
|
||||||
|
// Draw background
|
||||||
|
drawBackground(x, y);
|
||||||
|
|
||||||
|
// Draw icon
|
||||||
|
IIcon icon = TextureManager.getInstance().getDefault(
|
||||||
|
"misc/search_ingredients."
|
||||||
|
+ ingredientsSearch.getIngredientsStorage().toString().toLowerCase(Locale.ENGLISH));
|
||||||
|
drawIcon(icon, x + 3, y + 4);
|
||||||
|
|
||||||
|
// Draw description
|
||||||
|
if (!isFullyOpened()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
drawHeader(StringUtil.localize("gui.search_ingredients"), x + 22, y + 8);
|
||||||
|
drawText(
|
||||||
|
StringUtil.localize(
|
||||||
|
"gui.search_ingredients."
|
||||||
|
+ ingredientsSearch.getIngredientsStorage().toString().toLowerCase(Locale.ENGLISH)),
|
||||||
|
x + 22,
|
||||||
|
y + 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTooltip() {
|
||||||
|
return StringUtil.localize("gui.search_ingredients") + ": "
|
||||||
|
+ StringUtil.localize(
|
||||||
|
"gui.search_ingredients."
|
||||||
|
+ ingredientsSearch.getIngredientsStorage().toString().toLowerCase(Locale.ENGLISH));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handleMouseClicked(int x, int y, int mouseButton) {
|
||||||
|
if (isSwitchButton(x, y)) {
|
||||||
|
IngredientsStorage ingredientsStorage = ingredientsSearch.getIngredientsStorage();
|
||||||
|
IngredientsStorage newIngredientsStorage = mouseButton == 0 ? ingredientsStorage.next()
|
||||||
|
: ingredientsStorage.previous();
|
||||||
|
ingredientsSearch.setIngredientsStorage(newIngredientsStorage);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptMouseButton(int mouseButton) {
|
||||||
|
return mouseButton == 0 || mouseButton == 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,12 +20,14 @@ public class SlotCrafter extends SlotCrafting {
|
|||||||
|
|
||||||
private final IInventory craftMatrix;
|
private final IInventory craftMatrix;
|
||||||
private final ICrafterWorktable crafter;
|
private final ICrafterWorktable crafter;
|
||||||
|
private final EntityPlayer player;
|
||||||
|
|
||||||
public SlotCrafter(EntityPlayer player, IInventory craftMatrix, ICrafterWorktable crafter, int slot, int xPos,
|
public SlotCrafter(EntityPlayer player, IInventory craftMatrix, ICrafterWorktable crafter, int slot, int xPos,
|
||||||
int yPos) {
|
int yPos) {
|
||||||
super(player, craftMatrix, craftMatrix, slot, xPos, yPos);
|
super(player, craftMatrix, craftMatrix, slot, xPos, yPos);
|
||||||
this.craftMatrix = craftMatrix;
|
this.craftMatrix = craftMatrix;
|
||||||
this.crafter = crafter;
|
this.crafter = crafter;
|
||||||
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -39,7 +41,7 @@ public class SlotCrafter extends SlotCrafting {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTakeStack(EntityPlayer player) {
|
public boolean canTakeStack(EntityPlayer player) {
|
||||||
return crafter.canTakeStack(getSlotIndex());
|
return crafter.canTakeStack(player, getSlotIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -49,7 +51,7 @@ public class SlotCrafter extends SlotCrafting {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getHasStack() {
|
public boolean getHasStack() {
|
||||||
return getStack() != null && crafter.canTakeStack(getSlotIndex());
|
return getStack() != null && crafter.canTakeStack(player, getSlotIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
package forestry.core.inventory;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class MergedInventories implements IInventory {
|
||||||
|
|
||||||
|
private final IInventory first;
|
||||||
|
private final IInventory second;
|
||||||
|
|
||||||
|
public MergedInventories(IInventory first, IInventory second) {
|
||||||
|
this.first = first;
|
||||||
|
this.second = second;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSizeInventory() {
|
||||||
|
return first.getSizeInventory() + second.getSizeInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackInSlot(int slotIn) {
|
||||||
|
if (slotIn < first.getSizeInventory()) {
|
||||||
|
return first.getStackInSlot(slotIn);
|
||||||
|
}
|
||||||
|
return second.getStackInSlot(slotIn - first.getSizeInventory());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack decrStackSize(int index, int count) {
|
||||||
|
if (index < first.getSizeInventory()) {
|
||||||
|
return first.decrStackSize(index, count);
|
||||||
|
}
|
||||||
|
return second.decrStackSize(index - first.getSizeInventory(), count);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackInSlotOnClosing(int index) {
|
||||||
|
if (index < first.getSizeInventory()) {
|
||||||
|
return first.getStackInSlotOnClosing(index);
|
||||||
|
}
|
||||||
|
return second.getStackInSlotOnClosing(index - first.getSizeInventory());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInventorySlotContents(int index, ItemStack stack) {
|
||||||
|
if (index < first.getSizeInventory()) {
|
||||||
|
first.setInventorySlotContents(index, stack);
|
||||||
|
} else {
|
||||||
|
second.setInventorySlotContents(index - first.getSizeInventory(), stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInventoryName() {
|
||||||
|
return first.getInventoryName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCustomInventoryName() {
|
||||||
|
return first.hasCustomInventoryName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInventoryStackLimit() {
|
||||||
|
return Math.min(first.getInventoryStackLimit(), second.getInventoryStackLimit());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void markDirty() {
|
||||||
|
first.markDirty();
|
||||||
|
second.markDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||||
|
return first.isUseableByPlayer(player) && second.isUseableByPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openInventory() {
|
||||||
|
first.openInventory();
|
||||||
|
second.openInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closeInventory() {
|
||||||
|
first.closeInventory();
|
||||||
|
second.closeInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
||||||
|
if (index < first.getSizeInventory()) {
|
||||||
|
return first.isItemValidForSlot(index, stack);
|
||||||
|
}
|
||||||
|
return second.isItemValidForSlot(index - first.getSizeInventory(), stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,6 +32,7 @@ public enum PacketIdClient implements IPacketId {
|
|||||||
ITEMSTACK_DISPLAY,
|
ITEMSTACK_DISPLAY,
|
||||||
FX_SIGNAL,
|
FX_SIGNAL,
|
||||||
TANK_LEVEL_UPDATE,
|
TANK_LEVEL_UPDATE,
|
||||||
|
TILE_CONFIGURATION,
|
||||||
|
|
||||||
// Core Genome
|
// Core Genome
|
||||||
GENOME_TRACKER_UPDATE,
|
GENOME_TRACKER_UPDATE,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import forestry.core.network.packets.PacketPipetteClick;
|
|||||||
import forestry.core.network.packets.PacketSocketUpdate;
|
import forestry.core.network.packets.PacketSocketUpdate;
|
||||||
import forestry.core.network.packets.PacketSolderingIronClick;
|
import forestry.core.network.packets.PacketSolderingIronClick;
|
||||||
import forestry.core.network.packets.PacketTankLevelUpdate;
|
import forestry.core.network.packets.PacketTankLevelUpdate;
|
||||||
|
import forestry.core.network.packets.PacketTileConfiguration;
|
||||||
import forestry.core.network.packets.PacketTileStream;
|
import forestry.core.network.packets.PacketTileStream;
|
||||||
|
|
||||||
public class PacketRegistryCore extends PacketRegistry {
|
public class PacketRegistryCore extends PacketRegistry {
|
||||||
@@ -47,6 +48,7 @@ public class PacketRegistryCore extends PacketRegistry {
|
|||||||
registerClientPacket(new PacketFXSignal());
|
registerClientPacket(new PacketFXSignal());
|
||||||
registerClientPacket(new PacketTankLevelUpdate());
|
registerClientPacket(new PacketTankLevelUpdate());
|
||||||
registerClientPacket(new PacketGenomeTrackerSync());
|
registerClientPacket(new PacketGenomeTrackerSync());
|
||||||
|
registerClientPacket(new PacketTileConfiguration());
|
||||||
|
|
||||||
registerServerPacket(new PacketGuiSelectRequest());
|
registerServerPacket(new PacketGuiSelectRequest());
|
||||||
registerServerPacket(new PacketPipetteClick());
|
registerServerPacket(new PacketPipetteClick());
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package forestry.core.network.packets;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
|
import forestry.core.network.DataInputStreamForestry;
|
||||||
|
import forestry.core.network.DataOutputStreamForestry;
|
||||||
|
import forestry.core.network.IForestryPacketClient;
|
||||||
|
import forestry.core.network.PacketIdClient;
|
||||||
|
import forestry.core.proxy.Proxies;
|
||||||
|
import forestry.core.tiles.IConfigurable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to sync the tile configuration from Server to Client.
|
||||||
|
*/
|
||||||
|
public class PacketTileConfiguration extends PacketCoordinates implements IForestryPacketClient {
|
||||||
|
|
||||||
|
private TileEntity tileEntity = null;
|
||||||
|
|
||||||
|
public PacketTileConfiguration() {}
|
||||||
|
|
||||||
|
public PacketTileConfiguration(TileEntity tileEntity) {
|
||||||
|
super(tileEntity);
|
||||||
|
this.tileEntity = tileEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||||
|
super.writeData(data);
|
||||||
|
if (tileEntity instanceof IConfigurable) {
|
||||||
|
((IConfigurable) tileEntity).writeConfigurationData(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||||
|
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||||
|
if (tile instanceof IConfigurable) {
|
||||||
|
((IConfigurable) tile).readConfigurationData(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PacketIdClient getPacketId() {
|
||||||
|
return PacketIdClient.TILE_CONFIGURATION;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -51,7 +51,9 @@ public class TextureManager implements ITextureManager {
|
|||||||
"analyzer/nocturnal", "analyzer/princess", "analyzer/pure_breed", "analyzer/pure_cave",
|
"analyzer/nocturnal", "analyzer/princess", "analyzer/pure_breed", "analyzer/pure_cave",
|
||||||
"analyzer/pure_flyer", "analyzer/pure_nocturnal", "analyzer/queen", "particles/swarm_bee",
|
"analyzer/pure_flyer", "analyzer/pure_nocturnal", "analyzer/queen", "particles/swarm_bee",
|
||||||
"errors/errored", "errors/unknown", "slots/blocked", "slots/blocked_2", "slots/liquid",
|
"errors/errored", "errors/unknown", "slots/blocked", "slots/blocked_2", "slots/liquid",
|
||||||
"slots/container", "slots/locked", "mail/carrier.player", "mail/carrier.trader" };
|
"slots/container", "slots/locked", "mail/carrier.player", "mail/carrier.trader",
|
||||||
|
"misc/search_ingredients.internal_inventory", "misc/search_ingredients.player_inventory",
|
||||||
|
"misc/search_ingredients.all_inventories" };
|
||||||
for (String str : defaultIconNames) {
|
for (String str : defaultIconNames) {
|
||||||
IIcon icon = registerTex(register, str);
|
IIcon icon = registerTex(register, str);
|
||||||
defaultIcons.put(str, icon);
|
defaultIcons.put(str, icon);
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package forestry.core.tiles;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import forestry.core.network.DataInputStreamForestry;
|
||||||
|
import forestry.core.network.DataOutputStreamForestry;
|
||||||
|
|
||||||
|
public interface IConfigurable {
|
||||||
|
|
||||||
|
void writeConfigurationData(DataOutputStreamForestry data) throws IOException;
|
||||||
|
|
||||||
|
void readConfigurationData(DataInputStreamForestry data) throws IOException;
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package forestry.core.tiles;
|
||||||
|
|
||||||
|
public interface IIngredientsSearchController {
|
||||||
|
|
||||||
|
IngredientsStorage getIngredientsStorage();
|
||||||
|
|
||||||
|
void setIngredientsStorage(IngredientsStorage ingredientsStorage);
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package forestry.core.tiles;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
|
||||||
|
import forestry.core.inventory.MergedInventories;
|
||||||
|
|
||||||
|
public enum IngredientsStorage {
|
||||||
|
|
||||||
|
INTERNAL_INVENTORY,
|
||||||
|
PLAYER_INVENTORY,
|
||||||
|
ALL_INVENTORIES;
|
||||||
|
|
||||||
|
public static final IngredientsStorage[] VALUES = values();
|
||||||
|
|
||||||
|
public static IngredientsStorage fromInt(int value) {
|
||||||
|
value = value % VALUES.length;
|
||||||
|
if (value < 0) {
|
||||||
|
value += VALUES.length;
|
||||||
|
}
|
||||||
|
return VALUES[value];
|
||||||
|
}
|
||||||
|
|
||||||
|
public IngredientsStorage next() {
|
||||||
|
return fromInt(ordinal() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IngredientsStorage previous() {
|
||||||
|
return fromInt(ordinal() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IInventory getInventory(IInventory internal, EntityPlayer player) {
|
||||||
|
switch (this) {
|
||||||
|
case PLAYER_INVENTORY:
|
||||||
|
return player.inventory;
|
||||||
|
case ALL_INVENTORIES:
|
||||||
|
return new MergedInventories(internal, player.inventory);
|
||||||
|
default:
|
||||||
|
return internal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ import forestry.core.gui.slots.SlotCraftMatrix;
|
|||||||
import forestry.core.gui.slots.SlotCrafter;
|
import forestry.core.gui.slots.SlotCrafter;
|
||||||
import forestry.core.network.packets.PacketGuiSelectRequest;
|
import forestry.core.network.packets.PacketGuiSelectRequest;
|
||||||
import forestry.core.proxy.Proxies;
|
import forestry.core.proxy.Proxies;
|
||||||
|
import forestry.core.tiles.IngredientsStorage;
|
||||||
import forestry.core.utils.ItemStackUtil;
|
import forestry.core.utils.ItemStackUtil;
|
||||||
import forestry.core.utils.Log;
|
import forestry.core.utils.Log;
|
||||||
import forestry.factory.inventory.InventoryCraftingForestry;
|
import forestry.factory.inventory.InventoryCraftingForestry;
|
||||||
@@ -207,6 +208,15 @@ public class ContainerWorktable extends ContainerTile<TileWorktable> implements
|
|||||||
sendPacketToCrafters(new PacketWorktableRecipeUpdate(tile));
|
sendPacketToCrafters(new PacketWorktableRecipeUpdate(tile));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 200: { // switch ingredients storage
|
||||||
|
tile.setIngredientsStorage(IngredientsStorage.fromInt(secondary));
|
||||||
|
markConfigurationDirty();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IngredientsStorage getIngredientsStorage() {
|
||||||
|
return tile.getIngredientsStorage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -19,9 +19,12 @@ import forestry.core.config.Constants;
|
|||||||
import forestry.core.gui.GuiForestryTitled;
|
import forestry.core.gui.GuiForestryTitled;
|
||||||
import forestry.core.gui.buttons.GuiBetterButton;
|
import forestry.core.gui.buttons.GuiBetterButton;
|
||||||
import forestry.core.gui.buttons.StandardButtonTextureSets;
|
import forestry.core.gui.buttons.StandardButtonTextureSets;
|
||||||
|
import forestry.core.gui.ledgers.SearchIngregientsLedger;
|
||||||
import forestry.core.network.packets.PacketGuiSelectRequest;
|
import forestry.core.network.packets.PacketGuiSelectRequest;
|
||||||
import forestry.core.proxy.Proxies;
|
import forestry.core.proxy.Proxies;
|
||||||
import forestry.core.recipes.RecipeUtil;
|
import forestry.core.recipes.RecipeUtil;
|
||||||
|
import forestry.core.tiles.IIngredientsSearchController;
|
||||||
|
import forestry.core.tiles.IngredientsStorage;
|
||||||
import forestry.core.utils.InventoryUtil;
|
import forestry.core.utils.InventoryUtil;
|
||||||
import forestry.factory.gui.widgets.ClearWorktable;
|
import forestry.factory.gui.widgets.ClearWorktable;
|
||||||
import forestry.factory.gui.widgets.MemorizedRecipeSlot;
|
import forestry.factory.gui.widgets.MemorizedRecipeSlot;
|
||||||
@@ -30,13 +33,16 @@ import forestry.factory.recipes.MemorizedRecipe;
|
|||||||
import forestry.factory.recipes.RecipeMemory;
|
import forestry.factory.recipes.RecipeMemory;
|
||||||
import forestry.factory.tiles.TileWorktable;
|
import forestry.factory.tiles.TileWorktable;
|
||||||
|
|
||||||
public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWorktable> {
|
public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWorktable>
|
||||||
|
implements IIngredientsSearchController {
|
||||||
|
|
||||||
private static final int SPACING = 18;
|
private static final int SPACING = 18;
|
||||||
private boolean hasRecipeConflict = false;
|
private boolean hasRecipeConflict = false;
|
||||||
|
private final EntityPlayer player;
|
||||||
|
|
||||||
public GuiWorktable(EntityPlayer player, TileWorktable tile) {
|
public GuiWorktable(EntityPlayer player, TileWorktable tile) {
|
||||||
super(Constants.TEXTURE_PATH_GUI + "/worktable2.png", new ContainerWorktable(player, tile), tile);
|
super(Constants.TEXTURE_PATH_GUI + "/worktable2.png", new ContainerWorktable(player, tile), tile);
|
||||||
|
this.player = player;
|
||||||
|
|
||||||
ySize = 218;
|
ySize = 218;
|
||||||
|
|
||||||
@@ -60,6 +66,12 @@ public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWork
|
|||||||
widgetManager.add(new ClearWorktable(widgetManager, 66, 19));
|
widgetManager.add(new ClearWorktable(widgetManager, 66, 19));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addLedgers() {
|
||||||
|
super.addLedgers();
|
||||||
|
ledgerManager.add(new SearchIngregientsLedger(ledgerManager, this));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateScreen() {
|
public void updateScreen() {
|
||||||
super.updateScreen();
|
super.updateScreen();
|
||||||
@@ -82,7 +94,7 @@ public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWork
|
|||||||
.get(54 + InventoryGhostCrafting.SLOT_CRAFTING_RESULT);
|
.get(54 + InventoryGhostCrafting.SLOT_CRAFTING_RESULT);
|
||||||
|
|
||||||
if (func_146978_c(itemSlot.xDisplayPosition, itemSlot.yDisplayPosition, 16, 16, mouseX, mouseY)
|
if (func_146978_c(itemSlot.xDisplayPosition, itemSlot.yDisplayPosition, 16, 16, mouseX, mouseY)
|
||||||
&& !inventory.canTakeStack(InventoryGhostCrafting.SLOT_CRAFTING_RESULT)) {
|
&& !inventory.canTakeStack(player, InventoryGhostCrafting.SLOT_CRAFTING_RESULT)) {
|
||||||
final MemorizedRecipe recipe = inventory.getCurrentRecipe();
|
final MemorizedRecipe recipe = inventory.getCurrentRecipe();
|
||||||
|
|
||||||
if (recipe != null) {
|
if (recipe != null) {
|
||||||
@@ -121,4 +133,14 @@ public class GuiWorktable extends GuiForestryTitled<ContainerWorktable, TileWork
|
|||||||
int id = 100 + button.id;
|
int id = 100 + button.id;
|
||||||
Proxies.net.sendToServer(new PacketGuiSelectRequest(id, 0));
|
Proxies.net.sendToServer(new PacketGuiSelectRequest(id, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IngredientsStorage getIngredientsStorage() {
|
||||||
|
return container.getIngredientsStorage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIngredientsStorage(IngredientsStorage ingredientsStorage) {
|
||||||
|
Proxies.net.sendToServer(new PacketGuiSelectRequest(200, ingredientsStorage.ordinal()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ public interface ICrafterWorktable {
|
|||||||
|
|
||||||
ItemStack getResult();
|
ItemStack getResult();
|
||||||
|
|
||||||
boolean canTakeStack(int slotIndex);
|
boolean canTakeStack(EntityPlayer player, int slotIndex);
|
||||||
|
|
||||||
boolean onCraftingStart(EntityPlayer player);
|
boolean onCraftingStart(EntityPlayer player);
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ import forestry.core.inventory.wrappers.InventoryMapper;
|
|||||||
import forestry.core.network.DataInputStreamForestry;
|
import forestry.core.network.DataInputStreamForestry;
|
||||||
import forestry.core.network.DataOutputStreamForestry;
|
import forestry.core.network.DataOutputStreamForestry;
|
||||||
import forestry.core.recipes.RecipeUtil;
|
import forestry.core.recipes.RecipeUtil;
|
||||||
|
import forestry.core.tiles.IConfigurable;
|
||||||
|
import forestry.core.tiles.IngredientsStorage;
|
||||||
import forestry.core.tiles.TileBase;
|
import forestry.core.tiles.TileBase;
|
||||||
import forestry.core.utils.InventoryUtil;
|
import forestry.core.utils.InventoryUtil;
|
||||||
import forestry.core.utils.ItemStackUtil;
|
import forestry.core.utils.ItemStackUtil;
|
||||||
@@ -35,13 +37,14 @@ import forestry.factory.inventory.InventoryWorktable;
|
|||||||
import forestry.factory.recipes.MemorizedRecipe;
|
import forestry.factory.recipes.MemorizedRecipe;
|
||||||
import forestry.factory.recipes.RecipeMemory;
|
import forestry.factory.recipes.RecipeMemory;
|
||||||
|
|
||||||
public class TileWorktable extends TileBase implements ICrafterWorktable {
|
public class TileWorktable extends TileBase implements ICrafterWorktable, IConfigurable {
|
||||||
|
|
||||||
private final RecipeMemory recipeMemory;
|
private final RecipeMemory recipeMemory;
|
||||||
private final InventoryAdapterTile<?> craftingDisplay;
|
private final InventoryAdapterTile<?> craftingDisplay;
|
||||||
private MemorizedRecipe currentRecipe;
|
private MemorizedRecipe currentRecipe;
|
||||||
private long savedTick = 0;
|
private long savedTick = 0;
|
||||||
private long savedSystemTimeExpiration = 0;
|
private long savedSystemTimeExpiration = 0;
|
||||||
|
private IngredientsStorage ingredientsStorage = IngredientsStorage.INTERNAL_INVENTORY;
|
||||||
|
|
||||||
public TileWorktable() {
|
public TileWorktable() {
|
||||||
super("worktable");
|
super("worktable");
|
||||||
@@ -58,6 +61,7 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
|||||||
|
|
||||||
craftingDisplay.writeToNBT(nbttagcompound);
|
craftingDisplay.writeToNBT(nbttagcompound);
|
||||||
recipeMemory.writeToNBT(nbttagcompound);
|
recipeMemory.writeToNBT(nbttagcompound);
|
||||||
|
nbttagcompound.setInteger("IngredientsStorage", ingredientsStorage.ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -66,6 +70,7 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
|||||||
|
|
||||||
craftingDisplay.readFromNBT(nbttagcompound);
|
craftingDisplay.readFromNBT(nbttagcompound);
|
||||||
recipeMemory.readFromNBT(nbttagcompound);
|
recipeMemory.readFromNBT(nbttagcompound);
|
||||||
|
ingredientsStorage = IngredientsStorage.fromInt(nbttagcompound.getInteger("IngredientsStorage"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NETWORK */
|
/* NETWORK */
|
||||||
@@ -108,16 +113,20 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IInventory getIngredientsInventory(EntityPlayer player) {
|
||||||
|
return ingredientsStorage.getInventory(this, player);
|
||||||
|
}
|
||||||
|
|
||||||
/* ICrafterWorktable */
|
/* ICrafterWorktable */
|
||||||
@Override
|
@Override
|
||||||
public boolean canTakeStack(int craftingSlotIndex) {
|
public boolean canTakeStack(EntityPlayer player, int craftingSlotIndex) {
|
||||||
if (craftingSlotIndex == InventoryGhostCrafting.SLOT_CRAFTING_RESULT) {
|
if (craftingSlotIndex == InventoryGhostCrafting.SLOT_CRAFTING_RESULT) {
|
||||||
return canCraftCurrentRecipe();
|
return canCraftCurrentRecipe(player);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canCraftCurrentRecipe() {
|
private boolean canCraftCurrentRecipe(EntityPlayer player) {
|
||||||
if (currentRecipe == null) {
|
if (currentRecipe == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -139,7 +148,7 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ItemStack[] recipeItems = InventoryUtil.getStacks(currentRecipe.getCraftMatrix());
|
ItemStack[] recipeItems = InventoryUtil.getStacks(currentRecipe.getCraftMatrix());
|
||||||
ItemStack[] inventory = InventoryUtil.getStacks(this);
|
ItemStack[] inventory = InventoryUtil.getStacks(getIngredientsInventory(player));
|
||||||
InventoryCraftingForestry crafting = RecipeUtil
|
InventoryCraftingForestry crafting = RecipeUtil
|
||||||
.getCraftRecipe(recipeItems, inventory, worldObj, currentRecipe.getRecipeOutput());
|
.getCraftRecipe(recipeItems, inventory, worldObj, currentRecipe.getRecipeOutput());
|
||||||
|
|
||||||
@@ -152,8 +161,9 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IInventory ingredientsInventory = getIngredientsInventory(player);
|
||||||
ItemStack[] recipeItems = InventoryUtil.getStacks(currentRecipe.getCraftMatrix());
|
ItemStack[] recipeItems = InventoryUtil.getStacks(currentRecipe.getCraftMatrix());
|
||||||
ItemStack[] inventory = InventoryUtil.getStacks(this);
|
ItemStack[] inventory = InventoryUtil.getStacks(ingredientsInventory);
|
||||||
InventoryCraftingForestry crafting = RecipeUtil
|
InventoryCraftingForestry crafting = RecipeUtil
|
||||||
.getCraftRecipe(recipeItems, inventory, worldObj, currentRecipe.getRecipeOutput());
|
.getCraftRecipe(recipeItems, inventory, worldObj, currentRecipe.getRecipeOutput());
|
||||||
if (crafting == null) {
|
if (crafting == null) {
|
||||||
@@ -163,7 +173,8 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
|||||||
recipeItems = InventoryUtil.getStacks(crafting);
|
recipeItems = InventoryUtil.getStacks(crafting);
|
||||||
|
|
||||||
// craft recipe should exactly match ingredients here, so no oreDict or tool matching
|
// craft recipe should exactly match ingredients here, so no oreDict or tool matching
|
||||||
ItemStack[] removed = InventoryUtil.removeSets(this, 1, recipeItems, player, false, false, false);
|
ItemStack[] removed = InventoryUtil
|
||||||
|
.removeSets(ingredientsInventory, 1, recipeItems, player, false, false, false);
|
||||||
if (removed == null) {
|
if (removed == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -175,6 +186,7 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
|||||||
@Override
|
@Override
|
||||||
public void onCraftingComplete(EntityPlayer player) {
|
public void onCraftingComplete(EntityPlayer player) {
|
||||||
IInventory craftingInventory = getCraftingDisplay();
|
IInventory craftingInventory = getCraftingDisplay();
|
||||||
|
IInventory ingredientsInventory = getIngredientsInventory(player);
|
||||||
for (int i = 0; i < craftingInventory.getSizeInventory(); ++i) {
|
for (int i = 0; i < craftingInventory.getSizeInventory(); ++i) {
|
||||||
ItemStack itemStack = craftingInventory.getStackInSlot(i);
|
ItemStack itemStack = craftingInventory.getStackInSlot(i);
|
||||||
if (itemStack == null) {
|
if (itemStack == null) {
|
||||||
@@ -202,7 +214,7 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!InventoryUtil.tryAddStack(this, container, true)) {
|
if (!InventoryUtil.tryAddStack(ingredientsInventory, container, true)) {
|
||||||
player.dropPlayerItemWithRandomChoice(container, false);
|
player.dropPlayerItemWithRandomChoice(container, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -287,6 +299,14 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IngredientsStorage getIngredientsStorage() {
|
||||||
|
return ingredientsStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIngredientsStorage(IngredientsStorage ingredientsStorage) {
|
||||||
|
this.ingredientsStorage = ingredientsStorage;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getGui(EntityPlayer player, int data) {
|
public Object getGui(EntityPlayer player, int data) {
|
||||||
return new GuiWorktable(player, this);
|
return new GuiWorktable(player, this);
|
||||||
@@ -296,4 +316,14 @@ public class TileWorktable extends TileBase implements ICrafterWorktable {
|
|||||||
public Object getContainer(EntityPlayer player, int data) {
|
public Object getContainer(EntityPlayer player, int data) {
|
||||||
return new ContainerWorktable(player, this);
|
return new ContainerWorktable(player, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeConfigurationData(DataOutputStreamForestry data) throws IOException {
|
||||||
|
data.writeEnum(ingredientsStorage, IngredientsStorage.VALUES);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readConfigurationData(DataInputStreamForestry data) throws IOException {
|
||||||
|
ingredientsStorage = data.readEnum(IngredientsStorage.VALUES);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -243,6 +243,11 @@ for.gui.noeffect=No effect
|
|||||||
for.gui.owner=Owner
|
for.gui.owner=Owner
|
||||||
for.gui.page=Page
|
for.gui.page=Page
|
||||||
|
|
||||||
|
for.gui.search_ingredients=Search Items
|
||||||
|
for.gui.search_ingredients.internal_inventory=Internal Inventory
|
||||||
|
for.gui.search_ingredients.player_inventory=Player Inventory
|
||||||
|
for.gui.search_ingredients.all_inventories=All Inventories
|
||||||
|
|
||||||
for.gui.pipe.filter.anything=Anything
|
for.gui.pipe.filter.anything=Anything
|
||||||
for.gui.pipe.filter.bee=Any Bees
|
for.gui.pipe.filter.bee=Any Bees
|
||||||
for.gui.pipe.filter.cave=Cave-Dwellers
|
for.gui.pipe.filter.cave=Cave-Dwellers
|
||||||
|
|||||||
@@ -241,6 +241,11 @@ for.gui.noeffect=Нет эффекта
|
|||||||
for.gui.owner=Владелец
|
for.gui.owner=Владелец
|
||||||
for.gui.page=Страница
|
for.gui.page=Страница
|
||||||
|
|
||||||
|
for.gui.search_ingredients=Искать предметы
|
||||||
|
for.gui.search_ingredients.internal_inventory=Встроенный инвентарь
|
||||||
|
for.gui.search_ingredients.player_inventory=Инвентарь игрока
|
||||||
|
for.gui.search_ingredients.all_inventories=Все инвентари
|
||||||
|
|
||||||
for.gui.pipe.filter.anything=Всё
|
for.gui.pipe.filter.anything=Всё
|
||||||
for.gui.pipe.filter.bee=Любые пчелы
|
for.gui.pipe.filter.bee=Любые пчелы
|
||||||
for.gui.pipe.filter.cave=Пещерные
|
for.gui.pipe.filter.cave=Пещерные
|
||||||
|
|||||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 469 B |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 446 B |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 456 B |
@@ -45,3 +45,7 @@ ledger.farm.background=2ca22c
|
|||||||
ledger.farm.header=e1c92f
|
ledger.farm.header=e1c92f
|
||||||
ledger.farm.subheader=aaafb8
|
ledger.farm.subheader=aaafb8
|
||||||
ledger.farm.text=000000
|
ledger.farm.text=000000
|
||||||
|
|
||||||
|
ledger.search_ingredients.background=ffffff
|
||||||
|
ledger.search_ingredients.header=587b96
|
||||||
|
ledger.search_ingredients.text=000000
|
||||||
Reference in new issue
Block a user