Jump to content

Azazell

Members
  • Posts

    4
  • Joined

  • Last visited

Azazell's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Delete this post
  2. I cannot just update mod right now, because mod is done for 3/4. If this forum are no longer supports 1.7.10 version, then i will close this topic. Thank for informing.
  3. ClientMessageHandler: public abstract class ClientMessageHandler<T extends IMessage> extends AIMessageHandler<T>{ public final IMessage handleServerMessage(EntityPlayer player, T message, MessageContext ctx) { return null; } } AIMessageHandler: public abstract class AIMessageHandler<T extends IMessage> implements IMessageHandler<T, IMessage> { @SideOnly(Side.CLIENT) public abstract IMessage handleClientMessage (EntityPlayer player, T message, MessageContext ctx); public abstract IMessage handleServerMessage (EntityPlayer player, T message, MessageContext ctx); @Override public IMessage onMessage (T message, MessageContext ctx){ if (ctx.side.isClient()) { return handleClientMessage(AppliedIntegrations.proxy.getPlayerEntity(ctx), message, ctx); } else { return handleServerMessage(AppliedIntegrations.proxy.getPlayerEntity(ctx), message, ctx); } } } Sending: NetworkHandler.sendTo(new PacketProgressBar(this), (EntityPlayerMP) listener.player); Handler: public class NetworkHandler { private static byte packetId = 0; private static final SimpleNetworkWrapper Handler = NetworkRegistry.INSTANCE.newSimpleChannel(AppliedIntegrations.modid); /** * Call this during pre-init or loading and register all of your packets (messages) here */ public static final void registerPackets() { NetworkHandler.registerMessage(PacketProgressBar.Handler.class, PacketProgressBar.class, Side.CLIENT); NetworkHandler.registerMessage(PacketFilterChange.Handler.class,PacketFilterChange.class,Side.SERVER); NetworkHandler.registerMessage(PacketBarChange.Handler.class,PacketBarChange.class,Side.CLIENT); } /** * Registers a message and message handler */ private static final void registerMessage(Class handlerClass, Class messageClass, Side side) { NetworkHandler.Handler.registerMessage(handlerClass, messageClass, packetId++, side); } // send packet info to player public static final void sendTo(IMessage message, EntityPlayerMP player) { NetworkHandler.Handler.sendTo(message, player); } public static final void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) { NetworkHandler.Handler.sendToAllAround(message, point); } public static final void sendToAllAround(IMessage message, int dimension, double x, double y, double z, double range) { NetworkHandler.sendToAllAround(message, new NetworkRegistry.TargetPoint(dimension, x, y, z, range)); } public static final void sendToAllAround(IMessage message, EntityPlayer player, double range) { NetworkHandler.sendToAllAround(message, player.worldObj.provider.dimensionId, player.posX, player.posY, player.posZ, range); } public static final void sendToDimension(IMessage message, int dimensionId) { NetworkHandler.Handler.sendToDimension(message, dimensionId); } public static final void sendToServer(IMessage message) { NetworkHandler.Handler.sendToServer(message); } }
  4. I created working packets, but by some reasons all machines updates gui of each others, when 1 machines contains 1000RF, and i placing other machine, and open it's gui it displays 1000RF, but this machine not contains 1000RF. Here's my code of packets: public class PacketProgressBar implements IMessage{ private PartEnergyInterface sender; private NBTTagCompound data; public PacketProgressBar(){ // AutoMate, added for minecraft base handling } public PacketProgressBar(int Storage, int x,int y,int z,ForgeDirection dir){ this.data = new NBTTagCompound(); data.setInteger("EnergyStored",Storage); Gui gui = Minecraft.getMinecraft().currentScreen; if(gui instanceof GuiEnergyInterface){ GuiEnergyInterface GEI = (GuiEnergyInterface)gui; GEI.storage = Storage; } } public PacketProgressBar(PartEnergyInterface sender){ this(sender.getEnergyStorage(sender.bar).getEnergyStored(),sender.getX(),sender.getY(),sender.getZ(),sender.getSide()); this.sender = sender; } @Override public void fromBytes(ByteBuf buf) { data = ByteBufUtils.readTag(buf); } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeTag(buf,data); } public static class Handler extends ClientMessageHandler<PacketProgressBar>{ @Override public IMessage handleClientMessage(EntityPlayer player, PacketProgressBar message, MessageContext ctx) { return null; } } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.