Added packet handlers, guis, etc required to handle the routing nodes. Added the ability to have a different filter for each direction.
This commit is contained in:
parent
ac919c7882
commit
a895809274
13 changed files with 508 additions and 78 deletions
|
@ -16,6 +16,7 @@ public class BloodMagicPacketHandler
|
|||
public static void init()
|
||||
{
|
||||
INSTANCE.registerMessage(ChatUtil.PacketNoSpamChat.Handler.class, ChatUtil.PacketNoSpamChat.class, 0, Side.CLIENT);
|
||||
INSTANCE.registerMessage(ItemRouterButtonPacketProcessor.class, ItemRouterButtonPacketProcessor.class, 1, Side.SERVER);
|
||||
}
|
||||
|
||||
public static void sendToAllAround(IMessage message, TileEntity te, int range)
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
package WayofTime.bloodmagic.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
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 net.minecraftforge.fml.relauncher.Side;
|
||||
import WayofTime.bloodmagic.tile.routing.TileFilteredRoutingNode;
|
||||
|
||||
public class ItemRouterButtonPacketProcessor implements IMessage, IMessageHandler<ItemRouterButtonPacketProcessor, IMessage>
|
||||
{
|
||||
private int buttonPress;
|
||||
private int dimension;
|
||||
private BlockPos pos;
|
||||
|
||||
public ItemRouterButtonPacketProcessor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ItemRouterButtonPacketProcessor(int buttonPress, BlockPos pos, World world)
|
||||
{
|
||||
this.buttonPress = buttonPress;
|
||||
this.pos = pos;
|
||||
this.dimension = world.provider.getDimensionId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buffer)
|
||||
{
|
||||
PacketBuffer buff = new PacketBuffer(buffer);
|
||||
dimension = buff.readInt();
|
||||
pos = buff.readBlockPos();
|
||||
buttonPress = buff.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buffer)
|
||||
{
|
||||
PacketBuffer buff = new PacketBuffer(buffer);
|
||||
buff.writeInt(dimension);
|
||||
buff.writeBlockPos(pos);
|
||||
buff.writeInt(buttonPress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(ItemRouterButtonPacketProcessor message, MessageContext ctx)
|
||||
{
|
||||
if (ctx.side == Side.SERVER)
|
||||
{
|
||||
message.onMessageFromClient();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onMessageFromClient()
|
||||
{
|
||||
World world = DimensionManager.getWorld(dimension);
|
||||
if (world != null)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileFilteredRoutingNode)
|
||||
{
|
||||
((TileFilteredRoutingNode) tile).swapFilters(buttonPress);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue