mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 10:34:40 +00:00
x2 button funtional for fluid pattern terminals. And varions fixes. (#252)
Co-authored-by: Martin Robertz <[email protected]> Co-authored-by: Alexdoru <[email protected]> Co-authored-by: Maya <[email protected]>
This commit is contained in:
15 files changed
+388
-26
No files matched your search
@@ -77,7 +77,7 @@ public class CPacketFluidPatternTermBtns implements IMessage {
|
||||
case "PatternTerminal.Clear" -> cpt.clear();
|
||||
case "PatternTerminal.Substitute" -> cpt.getPatternTerminal().setSubstitution(Value.equals("1"));
|
||||
case "PatternTerminal.Invert" -> cpt.getPatternTerminal().setInverted(Value.equals("1"));
|
||||
case "PatternTerminal.Double" -> cpt.doubleStacks(Value.charAt(0) == '1', Value.charAt(1) == '1');
|
||||
case "PatternTerminal.Double" -> cpt.doubleStacks(Integer.parseInt(message.Value));
|
||||
case "PatternTerminal.Combine" -> cpt.getPatternTerminal().setCombineMode(Value.equals("1"));
|
||||
case "PatternTerminal.beSubstitute" -> cpt.getPatternTerminal().setBeSubstitute(Value.equals("1"));
|
||||
case "PatternTerminal.ActivePage" ->
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerPatternMulti;
|
||||
import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
@@ -105,12 +106,12 @@ public class CPacketInventoryAction implements IMessage {
|
||||
new BlockPos(te),
|
||||
Objects.requireNonNull(baseContainer.getOpenContext().getSide()),
|
||||
GuiType.FLUID_CRAFTING_AMOUNT);
|
||||
} else if (target instanceof IWirelessTerminal) {
|
||||
} else if (target instanceof IWirelessTerminal wt) {
|
||||
InventoryHandler.openGui(
|
||||
sender,
|
||||
sender.worldObj,
|
||||
new BlockPos(
|
||||
((IWirelessTerminal) target).getInventorySlot(),
|
||||
wt.getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0),
|
||||
ForgeDirection.UNKNOWN,
|
||||
@@ -135,12 +136,12 @@ public class CPacketInventoryAction implements IMessage {
|
||||
new BlockPos(te),
|
||||
Objects.requireNonNull(baseContainer.getOpenContext().getSide()),
|
||||
GuiType.PATTERN_VALUE_SET);
|
||||
} else if (target instanceof IWirelessTerminal) {
|
||||
} else if (target instanceof IWirelessTerminal wt) {
|
||||
InventoryHandler.openGui(
|
||||
sender,
|
||||
sender.worldObj,
|
||||
new BlockPos(
|
||||
((IWirelessTerminal) target).getInventorySlot(),
|
||||
wt.getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0),
|
||||
ForgeDirection.UNKNOWN,
|
||||
@@ -160,6 +161,32 @@ public class CPacketInventoryAction implements IMessage {
|
||||
cpv.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
} else if (message.action == InventoryAction.SET_PATTERN_MULTI) {
|
||||
final ContainerOpenContext context = baseContainer.getOpenContext();
|
||||
if (context != null) {
|
||||
final TileEntity te = context.getTile();
|
||||
if (te != null) {
|
||||
InventoryHandler.openGui(
|
||||
sender,
|
||||
te.getWorldObj(),
|
||||
new BlockPos(te),
|
||||
Objects.requireNonNull(baseContainer.getOpenContext().getSide()),
|
||||
GuiType.GUI_PATTERN_MULTI);
|
||||
} else if (target instanceof IWirelessTerminal wt) {
|
||||
InventoryHandler.openGui(
|
||||
sender,
|
||||
sender.worldObj,
|
||||
new BlockPos(
|
||||
wt.getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0),
|
||||
ForgeDirection.UNKNOWN,
|
||||
GuiType.GUI_PATTERN_MULTI);
|
||||
}
|
||||
if (sender.openContainer instanceof ContainerPatternMulti cpm) {
|
||||
cpm.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
baseContainer.doAction(sender, message.action, message.slot, message.id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.client.gui.container.ContainerPatternMulti;
|
||||
import com.glodblock.github.client.gui.container.base.FCContainerEncodeTerminal;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class CPacketPatternMultiSet implements IMessage {
|
||||
|
||||
private static GuiType guiType;
|
||||
private static int multi;
|
||||
|
||||
public CPacketPatternMultiSet(GuiType guiType, int multi) {
|
||||
CPacketPatternMultiSet.guiType = guiType;
|
||||
CPacketPatternMultiSet.multi = multi;
|
||||
}
|
||||
|
||||
public CPacketPatternMultiSet() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf byteBuf) {
|
||||
guiType = GuiType.getByOrdinal(byteBuf.readByte());
|
||||
multi = byteBuf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf byteBuf) {
|
||||
byteBuf.writeByte(guiType != null ? guiType.ordinal() : 0);
|
||||
byteBuf.writeInt(multi);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<CPacketPatternMultiSet, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(CPacketPatternMultiSet message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
if (player.openContainer instanceof ContainerPatternMulti cpv) {
|
||||
final Object target = cpv.getTarget();
|
||||
if (target instanceof IGridHost) {
|
||||
final ContainerOpenContext context = cpv.getOpenContext();
|
||||
if (context != null) {
|
||||
final TileEntity te = context.getTile();
|
||||
if (te != null) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
te.getWorldObj(),
|
||||
new BlockPos(te),
|
||||
Objects.requireNonNull(cpv.getOpenContext().getSide()),
|
||||
guiType);
|
||||
} else if (target instanceof IWirelessTerminal wt) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(
|
||||
wt.getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0),
|
||||
ForgeDirection.UNKNOWN,
|
||||
guiType);
|
||||
}
|
||||
if (player.openContainer instanceof FCContainerEncodeTerminal cpt) {
|
||||
cpt.multiplyOrDivideStacks(multi);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,7 +32,8 @@ public class CPacketTransferRecipe implements IMessage {
|
||||
private List<OrderStack<?>> inputs;
|
||||
private List<OrderStack<?>> outputs;
|
||||
private boolean isCraft;
|
||||
private static final int MAX_INDEX = 32;
|
||||
private static final int MAX_INDEX = 81;
|
||||
private static final int MAX_SLOTS_INDEX = 32;
|
||||
private boolean shift;
|
||||
|
||||
public CPacketTransferRecipe() {}
|
||||
@@ -79,11 +80,11 @@ public class CPacketTransferRecipe implements IMessage {
|
||||
NBTTagCompound nbt_o = nbt_m.getCompoundTag("o");
|
||||
for (int i = 0; i < MAX_INDEX; i++) {
|
||||
OrderStack<?> tmp = OrderStack.readFromNBT(nbt_i, null, i);
|
||||
if (tmp != null) inputs.add(tmp);
|
||||
if (tmp != null && inputs.size() < MAX_SLOTS_INDEX) inputs.add(tmp);
|
||||
}
|
||||
for (int i = 0; i < MAX_INDEX; i++) {
|
||||
OrderStack<?> tmp = OrderStack.readFromNBT(nbt_o, null, i);
|
||||
if (tmp != null) outputs.add(tmp);
|
||||
if (tmp != null && inputs.size() < MAX_SLOTS_INDEX) outputs.add(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user