mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-17 10:55:06 +00:00
begin work
This commit is contained in:
commit
632c0c3b8f
170 files changed
+8945
No files matched your search
@@ -0,0 +1,50 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import com.glodblock.github.interfaces.TankDumpable;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class CPacketDumpTank implements IMessage {
|
||||
|
||||
private int index;
|
||||
|
||||
public CPacketDumpTank(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public CPacketDumpTank() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeShort(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
index = buf.readShort();
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<CPacketDumpTank, IMessage> {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IMessage onMessage(CPacketDumpTank message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().player;
|
||||
player.getServerWorld().addScheduledTask(() -> {
|
||||
if (player.openContainer instanceof TankDumpable) {
|
||||
((TankDumpable)player.openContainer).dumpTank(message.index);
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import com.glodblock.github.client.container.ContainerFluidPatternEncoder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class CPacketEncodePattern implements IMessage {
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<CPacketEncodePattern, IMessage> {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IMessage onMessage(CPacketEncodePattern message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().player;
|
||||
player.getServerWorld().addScheduledTask(() -> {
|
||||
if (player.openContainer instanceof ContainerFluidPatternEncoder) {
|
||||
((ContainerFluidPatternEncoder)player.openContainer).encodePattern();
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.interfaces.PatternConsumer;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
public class CPacketLoadPattern implements IMessage {
|
||||
|
||||
private IAEItemStack[] crafting, output;
|
||||
|
||||
public CPacketLoadPattern(IAEItemStack[] crafting, IAEItemStack[] output) {
|
||||
this.crafting = crafting;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
public CPacketLoadPattern() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
writeStacksWithNulls(buf, crafting);
|
||||
writeStacksWithNulls(buf, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
crafting = readStacksWithNulls(buf);
|
||||
output = readStacksWithNulls(buf);
|
||||
}
|
||||
|
||||
private static IAEItemStack[] readStacksWithNulls(ByteBuf buf) {
|
||||
IAEItemStack[] stacks = new IAEItemStack[buf.readByte()];
|
||||
int mask = buf.readInt();
|
||||
for (int i = 0; i < stacks.length; i++) {
|
||||
if ((mask & (1 << i)) != 0) {
|
||||
stacks[i] = AEItemStack.fromPacket(buf);
|
||||
}
|
||||
}
|
||||
return stacks;
|
||||
}
|
||||
|
||||
private static void writeStacksWithNulls(ByteBuf buf, IAEItemStack[] stacks) {
|
||||
buf.writeByte(stacks.length);
|
||||
int mask = 0;
|
||||
for (int i = 0; i < stacks.length; i++) {
|
||||
if (stacks[i] != null) {
|
||||
mask |= 1 << i;
|
||||
}
|
||||
}
|
||||
buf.writeInt(mask);
|
||||
for (IAEItemStack stack : stacks) {
|
||||
try {
|
||||
if (stack != null) {
|
||||
stack.writeToPacket(buf);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("Failed to write AE item stack!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<CPacketLoadPattern, IMessage> {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IMessage onMessage(CPacketLoadPattern message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().player;
|
||||
player.getServerWorld().addScheduledTask(() -> {
|
||||
if (player.openContainer instanceof PatternConsumer) {
|
||||
((PatternConsumer)player.openContainer).acceptPattern(message.crafting, message.output);
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import com.glodblock.github.inventory.GuiType;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class CPacketSwitchGuis implements IMessage {
|
||||
|
||||
private GuiType guiType;
|
||||
|
||||
public CPacketSwitchGuis(GuiType guiType) {
|
||||
this.guiType = guiType;
|
||||
}
|
||||
|
||||
public CPacketSwitchGuis() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf byteBuf) {
|
||||
guiType = GuiType.getByOrdinal(byteBuf.readByte());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf byteBuf) {
|
||||
byteBuf.writeByte(guiType != null ? guiType.ordinal() : 0);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<CPacketSwitchGuis, IMessage> {
|
||||
@Nullable
|
||||
@Override
|
||||
public IMessage onMessage(CPacketSwitchGuis message, MessageContext ctx) {
|
||||
if (message.guiType == null) {
|
||||
return null;
|
||||
}
|
||||
EntityPlayerMP player = ctx.getServerHandler().player;
|
||||
Container cont = player.openContainer;
|
||||
if (!(cont instanceof AEBaseContainer)) {
|
||||
return null;
|
||||
}
|
||||
ContainerOpenContext context = ((AEBaseContainer)cont).getOpenContext();
|
||||
if (context == null) {
|
||||
return null;
|
||||
}
|
||||
TileEntity te = context.getTile();
|
||||
if (te == null) {
|
||||
return null;
|
||||
}
|
||||
InventoryHandler.openGui(player, player.world, te.getPos(), context.getSide().getFacing(), message.guiType);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import com.glodblock.github.client.container.ContainerBurette;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class CPacketTransposeFluid implements IMessage {
|
||||
|
||||
private int amount;
|
||||
private boolean into;
|
||||
|
||||
public CPacketTransposeFluid(int amount, boolean into) {
|
||||
this.amount = amount;
|
||||
this.into = into;
|
||||
}
|
||||
|
||||
public CPacketTransposeFluid() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(amount).writeBoolean(into);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
amount = buf.readInt();
|
||||
into = buf.readBoolean();
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<CPacketTransposeFluid, IMessage> {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IMessage onMessage(CPacketTransposeFluid message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().player;
|
||||
player.getServerWorld().addScheduledTask(() -> {
|
||||
if (player.openContainer instanceof ContainerBurette) {
|
||||
((ContainerBurette)player.openContainer).tryTransferFluid(message.amount, message.into);
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user