Make the slot clear before recipe is transferred to pp encoder
This commit is contained in:
@@ -11,18 +11,18 @@ import refinedstorage.tile.TileProcessingPatternEncoder;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public class ContainerProcessingPatternEncoder extends ContainerBase {
|
public class ContainerProcessingPatternEncoder extends ContainerBase {
|
||||||
public ContainerProcessingPatternEncoder(TileProcessingPatternEncoder processingPatternEncoder, EntityPlayer player) {
|
public ContainerProcessingPatternEncoder(TileProcessingPatternEncoder encoder, EntityPlayer player) {
|
||||||
super(processingPatternEncoder, player);
|
super(encoder, player);
|
||||||
|
|
||||||
addSlotToContainer(new SlotItemHandler(processingPatternEncoder.getPatterns(), 0, 152, 18));
|
addSlotToContainer(new SlotItemHandler(encoder.getPatterns(), 0, 152, 18));
|
||||||
addSlotToContainer(new SlotOutput(processingPatternEncoder.getPatterns(), 1, 152, 58));
|
addSlotToContainer(new SlotOutput(encoder.getPatterns(), 1, 152, 58));
|
||||||
|
|
||||||
int ox = 8;
|
int ox = 8;
|
||||||
int x = ox;
|
int x = ox;
|
||||||
int y = 20;
|
int y = 20;
|
||||||
|
|
||||||
for (int i = 0; i < 9 * 2; ++i) {
|
for (int i = 0; i < 9 * 2; ++i) {
|
||||||
addSlotToContainer(new SlotSpecimen(processingPatternEncoder.getConfiguration(), i, x, y, SlotSpecimen.SPECIMEN_SIZE));
|
addSlotToContainer(new SlotSpecimen(encoder.getConfiguration(), i, x, y, SlotSpecimen.SPECIMEN_SIZE));
|
||||||
|
|
||||||
x += 18;
|
x += 18;
|
||||||
|
|
||||||
@@ -68,6 +68,13 @@ public class ContainerProcessingPatternEncoder extends ContainerBase {
|
|||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearInputsAndOutputs() {
|
||||||
|
for (int i = 2; i < 2 + (9 * 2); ++i) {
|
||||||
|
getSlot(i).putStack(null);
|
||||||
|
getSlot(i).onSlotChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setInputs(Collection<ItemStack> stacks) {
|
public void setInputs(Collection<ItemStack> stacks) {
|
||||||
setSlots(stacks, 2 , 2 + 9);
|
setSlots(stacks, 2 , 2 + 9);
|
||||||
}
|
}
|
||||||
@@ -84,6 +91,7 @@ public class ContainerProcessingPatternEncoder extends ContainerBase {
|
|||||||
if (!slot.getHasStack() && slot.isItemValid(stack)) {
|
if (!slot.getHasStack() && slot.isItemValid(stack)) {
|
||||||
slot.putStack(stack);
|
slot.putStack(stack);
|
||||||
slot.onSlotChanged();
|
slot.onSlotChanged();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ import refinedstorage.tile.TileProcessingPatternEncoder;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class GuiProcessingPatternEncoder extends GuiBase {
|
public class GuiProcessingPatternEncoder extends GuiBase {
|
||||||
private TileProcessingPatternEncoder processingPatternEncoder;
|
private TileProcessingPatternEncoder encoder;
|
||||||
|
|
||||||
public GuiProcessingPatternEncoder(ContainerProcessingPatternEncoder container, TileProcessingPatternEncoder processingPatternEncoder) {
|
public GuiProcessingPatternEncoder(ContainerProcessingPatternEncoder container, TileProcessingPatternEncoder encoder) {
|
||||||
super(container, 176, 172);
|
super(container, 176, 172);
|
||||||
|
|
||||||
this.processingPatternEncoder = processingPatternEncoder;
|
this.encoder = encoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -28,7 +28,7 @@ public class GuiProcessingPatternEncoder extends GuiBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isOverCreatePattern(int mouseX, int mouseY) {
|
private boolean isOverCreatePattern(int mouseX, int mouseY) {
|
||||||
return inBounds(152, 38, 16, 16, mouseX, mouseY) && processingPatternEncoder.canCreatePattern();
|
return inBounds(152, 38, 16, 16, mouseX, mouseY) && encoder.canCreatePattern();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isOverClear(int mouseX, int mouseY) {
|
private boolean isOverClear(int mouseX, int mouseY) {
|
||||||
@@ -47,7 +47,7 @@ public class GuiProcessingPatternEncoder extends GuiBase {
|
|||||||
ty = 1;
|
ty = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!processingPatternEncoder.canCreatePattern()) {
|
if (!encoder.canCreatePattern()) {
|
||||||
ty = 2;
|
ty = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,11 +73,11 @@ public class GuiProcessingPatternEncoder extends GuiBase {
|
|||||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
|
||||||
if (isOverCreatePattern(mouseX - guiLeft, mouseY - guiTop)) {
|
if (isOverCreatePattern(mouseX - guiLeft, mouseY - guiTop)) {
|
||||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageGridPatternCreate(processingPatternEncoder.getPos().getX(), processingPatternEncoder.getPos().getY(), processingPatternEncoder.getPos().getZ()));
|
RefinedStorage.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));
|
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||||
} else if (isOverClear(mouseX - guiLeft, mouseY - guiTop)) {
|
} else if (isOverClear(mouseX - guiLeft, mouseY - guiTop)) {
|
||||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageProcessingPatternEncoderClear(processingPatternEncoder));
|
RefinedStorage.INSTANCE.network.sendToServer(new MessageProcessingPatternEncoderClear(encoder));
|
||||||
|
|
||||||
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||||
}
|
}
|
||||||
|
|||||||
42
src/main/java/refinedstorage/integration/jei/RecipeTransferHandlerPattern.java
Normal file → Executable file
42
src/main/java/refinedstorage/integration/jei/RecipeTransferHandlerPattern.java
Normal file → Executable file
@@ -32,28 +32,32 @@ public class RecipeTransferHandlerPattern implements IRecipeTransferHandler<Cont
|
|||||||
if (doTransfer) {
|
if (doTransfer) {
|
||||||
Map<Integer, ItemStack> inputs = new HashMap<>();
|
Map<Integer, ItemStack> inputs = new HashMap<>();
|
||||||
Map<Integer, ItemStack> outputs = new HashMap<>();
|
Map<Integer, ItemStack> outputs = new HashMap<>();
|
||||||
for (IGuiIngredient<ItemStack> guiIngredient : recipeLayout.getItemStacks().getGuiIngredients().values()) {
|
|
||||||
if (guiIngredient != null && guiIngredient.getDisplayedIngredient() != null) {
|
for (IGuiIngredient<ItemStack> guiIngredient : recipeLayout.getItemStacks().getGuiIngredients().values()) {
|
||||||
ItemStack ingredient = guiIngredient.getDisplayedIngredient();
|
if (guiIngredient != null && guiIngredient.getDisplayedIngredient() != null) {
|
||||||
int hashCode = NetworkUtils.getItemStackHashCode(ingredient);
|
ItemStack ingredient = guiIngredient.getDisplayedIngredient();
|
||||||
if (guiIngredient.isInput()) {
|
|
||||||
if (inputs.containsKey(hashCode)) {
|
int hash = NetworkUtils.getItemStackHashCode(ingredient);
|
||||||
inputs.get(hashCode).stackSize++;
|
|
||||||
} else {
|
if (guiIngredient.isInput()) {
|
||||||
inputs.put(hashCode, ingredient);
|
if (inputs.containsKey(hash)) {
|
||||||
}
|
inputs.get(hash).stackSize++;
|
||||||
} else {
|
} else {
|
||||||
if (outputs.containsKey(hashCode)) {
|
inputs.put(hash, ingredient);
|
||||||
outputs.get(hashCode).stackSize++;
|
}
|
||||||
} else {
|
} else {
|
||||||
outputs.put(hashCode, ingredient);
|
if (outputs.containsKey(hash)) {
|
||||||
}
|
outputs.get(hash).stackSize++;
|
||||||
}
|
} else {
|
||||||
}
|
outputs.put(hash, ingredient);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RefinedStorage.INSTANCE.network.sendToServer(new MessageProcessingPatternEncoderTransfer(inputs.values(), outputs.values()));
|
RefinedStorage.INSTANCE.network.sendToServer(new MessageProcessingPatternEncoderTransfer(inputs.values(), outputs.values()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ public class MessageProcessingPatternEncoderClear extends MessageHandlerPlayerTo
|
|||||||
public MessageProcessingPatternEncoderClear() {
|
public MessageProcessingPatternEncoderClear() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageProcessingPatternEncoderClear(TileProcessingPatternEncoder processingPatternEncoder) {
|
public MessageProcessingPatternEncoderClear(TileProcessingPatternEncoder encoder) {
|
||||||
this.x = processingPatternEncoder.getPos().getX();
|
this.x = encoder.getPos().getX();
|
||||||
this.y = processingPatternEncoder.getPos().getY();
|
this.y = encoder.getPos().getY();
|
||||||
this.z = processingPatternEncoder.getPos().getZ();
|
this.z = encoder.getPos().getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -40,10 +40,10 @@ public class MessageProcessingPatternEncoderClear extends MessageHandlerPlayerTo
|
|||||||
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.x, message.y, message.z));
|
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.x, message.y, message.z));
|
||||||
|
|
||||||
if (tile instanceof TileProcessingPatternEncoder) {
|
if (tile instanceof TileProcessingPatternEncoder) {
|
||||||
TileProcessingPatternEncoder processingPatternEncoder = (TileProcessingPatternEncoder) tile;
|
TileProcessingPatternEncoder encoder = (TileProcessingPatternEncoder) tile;
|
||||||
|
|
||||||
for (int i = 0; i < processingPatternEncoder.getConfiguration().getSlots(); ++i) {
|
for (int i = 0; i < encoder.getConfiguration().getSlots(); ++i) {
|
||||||
processingPatternEncoder.getConfiguration().setStackInSlot(i, null);
|
encoder.getConfiguration().setStackInSlot(i, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
16
src/main/java/refinedstorage/network/MessageProcessingPatternEncoderTransfer.java
Normal file → Executable file
16
src/main/java/refinedstorage/network/MessageProcessingPatternEncoderTransfer.java
Normal file → Executable file
@@ -11,11 +11,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public class MessageProcessingPatternEncoderTransfer extends MessageHandlerPlayerToServer<MessageProcessingPatternEncoderTransfer> implements IMessage {
|
public class MessageProcessingPatternEncoderTransfer extends MessageHandlerPlayerToServer<MessageProcessingPatternEncoderTransfer> implements IMessage {
|
||||||
|
private Collection<ItemStack> inputs;
|
||||||
private Collection<ItemStack> inputs, outputs;
|
private Collection<ItemStack> outputs;
|
||||||
|
|
||||||
public MessageProcessingPatternEncoderTransfer() {
|
public MessageProcessingPatternEncoderTransfer() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageProcessingPatternEncoderTransfer(Collection<ItemStack> inputs, Collection<ItemStack> outputs) {
|
public MessageProcessingPatternEncoderTransfer(Collection<ItemStack> inputs, Collection<ItemStack> outputs) {
|
||||||
@@ -23,16 +22,20 @@ public class MessageProcessingPatternEncoderTransfer extends MessageHandlerPlaye
|
|||||||
this.outputs = outputs;
|
this.outputs = outputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromBytes(ByteBuf buf) {
|
public void fromBytes(ByteBuf buf) {
|
||||||
int size = buf.readInt();
|
int size = buf.readInt();
|
||||||
|
|
||||||
this.inputs = new ArrayList<>(size);
|
this.inputs = new ArrayList<>(size);
|
||||||
|
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
this.inputs.add(ByteBufUtils.readItemStack(buf));
|
this.inputs.add(ByteBufUtils.readItemStack(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
size = buf.readInt();
|
size = buf.readInt();
|
||||||
|
|
||||||
this.outputs = new ArrayList<>(size);
|
this.outputs = new ArrayList<>(size);
|
||||||
|
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
this.outputs.add(ByteBufUtils.readItemStack(buf));
|
this.outputs.add(ByteBufUtils.readItemStack(buf));
|
||||||
}
|
}
|
||||||
@@ -41,10 +44,13 @@ public class MessageProcessingPatternEncoderTransfer extends MessageHandlerPlaye
|
|||||||
@Override
|
@Override
|
||||||
public void toBytes(ByteBuf buf) {
|
public void toBytes(ByteBuf buf) {
|
||||||
buf.writeInt(inputs.size());
|
buf.writeInt(inputs.size());
|
||||||
|
|
||||||
for (ItemStack stack : inputs) {
|
for (ItemStack stack : inputs) {
|
||||||
ByteBufUtils.writeItemStack(buf, stack);
|
ByteBufUtils.writeItemStack(buf, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.writeInt(outputs.size());
|
buf.writeInt(outputs.size());
|
||||||
|
|
||||||
for (ItemStack stack : outputs) {
|
for (ItemStack stack : outputs) {
|
||||||
ByteBufUtils.writeItemStack(buf, stack);
|
ByteBufUtils.writeItemStack(buf, stack);
|
||||||
}
|
}
|
||||||
@@ -55,6 +61,8 @@ public class MessageProcessingPatternEncoderTransfer extends MessageHandlerPlaye
|
|||||||
if (player.openContainer instanceof ContainerProcessingPatternEncoder) {
|
if (player.openContainer instanceof ContainerProcessingPatternEncoder) {
|
||||||
ContainerProcessingPatternEncoder encoder = (ContainerProcessingPatternEncoder) player.openContainer;
|
ContainerProcessingPatternEncoder encoder = (ContainerProcessingPatternEncoder) player.openContainer;
|
||||||
|
|
||||||
|
encoder.clearInputsAndOutputs();
|
||||||
|
|
||||||
encoder.setInputs(message.inputs);
|
encoder.setInputs(message.inputs);
|
||||||
encoder.setOutputs(message.outputs);
|
encoder.setOutputs(message.outputs);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user