mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Major packet work, I think it's done. 34 errors to go!
This commit is contained in:
1 parent
659b963af6
commit
1933723b52
41 files changed
+638
-886
No files matched your search
@@ -1,7 +1,7 @@
|
||||
package mekanism.common.network;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.tile.TileEntityBasicBlock;
|
||||
@@ -9,11 +9,6 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -30,31 +25,6 @@ public class PacketSimpleGui extends MekanismPacket
|
||||
guiId = gui;
|
||||
}
|
||||
|
||||
public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception
|
||||
{
|
||||
coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
|
||||
|
||||
guiId = dataStream.readInt();
|
||||
|
||||
if(!world.isRemote)
|
||||
{
|
||||
World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(coord4D.dimensionId);
|
||||
|
||||
if(worldServer != null && coord4D.getTileEntity(worldServer) instanceof TileEntityBasicBlock)
|
||||
{
|
||||
if(guiId == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
openServerGui(guiId, (EntityPlayerMP)player, world, coord4D);
|
||||
}
|
||||
}
|
||||
else {
|
||||
FMLCommonHandler.instance().showGuiScreen(getGui(guiId, player, world, coord4D));
|
||||
}
|
||||
}
|
||||
|
||||
public static void openServerGui(int id, EntityPlayerMP playerMP, World world, Coord4D obj)
|
||||
{
|
||||
playerMP.closeContainer();
|
||||
@@ -75,7 +45,8 @@ public class PacketSimpleGui extends MekanismPacket
|
||||
return (GuiScreen)Mekanism.proxy.getClientGui(id, player, world, obj.xCoord, obj.yCoord, obj.zCoord);
|
||||
}
|
||||
|
||||
public void write(DataOutputStream dataStream) throws Exception
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, ByteBuf dataStream)
|
||||
{
|
||||
dataStream.writeInt(coord4D.xCoord);
|
||||
dataStream.writeInt(coord4D.yCoord);
|
||||
@@ -87,15 +58,29 @@ public class PacketSimpleGui extends MekanismPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, ByteBuf buffer)
|
||||
public void read(ChannelHandlerContext ctx, EntityPlayer player, ByteBuf dataStream)
|
||||
{
|
||||
coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
|
||||
|
||||
}
|
||||
guiId = dataStream.readInt();
|
||||
|
||||
@Override
|
||||
public void read(ChannelHandlerContext ctx, ByteBuf buffer)
|
||||
{
|
||||
if(!player.worldObj.isRemote)
|
||||
{
|
||||
World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(coord4D.dimensionId);
|
||||
|
||||
if(worldServer != null && coord4D.getTileEntity(worldServer) instanceof TileEntityBasicBlock)
|
||||
{
|
||||
if(guiId == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
openServerGui(guiId, (EntityPlayerMP)player, player.worldObj, coord4D);
|
||||
}
|
||||
}
|
||||
else {
|
||||
FMLCommonHandler.instance().showGuiScreen(getGui(guiId, player, player.worldObj, coord4D));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user