Removed Processing Pattern Encoder, that functionality is now available in the Pattern Grid

This commit is contained in:
raoulvdberge
2017-06-28 06:31:43 +02:00
parent bef1535c4d
commit f914596fe8
30 changed files with 414 additions and 768 deletions

View File

@@ -21,7 +21,6 @@ public final class RSBlocks {
public static final BlockCraftingMonitor CRAFTING_MONITOR = new BlockCraftingMonitor();
public static final BlockWirelessTransmitter WIRELESS_TRANSMITTER = new BlockWirelessTransmitter();
public static final BlockCrafter CRAFTER = new BlockCrafter();
public static final BlockProcessingPatternEncoder PROCESSING_PATTERN_ENCODER = new BlockProcessingPatternEncoder();
public static final BlockNetworkTransmitter NETWORK_TRANSMITTER = new BlockNetworkTransmitter();
public static final BlockNetworkReceiver NETWORK_RECEIVER = new BlockNetworkReceiver();
public static final BlockFluidInterface FLUID_INTERFACE = new BlockFluidInterface();

View File

@@ -17,16 +17,15 @@ public final class RSGui {
public static final int CRAFTING_MONITOR = 13;
public static final int WIRELESS_TRANSMITTER = 14;
public static final int CRAFTER = 15;
public static final int PROCESSING_PATTERN_ENCODER = 16;
public static final int FILTER = 17;
public static final int NETWORK_TRANSMITTER = 18;
public static final int FLUID_INTERFACE = 19;
public static final int EXTERNAL_STORAGE = 20;
public static final int FLUID_STORAGE = 21;
public static final int DISK_MANIPULATOR = 22;
public static final int WIRELESS_CRAFTING_MONITOR = 23;
public static final int READER_WRITER = 24;
public static final int SECURITY_MANAGER = 25;
public static final int STORAGE_MONITOR = 26;
public static final int PORTABLE_GRID = 27;
public static final int FILTER = 16;
public static final int NETWORK_TRANSMITTER = 17;
public static final int FLUID_INTERFACE = 18;
public static final int EXTERNAL_STORAGE = 19;
public static final int FLUID_STORAGE = 20;
public static final int DISK_MANIPULATOR = 21;
public static final int WIRELESS_CRAFTING_MONITOR = 22;
public static final int READER_WRITER = 23;
public static final int SECURITY_MANAGER = 24;
public static final int STORAGE_MONITOR = 25;
public static final int PORTABLE_GRID = 26;
}

View File

@@ -9,6 +9,7 @@ import com.raoulvdberge.refinedstorage.api.util.IComparer;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.block.BlockGrid;
import com.raoulvdberge.refinedstorage.block.GridType;
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFilter;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
@@ -48,6 +49,8 @@ public class NetworkNodeGrid extends NetworkNode implements IGrid {
public static final String NBT_OREDICT_PATTERN = "OredictPattern";
public static final String NBT_TAB_SELECTED = "TabSelected";
public static final String NBT_SIZE = "Size";
public static final String NBT_PROCESSING_PATTERN = "ProcessingPattern";
public static final String NBT_BLOCKING_PATTERN = "BlockingPattern";
public static final int SORTING_DIRECTION_ASCENDING = 0;
public static final int SORTING_DIRECTION_DESCENDING = 1;
@@ -83,6 +86,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGrid {
};
private InventoryCrafting matrix = new InventoryCrafting(craftingContainer, 3, 3);
private InventoryCraftResult result = new InventoryCraftResult();
private ItemHandlerBase matrixProcessing = new ItemHandlerBase(9 * 2, new ItemHandlerListenerNetworkNode(this));
private ItemHandlerBase patterns = new ItemHandlerBase(2, new ItemHandlerListenerNetworkNode(this), new ItemValidatorBasic(RSItems.PATTERN));
private List<Filter> filters = new ArrayList<>();
@@ -100,6 +104,8 @@ public class NetworkNodeGrid extends NetworkNode implements IGrid {
private int tabSelected = -1;
private boolean oredictPattern = false;
private boolean processingPattern = false;
private boolean blockingPattern = false;
public NetworkNodeGrid(World world, BlockPos pos) {
super(world, pos);
@@ -153,6 +159,22 @@ public class NetworkNodeGrid extends NetworkNode implements IGrid {
this.oredictPattern = oredictPattern;
}
public boolean isProcessingPattern() {
return world.isRemote ? TileGrid.PROCESSING_PATTERN.getValue() : processingPattern;
}
public void setProcessingPattern(boolean processingPattern) {
this.processingPattern = processingPattern;
}
public boolean isBlockingPattern() {
return blockingPattern;
}
public void setBlockingPattern(boolean blockingPattern) {
this.blockingPattern = blockingPattern;
}
public GridType getType() {
if (type == null && world.getBlockState(pos).getBlock() == RSBlocks.GRID) {
type = (GridType) world.getBlockState(pos).getValue(BlockGrid.TYPE);
@@ -205,6 +227,10 @@ public class NetworkNodeGrid extends NetworkNode implements IGrid {
return result;
}
public ItemHandlerBase getProcessingMatrix() {
return matrixProcessing;
}
@Override
public void onCraftingMatrixChanged() {
result.setInventorySlotContents(0, CraftingManager.findMatchingResult(matrix, world));
@@ -296,6 +322,20 @@ public class NetworkNodeGrid extends NetworkNode implements IGrid {
}
}
public void onPatternMatrixClear() {
for (int i = 0; i < matrixProcessing.getSlots(); ++i) {
matrixProcessing.setStackInSlot(i, ItemStack.EMPTY);
}
for (int i = 0; i < matrix.getSizeInventory(); ++i) {
matrix.setInventorySlotContents(i, ItemStack.EMPTY);
}
world.getMinecraftServer().getPlayerList().getPlayers().stream()
.filter(player -> player.openContainer instanceof ContainerGrid && ((ContainerGrid) player.openContainer).getTile() != null && ((ContainerGrid) player.openContainer).getTile().getPos().equals(pos))
.forEach(player -> player.openContainer.detectAndSendChanges());
}
@Override
public void onClosed(EntityPlayer player) {
// NO OP
@@ -372,13 +412,29 @@ public class NetworkNodeGrid extends NetworkNode implements IGrid {
ItemStack pattern = new ItemStack(RSItems.PATTERN);
if (processingPattern) {
ItemPattern.setBlocking(pattern, blockingPattern);
}
ItemPattern.setOredict(pattern, oredictPattern);
for (int i = 0; i < 9; ++i) {
ItemStack ingredient = matrix.getStackInSlot(i);
if (processingPattern) {
for (int i = 0; i < 18; ++i) {
if (!matrixProcessing.getStackInSlot(i).isEmpty()) {
if (i >= 9) {
ItemPattern.addOutput(pattern, matrixProcessing.getStackInSlot(i));
} else {
ItemPattern.setSlot(pattern, i, matrixProcessing.getStackInSlot(i));
}
}
}
} else {
for (int i = 0; i < 9; ++i) {
ItemStack ingredient = matrix.getStackInSlot(i);
if (!ingredient.isEmpty()) {
ItemPattern.setSlot(pattern, i, ingredient);
if (!ingredient.isEmpty()) {
ItemPattern.setSlot(pattern, i, ingredient);
}
}
}
@@ -387,7 +443,30 @@ public class NetworkNodeGrid extends NetworkNode implements IGrid {
}
public boolean canCreatePattern() {
return !result.getStackInSlot(0).isEmpty() && patterns.getStackInSlot(1).isEmpty() && !patterns.getStackInSlot(0).isEmpty();
if (patterns.getStackInSlot(0).isEmpty() || !patterns.getStackInSlot(1).isEmpty()) {
return false;
}
if (isProcessingPattern()) {
int inputsFilled = 0;
int outputsFilled = 0;
for (int i = 0; i < 9; ++i) {
if (!matrixProcessing.getStackInSlot(i).isEmpty()) {
inputsFilled++;
}
}
for (int i = 9; i < 18; ++i) {
if (!matrixProcessing.getStackInSlot(i).isEmpty()) {
outputsFilled++;
}
}
return inputsFilled > 0 && outputsFilled > 0;
} else {
return !result.getStackInSlot(0).isEmpty();
}
}
@Override
@@ -467,6 +546,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGrid {
RSUtils.readItemsLegacy(matrix, 0, tag);
RSUtils.readItems(patterns, 1, tag);
RSUtils.readItems(filter, 2, tag);
RSUtils.readItems(matrixProcessing, 3, tag);
if (tag.hasKey(NBT_TAB_SELECTED)) {
tabSelected = tag.getInteger(NBT_TAB_SELECTED);
@@ -485,6 +565,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGrid {
RSUtils.writeItemsLegacy(matrix, 0, tag);
RSUtils.writeItems(patterns, 1, tag);
RSUtils.writeItems(filter, 2, tag);
RSUtils.writeItems(matrixProcessing, 3, tag);
tag.setInteger(NBT_TAB_SELECTED, tabSelected);
@@ -502,6 +583,8 @@ public class NetworkNodeGrid extends NetworkNode implements IGrid {
tag.setInteger(NBT_SIZE, size);
tag.setBoolean(NBT_OREDICT_PATTERN, oredictPattern);
tag.setBoolean(NBT_PROCESSING_PATTERN, processingPattern);
tag.setBoolean(NBT_BLOCKING_PATTERN, blockingPattern);
return tag;
}
@@ -533,6 +616,14 @@ public class NetworkNodeGrid extends NetworkNode implements IGrid {
if (tag.hasKey(NBT_OREDICT_PATTERN)) {
oredictPattern = tag.getBoolean(NBT_OREDICT_PATTERN);
}
if (tag.hasKey(NBT_PROCESSING_PATTERN)) {
processingPattern = tag.getBoolean(NBT_PROCESSING_PATTERN);
}
if (tag.hasKey(NBT_BLOCKING_PATTERN)) {
blockingPattern = tag.getBoolean(NBT_BLOCKING_PATTERN);
}
}
@Override

View File

@@ -1,58 +0,0 @@
package com.raoulvdberge.refinedstorage.block;
import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.RSGui;
import com.raoulvdberge.refinedstorage.tile.TileProcessingPatternEncoder;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import javax.annotation.Nullable;
import java.util.List;
public class BlockProcessingPatternEncoder extends BlockBase {
public BlockProcessingPatternEncoder() {
super("processing_pattern_encoder");
}
@Override
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flag) {
super.addInformation(stack, world, tooltip, flag);
tooltip.add(I18n.format("block.refinedstorage:processing_pattern_encoder.tooltip.0"));
tooltip.add(I18n.format("block.refinedstorage:processing_pattern_encoder.tooltip.1", TextFormatting.WHITE + I18n.format("block.refinedstorage:grid.2.name") + TextFormatting.GRAY));
}
@Override
public boolean hasTileEntity(IBlockState state) {
return true;
}
@Override
public TileEntity createTileEntity(World world, IBlockState state) {
return new TileProcessingPatternEncoder();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (!world.isRemote) {
player.openGui(RS.INSTANCE, RSGui.PROCESSING_PATTERN_ENCODER, world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
}
@Override
@Nullable
public Direction getDirection() {
return null;
}
}

View File

@@ -60,8 +60,8 @@ public class ContainerGrid extends ContainerBase {
}
if (grid.getType() == GridType.PATTERN) {
addSlotToContainer(new SlotItemHandler(((NetworkNodeGrid) grid).getPatterns(), 0, 152, headerAndSlots + 4));
addSlotToContainer(new SlotOutput(((NetworkNodeGrid) grid).getPatterns(), 1, 152, headerAndSlots + 40));
addSlotToContainer(new SlotItemHandler(((NetworkNodeGrid) grid).getPatterns(), 0, 172, headerAndSlots + 4));
addSlotToContainer(new SlotOutput(((NetworkNodeGrid) grid).getPatterns(), 1, 172, headerAndSlots + 40));
}
if (grid instanceof IPortableGrid) {
@@ -87,21 +87,44 @@ public class ContainerGrid extends ContainerBase {
addSlotToContainer(craftingResultSlot = new SlotGridCraftingResult(this, getPlayer(), grid, 0, 130 + 4, headerAndSlots + 22));
} else if (grid.getType() == GridType.PATTERN) {
int x = 8;
int y = headerAndSlots + 4;
if (((NetworkNodeGrid) grid).isProcessingPattern()) {
int ox = 8;
int x = ox;
int y = headerAndSlots + 4;
for (int i = 0; i < 9; ++i) {
addSlotToContainer(new SlotFilterLegacy(grid.getCraftingMatrix(), i, x, y));
for (int i = 0; i < 9 * 2; ++i) {
addSlotToContainer(new SlotFilter(((NetworkNodeGrid) grid).getProcessingMatrix(), i, x, y, SlotFilter.FILTER_ALLOW_SIZE));
x += 18;
x += 18;
if ((i + 1) % 3 == 0) {
y += 18;
x = 8;
if ((i + 1) % 3 == 0) {
if (i == 8) {
ox = 98;
x = ox;
y = headerAndSlots + 4;
} else {
x = ox;
y += 18;
}
}
}
}
} else {
int x = 26;
int y = headerAndSlots + 4;
addSlotToContainer(patternResultSlot = new SlotDisabled(grid.getCraftingResult(), 0, 112 + 4, headerAndSlots + 22));
for (int i = 0; i < 9; ++i) {
addSlotToContainer(new SlotFilterLegacy(grid.getCraftingMatrix(), i, x, y));
x += 18;
if ((i + 1) % 3 == 0) {
y += 18;
x = 26;
}
}
addSlotToContainer(patternResultSlot = new SlotDisabled(grid.getCraftingResult(), 0, 134, headerAndSlots + 22));
}
}
}

View File

@@ -1,100 +0,0 @@
package com.raoulvdberge.refinedstorage.container;
import com.raoulvdberge.refinedstorage.container.slot.SlotFilter;
import com.raoulvdberge.refinedstorage.container.slot.SlotOutput;
import com.raoulvdberge.refinedstorage.tile.TileProcessingPatternEncoder;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.SlotItemHandler;
import java.util.Collection;
public class ContainerProcessingPatternEncoder extends ContainerBase {
public ContainerProcessingPatternEncoder(TileProcessingPatternEncoder encoder, EntityPlayer player) {
super(encoder, player);
addSlotToContainer(new SlotItemHandler(encoder.getPatterns(), 0, 152, 18));
addSlotToContainer(new SlotOutput(encoder.getPatterns(), 1, 152, 58));
int ox = 8;
int x = ox;
int y = 20;
for (int i = 0; i < 9 * 2; ++i) {
addSlotToContainer(new SlotFilter(encoder.getConfiguration(), i, x, y, SlotFilter.FILTER_ALLOW_SIZE));
x += 18;
if ((i + 1) % 3 == 0) {
if (i == 8) {
ox = 90;
x = ox;
y = 20;
} else {
x = ox;
y += 18;
}
}
}
addPlayerInventory(8, 101);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
ItemStack stack = ItemStack.EMPTY;
Slot slot = getSlot(index);
if (!(slot instanceof SlotFilter) && slot.getHasStack()) {
stack = slot.getStack();
if (index < 2) {
if (!mergeItemStack(stack, 2 + 18, inventorySlots.size(), false)) {
return ItemStack.EMPTY;
}
} else if (!mergeItemStack(stack, 0, 1, false)) {
return ItemStack.EMPTY;
}
if (stack.getCount() == 0) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
}
return stack;
}
public void clearInputsAndOutputs() {
for (int i = 2; i < 2 + (9 * 2); ++i) {
getSlot(i).putStack(ItemStack.EMPTY);
getSlot(i).onSlotChanged();
}
}
public void setInputs(Collection<ItemStack> stacks) {
setSlots(stacks, 2, 2 + 9);
}
public void setOutputs(Collection<ItemStack> stacks) {
setSlots(stacks, 2 + 9, 2 + 9 * 2);
}
private void setSlots(Collection<ItemStack> stacks, int begin, int end) {
for (ItemStack stack : stacks) {
for (int i = begin; i < end; ++i) {
Slot slot = getSlot(i);
if (!slot.getHasStack() && slot.isItemValid(stack)) {
slot.putStack(stack);
slot.onSlotChanged();
break;
}
}
}
}
}

View File

@@ -62,8 +62,6 @@ public class GuiHandler implements IGuiHandler {
return new ContainerWirelessTransmitter((TileWirelessTransmitter) tile, player);
case RSGui.CRAFTER:
return new ContainerCrafter((TileCrafter) tile, player);
case RSGui.PROCESSING_PATTERN_ENCODER:
return new ContainerProcessingPatternEncoder((TileProcessingPatternEncoder) tile, player);
case RSGui.NETWORK_TRANSMITTER:
return new ContainerNetworkTransmitter((TileNetworkTransmitter) tile, player);
case RSGui.FLUID_INTERFACE:
@@ -139,8 +137,6 @@ public class GuiHandler implements IGuiHandler {
return new GuiWirelessTransmitter((ContainerWirelessTransmitter) getContainer(ID, player, tile));
case RSGui.CRAFTER:
return new GuiCrafter((ContainerCrafter) getContainer(ID, player, tile));
case RSGui.PROCESSING_PATTERN_ENCODER:
return new GuiProcessingPatternEncoder((ContainerProcessingPatternEncoder) getContainer(ID, player, tile), (TileProcessingPatternEncoder) tile);
case RSGui.FILTER:
return new GuiFilter(getFilterContainer(player, x));
case RSGui.NETWORK_TRANSMITTER:

View File

@@ -1,117 +0,0 @@
package com.raoulvdberge.refinedstorage.gui;
import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.container.ContainerProcessingPatternEncoder;
import com.raoulvdberge.refinedstorage.network.MessageGridPatternCreate;
import com.raoulvdberge.refinedstorage.network.MessageProcessingPatternEncoderClear;
import com.raoulvdberge.refinedstorage.tile.TileProcessingPatternEncoder;
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
import net.minecraft.init.SoundEvents;
import net.minecraftforge.fml.client.config.GuiCheckBox;
import java.io.IOException;
public class GuiProcessingPatternEncoder extends GuiBase {
private TileProcessingPatternEncoder encoder;
private GuiCheckBox oredictPattern;
private GuiCheckBox blockingPattern;
public GuiProcessingPatternEncoder(ContainerProcessingPatternEncoder container, TileProcessingPatternEncoder encoder) {
super(container, 176, 183);
this.encoder = encoder;
}
@Override
public void init(int x, int y) {
oredictPattern = addCheckBox(x + 7, y + 76, I18n.format("misc.refinedstorage:oredict"), TileProcessingPatternEncoder.OREDICT_PATTERN.getValue());
blockingPattern = addCheckBox(x + 60, y + 76, I18n.format("misc.refinedstorage:blocking"), TileProcessingPatternEncoder.BLOCKING_TASK_PATTERN.getValue());
}
@Override
public void update(int x, int y) {
}
private boolean isOverCreatePattern(int mouseX, int mouseY) {
return inBounds(152, 38, 16, 16, mouseX, mouseY) && encoder.canCreatePattern();
}
private boolean isOverClear(int mouseX, int mouseY) {
return inBounds(80, 19, 7, 7, mouseX, mouseY);
}
@Override
public void drawBackground(int x, int y, int mouseX, int mouseY) {
bindTexture("gui/processing_pattern_encoder.png");
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
int ty = 0;
if (isOverCreatePattern(mouseX - guiLeft, mouseY - guiTop)) {
ty = 1;
}
if (!encoder.canCreatePattern()) {
ty = 2;
}
drawTexture(x + 152, y + 38, 178, ty * 16, 16, 16);
}
@Override
public void drawForeground(int mouseX, int mouseY) {
drawString(7, 7, t("gui.refinedstorage:processing_pattern_encoder"));
drawString(7, 90, t("container.inventory"));
if (isOverCreatePattern(mouseX, mouseY)) {
drawTooltip(mouseX, mouseY, t("gui.refinedstorage:processing_pattern_encoder.pattern_create"));
}
if (isOverClear(mouseX, mouseY)) {
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:clear"));
}
}
@Override
protected void actionPerformed(GuiButton button) throws IOException {
super.actionPerformed(button);
if (button == oredictPattern) {
TileDataManager.setParameter(TileProcessingPatternEncoder.OREDICT_PATTERN, oredictPattern.isChecked());
} else if (button == blockingPattern) {
TileDataManager.setParameter(TileProcessingPatternEncoder.BLOCKING_TASK_PATTERN, blockingPattern.isChecked());
}
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
if (isOverCreatePattern(mouseX - guiLeft, mouseY - guiTop)) {
RS.INSTANCE.network.sendToServer(new MessageGridPatternCreate(encoder.getPos().getX(), encoder.getPos().getY(), encoder.getPos().getZ()));
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
} else if (isOverClear(mouseX - guiLeft, mouseY - guiTop)) {
RS.INSTANCE.network.sendToServer(new MessageProcessingPatternEncoderClear(encoder));
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
}
}
public void updateOredictPattern(boolean checked) {
if (oredictPattern != null) {
oredictPattern.setIsChecked(checked);
}
}
public void updateBlockingPattern(boolean checked) {
if (blockingPattern != null) {
blockingPattern.setIsChecked(checked);
}
}
}

View File

@@ -66,7 +66,10 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
private boolean wasConnected;
private GuiTextField searchField;
private GuiCheckBox oredictPattern;
private GuiCheckBox processingPattern;
private GuiCheckBox blockingPattern;
private IGrid grid;
@@ -144,7 +147,12 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
}
if (grid.getType() == GridType.PATTERN) {
oredictPattern = addCheckBox(x + 64, y + getTabDelta() + getHeader() + (getVisibleRows() * 18) + 46, t("misc.refinedstorage:oredict"), TileGrid.OREDICT_PATTERN.getValue());
processingPattern = addCheckBox(x + 7, y + getTabDelta() + getHeader() + (getVisibleRows() * 18) + 60, t("misc.refinedstorage:processing"), TileGrid.PROCESSING_PATTERN.getValue());
oredictPattern = addCheckBox(processingPattern.x + processingPattern.width + 5, y + getTabDelta() + getHeader() + (getVisibleRows() * 18) + 60, t("misc.refinedstorage:oredict"), TileGrid.OREDICT_PATTERN.getValue());
if (((NetworkNodeGrid) grid).isProcessingPattern()) {
blockingPattern = addCheckBox(oredictPattern.x + oredictPattern.width + 5, y + getTabDelta() + getHeader() + (getVisibleRows() * 18) + 60, t("misc.refinedstorage:blocking"), TileGrid.BLOCKING_PATTERN.getValue());
}
}
if (grid.getType() != GridType.FLUID && grid.getViewType() != -1) {
@@ -250,7 +258,13 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
@Override
public int getFooter() {
return (grid.getType() == GridType.CRAFTING || grid.getType() == GridType.PATTERN) ? 156 : 99;
if (grid.getType() == GridType.CRAFTING) {
return 156;
} else if (grid.getType() == GridType.PATTERN) {
return 169;
} else {
return 99;
}
}
@Override
@@ -259,8 +273,10 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
if (grid.getType() == GridType.NORMAL || grid.getType() == GridType.FLUID) {
yp += 16;
} else if (grid.getType() == GridType.CRAFTING || grid.getType() == GridType.PATTERN) {
} else if (grid.getType() == GridType.CRAFTING) {
yp += 73;
} else if (grid.getType() == GridType.PATTERN) {
yp += 86;
}
return yp;
@@ -308,14 +324,18 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
case CRAFTING:
return inBounds(82, y, 7, 7, mouseX, mouseY);
case PATTERN:
return inBounds(64, y, 7, 7, mouseX, mouseY);
if (TileGrid.PROCESSING_PATTERN.getValue()) {
return inBounds(154, y, 7, 7, mouseX, mouseY);
}
return inBounds(82, y, 7, 7, mouseX, mouseY);
default:
return false;
}
}
private boolean isOverCreatePattern(int mouseX, int mouseY) {
return grid.getType() == GridType.PATTERN && inBounds(152, getTabDelta() + getHeader() + (getVisibleRows() * 18) + 22, 16, 16, mouseX, mouseY) && ((NetworkNodeGrid) grid).canCreatePattern();
return grid.getType() == GridType.PATTERN && inBounds(172, getTabDelta() + getHeader() + (getVisibleRows() * 18) + 22, 16, 16, mouseX, mouseY) && ((NetworkNodeGrid) grid).canCreatePattern();
}
private int getTabDelta() {
@@ -379,7 +399,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
if (grid.getType() == GridType.CRAFTING) {
bindTexture("gui/crafting_grid.png");
} else if (grid.getType() == GridType.PATTERN) {
bindTexture("gui/pattern_grid.png");
bindTexture("gui/pattern_grid" + (((NetworkNodeGrid) grid).isProcessingPattern() ? "_processing" : "") + ".png");
} else if (grid instanceof IPortableGrid) {
bindTexture("gui/portable_grid.png");
} else {
@@ -421,7 +441,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
ty = 2;
}
drawTexture(x + 152, y + getTabDelta() + getHeader() + (getVisibleRows() * 18) + 22, 240, ty * 16, 16, 16);
drawTexture(x + 172, y + getTabDelta() + getHeader() + (getVisibleRows() * 18) + 22, 240, ty * 16, 16, 16);
}
if (searchField != null) {
@@ -504,6 +524,10 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
if (button == oredictPattern) {
TileDataManager.setParameter(TileGrid.OREDICT_PATTERN, oredictPattern.isChecked());
} else if (button == blockingPattern) {
TileDataManager.setParameter(TileGrid.BLOCKING_PATTERN, blockingPattern.isChecked());
} else if (button == processingPattern) {
TileDataManager.setParameter(TileGrid.PROCESSING_PATTERN, processingPattern.isChecked());
}
}
@@ -539,7 +563,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
RS.INSTANCE.network.sendToServer(new MessageGridPatternCreate(gridPos.getX(), gridPos.getY(), gridPos.getZ()));
} else if (grid.isActive()) {
if (clickedClear) {
RS.INSTANCE.network.sendToServer(new MessageGridCraftingClear());
RS.INSTANCE.network.sendToServer(new MessageGridClear());
}
ItemStack held = ((ContainerGrid) this.inventorySlots).getPlayer().inventory.getItemStack();
@@ -680,4 +704,10 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
oredictPattern.setIsChecked(checked);
}
}
public void updateBlockingPattern(boolean checked) {
if (blockingPattern != null) {
blockingPattern.setIsChecked(checked);
}
}
}

View File

@@ -20,8 +20,7 @@ public class RSJEIPlugin implements IModPlugin {
public void register(IModRegistry registry) {
INSTANCE = this;
registry.getRecipeTransferRegistry().addUniversalRecipeTransferHandler(new RecipeTransferHandlerPattern());
registry.getRecipeTransferRegistry().addRecipeTransferHandler(new RecipeTransferHandlerGrid(), "minecraft.crafting");
registry.getRecipeTransferRegistry().addUniversalRecipeTransferHandler(new RecipeTransferHandlerGrid());
registry.getRecipeTransferRegistry().addRecipeTransferHandler(ContainerSolderer.class, RecipeCategorySolderer.ID, 0, 3, 8, 36);
registry.handleRecipes(RecipeWrapperSolderer.class, recipe -> recipe, RecipeCategorySolderer.ID);

View File

@@ -1,8 +1,12 @@
package com.raoulvdberge.refinedstorage.integration.jei;
import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
import com.raoulvdberge.refinedstorage.block.GridType;
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
import com.raoulvdberge.refinedstorage.network.MessageGridCraftingTransfer;
import com.raoulvdberge.refinedstorage.network.MessageGridProcessingTransfer;
import com.raoulvdberge.refinedstorage.network.MessageGridTransfer;
import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
import mezz.jei.api.gui.IGuiIngredient;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
@@ -15,12 +19,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* @link https://github.com/zerofall/EZStorage/blob/master/src/main/java/com/zerofall/ezstorage/jei/RecipeTransferHandler.java
*/
public class RecipeTransferHandlerGrid implements IRecipeTransferHandler {
@Override
public Class<? extends Container> getContainerClass() {
@@ -30,35 +32,55 @@ public class RecipeTransferHandlerGrid implements IRecipeTransferHandler {
@Override
public IRecipeTransferError transferRecipe(Container container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
if (doTransfer) {
Map<Integer, ? extends IGuiIngredient<ItemStack>> inputs = recipeLayout.getItemStacks().getGuiIngredients();
IGrid grid = ((ContainerGrid) container).getGrid();
NBTTagCompound recipe = new NBTTagCompound();
if (grid.getType() == GridType.PATTERN && ((NetworkNodeGrid) grid).isProcessingPattern()) {
List<ItemStack> inputs = new LinkedList<>();
List<ItemStack> outputs = new LinkedList<>();
for (Slot slot : container.inventorySlots) {
if (slot.inventory instanceof InventoryCrafting) {
IGuiIngredient<ItemStack> ingredient = inputs.get(slot.getSlotIndex() + 1);
if (ingredient != null) {
List<ItemStack> possibleItems = ingredient.getAllIngredients();
NBTTagList tags = new NBTTagList();
for (int i = 0; i < possibleItems.size(); ++i) {
if (i >= 5) {
break; // Max 5 possible items to avoid reaching max network packet size
}
NBTTagCompound tag = new NBTTagCompound();
possibleItems.get(i).writeToNBT(tag);
tags.appendTag(tag);
for (IGuiIngredient<ItemStack> guiIngredient : recipeLayout.getItemStacks().getGuiIngredients().values()) {
if (guiIngredient != null && guiIngredient.getDisplayedIngredient() != null) {
ItemStack ingredient = guiIngredient.getDisplayedIngredient().copy();
if (guiIngredient.isInput()) {
inputs.add(ingredient);
} else {
outputs.add(ingredient);
}
recipe.setTag("#" + slot.getSlotIndex(), tags);
}
}
}
RS.INSTANCE.network.sendToServer(new MessageGridCraftingTransfer(recipe));
RS.INSTANCE.network.sendToServer(new MessageGridProcessingTransfer(inputs, outputs));
} else {
Map<Integer, ? extends IGuiIngredient<ItemStack>> inputs = recipeLayout.getItemStacks().getGuiIngredients();
NBTTagCompound recipe = new NBTTagCompound();
for (Slot slot : container.inventorySlots) {
if (slot.inventory instanceof InventoryCrafting) {
IGuiIngredient<ItemStack> ingredient = inputs.get(slot.getSlotIndex() + 1);
if (ingredient != null) {
List<ItemStack> possibleItems = ingredient.getAllIngredients();
NBTTagList tags = new NBTTagList();
for (int i = 0; i < possibleItems.size(); ++i) {
if (i >= 5) {
break; // Max 5 possible items to avoid reaching max network packet size
}
NBTTagCompound tag = new NBTTagCompound();
possibleItems.get(i).writeToNBT(tag);
tags.appendTag(tag);
}
recipe.setTag("#" + slot.getSlotIndex(), tags);
}
}
}
RS.INSTANCE.network.sendToServer(new MessageGridTransfer(recipe));
}
}
return null;

View File

@@ -1,46 +0,0 @@
package com.raoulvdberge.refinedstorage.integration.jei;
import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.container.ContainerProcessingPatternEncoder;
import com.raoulvdberge.refinedstorage.network.MessageProcessingPatternEncoderTransfer;
import mezz.jei.api.gui.IGuiIngredient;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import javax.annotation.Nullable;
import java.util.LinkedList;
import java.util.List;
public class RecipeTransferHandlerPattern implements IRecipeTransferHandler<ContainerProcessingPatternEncoder> {
@Override
public Class<ContainerProcessingPatternEncoder> getContainerClass() {
return ContainerProcessingPatternEncoder.class;
}
@Nullable
@Override
public IRecipeTransferError transferRecipe(ContainerProcessingPatternEncoder container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
if (doTransfer) {
List<ItemStack> inputs = new LinkedList<>();
List<ItemStack> outputs = new LinkedList<>();
for (IGuiIngredient<ItemStack> guiIngredient : recipeLayout.getItemStacks().getGuiIngredients().values()) {
if (guiIngredient != null && guiIngredient.getDisplayedIngredient() != null) {
ItemStack ingredient = guiIngredient.getDisplayedIngredient().copy();
if (guiIngredient.isInput()) {
inputs.add(ingredient);
} else {
outputs.add(ingredient);
}
}
}
RS.INSTANCE.network.sendToServer(new MessageProcessingPatternEncoderTransfer(inputs, outputs));
}
return null;
}
}

View File

@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.network;
import com.raoulvdberge.refinedstorage.RSUtils;
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
import com.raoulvdberge.refinedstorage.block.GridType;
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
@@ -12,8 +13,8 @@ import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
public class MessageGridCraftingClear extends MessageHandlerPlayerToServer<MessageGridCraftingClear> implements IMessage {
public MessageGridCraftingClear() {
public class MessageGridClear extends MessageHandlerPlayerToServer<MessageGridClear> implements IMessage {
public MessageGridClear() {
}
@Override
@@ -27,7 +28,7 @@ public class MessageGridCraftingClear extends MessageHandlerPlayerToServer<Messa
}
@Override
public void handle(MessageGridCraftingClear message, EntityPlayerMP player) {
public void handle(MessageGridClear message, EntityPlayerMP player) {
Container container = player.openContainer;
if (container instanceof ContainerGrid) {
@@ -44,9 +45,7 @@ public class MessageGridCraftingClear extends MessageHandlerPlayerToServer<Messa
}
}
} else if (grid.getType() == GridType.PATTERN) {
for (int i = 0; i < matrix.getSizeInventory(); ++i) {
matrix.setInventorySlotContents(i, ItemStack.EMPTY);
}
((NetworkNodeGrid) grid).onPatternMatrixClear();
}
}
}

View File

@@ -1,7 +1,6 @@
package com.raoulvdberge.refinedstorage.network;
import com.raoulvdberge.refinedstorage.block.GridType;
import com.raoulvdberge.refinedstorage.tile.TileProcessingPatternEncoder;
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -43,8 +42,6 @@ public class MessageGridPatternCreate extends MessageHandlerPlayerToServer<Messa
if (tile instanceof TileGrid && ((TileGrid) tile).getNode().getType() == GridType.PATTERN) {
((TileGrid) tile).getNode().onCreatePattern();
} else if (tile instanceof TileProcessingPatternEncoder) {
((TileProcessingPatternEncoder) tile).onCreatePattern();
}
}
}

View File

@@ -0,0 +1,104 @@
package com.raoulvdberge.refinedstorage.network;
import com.raoulvdberge.refinedstorage.RSUtils;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
import com.raoulvdberge.refinedstorage.block.GridType;
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import java.util.ArrayList;
import java.util.Collection;
public class MessageGridProcessingTransfer extends MessageHandlerPlayerToServer<MessageGridProcessingTransfer> implements IMessage {
private Collection<ItemStack> inputs;
private Collection<ItemStack> outputs;
public MessageGridProcessingTransfer() {
}
public MessageGridProcessingTransfer(Collection<ItemStack> inputs, Collection<ItemStack> outputs) {
this.inputs = inputs;
this.outputs = outputs;
}
@Override
public void fromBytes(ByteBuf buf) {
int size = buf.readInt();
this.inputs = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
this.inputs.add(RSUtils.readItemStack(buf));
}
size = buf.readInt();
this.outputs = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
this.outputs.add(RSUtils.readItemStack(buf));
}
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(inputs.size());
for (ItemStack stack : inputs) {
RSUtils.writeItemStack(buf, stack);
}
buf.writeInt(outputs.size());
for (ItemStack stack : outputs) {
RSUtils.writeItemStack(buf, stack);
}
}
@Override
public void handle(MessageGridProcessingTransfer message, EntityPlayerMP player) {
if (player.openContainer instanceof ContainerGrid) {
IGrid grid = ((ContainerGrid) player.openContainer).getGrid();
if (grid.getType() == GridType.PATTERN) {
ItemHandlerBase handler = ((NetworkNodeGrid) grid).getProcessingMatrix();
clearInputsAndOutputs(handler);
setInputs(handler, message.inputs);
setOutputs(handler, message.outputs);
}
}
}
private void clearInputsAndOutputs(ItemHandlerBase handler) {
for (int i = 0; i < 9 * 2; ++i) {
handler.setStackInSlot(i, ItemStack.EMPTY);
}
}
private void setInputs(ItemHandlerBase handler, Collection<ItemStack> stacks) {
setSlots(handler, stacks, 0, 9);
}
private void setOutputs(ItemHandlerBase handler, Collection<ItemStack> stacks) {
setSlots(handler, stacks, 9, 18);
}
private void setSlots(ItemHandlerBase handler, Collection<ItemStack> stacks, int begin, int end) {
for (ItemStack stack : stacks) {
handler.setStackInSlot(begin, stack);
begin++;
if (begin >= end) {
break;
}
}
}
}

View File

@@ -12,13 +12,13 @@ import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
public class MessageGridCraftingTransfer extends MessageHandlerPlayerToServer<MessageGridCraftingTransfer> implements IMessage {
public class MessageGridTransfer extends MessageHandlerPlayerToServer<MessageGridTransfer> implements IMessage {
private NBTTagCompound recipe;
public MessageGridCraftingTransfer() {
public MessageGridTransfer() {
}
public MessageGridCraftingTransfer(NBTTagCompound recipe) {
public MessageGridTransfer(NBTTagCompound recipe) {
this.recipe = recipe;
}
@@ -33,7 +33,7 @@ public class MessageGridCraftingTransfer extends MessageHandlerPlayerToServer<Me
}
@Override
public void handle(MessageGridCraftingTransfer message, EntityPlayerMP player) {
public void handle(MessageGridTransfer message, EntityPlayerMP player) {
if (player.openContainer instanceof ContainerGrid) {
IGrid grid = ((ContainerGrid) player.openContainer).getGrid();

View File

@@ -1,52 +0,0 @@
package com.raoulvdberge.refinedstorage.network;
import com.raoulvdberge.refinedstorage.tile.TileProcessingPatternEncoder;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
public class MessageProcessingPatternEncoderClear extends MessageHandlerPlayerToServer<MessageProcessingPatternEncoderClear> implements IMessage {
private int x;
private int y;
private int z;
public MessageProcessingPatternEncoderClear() {
}
public MessageProcessingPatternEncoderClear(TileProcessingPatternEncoder encoder) {
this.x = encoder.getPos().getX();
this.y = encoder.getPos().getY();
this.z = encoder.getPos().getZ();
}
@Override
public void fromBytes(ByteBuf buf) {
x = buf.readInt();
y = buf.readInt();
z = buf.readInt();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(x);
buf.writeInt(y);
buf.writeInt(z);
}
@Override
public void handle(MessageProcessingPatternEncoderClear message, EntityPlayerMP player) {
TileEntity tile = player.getEntityWorld().getTileEntity(new BlockPos(message.x, message.y, message.z));
if (tile instanceof TileProcessingPatternEncoder) {
TileProcessingPatternEncoder encoder = (TileProcessingPatternEncoder) tile;
for (int i = 0; i < encoder.getConfiguration().getSlots(); ++i) {
encoder.getConfiguration().setStackInSlot(i, ItemStack.EMPTY);
}
}
}
}

View File

@@ -1,70 +0,0 @@
package com.raoulvdberge.refinedstorage.network;
import com.raoulvdberge.refinedstorage.RSUtils;
import com.raoulvdberge.refinedstorage.container.ContainerProcessingPatternEncoder;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import java.util.ArrayList;
import java.util.Collection;
public class MessageProcessingPatternEncoderTransfer extends MessageHandlerPlayerToServer<MessageProcessingPatternEncoderTransfer> implements IMessage {
private Collection<ItemStack> inputs;
private Collection<ItemStack> outputs;
public MessageProcessingPatternEncoderTransfer() {
}
public MessageProcessingPatternEncoderTransfer(Collection<ItemStack> inputs, Collection<ItemStack> outputs) {
this.inputs = inputs;
this.outputs = outputs;
}
@Override
public void fromBytes(ByteBuf buf) {
int size = buf.readInt();
this.inputs = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
this.inputs.add(RSUtils.readItemStack(buf));
}
size = buf.readInt();
this.outputs = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
this.outputs.add(RSUtils.readItemStack(buf));
}
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(inputs.size());
for (ItemStack stack : inputs) {
RSUtils.writeItemStack(buf, stack);
}
buf.writeInt(outputs.size());
for (ItemStack stack : outputs) {
RSUtils.writeItemStack(buf, stack);
}
}
@Override
public void handle(MessageProcessingPatternEncoderTransfer message, EntityPlayerMP player) {
if (player.openContainer instanceof ContainerProcessingPatternEncoder) {
ContainerProcessingPatternEncoder encoder = (ContainerProcessingPatternEncoder) player.openContainer;
encoder.clearInputsAndOutputs();
encoder.setInputs(message.inputs);
encoder.setOutputs(message.outputs);
}
}
}

View File

@@ -217,7 +217,6 @@ public class ProxyClient extends ProxyCommon {
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.WIRELESS_TRANSMITTER), 0, new ModelResourceLocation("refinedstorage:wireless_transmitter", "inventory"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.CRAFTING_MONITOR), 0, new ModelResourceLocation("refinedstorage:crafting_monitor", "inventory"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.CRAFTER), 0, new ModelResourceLocation("refinedstorage:crafter", "connected=false,direction=north"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.PROCESSING_PATTERN_ENCODER), 0, new ModelResourceLocation("refinedstorage:processing_pattern_encoder", "inventory"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.NETWORK_TRANSMITTER), 0, new ModelResourceLocation("refinedstorage:network_transmitter", "inventory"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.NETWORK_RECEIVER), 0, new ModelResourceLocation("refinedstorage:network_receiver", "inventory"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.STORAGE), ItemStorageType.TYPE_1K.getId(), new ModelResourceLocation("refinedstorage:storage", "type=1k"));
@@ -235,6 +234,7 @@ public class ProxyClient extends ProxyCommon {
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.QUARTZ_ENRICHED_IRON), 0, new ModelResourceLocation("refinedstorage:quartz_enriched_iron_block", "inventory"));
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSBlocks.STORAGE_MONITOR), 0, new ModelResourceLocation("refinedstorage:storage_monitor", "connected=false,direction=north"));
// Disk Drive
ModelLoaderRegistry.registerLoader(new ICustomModelLoader() {
@Override
public boolean accepts(ResourceLocation modelLocation) {
@@ -251,6 +251,7 @@ public class ProxyClient extends ProxyCommon {
}
});
// Disk Manipulator
ModelLoaderRegistry.registerLoader(new ICustomModelLoader() {
@Override
public boolean accepts(ResourceLocation modelLocation) {

View File

@@ -97,8 +97,8 @@ public class ProxyCommon {
RS.INSTANCE.network.registerMessage(MessageTileDataParameterUpdate.class, MessageTileDataParameterUpdate.class, id++, Side.SERVER);
RS.INSTANCE.network.registerMessage(MessageGridItemInsertHeld.class, MessageGridItemInsertHeld.class, id++, Side.SERVER);
RS.INSTANCE.network.registerMessage(MessageGridItemPull.class, MessageGridItemPull.class, id++, Side.SERVER);
RS.INSTANCE.network.registerMessage(MessageGridCraftingClear.class, MessageGridCraftingClear.class, id++, Side.SERVER);
RS.INSTANCE.network.registerMessage(MessageGridCraftingTransfer.class, MessageGridCraftingTransfer.class, id++, Side.SERVER);
RS.INSTANCE.network.registerMessage(MessageGridClear.class, MessageGridClear.class, id++, Side.SERVER);
RS.INSTANCE.network.registerMessage(MessageGridTransfer.class, MessageGridTransfer.class, id++, Side.SERVER);
RS.INSTANCE.network.registerMessage(MessageGridSettingsUpdate.class, MessageGridSettingsUpdate.class, id++, Side.SERVER);
RS.INSTANCE.network.registerMessage(MessageGridCraftingStart.class, MessageGridCraftingStart.class, id++, Side.SERVER);
RS.INSTANCE.network.registerMessage(MessageGridPatternCreate.class, MessageGridPatternCreate.class, id++, Side.SERVER);
@@ -110,12 +110,11 @@ public class ProxyCommon {
RS.INSTANCE.network.registerMessage(MessageGridFluidDelta.class, MessageGridFluidDelta.class, id++, Side.CLIENT);
RS.INSTANCE.network.registerMessage(MessageGridFluidPull.class, MessageGridFluidPull.class, id++, Side.SERVER);
RS.INSTANCE.network.registerMessage(MessageGridFluidInsertHeld.class, MessageGridFluidInsertHeld.class, id++, Side.SERVER);
RS.INSTANCE.network.registerMessage(MessageProcessingPatternEncoderClear.class, MessageProcessingPatternEncoderClear.class, id++, Side.SERVER);
RS.INSTANCE.network.registerMessage(MessageFilterUpdate.class, MessageFilterUpdate.class, id++, Side.SERVER);
RS.INSTANCE.network.registerMessage(MessageGridCraftingPreview.class, MessageGridCraftingPreview.class, id++, Side.SERVER);
RS.INSTANCE.network.registerMessage(MessageGridCraftingPreviewResponse.class, MessageGridCraftingPreviewResponse.class, id++, Side.CLIENT);
RS.INSTANCE.network.registerMessage(MessageGridCraftingStartResponse.class, MessageGridCraftingStartResponse.class, id++, Side.CLIENT);
RS.INSTANCE.network.registerMessage(MessageProcessingPatternEncoderTransfer.class, MessageProcessingPatternEncoderTransfer.class, id++, Side.SERVER);
RS.INSTANCE.network.registerMessage(MessageGridProcessingTransfer.class, MessageGridProcessingTransfer.class, id++, Side.SERVER);
RS.INSTANCE.network.registerMessage(MessageReaderWriterUpdate.class, MessageReaderWriterUpdate.class, id++, Side.CLIENT);
RS.INSTANCE.network.registerMessage(MessageReaderWriterChannelAdd.class, MessageReaderWriterChannelAdd.class, id++, Side.SERVER);
RS.INSTANCE.network.registerMessage(MessageReaderWriterChannelRemove.class, MessageReaderWriterChannelRemove.class, id++, Side.SERVER);
@@ -144,7 +143,6 @@ public class ProxyCommon {
registerTile(TileCraftingMonitor.class, "crafting_monitor");
registerTile(TileWirelessTransmitter.class, "wireless_transmitter");
registerTile(TileCrafter.class, "crafter");
registerTile(TileProcessingPatternEncoder.class, "processing_pattern_encoder");
registerTile(TileCable.class, "cable");
registerTile(TileNetworkReceiver.class, "network_receiver");
registerTile(TileNetworkTransmitter.class, "network_transmitter");
@@ -164,7 +162,6 @@ public class ProxyCommon {
registerBlock(RSBlocks.STORAGE_MONITOR);
registerBlock(RSBlocks.SECURITY_MANAGER);
registerBlock(RSBlocks.CRAFTER);
registerBlock(RSBlocks.PROCESSING_PATTERN_ENCODER);
registerBlock(RSBlocks.DISK_DRIVE);
registerBlock(RSBlocks.STORAGE);
registerBlock(RSBlocks.FLUID_STORAGE);
@@ -320,8 +317,21 @@ public class ProxyCommon {
@SubscribeEvent
public void fixItemMappings(RegistryEvent.MissingMappings<Item> e) {
for (RegistryEvent.MissingMappings.Mapping<Item> missing : e.getMappings()) {
if (missing.key.getResourceDomain().equals(RS.ID) && missing.key.getResourcePath().equals("grid_filter")) {
missing.remap(RSItems.FILTER);
if (missing.key.getResourceDomain().equals(RS.ID)) {
if (missing.key.getResourcePath().equals("grid_filter")) {
missing.remap(RSItems.FILTER);
} else if (missing.key.getResourcePath().equals("processing_pattern_encoder")) {
missing.ignore();
}
}
}
}
@SubscribeEvent
public void fixBlockMappings(RegistryEvent.MissingMappings<Block> e) {
for (RegistryEvent.MissingMappings.Mapping<Block> missing : e.getMappings()) {
if (missing.key.getResourceDomain().equals(RS.ID) && missing.key.getResourcePath().equals("processing_pattern_encoder")) {
missing.ignore();
}
}
}

View File

@@ -1,172 +0,0 @@
package com.raoulvdberge.refinedstorage.tile;
import com.raoulvdberge.refinedstorage.RSItems;
import com.raoulvdberge.refinedstorage.RSUtils;
import com.raoulvdberge.refinedstorage.gui.GuiProcessingPatternEncoder;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerTile;
import com.raoulvdberge.refinedstorage.inventory.ItemValidatorBasic;
import com.raoulvdberge.refinedstorage.item.ItemPattern;
import com.raoulvdberge.refinedstorage.tile.data.ITileDataConsumer;
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class TileProcessingPatternEncoder extends TileBase {
private static final String NBT_OREDICT_PATTERN = "OredictPattern";
private static final String NBT_BLOCKING_PATTERN = "BlockingPattern";
public static final TileDataParameter<Boolean> OREDICT_PATTERN = new TileDataParameter<>(DataSerializers.BOOLEAN, false, new ITileDataProducer<Boolean, TileProcessingPatternEncoder>() {
@Override
public Boolean getValue(TileProcessingPatternEncoder tile) {
return tile.oredictPattern;
}
}, new ITileDataConsumer<Boolean, TileProcessingPatternEncoder>() {
@Override
public void setValue(TileProcessingPatternEncoder tile, Boolean value) {
tile.oredictPattern = value;
tile.markDirty();
}
}, parameter -> {
if (Minecraft.getMinecraft().currentScreen instanceof GuiProcessingPatternEncoder) {
((GuiProcessingPatternEncoder) Minecraft.getMinecraft().currentScreen).updateOredictPattern(parameter.getValue());
}
});
public static final TileDataParameter<Boolean> BLOCKING_TASK_PATTERN = new TileDataParameter<>(DataSerializers.BOOLEAN, false, new ITileDataProducer<Boolean, TileProcessingPatternEncoder>() {
@Override
public Boolean getValue(TileProcessingPatternEncoder tile) {
return tile.blockingTask;
}
}, new ITileDataConsumer<Boolean, TileProcessingPatternEncoder>() {
@Override
public void setValue(TileProcessingPatternEncoder tile, Boolean value) {
tile.blockingTask = value;
tile.markDirty();
}
}, parameter -> {
if (Minecraft.getMinecraft().currentScreen instanceof GuiProcessingPatternEncoder) {
((GuiProcessingPatternEncoder) Minecraft.getMinecraft().currentScreen).updateBlockingPattern(parameter.getValue());
}
});
private ItemHandlerBase patterns = new ItemHandlerBase(2, new ItemHandlerListenerTile(this), new ItemValidatorBasic(RSItems.PATTERN));
private ItemHandlerBase configuration = new ItemHandlerBase(9 * 2, new ItemHandlerListenerTile(this));
private boolean oredictPattern;
private boolean blockingTask = false;
public TileProcessingPatternEncoder() {
dataManager.addWatchedParameter(OREDICT_PATTERN);
dataManager.addWatchedParameter(BLOCKING_TASK_PATTERN);
}
@Override
public NBTTagCompound write(NBTTagCompound tag) {
super.write(tag);
RSUtils.writeItems(patterns, 0, tag);
RSUtils.writeItems(configuration, 1, tag);
tag.setBoolean(NBT_OREDICT_PATTERN, oredictPattern);
tag.setBoolean(NBT_BLOCKING_PATTERN, blockingTask);
return tag;
}
@Override
public void read(NBTTagCompound tag) {
super.read(tag);
RSUtils.readItems(patterns, 0, tag);
RSUtils.readItems(configuration, 1, tag);
if (tag.hasKey(NBT_OREDICT_PATTERN)) {
oredictPattern = tag.getBoolean(NBT_OREDICT_PATTERN);
}
if (tag.hasKey(NBT_BLOCKING_PATTERN)) {
blockingTask = tag.getBoolean(NBT_BLOCKING_PATTERN);
}
}
public void onCreatePattern() {
if (canCreatePattern()) {
ItemStack pattern = new ItemStack(RSItems.PATTERN);
ItemPattern.setOredict(pattern, oredictPattern);
ItemPattern.setBlocking(pattern, blockingTask);
for (int i = 0; i < 18; ++i) {
if (!configuration.getStackInSlot(i).isEmpty()) {
if (i >= 9) {
ItemPattern.addOutput(pattern, configuration.getStackInSlot(i));
} else {
ItemPattern.setSlot(pattern, i, configuration.getStackInSlot(i));
}
}
}
patterns.extractItem(0, 1, false);
patterns.setStackInSlot(1, pattern);
}
}
public boolean canCreatePattern() {
int inputsFilled = 0, outputsFilled = 0;
for (int i = 0; i < 9; ++i) {
if (!configuration.getStackInSlot(i).isEmpty()) {
inputsFilled++;
}
}
for (int i = 9; i < 18; ++i) {
if (!configuration.getStackInSlot(i).isEmpty()) {
outputsFilled++;
}
}
return inputsFilled > 0 && outputsFilled > 0 && !patterns.getStackInSlot(0).isEmpty() && patterns.getStackInSlot(1).isEmpty();
}
public ItemHandlerBase getPatterns() {
return patterns;
}
public ItemHandlerBase getConfiguration() {
return configuration;
}
@Override
@Nullable
public IItemHandler getDrops() {
return patterns;
}
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(patterns);
}
return super.getCapability(capability, facing);
}
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
}
}

View File

@@ -1,6 +1,7 @@
package com.raoulvdberge.refinedstorage.tile.grid;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
import com.raoulvdberge.refinedstorage.tile.TileNode;
import com.raoulvdberge.refinedstorage.tile.data.ITileDataConsumer;
@@ -131,6 +132,50 @@ public class TileGrid extends TileNode<NetworkNodeGrid> {
}
});
public static final TileDataParameter<Boolean> PROCESSING_PATTERN = new TileDataParameter<>(DataSerializers.BOOLEAN, false, new ITileDataProducer<Boolean, TileGrid>() {
@Override
public Boolean getValue(TileGrid tile) {
return tile.getNode().isProcessingPattern();
}
}, new ITileDataConsumer<Boolean, TileGrid>() {
@Override
public void setValue(TileGrid tile, Boolean value) {
tile.getNode().setProcessingPattern(value);
tile.getNode().markDirty();
tile.getNode().onPatternMatrixClear();
tile.world.getMinecraftServer().getPlayerList().getPlayers().stream()
.filter(player -> player.openContainer instanceof ContainerGrid && ((ContainerGrid) player.openContainer).getTile() != null && ((ContainerGrid) player.openContainer).getTile().getPos().equals(tile.getPos()))
.forEach(player -> {
((ContainerGrid) player.openContainer).initSlots();
player.openContainer.detectAndSendChanges();
});
}
}, parameter -> {
if (Minecraft.getMinecraft().currentScreen != null) {
Minecraft.getMinecraft().currentScreen.initGui();
}
});
public static final TileDataParameter<Boolean> BLOCKING_PATTERN = new TileDataParameter<>(DataSerializers.BOOLEAN, false, new ITileDataProducer<Boolean, TileGrid>() {
@Override
public Boolean getValue(TileGrid tile) {
return tile.getNode().isBlockingPattern();
}
}, new ITileDataConsumer<Boolean, TileGrid>() {
@Override
public void setValue(TileGrid tile, Boolean value) {
tile.getNode().setBlockingPattern(value);
tile.getNode().markDirty();
}
}, parameter -> {
if (Minecraft.getMinecraft().currentScreen instanceof GuiGrid) {
((GuiGrid) Minecraft.getMinecraft().currentScreen).updateBlockingPattern(parameter.getValue());
}
});
public TileGrid() {
dataManager.addWatchedParameter(VIEW_TYPE);
dataManager.addWatchedParameter(SORTING_DIRECTION);
@@ -139,6 +184,8 @@ public class TileGrid extends TileNode<NetworkNodeGrid> {
dataManager.addWatchedParameter(SIZE);
dataManager.addWatchedParameter(TAB_SELECTED);
dataManager.addWatchedParameter(OREDICT_PATTERN);
dataManager.addWatchedParameter(PROCESSING_PATTERN);
dataManager.addWatchedParameter(BLOCKING_PATTERN);
}
@Override

View File

@@ -1,25 +0,0 @@
{
"forge_marker": 1,
"defaults": {
"model": "cube",
"textures": {
"particle": "refinedstorage:blocks/processing_pattern_encoder",
"down": "refinedstorage:blocks/side",
"up": "refinedstorage:blocks/processing_pattern_encoder",
"north": "refinedstorage:blocks/processing_pattern_encoder_side",
"east": "refinedstorage:blocks/processing_pattern_encoder_side",
"south": "refinedstorage:blocks/processing_pattern_encoder_side",
"west": "refinedstorage:blocks/processing_pattern_encoder_side"
}
},
"variants": {
"inventory": [
{
"transform": "forge:default-block"
}
],
"normal": {
"model": "cube"
}
}
}

View File

@@ -35,9 +35,6 @@ gui.refinedstorage:crafting_monitor.blocked=Blocked, waiting on other task
gui.refinedstorage:wireless_transmitter=Wireless Transmitter
gui.refinedstorage:wireless_transmitter.distance=%d blocks
gui.refinedstorage:crafter=Crafter
gui.refinedstorage:crafter.processing=Processing
gui.refinedstorage:processing_pattern_encoder=Processing Pattern Encoder
gui.refinedstorage:processing_pattern_encoder.pattern_create=Create Pattern
gui.refinedstorage:filter=Filter
gui.refinedstorage:filter.compare_damage=Damage
gui.refinedstorage:filter.compare_nbt=NBT
@@ -107,6 +104,7 @@ misc.refinedstorage:cancel_all=Cancel All
misc.refinedstorage:priority=Priority
misc.refinedstorage:oredict=Oredict
misc.refinedstorage:blocking=Blocking
misc.refinedstorage:processing=Processing
misc.refinedstorage:reader_writer.redstone=Redstone strength: %d
@@ -208,9 +206,6 @@ block.refinedstorage:crafting_monitor.name=Crafting Monitor
block.refinedstorage:wireless_transmitter.name=Wireless Transmitter
block.refinedstorage:wireless_transmitter.tooltip=Needs to be placed on %s.
block.refinedstorage:crafter.name=Crafter
block.refinedstorage:processing_pattern_encoder.name=Processing Pattern Encoder
block.refinedstorage:processing_pattern_encoder.tooltip.0=Only used for creating processing patterns.
block.refinedstorage:processing_pattern_encoder.tooltip.1=For regular crafting pattern creation, use the %s.
block.refinedstorage:network_receiver.name=Network Receiver
block.refinedstorage:network_transmitter.name=Network Transmitter
block.refinedstorage:fluid_interface.name=Fluid Interface

View File

@@ -1,29 +0,0 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"ECE",
"PMP",
"EFE"
],
"key": {
"E": {
"item": "refinedstorage:quartz_enriched_iron"
},
"C": {
"type": "forge:ore_dict",
"ore": "workbench"
},
"P": {
"item": "refinedstorage:pattern"
},
"M": {
"item": "refinedstorage:machine_casing"
},
"F": {
"item": "minecraft:furnace"
}
},
"result": {
"item": "refinedstorage:processing_pattern_encoder"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB