mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-15 09:34:42 +00:00
add fluid level emitter
This commit is contained in:
1 parent
b1dff2ec2c
commit
5ca8909dbf
15 files changed
+1087
No files matched your search
@@ -0,0 +1,48 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidLevelEmitter;
|
||||
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;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
public class CPacketValueConfig implements IMessage {
|
||||
private long amount;
|
||||
private int valueIndex;
|
||||
|
||||
public CPacketValueConfig() {}
|
||||
|
||||
public CPacketValueConfig(long amount, int valueIndex) {
|
||||
this.amount = amount;
|
||||
this.valueIndex = valueIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.amount = buf.readLong();
|
||||
this.valueIndex = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeLong(amount);
|
||||
buf.writeInt(valueIndex);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<CPacketValueConfig, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(CPacketValueConfig message, MessageContext ctx) {
|
||||
EntityPlayer player = ctx.getServerHandler().playerEntity;
|
||||
if (player.openContainer != null) {
|
||||
Container container = player.openContainer;
|
||||
if (container instanceof ContainerFluidLevelEmitter) {
|
||||
((ContainerFluidLevelEmitter) container).setLevel(message.amount, player);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,6 +111,10 @@ public class SPacketFluidUpdate implements IMessage {
|
||||
} else {
|
||||
((GuiFluidTerminal) gs).update(null);
|
||||
}
|
||||
} else if (gs instanceof GuiFluidLevelEmitter) {
|
||||
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet()) {
|
||||
((GuiFluidLevelEmitter) gs).update(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user