Upload my Code Changes/Format/imports

This commit is contained in:
Alexander committed 2014-02-16 14:23:50 -05:00
1 parent 5bcdb7ca46
commit 5d4e38c0cb
264 files changed
+4014 -3972

No files matched your search

@@ -5,39 +5,53 @@ import io.netty.channel.ChannelHandlerContext;
import net.minecraft.entity.player.EntityPlayer;
/**
* AbstractPacket class. Should be the parent of all packets wishing to use the PacketPipeline.
* AbstractPacket class. Should be the parent of all packets wishing to use the
* PacketPipeline.
*
* @author sirgingalot
*/
public abstract class AbstractPacket
{
/**
* Encode the packet data into the ByteBuf stream. Complex data sets may need specific data handlers (See @link{cpw.mods.fml.common.network.ByteBuffUtils})
*
* @param ctx channel context
* @param buffer the buffer to encode into
* Encode the packet data into the ByteBuf stream. Complex data sets may
* need specific data handlers (See
* @link{cpw.mods.fml.common.network.ByteBuffUtils})
*
* @param ctx
* channel context
* @param buffer
* the buffer to encode into
*/
public abstract void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer);
/**
* Decode the packet data from the ByteBuf stream. Complex data sets may need specific data handlers (See @link{cpw.mods.fml.common.network.ByteBuffUtils})
*
* @param ctx channel context
* @param buffer the buffer to decode from
* Decode the packet data from the ByteBuf stream. Complex data sets may
* need specific data handlers (See
* @link{cpw.mods.fml.common.network.ByteBuffUtils})
*
* @param ctx
* channel context
* @param buffer
* the buffer to decode from
*/
public abstract void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer);
/**
* Handle a packet on the client side. Note this occurs after decoding has completed.
*
* @param player the player reference
* Handle a packet on the client side. Note this occurs after decoding has
* completed.
*
* @param player
* the player reference
*/
public abstract void handleClientSide (EntityPlayer player);
/**
* Handle a packet on the server side. Note this occurs after decoding has completed.
*
* @param player the player reference
* Handle a packet on the server side. Note this occurs after decoding has
* completed.
*
* @param player
* the player reference
*/
public abstract void handleServerSide (EntityPlayer player);
}
@@ -28,8 +28,8 @@ public class PacketDoubleJump extends AbstractPacket
@Override
public void handleServerSide (EntityPlayer player)
{
//String user = inputStream.readUTF();
//EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user);
// String user = inputStream.readUTF();
// EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user);
player.fallDistance = 0;
}
@@ -2,34 +2,41 @@ package tconstruct.util.network.packet;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import tconstruct.TConstruct;
public class PacketExtendedInventory extends AbstractPacket
{
byte type;
byte[] type;
public PacketExtendedInventory()
{
}
public PacketExtendedInventory(byte type)
public PacketExtendedInventory(byte[] bs)
{
this.type = type;
this.type = bs;
TConstruct.logger.error(type);
}
@Override
public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
buffer.writeByte(type);
// buffer.writeBytes(type);
}
@Override
public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer)
{
type = buffer.readByte();
// type = buffer.(buffer);
}
@Override
@@ -41,19 +48,28 @@ public class PacketExtendedInventory extends AbstractPacket
@Override
public void handleServerSide (EntityPlayer player)
{
//String user = inputStream.readUTF();
//EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user);
switch (type)
// String user = inputStream.readUTF();
// EntityPlayer player = TConstruct.playerTracker.getEntityPlayer(user);
DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(type));
try
{
case 0:
player.openGui(TConstruct.instance, TConstruct.proxy.inventoryGui, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
break;
case 1:
player.openGui(TConstruct.instance, TConstruct.proxy.armorGuiID, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
break;
case 2:
player.openGui(TConstruct.instance, TConstruct.proxy.knapsackGuiID, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
break;
switch (inputStream.readByte())
{
case 0:
player.openGui(TConstruct.instance, TConstruct.proxy.inventoryGui, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
break;
case 1:
player.openGui(TConstruct.instance, TConstruct.proxy.armorGuiID, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
break;
case 2:
player.openGui(TConstruct.instance, TConstruct.proxy.knapsackGuiID, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
break;
}
}
catch (IOException e)
{
TConstruct.logger.error("Failed at reading server packet for TConstruct.");
e.printStackTrace();
}
}
@@ -26,9 +26,10 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* Packet pipeline class. Directs all registered packet data to be handled by the packets themselves.
* @author sirgingalot
* some code from: cpw
* Packet pipeline class. Directs all registered packet data to be handled by
* the packets themselves.
*
* @author sirgingalot some code from: cpw
*/
@ChannelHandler.Sharable
public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, AbstractPacket>
@@ -39,11 +40,15 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
private boolean isPostInitialised = false;
/**
* Register your packet with the pipeline. Discriminators are automatically set.
*
* @param clazz the class to register
*
* @return whether registration was successful. Failure may occur if 256 packets have been registered or if the registry already contains this packet
* Register your packet with the pipeline. Discriminators are automatically
* set.
*
* @param clazz
* the class to register
*
* @return whether registration was successful. Failure may occur if 256
* packets have been registered or if the registry already contains
* this packet
*/
public boolean registerPacket (Class<? extends AbstractPacket> clazz)
{
@@ -139,7 +144,8 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
}
// Method to call from FMLPostInitializationEvent
// Ensures that packet discriminators are common between server and client by using logical sorting
// Ensures that packet discriminators are common between server and client
// by using logical sorting
public void postInitialise ()
{
if (this.isPostInitialised)
@@ -174,9 +180,11 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
/**
* Send this message to everyone.
* <p/>
* Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
* @param message The message to send
* Adapted from CPW's code in
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
* @param message
* The message to send
*/
public void sendToAll (AbstractPacket message)
{
@@ -187,10 +195,13 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
/**
* Send this message to the specified player.
* <p/>
* Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
* @param message The message to send
* @param player The player to send it to
* Adapted from CPW's code in
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
* @param message
* The message to send
* @param player
* The player to send it to
*/
public void sendTo (AbstractPacket message, EntityPlayerMP player)
{
@@ -202,10 +213,15 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
/**
* Send this message to everyone within a certain range of a point.
* <p/>
* Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
* @param message The message to send
* @param point The {@link cpw.mods.fml.common.network.NetworkRegistry.TargetPoint} around which to send
* Adapted from CPW's code in
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
* @param message
* The message to send
* @param point
* The
* {@link cpw.mods.fml.common.network.NetworkRegistry.TargetPoint}
* around which to send
*/
public void sendToAllAround (AbstractPacket message, NetworkRegistry.TargetPoint point)
{
@@ -217,10 +233,13 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
/**
* Send this message to everyone within the supplied dimension.
* <p/>
* Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
* @param message The message to send
* @param dimensionId The dimension id to target
* Adapted from CPW's code in
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
* @param message
* The message to send
* @param dimensionId
* The dimension id to target
*/
public void sendToDimension (AbstractPacket message, int dimensionId)
{
@@ -232,9 +251,11 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
/**
* Send this message to the server.
* <p/>
* Adapted from CPW's code in cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
* @param message The message to send
* Adapted from CPW's code in
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
* @param message
* The message to send
*/
public void sendToServer (AbstractPacket message)
{
@@ -70,7 +70,10 @@ public class PacketSmeltery extends AbstractPacket
FluidStack temp = null;
for (FluidStack liquid : ((SmelteryLogic) te).moltenMetal)
{//TODO update fluid stuffs
{// TODO
// update
// fluid
// stuffs
if (liquid.fluidID == fluidID)
{
temp = liquid;
@@ -85,8 +88,10 @@ public class PacketSmeltery extends AbstractPacket
else
((SmelteryLogic) te).moltenMetal.add(0, temp);
}
//TODO check if this works like it should
//Old code: PacketDispatcher.sendPacketToAllInDimension(te.getDescriptionPacket(), dimension);
// TODO check if this works like it should
// Old code:
// PacketDispatcher.sendPacketToAllInDimension(te.getDescriptionPacket(),
// dimension);
FMLCommonHandler.instance().getClientToServerNetworkManager().scheduleOutboundPacket(te.getDescriptionPacket());
}
}