mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 01:54:59 +00:00
Allows the use of the middle mouse button to modify the number of items in the pattern.
This commit is contained in:
1 parent
1998750489
commit
dbbaea9235
33 files changed
+539
-38
No files matched your search
@@ -4,8 +4,11 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
@@ -108,6 +111,24 @@ public class CPacketInventoryAction implements IMessage {
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
}else if (message.action == InventoryAction.valueOf("SET_PATTERN_VALUE"))
|
||||
{
|
||||
final ContainerOpenContext context = baseContainer.getOpenContext();
|
||||
if( context != null )
|
||||
{
|
||||
final TileEntity te = context.getTile();
|
||||
InventoryHandler.openGui(sender, te.getWorldObj(), new BlockPos(te), Objects.requireNonNull(Util.from(baseContainer.getOpenContext().getSide())), GuiType.PATTERN_VALUE_SET );
|
||||
if( sender.openContainer instanceof ContainerPatternValueAmount)
|
||||
{
|
||||
final ContainerPatternValueAmount cpv = (ContainerPatternValueAmount) sender.openContainer;
|
||||
if( baseContainer.getTargetStack() != null )
|
||||
{
|
||||
cpv.setValueIndex( message.slot );
|
||||
cpv.getPatternValue().putStack( baseContainer.getTargetStack().getItemStack() );
|
||||
}
|
||||
cpv.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
<<<<<<< Updated upstream
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.implementations.ContainerPatternTermEx;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
=======
|
||||
>>>>>>> Stashed changes
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminalEx;
|
||||
import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
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;
|
||||
<<<<<<< Updated upstream
|
||||
import io.netty.buffer.Unpooled;
|
||||
=======
|
||||
>>>>>>> Stashed changes
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class CPacketPatternValueSet implements IMessage {
|
||||
|
||||
|
||||
private GuiType originGui;
|
||||
private int amount;
|
||||
private int valueIndex;
|
||||
|
||||
public CPacketPatternValueSet() {
|
||||
|
||||
}
|
||||
|
||||
public CPacketPatternValueSet( int originalGui, int amount, int valueIndex ){
|
||||
this.originGui = GuiType.getByOrdinal(originalGui);
|
||||
this.amount = amount;
|
||||
this.valueIndex = valueIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(originGui.ordinal());
|
||||
buf.writeInt(amount);
|
||||
buf.writeInt(valueIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.originGui = GuiType.getByOrdinal(buf.readInt());
|
||||
this.amount = buf.readInt();
|
||||
this.valueIndex = buf.readInt();
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<CPacketPatternValueSet, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(CPacketPatternValueSet message, MessageContext ctx) {
|
||||
EntityPlayer player = ctx.getServerHandler().playerEntity;
|
||||
if (player.openContainer instanceof ContainerPatternValueAmount) {
|
||||
ContainerPatternValueAmount cpv = (ContainerPatternValueAmount) player.openContainer;
|
||||
final Object target = cpv.getTarget();
|
||||
if (target instanceof IGridHost) {
|
||||
final ContainerOpenContext context = cpv.getOpenContext();
|
||||
if (context != null) {
|
||||
final TileEntity te = context.getTile();
|
||||
InventoryHandler.openGui(player, player.worldObj, new BlockPos(te), Objects.requireNonNull(Util.from(context.getSide())), message.originGui);
|
||||
if (player.openContainer instanceof ContainerFluidPatternTerminal || player.openContainer instanceof ContainerFluidPatternTerminalEx) {
|
||||
Slot slot = player.openContainer.getSlot(message.valueIndex);
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
ItemStack stack = slot.getStack().copy();
|
||||
if (Util.isFluidPacket(stack)) {
|
||||
FluidStack fluidStack = ItemFluidPacket.getFluidStack(stack);
|
||||
if (fluidStack != null) {
|
||||
fluidStack = ItemFluidPacket.getFluidStack(stack).copy();
|
||||
fluidStack.amount = message.amount;
|
||||
}
|
||||
slot.putStack(ItemFluidPacket.newStack(fluidStack));
|
||||
} else {
|
||||
stack.stackSize = message.amount;
|
||||
slot.putStack(stack);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,6 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CPacketTransferRecipe implements IMessage {
|
||||
|
||||
|
||||
Reference in new issue
Block a user