network code cleanup
This commit is contained in:
parent
1eefb197f0
commit
bd4b8d427a
116 changed files with 1541 additions and 2022 deletions
|
@ -63,37 +63,37 @@ import common.network.IClientPlayer;
|
|||
import common.network.NetConnection;
|
||||
import common.network.NetHandler;
|
||||
import common.network.Packet;
|
||||
import common.packet.CPacketPlayerPosLook;
|
||||
import common.packet.CPacketAction;
|
||||
import common.packet.CPacketKeepAlive;
|
||||
import common.packet.CPacketPlayer;
|
||||
import common.packet.S14PacketEntity;
|
||||
import common.packet.S18PacketEntityTeleport;
|
||||
import common.packet.S19PacketEntityHeadLook;
|
||||
import common.packet.S1APacketEntityStatus;
|
||||
import common.packet.S1BPacketEntityAttach;
|
||||
import common.packet.S1CPacketEntityMetadata;
|
||||
import common.packet.S1DPacketEntityEffect;
|
||||
import common.packet.S1EPacketRemoveEntityEffect;
|
||||
import common.packet.S20PacketEntityProperties;
|
||||
import common.packet.S27PacketExplosion;
|
||||
import common.packet.S28PacketEffect;
|
||||
import common.packet.S29PacketSoundEffect;
|
||||
import common.packet.S2APacketParticles;
|
||||
import common.packet.S2BPacketChangeGameState;
|
||||
import common.packet.S2CPacketSpawnGlobalEntity;
|
||||
import common.packet.S2DPacketOpenWindow;
|
||||
import common.packet.S2EPacketCloseWindow;
|
||||
import common.packet.S2FPacketSetSlot;
|
||||
import common.packet.S30PacketWindowItems;
|
||||
import common.packet.S31PacketWindowProperty;
|
||||
import common.packet.S32PacketConfirmTransaction;
|
||||
import common.packet.S33PacketUpdateSign;
|
||||
import common.packet.S35PacketUpdateTileEntity;
|
||||
import common.packet.S36PacketSignEditorOpen;
|
||||
import common.packet.S38PacketPlayerListItem;
|
||||
import common.packet.S39PacketPlayerAbilities;
|
||||
import common.packet.S3APacketTabComplete;
|
||||
import common.packet.S43PacketUpdateEntityNBT;
|
||||
import common.packet.SPacketEntity;
|
||||
import common.packet.SPacketEntityTeleport;
|
||||
import common.packet.SPacketEntityHeadLook;
|
||||
import common.packet.SPacketEntityStatus;
|
||||
import common.packet.SPacketEntityAttach;
|
||||
import common.packet.SPacketEntityMetadata;
|
||||
import common.packet.SPacketEntityEffect;
|
||||
import common.packet.SPacketRemoveEntityEffect;
|
||||
import common.packet.SPacketEntityProperties;
|
||||
import common.packet.SPacketExplosion;
|
||||
import common.packet.SPacketEffect;
|
||||
import common.packet.SPacketSoundEffect;
|
||||
import common.packet.SPacketParticles;
|
||||
import common.packet.SPacketChangeGameState;
|
||||
import common.packet.SPacketSpawnGlobalEntity;
|
||||
import common.packet.SPacketOpenWindow;
|
||||
import common.packet.SPacketCloseWindow;
|
||||
import common.packet.SPacketSetSlot;
|
||||
import common.packet.SPacketWindowItems;
|
||||
import common.packet.SPacketWindowProperty;
|
||||
import common.packet.SPacketConfirmTransaction;
|
||||
import common.packet.SPacketUpdateSign;
|
||||
import common.packet.SPacketUpdateTileEntity;
|
||||
import common.packet.SPacketSignEditorOpen;
|
||||
import common.packet.SPacketPlayerListItem;
|
||||
import common.packet.SPacketPlayerAbilities;
|
||||
import common.packet.SPacketTabComplete;
|
||||
import common.packet.SPacketUpdateEntityNBT;
|
||||
import common.packet.SPacketAnimation;
|
||||
import common.packet.SPacketBiome;
|
||||
import common.packet.SPacketBlockAction;
|
||||
|
@ -452,7 +452,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
/**
|
||||
* Handles globally visible entities. Used in vanilla for lightning bolts
|
||||
*/
|
||||
public void handleSpawnGlobalEntity(S2CPacketSpawnGlobalEntity packetIn)
|
||||
public void handleSpawnGlobalEntity(SPacketSpawnGlobalEntity packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
double d0 = (double)packetIn.getEncodedX() / 32.0D;
|
||||
|
@ -505,7 +505,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
* Invoked when the server registers new proximate objects in your watchlist or when objects in your watchlist have
|
||||
* changed -> Registers any changes locally
|
||||
*/
|
||||
public void handleEntityMetadata(S1CPacketEntityMetadata packetIn)
|
||||
public void handleEntityMetadata(SPacketEntityMetadata packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
|
||||
|
@ -562,7 +562,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
/**
|
||||
* Updates an entity's position and rotation as specified by the packet
|
||||
*/
|
||||
public void handleEntityTeleport(S18PacketEntityTeleport packetIn)
|
||||
public void handleEntityTeleport(SPacketEntityTeleport packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
|
||||
|
@ -609,7 +609,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
* subclassing of the packet allows for the specification of a subset of this data (e.g. only rel. position, abs.
|
||||
* rotation or both).
|
||||
*/
|
||||
public void handleEntityMovement(S14PacketEntity packetIn)
|
||||
public void handleEntityMovement(SPacketEntity packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
Entity entity = packetIn.getEntity(this.clientWorldController);
|
||||
|
@ -633,7 +633,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
* Updates the direction in which the specified entity is looking, normally this head rotation is independent of the
|
||||
* rotation of the entity itself
|
||||
*/
|
||||
public void handleEntityHeadLook(S19PacketEntityHeadLook packetIn)
|
||||
public void handleEntityHeadLook(SPacketEntityHeadLook packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
Entity entity = packetIn.getEntity(this.clientWorldController);
|
||||
|
@ -714,7 +714,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
}
|
||||
|
||||
entityplayer.setPositionAndRotation(d0, d1, d2, f, f1);
|
||||
this.netManager.sendPacket(new CPacketPlayer.C06PacketPlayerPosLook(entityplayer.posX, entityplayer.getEntityBoundingBox().minY, entityplayer.posZ, entityplayer.rotYaw, entityplayer.rotPitch, false));
|
||||
this.netManager.sendPacket(new CPacketPlayerPosLook(entityplayer.posX, entityplayer.getEntityBoundingBox().minY, entityplayer.posZ, entityplayer.rotYaw, entityplayer.rotPitch, false));
|
||||
|
||||
if (!this.doneLoadingTerrain)
|
||||
{
|
||||
|
@ -1008,7 +1008,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
// this.gameController.thePlayer.setSpawnPoint(packetIn.getSpawnPos(), true);
|
||||
// }
|
||||
|
||||
public void handleEntityAttach(S1BPacketEntityAttach packetIn)
|
||||
public void handleEntityAttach(SPacketEntityAttach packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
|
||||
|
@ -1065,7 +1065,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
* (spawn particles), Zombie (villager transformation), Animal (breeding mode particles), Horse (breeding/smoke
|
||||
* particles), Sheep (...), Tameable (...), Villager (particles for breeding mode, angry and happy), Wolf (...)
|
||||
*/
|
||||
public void handleEntityStatus(S1APacketEntityStatus packetIn)
|
||||
public void handleEntityStatus(SPacketEntityStatus packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
Entity entity = packetIn.getEntity(this.clientWorldController);
|
||||
|
@ -1127,7 +1127,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
/**
|
||||
* Initiates a new explosion (sound, particles, drop spawn) for the affected blocks indicated by the packet.
|
||||
*/
|
||||
public void handleExplosion(S27PacketExplosion packetIn)
|
||||
public void handleExplosion(SPacketExplosion packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
Explosion explosion = new Explosion(this.gameController.world, (Entity)null, packetIn.getX(), packetIn.getY(), packetIn.getZ(), packetIn.getStrength(), packetIn.getAffectedBlockPositions());
|
||||
|
@ -1141,7 +1141,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
* Displays a GUI by ID. In order starting from id 0: Chest, Workbench, Furnace, Dispenser, Enchanting table,
|
||||
* Brewing stand, Villager merchant, Beacon, Anvil, Hopper, Dropper, Horse
|
||||
*/
|
||||
public void handleOpenWindow(S2DPacketOpenWindow packetIn)
|
||||
public void handleOpenWindow(SPacketOpenWindow packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
EntityNPC entityplayersp = this.gameController.player;
|
||||
|
@ -1190,7 +1190,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
/**
|
||||
* Handles pickin up an ItemStack or dropping one in your inventory or an open container
|
||||
*/
|
||||
public void handleSetSlot(S2FPacketSetSlot packetIn)
|
||||
public void handleSetSlot(SPacketSetSlot packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
EntityNPC entityplayer = this.gameController.player;
|
||||
|
@ -1231,7 +1231,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
* Verifies that the server and client are synchronized with respect to the inventory/container opened by the player
|
||||
* and confirms if it is the case.
|
||||
*/
|
||||
public void handleConfirmTransaction(S32PacketConfirmTransaction packetIn)
|
||||
public void handleConfirmTransaction(SPacketConfirmTransaction packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
Container container = null;
|
||||
|
@ -1255,7 +1255,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
/**
|
||||
* Handles the placement of a specified ItemStack in a specified container/inventory slot
|
||||
*/
|
||||
public void handleWindowItems(S30PacketWindowItems packetIn)
|
||||
public void handleWindowItems(SPacketWindowItems packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
EntityNPC entityplayer = this.gameController.player;
|
||||
|
@ -1273,7 +1273,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
/**
|
||||
* Creates a sign in the specified location if it didn't exist and opens the GUI to edit its text
|
||||
*/
|
||||
public void handleSignEditorOpen(S36PacketSignEditorOpen packetIn)
|
||||
public void handleSignEditorOpen(SPacketSignEditorOpen packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
TileEntity tileentity = this.clientWorldController.getTileEntity(packetIn.getSignPosition());
|
||||
|
@ -1296,7 +1296,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
/**
|
||||
* Updates a specified sign with the specified text lines
|
||||
*/
|
||||
public void handleUpdateSign(S33PacketUpdateSign packetIn)
|
||||
public void handleUpdateSign(SPacketUpdateSign packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
// boolean flag = false;
|
||||
|
@ -1331,7 +1331,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
* Updates the NBTTagCompound metadata of instances of the following entitytypes: Mob spawners, command blocks,
|
||||
* beacons, skulls, flowerpot
|
||||
*/
|
||||
public void handleUpdateTileEntity(S35PacketUpdateTileEntity packetIn)
|
||||
public void handleUpdateTileEntity(SPacketUpdateTileEntity packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
|
||||
|
@ -1350,7 +1350,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
/**
|
||||
* Sets the progressbar of the opened window to the specified value
|
||||
*/
|
||||
public void handleWindowProperty(S31PacketWindowProperty packetIn)
|
||||
public void handleWindowProperty(SPacketWindowProperty packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
EntityNPC entityplayer = this.gameController.player;
|
||||
|
@ -1375,7 +1375,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
/**
|
||||
* Resets the ItemStack held in hand and closes the window that is opened
|
||||
*/
|
||||
public void handleCloseWindow(S2EPacketCloseWindow packetIn)
|
||||
public void handleCloseWindow(SPacketCloseWindow packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
// this.gameController.thePlayer.closeScreenAndDropStack();
|
||||
|
@ -1423,7 +1423,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
}
|
||||
}
|
||||
|
||||
public void handleChangeGameState(S2BPacketChangeGameState packetIn)
|
||||
public void handleChangeGameState(SPacketChangeGameState packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
switch(packetIn.getAction()) {
|
||||
|
@ -1448,7 +1448,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
}
|
||||
}
|
||||
|
||||
public void handleEffect(S28PacketEffect packetIn)
|
||||
public void handleEffect(SPacketEffect packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
|
||||
|
@ -1513,7 +1513,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
// }
|
||||
// }
|
||||
|
||||
public void handleEntityEffect(S1DPacketEntityEffect packetIn)
|
||||
public void handleEntityEffect(SPacketEntityEffect packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
|
||||
|
@ -1590,7 +1590,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
//// }
|
||||
// }
|
||||
|
||||
public void handleRemoveEntityEffect(S1EPacketRemoveEntityEffect packetIn)
|
||||
public void handleRemoveEntityEffect(SPacketRemoveEntityEffect packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
|
||||
|
@ -1602,7 +1602,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
}
|
||||
|
||||
|
||||
public void handlePlayerListItem(S38PacketPlayerListItem packetIn)
|
||||
public void handlePlayerListItem(SPacketPlayerListItem packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController);
|
||||
|
||||
|
@ -1649,7 +1649,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
this.addToSendQueue(new CPacketKeepAlive(packetIn.getValue()));
|
||||
}
|
||||
|
||||
public void handlePlayerAbilities(S39PacketPlayerAbilities packetIn)
|
||||
public void handlePlayerAbilities(SPacketPlayerAbilities packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
EntityNPC entityplayer = this.gameController.player;
|
||||
|
@ -1662,7 +1662,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
/**
|
||||
* Displays the available command-completion options the server knows of
|
||||
*/
|
||||
public void handleTabComplete(S3APacketTabComplete packetIn)
|
||||
public void handleTabComplete(SPacketTabComplete packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
String[] astring = packetIn.func_149630_c();
|
||||
|
@ -1674,7 +1674,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
}
|
||||
}
|
||||
|
||||
public void handleSoundEffect(S29PacketSoundEffect packetIn)
|
||||
public void handleSoundEffect(SPacketSoundEffect packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
if(packetIn.getSound() == null) {
|
||||
|
@ -1711,7 +1711,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
//// }
|
||||
// }
|
||||
|
||||
public void handleEntityNBT(S43PacketUpdateEntityNBT packetIn)
|
||||
public void handleEntityNBT(SPacketUpdateEntityNBT packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
Entity entity = packetIn.getEntity(this.clientWorldController);
|
||||
|
@ -1835,7 +1835,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
* Spawns a specified number of particles at the specified location with a randomized displacement according to
|
||||
* specified bounds
|
||||
*/
|
||||
public void handleParticles(S2APacketParticles packetIn)
|
||||
public void handleParticles(SPacketParticles packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
|
||||
|
@ -1885,7 +1885,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
* sprinting, animals fleeing, baby speed), weapon/tool attackDamage, hostiles followRange randomization, zombie
|
||||
* maxHealth and knockback resistance as well as reinforcement spawning chance.
|
||||
*/
|
||||
public void handleEntityProperties(S20PacketEntityProperties packetIn)
|
||||
public void handleEntityProperties(SPacketEntityProperties packetIn)
|
||||
{
|
||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||
Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
|
||||
|
@ -1900,7 +1900,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
|||
{
|
||||
AttributeMap baseattributemap = ((EntityLiving)entity).getAttributeMap();
|
||||
|
||||
for (S20PacketEntityProperties.Snapshot s20packetentityproperties$snapshot : packetIn.func_149441_d())
|
||||
for (SPacketEntityProperties.Snapshot s20packetentityproperties$snapshot : packetIn.func_149441_d())
|
||||
{
|
||||
AttributeInstance iattributeinstance = baseattributemap.getAttributeInstanceByName(s20packetentityproperties$snapshot.func_151409_a());
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import common.inventory.InventoryLargeChest;
|
|||
import common.item.CheatTab;
|
||||
import common.item.ItemStack;
|
||||
import common.material.Material;
|
||||
import common.packet.S29PacketSoundEffect;
|
||||
import common.packet.SPacketSoundEffect;
|
||||
import common.properties.IProperty;
|
||||
import common.properties.PropertyDirection;
|
||||
import common.tileentity.ILockableContainer;
|
||||
|
@ -448,7 +448,7 @@ public class BlockChest extends BlockContainer
|
|||
ilockablecontainer.setLockCode(LockCode.EMPTY_CODE);
|
||||
// playerIn.triggerAchievement(StatRegistry.chestUnlockedStat);
|
||||
playerIn.connection.addHotbar(TextColor.BLUE + "%s wurde entriegelt", ilockablecontainer.getCommandName());
|
||||
playerIn.connection.sendPacket(new S29PacketSoundEffect(SoundEvent.DOOR, playerIn.posX, playerIn.posY, playerIn.posZ, 1.0F));
|
||||
playerIn.connection.sendPacket(new SPacketSoundEffect(SoundEvent.DOOR, playerIn.posX, playerIn.posY, playerIn.posZ, 1.0F));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ public class BlockChest extends BlockContainer
|
|||
ilockablecontainer.setLockCode(new LockCode(stack.getDisplayName()));
|
||||
// playerIn.triggerAchievement(StatRegistry.chestLockedStat);
|
||||
playerIn.connection.addHotbar(TextColor.ORANGE + "%s wurde verriegelt", ilockablecontainer.getCommandName());
|
||||
playerIn.connection.sendPacket(new S29PacketSoundEffect(SoundEvent.DOOR, playerIn.posX, playerIn.posY, playerIn.posZ, 1.0F));
|
||||
playerIn.connection.sendPacket(new SPacketSoundEffect(SoundEvent.DOOR, playerIn.posX, playerIn.posY, playerIn.posZ, 1.0F));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ public class DataWatcher {
|
|||
|
||||
case 5:
|
||||
ItemStack itemstack = (ItemStack)object.getObject();
|
||||
buffer.writeItemStackToBuffer(itemstack);
|
||||
buffer.writeItemStack(itemstack);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
|
@ -250,11 +250,11 @@ public class DataWatcher {
|
|||
break;
|
||||
|
||||
case 4:
|
||||
datawatcher$watchableobject = new DataWatcher.WatchableObject(j, k, buffer.readStringFromBuffer(32767));
|
||||
datawatcher$watchableobject = new DataWatcher.WatchableObject(j, k, buffer.readString(32767));
|
||||
break;
|
||||
|
||||
case 5:
|
||||
datawatcher$watchableobject = new DataWatcher.WatchableObject(j, k, buffer.readItemStackFromBuffer());
|
||||
datawatcher$watchableobject = new DataWatcher.WatchableObject(j, k, buffer.readItemStack());
|
||||
break;
|
||||
|
||||
case 6:
|
||||
|
|
|
@ -14,14 +14,16 @@ import common.item.ItemStack;
|
|||
import common.log.Log;
|
||||
import common.nbt.NBTTagCompound;
|
||||
import common.network.Packet;
|
||||
import common.packet.S14PacketEntity;
|
||||
import common.packet.S18PacketEntityTeleport;
|
||||
import common.packet.S19PacketEntityHeadLook;
|
||||
import common.packet.S1BPacketEntityAttach;
|
||||
import common.packet.S1CPacketEntityMetadata;
|
||||
import common.packet.S1DPacketEntityEffect;
|
||||
import common.packet.S20PacketEntityProperties;
|
||||
import common.packet.S43PacketUpdateEntityNBT;
|
||||
import common.packet.SPacketEntityRelMove;
|
||||
import common.packet.SPacketEntityLook;
|
||||
import common.packet.SPacketEntityLookMove;
|
||||
import common.packet.SPacketEntityTeleport;
|
||||
import common.packet.SPacketEntityHeadLook;
|
||||
import common.packet.SPacketEntityAttach;
|
||||
import common.packet.SPacketEntityMetadata;
|
||||
import common.packet.SPacketEntityEffect;
|
||||
import common.packet.SPacketEntityProperties;
|
||||
import common.packet.SPacketUpdateEntityNBT;
|
||||
import common.packet.SPacketEntityEquipment;
|
||||
import common.packet.SPacketEntityVelocity;
|
||||
import common.packet.SPacketSpawnMob;
|
||||
|
@ -96,7 +98,7 @@ public class EntityTrackerEntry {
|
|||
|
||||
if(this.lastRiding != this.trackedEntity.vehicle || this.trackedEntity.vehicle != null && this.updateCounter % 60 == 0) {
|
||||
this.lastRiding = this.trackedEntity.vehicle;
|
||||
this.sendPacketToTrackedPlayers(new S1BPacketEntityAttach(0, this.trackedEntity, this.trackedEntity.vehicle));
|
||||
this.sendPacketToTrackedPlayers(new SPacketEntityAttach(0, this.trackedEntity, this.trackedEntity.vehicle));
|
||||
}
|
||||
|
||||
// if(this.trackedEntity instanceof EntityFrame && this.updateCounter % 10 == 0) {
|
||||
|
@ -141,23 +143,23 @@ public class EntityTrackerEntry {
|
|||
&& !this.ridingEntity && this.onGround == this.trackedEntity.onGround) {
|
||||
if((!flag || !flag1) && !(this.trackedEntity instanceof EntityArrow)) {
|
||||
if(flag) {
|
||||
packet1 = new S14PacketEntity.S15PacketEntityRelMove(this.trackedEntity.getId(), (byte)j2, (byte)k2, (byte)i,
|
||||
packet1 = new SPacketEntityRelMove(this.trackedEntity.getId(), (byte)j2, (byte)k2, (byte)i,
|
||||
this.trackedEntity.onGround);
|
||||
}
|
||||
else if(flag1) {
|
||||
packet1 = new S14PacketEntity.S16PacketEntityLook(this.trackedEntity.getId(), (byte)l1, (byte)i2,
|
||||
packet1 = new SPacketEntityLook(this.trackedEntity.getId(), (byte)l1, (byte)i2,
|
||||
this.trackedEntity.onGround);
|
||||
}
|
||||
}
|
||||
else {
|
||||
packet1 = new S14PacketEntity.S17PacketEntityLookMove(this.trackedEntity.getId(), (byte)j2, (byte)k2, (byte)i,
|
||||
packet1 = new SPacketEntityLookMove(this.trackedEntity.getId(), (byte)j2, (byte)k2, (byte)i,
|
||||
(byte)l1, (byte)i2, this.trackedEntity.onGround);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.onGround = this.trackedEntity.onGround;
|
||||
this.ticksSinceLastForcedTeleport = 0;
|
||||
packet1 = new S18PacketEntityTeleport(this.trackedEntity.getId(), k, j1, k1, (byte)l1, (byte)i2,
|
||||
packet1 = new SPacketEntityTeleport(this.trackedEntity.getId(), k, j1, k1, (byte)l1, (byte)i2,
|
||||
this.trackedEntity.onGround);
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +206,7 @@ public class EntityTrackerEntry {
|
|||
boolean flag2 = Math.abs(j - this.encodedRotationYaw) >= 4 || Math.abs(i1 - this.encodedRotationPitch) >= 4;
|
||||
|
||||
if(flag2) {
|
||||
this.sendPacketToTrackedPlayers(new S14PacketEntity.S16PacketEntityLook(this.trackedEntity.getId(), (byte)j, (byte)i1,
|
||||
this.sendPacketToTrackedPlayers(new SPacketEntityLook(this.trackedEntity.getId(), (byte)j, (byte)i1,
|
||||
this.trackedEntity.onGround));
|
||||
this.encodedRotationYaw = j;
|
||||
this.encodedRotationPitch = i1;
|
||||
|
@ -220,7 +222,7 @@ public class EntityTrackerEntry {
|
|||
int l = ExtMath.floorf(this.trackedEntity.getRotationYawHead() * 256.0F / 360.0F);
|
||||
|
||||
if(Math.abs(l - this.lastHeadMotion) >= 4) {
|
||||
this.sendPacketToTrackedPlayers(new S19PacketEntityHeadLook(this.trackedEntity, (byte)l));
|
||||
this.sendPacketToTrackedPlayers(new SPacketEntityHeadLook(this.trackedEntity, (byte)l));
|
||||
this.lastHeadMotion = l;
|
||||
}
|
||||
|
||||
|
@ -239,7 +241,7 @@ public class EntityTrackerEntry {
|
|||
DataWatcher datawatcher = this.trackedEntity.getDataWatcher();
|
||||
|
||||
if(datawatcher.hasObjectChanged()) {
|
||||
this.sendPacketToTrackedAndSelf(new S1CPacketEntityMetadata(this.trackedEntity.getId(), datawatcher, false));
|
||||
this.sendPacketToTrackedAndSelf(new SPacketEntityMetadata(this.trackedEntity.getId(), datawatcher, false));
|
||||
}
|
||||
|
||||
if(this.trackedEntity instanceof EntityLiving) {
|
||||
|
@ -247,7 +249,7 @@ public class EntityTrackerEntry {
|
|||
Set<AttributeInstance> set = serversideattributemap.getDirty();
|
||||
|
||||
if(!set.isEmpty()) {
|
||||
this.sendPacketToTrackedAndSelf(new S20PacketEntityProperties(this.trackedEntity.getId(), set));
|
||||
this.sendPacketToTrackedAndSelf(new SPacketEntityProperties(this.trackedEntity.getId(), set));
|
||||
}
|
||||
|
||||
set.clear();
|
||||
|
@ -291,13 +293,13 @@ public class EntityTrackerEntry {
|
|||
|
||||
if(!this.trackedEntity.getDataWatcher().isBlank()) {
|
||||
playerMP.connection
|
||||
.sendPacket(new S1CPacketEntityMetadata(this.trackedEntity.getId(), this.trackedEntity.getDataWatcher(), true));
|
||||
.sendPacket(new SPacketEntityMetadata(this.trackedEntity.getId(), this.trackedEntity.getDataWatcher(), true));
|
||||
}
|
||||
|
||||
NBTTagCompound nbttagcompound = this.trackedEntity.getNBTTagCompound();
|
||||
|
||||
if(nbttagcompound != null) {
|
||||
playerMP.connection.sendPacket(new S43PacketUpdateEntityNBT(this.trackedEntity.getId(), nbttagcompound));
|
||||
playerMP.connection.sendPacket(new SPacketUpdateEntityNBT(this.trackedEntity.getId(), nbttagcompound));
|
||||
}
|
||||
|
||||
if(this.trackedEntity instanceof EntityLiving) {
|
||||
|
@ -305,7 +307,7 @@ public class EntityTrackerEntry {
|
|||
Collection<AttributeInstance> collection = serversideattributemap.getWatchedAttributes();
|
||||
|
||||
if(!collection.isEmpty()) {
|
||||
playerMP.connection.sendPacket(new S20PacketEntityProperties(this.trackedEntity.getId(), collection));
|
||||
playerMP.connection.sendPacket(new SPacketEntityProperties(this.trackedEntity.getId(), collection));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,12 +324,12 @@ public class EntityTrackerEntry {
|
|||
}
|
||||
|
||||
if(this.trackedEntity.vehicle != null) {
|
||||
playerMP.connection.sendPacket(new S1BPacketEntityAttach(0, this.trackedEntity, this.trackedEntity.vehicle));
|
||||
playerMP.connection.sendPacket(new SPacketEntityAttach(0, this.trackedEntity, this.trackedEntity.vehicle));
|
||||
}
|
||||
|
||||
if(this.trackedEntity instanceof EntityLiving && ((EntityLiving)this.trackedEntity).getLeashedTo() != null) {
|
||||
playerMP.connection.sendPacket(
|
||||
new S1BPacketEntityAttach(1, this.trackedEntity, ((EntityLiving)this.trackedEntity).getLeashedTo()));
|
||||
new SPacketEntityAttach(1, this.trackedEntity, ((EntityLiving)this.trackedEntity).getLeashedTo()));
|
||||
}
|
||||
|
||||
if(this.trackedEntity instanceof EntityLiving) {
|
||||
|
@ -353,7 +355,7 @@ public class EntityTrackerEntry {
|
|||
EntityLiving entitylivingbase = (EntityLiving)this.trackedEntity;
|
||||
|
||||
for(PotionEffect potioneffect : entitylivingbase.getEffects()) {
|
||||
playerMP.connection.sendPacket(new S1DPacketEntityEffect(this.trackedEntity.getId(), potioneffect));
|
||||
playerMP.connection.sendPacket(new SPacketEntityEffect(this.trackedEntity.getId(), potioneffect));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,9 @@ import common.nbt.NBTTagCompound;
|
|||
import common.nbt.NBTTagList;
|
||||
import common.network.IClientPlayer;
|
||||
import common.network.IPlayer;
|
||||
import common.packet.CPacketPlayerPosition;
|
||||
import common.packet.CPacketPlayerLook;
|
||||
import common.packet.CPacketPlayerPosLook;
|
||||
import common.packet.CPacketAction;
|
||||
import common.packet.CPacketBreak;
|
||||
import common.packet.CPacketInput;
|
||||
|
@ -1799,7 +1802,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
|
||||
if (this.isRiding())
|
||||
{
|
||||
this.client.addToSendQueue(new CPacketPlayer.C05PacketPlayerLook(this.rotYaw, this.rotPitch, this.onGround));
|
||||
this.client.addToSendQueue(new CPacketPlayerLook(this.rotYaw, this.rotPitch, this.onGround));
|
||||
this.client.addToSendQueue(new CPacketInput(this.moveStrafe, this.moveForward, this.client.isJumping(), this.client.isSneaking()));
|
||||
}
|
||||
else
|
||||
|
@ -2667,15 +2670,15 @@ public abstract class EntityNPC extends EntityLiving
|
|||
{
|
||||
if (flag2 && flag3)
|
||||
{
|
||||
this.client.addToSendQueue(new CPacketPlayer.C06PacketPlayerPosLook(this.posX, this.getEntityBoundingBox().minY, this.posZ, this.rotYaw, this.rotPitch, this.onGround));
|
||||
this.client.addToSendQueue(new CPacketPlayerPosLook(this.posX, this.getEntityBoundingBox().minY, this.posZ, this.rotYaw, this.rotPitch, this.onGround));
|
||||
}
|
||||
else if (flag2)
|
||||
{
|
||||
this.client.addToSendQueue(new CPacketPlayer.C04PacketPlayerPosition(this.posX, this.getEntityBoundingBox().minY, this.posZ, this.onGround));
|
||||
this.client.addToSendQueue(new CPacketPlayerPosition(this.posX, this.getEntityBoundingBox().minY, this.posZ, this.onGround));
|
||||
}
|
||||
else if (flag3)
|
||||
{
|
||||
this.client.addToSendQueue(new CPacketPlayer.C05PacketPlayerLook(this.rotYaw, this.rotPitch, this.onGround));
|
||||
this.client.addToSendQueue(new CPacketPlayerLook(this.rotYaw, this.rotPitch, this.onGround));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2684,7 +2687,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
}
|
||||
else
|
||||
{
|
||||
this.client.addToSendQueue(new CPacketPlayer.C06PacketPlayerPosLook(this.motionX, -99999999.0D, this.motionZ, this.rotYaw, this.rotPitch, this.onGround));
|
||||
this.client.addToSendQueue(new CPacketPlayerPosLook(this.motionX, -99999999.0D, this.motionZ, this.rotYaw, this.rotPitch, this.onGround));
|
||||
flag2 = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ import common.model.ParticleType;
|
|||
import common.nbt.NBTTagCompound;
|
||||
import common.nbt.NBTTagList;
|
||||
import common.network.IPlayer;
|
||||
import common.packet.S1BPacketEntityAttach;
|
||||
import common.packet.SPacketEntityAttach;
|
||||
import common.packet.SPacketAnimation;
|
||||
import common.packet.SPacketCollectItem;
|
||||
import common.pathfinding.PathNavigate;
|
||||
|
@ -3094,7 +3094,7 @@ public abstract class EntityLiving extends Entity
|
|||
}
|
||||
|
||||
if(!this.worldObj.client && pkt && this.worldObj instanceof AWorldServer) {
|
||||
((AWorldServer)this.worldObj).sendToAllTrackingEntity(this, new S1BPacketEntityAttach(1, this, (Entity)null));
|
||||
((AWorldServer)this.worldObj).sendToAllTrackingEntity(this, new SPacketEntityAttach(1, this, (Entity)null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3116,7 +3116,7 @@ public abstract class EntityLiving extends Entity
|
|||
this.leashedTo = entity;
|
||||
|
||||
if(!this.worldObj.client && pkt && this.worldObj instanceof AWorldServer) {
|
||||
((AWorldServer)this.worldObj).sendToAllTrackingEntity(this, new S1BPacketEntityAttach(1, this, this.leashedTo));
|
||||
((AWorldServer)this.worldObj).sendToAllTrackingEntity(this, new SPacketEntityAttach(1, this, this.leashedTo));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -231,14 +231,6 @@ public class Item
|
|||
return this.display;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this function returns true (or the item is damageable), the ItemStack's NBT tag will be sent to the client.
|
||||
*/
|
||||
public boolean getShareTag()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public Item getContainerItem()
|
||||
{
|
||||
return this.containerItem;
|
||||
|
|
47
common/src/common/network/CompressionDecoder.java
Executable file
47
common/src/common/network/CompressionDecoder.java
Executable file
|
@ -0,0 +1,47 @@
|
|||
package common.network;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
|
||||
public class CompressionDecoder extends ByteToMessageDecoder {
|
||||
private final Inflater inflater;
|
||||
private int treshold;
|
||||
|
||||
public CompressionDecoder(int treshold) {
|
||||
this.treshold = treshold;
|
||||
this.inflater = new Inflater();
|
||||
}
|
||||
|
||||
protected void decode(ChannelHandlerContext context, ByteBuf buffer, List<Object> output) throws DataFormatException, Exception {
|
||||
if(buffer.readableBytes() == 0)
|
||||
return;
|
||||
PacketBuffer pbuf = new PacketBuffer(buffer);
|
||||
int len = pbuf.readVarInt();
|
||||
if(len == 0) {
|
||||
output.add(pbuf.readBytes(pbuf.readableBytes()));
|
||||
return;
|
||||
}
|
||||
if(len < this.treshold)
|
||||
throw new DecoderException("Badly compressed packet - size of " + len + " is below server threshold of " + this.treshold);
|
||||
if(len > 2097152)
|
||||
throw new DecoderException("Badly compressed packet - size of " + len + " is larger than protocol maximum of " + 2097152);
|
||||
byte[] comp = new byte[pbuf.readableBytes()];
|
||||
pbuf.readBytes(comp);
|
||||
this.inflater.setInput(comp);
|
||||
byte[] data = new byte[len];
|
||||
this.inflater.inflate(data);
|
||||
output.add(Unpooled.wrappedBuffer(data));
|
||||
this.inflater.reset();
|
||||
}
|
||||
|
||||
public void setTreshold(int treshold) {
|
||||
this.treshold = treshold;
|
||||
}
|
||||
}
|
42
common/src/common/network/CompressionEncoder.java
Executable file
42
common/src/common/network/CompressionEncoder.java
Executable file
|
@ -0,0 +1,42 @@
|
|||
package common.network;
|
||||
|
||||
import java.util.zip.Deflater;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
|
||||
public class CompressionEncoder extends MessageToByteEncoder<ByteBuf> {
|
||||
private final byte[] buffer = new byte[8192];
|
||||
private final Deflater deflater;
|
||||
private int treshold;
|
||||
|
||||
public CompressionEncoder(int treshold) {
|
||||
this.treshold = treshold;
|
||||
this.deflater = new Deflater();
|
||||
}
|
||||
|
||||
protected void encode(ChannelHandlerContext context, ByteBuf buffer, ByteBuf output) throws Exception {
|
||||
int len = buffer.readableBytes();
|
||||
PacketBuffer pbuf = new PacketBuffer(output);
|
||||
if(len < this.treshold) {
|
||||
pbuf.writeVarInt(0);
|
||||
pbuf.writeBuffer(buffer);
|
||||
return;
|
||||
}
|
||||
byte[] data = new byte[len];
|
||||
buffer.readBytes(data);
|
||||
pbuf.writeVarInt(data.length);
|
||||
this.deflater.setInput(data, 0, len);
|
||||
this.deflater.finish();
|
||||
while(!this.deflater.finished()) {
|
||||
int size = this.deflater.deflate(this.buffer);
|
||||
pbuf.writeBytes(this.buffer, 0, size);
|
||||
}
|
||||
this.deflater.reset();
|
||||
}
|
||||
|
||||
public void setTreshold(int treshold) {
|
||||
this.treshold = treshold;
|
||||
}
|
||||
}
|
|
@ -7,14 +7,14 @@ import java.util.List;
|
|||
import javax.crypto.Cipher;
|
||||
import javax.crypto.ShortBufferException;
|
||||
|
||||
public class NettyEncryptionDecoder extends MessageToMessageDecoder<ByteBuf> {
|
||||
public class EncryptionDecoder extends MessageToMessageDecoder<ByteBuf> {
|
||||
private final EncryptionCodec codec;
|
||||
|
||||
public NettyEncryptionDecoder(Cipher cipher) {
|
||||
public EncryptionDecoder(Cipher cipher) {
|
||||
this.codec = new EncryptionCodec(cipher);
|
||||
}
|
||||
|
||||
protected void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List<Object> p_decode_3_) throws ShortBufferException, Exception {
|
||||
p_decode_3_.add(this.codec.decipher(p_decode_1_, p_decode_2_));
|
||||
protected void decode(ChannelHandlerContext context, ByteBuf buffer, List<Object> output) throws ShortBufferException, Exception {
|
||||
output.add(this.codec.decipher(context, buffer));
|
||||
}
|
||||
}
|
|
@ -6,14 +6,14 @@ import io.netty.handler.codec.MessageToByteEncoder;
|
|||
import javax.crypto.Cipher;
|
||||
import javax.crypto.ShortBufferException;
|
||||
|
||||
public class NettyEncryptionEncoder extends MessageToByteEncoder<ByteBuf> {
|
||||
public class EncryptionEncoder extends MessageToByteEncoder<ByteBuf> {
|
||||
private final EncryptionCodec codec;
|
||||
|
||||
public NettyEncryptionEncoder(Cipher cipher) {
|
||||
public EncryptionEncoder(Cipher cipher) {
|
||||
this.codec = new EncryptionCodec(cipher);
|
||||
}
|
||||
|
||||
protected void encode(ChannelHandlerContext p_encode_1_, ByteBuf p_encode_2_, ByteBuf p_encode_3_) throws ShortBufferException, Exception {
|
||||
this.codec.cipher(p_encode_2_, p_encode_3_);
|
||||
protected void encode(ChannelHandlerContext context, ByteBuf buffer, ByteBuf output) throws ShortBufferException, Exception {
|
||||
this.codec.cipher(buffer, output);
|
||||
}
|
||||
}
|
|
@ -6,13 +6,8 @@ import common.packet.RPacketLoginSuccess;
|
|||
import common.packet.RPacketRequestEncrypt;
|
||||
|
||||
public interface IClientLoginHandler {
|
||||
|
||||
void handleDisconnect(RPacketDisconnect packetIn);
|
||||
|
||||
void handleLoginSuccess(RPacketLoginSuccess packetIn);
|
||||
|
||||
void handleEnableCompression(RPacketEnableCompression packetIn);
|
||||
|
||||
void handleDisconnect(RPacketDisconnect packet);
|
||||
void handleLoginSuccess(RPacketLoginSuccess packet);
|
||||
void handleEnableCompression(RPacketEnableCompression packet);
|
||||
void handleEncrypt(RPacketRequestEncrypt packet);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,34 +5,34 @@ import common.entity.animal.EntityHorse;
|
|||
import common.inventory.IInventory;
|
||||
import common.inventory.InventoryPlayer;
|
||||
import common.model.ParticleType;
|
||||
import common.packet.S14PacketEntity;
|
||||
import common.packet.S18PacketEntityTeleport;
|
||||
import common.packet.S19PacketEntityHeadLook;
|
||||
import common.packet.S1APacketEntityStatus;
|
||||
import common.packet.S1BPacketEntityAttach;
|
||||
import common.packet.S1CPacketEntityMetadata;
|
||||
import common.packet.S1DPacketEntityEffect;
|
||||
import common.packet.S1EPacketRemoveEntityEffect;
|
||||
import common.packet.S20PacketEntityProperties;
|
||||
import common.packet.S27PacketExplosion;
|
||||
import common.packet.S28PacketEffect;
|
||||
import common.packet.S29PacketSoundEffect;
|
||||
import common.packet.S2APacketParticles;
|
||||
import common.packet.S2BPacketChangeGameState;
|
||||
import common.packet.S2CPacketSpawnGlobalEntity;
|
||||
import common.packet.S2DPacketOpenWindow;
|
||||
import common.packet.S2EPacketCloseWindow;
|
||||
import common.packet.S2FPacketSetSlot;
|
||||
import common.packet.S30PacketWindowItems;
|
||||
import common.packet.S31PacketWindowProperty;
|
||||
import common.packet.S32PacketConfirmTransaction;
|
||||
import common.packet.S33PacketUpdateSign;
|
||||
import common.packet.S35PacketUpdateTileEntity;
|
||||
import common.packet.S36PacketSignEditorOpen;
|
||||
import common.packet.S38PacketPlayerListItem;
|
||||
import common.packet.S39PacketPlayerAbilities;
|
||||
import common.packet.S3APacketTabComplete;
|
||||
import common.packet.S43PacketUpdateEntityNBT;
|
||||
import common.packet.SPacketEntity;
|
||||
import common.packet.SPacketEntityTeleport;
|
||||
import common.packet.SPacketEntityHeadLook;
|
||||
import common.packet.SPacketEntityStatus;
|
||||
import common.packet.SPacketEntityAttach;
|
||||
import common.packet.SPacketEntityMetadata;
|
||||
import common.packet.SPacketEntityEffect;
|
||||
import common.packet.SPacketRemoveEntityEffect;
|
||||
import common.packet.SPacketEntityProperties;
|
||||
import common.packet.SPacketExplosion;
|
||||
import common.packet.SPacketEffect;
|
||||
import common.packet.SPacketSoundEffect;
|
||||
import common.packet.SPacketParticles;
|
||||
import common.packet.SPacketChangeGameState;
|
||||
import common.packet.SPacketSpawnGlobalEntity;
|
||||
import common.packet.SPacketOpenWindow;
|
||||
import common.packet.SPacketCloseWindow;
|
||||
import common.packet.SPacketSetSlot;
|
||||
import common.packet.SPacketWindowItems;
|
||||
import common.packet.SPacketWindowProperty;
|
||||
import common.packet.SPacketConfirmTransaction;
|
||||
import common.packet.SPacketUpdateSign;
|
||||
import common.packet.SPacketUpdateTileEntity;
|
||||
import common.packet.SPacketSignEditorOpen;
|
||||
import common.packet.SPacketPlayerListItem;
|
||||
import common.packet.SPacketPlayerAbilities;
|
||||
import common.packet.SPacketTabComplete;
|
||||
import common.packet.SPacketUpdateEntityNBT;
|
||||
import common.packet.SPacketAnimation;
|
||||
import common.packet.SPacketBiome;
|
||||
import common.packet.SPacketBlockAction;
|
||||
|
@ -76,7 +76,7 @@ public interface IClientPlayer {
|
|||
void playSound(Sound sound);
|
||||
boolean isRenderViewEntity(Entity entity);
|
||||
void updatePlayerMoveState();
|
||||
void emitParticleAtEntity(Entity entityIn, ParticleType particleTypes);
|
||||
void emitParticleAtEntity(Entity entity, ParticleType particleTypes);
|
||||
boolean isJumping();
|
||||
boolean isSprinting();
|
||||
boolean isSneaking();
|
||||
|
@ -86,73 +86,73 @@ public interface IClientPlayer {
|
|||
void setMoveStrafe(float value);
|
||||
void addToSendQueue(Packet packet);
|
||||
|
||||
void handleJoinGame(SPacketJoinGame packetIn);
|
||||
void handleSpawnObject(SPacketSpawnObject packetIn);
|
||||
void handleSpawnGlobalEntity(S2CPacketSpawnGlobalEntity packetIn);
|
||||
void handleEntityVelocity(SPacketEntityVelocity packetIn);
|
||||
void handleEntityMetadata(S1CPacketEntityMetadata packetIn);
|
||||
void handleSpawnPlayer(SPacketSpawnPlayer packetIn);
|
||||
void handleEntityTeleport(S18PacketEntityTeleport packetIn);
|
||||
void handleHeldItemChange(SPacketHeldItemChange packetIn);
|
||||
void handleEntityMovement(S14PacketEntity packetIn);
|
||||
void handleEntityHeadLook(S19PacketEntityHeadLook packetIn);
|
||||
void handleDestroyEntities(SPacketDestroyEntities packetIn);
|
||||
void handlePlayerPosLook(SPacketPlayerPosLook packetIn);
|
||||
void handleMultiBlockChange(SPacketMultiBlockChange packetIn);
|
||||
void handleChunkData(SPacketChunkData packetIn);
|
||||
void handleBiomes(SPacketBiome packetIn);
|
||||
void handleBlockChange(SPacketBlockChange packetIn);
|
||||
void handleDisconnect(SPacketDisconnect packetIn);
|
||||
void handleCollectItem(SPacketCollectItem packetIn);
|
||||
void handleMessage(SPacketMessage packetIn);
|
||||
void handleJoinGame(SPacketJoinGame packet);
|
||||
void handleSpawnObject(SPacketSpawnObject packet);
|
||||
void handleSpawnGlobalEntity(SPacketSpawnGlobalEntity packet);
|
||||
void handleEntityVelocity(SPacketEntityVelocity packet);
|
||||
void handleEntityMetadata(SPacketEntityMetadata packet);
|
||||
void handleSpawnPlayer(SPacketSpawnPlayer packet);
|
||||
void handleEntityTeleport(SPacketEntityTeleport packet);
|
||||
void handleHeldItemChange(SPacketHeldItemChange packet);
|
||||
void handleEntityMovement(SPacketEntity packet);
|
||||
void handleEntityHeadLook(SPacketEntityHeadLook packet);
|
||||
void handleDestroyEntities(SPacketDestroyEntities packet);
|
||||
void handlePlayerPosLook(SPacketPlayerPosLook packet);
|
||||
void handleMultiBlockChange(SPacketMultiBlockChange packet);
|
||||
void handleChunkData(SPacketChunkData packet);
|
||||
void handleBiomes(SPacketBiome packet);
|
||||
void handleBlockChange(SPacketBlockChange packet);
|
||||
void handleDisconnect(SPacketDisconnect packet);
|
||||
void handleCollectItem(SPacketCollectItem packet);
|
||||
void handleMessage(SPacketMessage packet);
|
||||
void handleLoading(SPacketLoading packet);
|
||||
void handleAnimation(SPacketAnimation packetIn);
|
||||
void handleSpawnMob(SPacketSpawnMob packetIn);
|
||||
void handleTimeUpdate(SPacketTimeUpdate packetIn);
|
||||
void handleAnimation(SPacketAnimation packet);
|
||||
void handleSpawnMob(SPacketSpawnMob packet);
|
||||
void handleTimeUpdate(SPacketTimeUpdate packet);
|
||||
void handleServerTick(SPacketServerTick packet);
|
||||
void handleEntityAttach(S1BPacketEntityAttach packetIn);
|
||||
void handleEntityStatus(S1APacketEntityStatus packetIn);
|
||||
void handleUpdateHealth(SPacketUpdateHealth packetIn);
|
||||
void handleSetExperience(SPacketSetExperience packetIn);
|
||||
void handleRespawn(SPacketRespawn packetIn);
|
||||
void handleExplosion(S27PacketExplosion packetIn);
|
||||
void handleOpenWindow(S2DPacketOpenWindow packetIn);
|
||||
void handleSetSlot(S2FPacketSetSlot packetIn);
|
||||
void handleConfirmTransaction(S32PacketConfirmTransaction packetIn);
|
||||
void handleWindowItems(S30PacketWindowItems packetIn);
|
||||
void handleSignEditorOpen(S36PacketSignEditorOpen packetIn);
|
||||
void handleUpdateSign(S33PacketUpdateSign packetIn);
|
||||
void handleUpdateTileEntity(S35PacketUpdateTileEntity packetIn);
|
||||
void handleWindowProperty(S31PacketWindowProperty packetIn);
|
||||
void handleEntityEquipment(SPacketEntityEquipment packetIn);
|
||||
void handleCloseWindow(S2EPacketCloseWindow packetIn);
|
||||
void handleBlockAction(SPacketBlockAction packetIn);
|
||||
void handleBlockBreakAnim(SPacketBlockBreakAnim packetIn);
|
||||
void handleMapChunkBulk(SPacketMapChunkBulk packetIn);
|
||||
void handleChangeGameState(S2BPacketChangeGameState packetIn);
|
||||
void handleEffect(S28PacketEffect packetIn);
|
||||
void handleEntityEffect(S1DPacketEntityEffect packetIn);
|
||||
void handleCamera(SPacketCamera packetIn);
|
||||
void handleRemoveEntityEffect(S1EPacketRemoveEntityEffect packetIn);
|
||||
void handlePlayerListItem(S38PacketPlayerListItem packetIn);
|
||||
void handleEntityAttach(SPacketEntityAttach packet);
|
||||
void handleEntityStatus(SPacketEntityStatus packet);
|
||||
void handleUpdateHealth(SPacketUpdateHealth packet);
|
||||
void handleSetExperience(SPacketSetExperience packet);
|
||||
void handleRespawn(SPacketRespawn packet);
|
||||
void handleExplosion(SPacketExplosion packet);
|
||||
void handleOpenWindow(SPacketOpenWindow packet);
|
||||
void handleSetSlot(SPacketSetSlot packet);
|
||||
void handleConfirmTransaction(SPacketConfirmTransaction packet);
|
||||
void handleWindowItems(SPacketWindowItems packet);
|
||||
void handleSignEditorOpen(SPacketSignEditorOpen packet);
|
||||
void handleUpdateSign(SPacketUpdateSign packet);
|
||||
void handleUpdateTileEntity(SPacketUpdateTileEntity packet);
|
||||
void handleWindowProperty(SPacketWindowProperty packet);
|
||||
void handleEntityEquipment(SPacketEntityEquipment packet);
|
||||
void handleCloseWindow(SPacketCloseWindow packet);
|
||||
void handleBlockAction(SPacketBlockAction packet);
|
||||
void handleBlockBreakAnim(SPacketBlockBreakAnim packet);
|
||||
void handleMapChunkBulk(SPacketMapChunkBulk packet);
|
||||
void handleChangeGameState(SPacketChangeGameState packet);
|
||||
void handleEffect(SPacketEffect packet);
|
||||
void handleEntityEffect(SPacketEntityEffect packet);
|
||||
void handleCamera(SPacketCamera packet);
|
||||
void handleRemoveEntityEffect(SPacketRemoveEntityEffect packet);
|
||||
void handlePlayerListItem(SPacketPlayerListItem packet);
|
||||
void handleCharacterList(SPacketCharacterList packet);
|
||||
void handleKeepAlive(SPacketKeepAlive packetIn);
|
||||
void handlePlayerAbilities(S39PacketPlayerAbilities packetIn);
|
||||
void handleTabComplete(S3APacketTabComplete packetIn);
|
||||
void handleSoundEffect(S29PacketSoundEffect packetIn);
|
||||
void handleEntityNBT(S43PacketUpdateEntityNBT packetIn);
|
||||
void handleParticles(S2APacketParticles packetIn);
|
||||
void handleEntityProperties(S20PacketEntityProperties packetIn);
|
||||
void handleSkin(SPacketSkin packetIn);
|
||||
void handleTrades(SPacketTrades packetIn);
|
||||
void handleWorld(SPacketWorld packetIn);
|
||||
void handleDimName(SPacketDimensionName packetIn);
|
||||
void handleKeepAlive(SPacketKeepAlive packet);
|
||||
void handlePlayerAbilities(SPacketPlayerAbilities packet);
|
||||
void handleTabComplete(SPacketTabComplete packet);
|
||||
void handleSoundEffect(SPacketSoundEffect packet);
|
||||
void handleEntityNBT(SPacketUpdateEntityNBT packet);
|
||||
void handleParticles(SPacketParticles packet);
|
||||
void handleEntityProperties(SPacketEntityProperties packet);
|
||||
void handleSkin(SPacketSkin packet);
|
||||
void handleTrades(SPacketTrades packet);
|
||||
void handleWorld(SPacketWorld packet);
|
||||
void handleDimName(SPacketDimensionName packet);
|
||||
void handleForm(SPacketDisplayForm packet);
|
||||
|
||||
void displayGUIChest(IInventory chestInventory, InventoryPlayer inventory);
|
||||
void displayGui(IInteractionObject guiOwner, InventoryPlayer inventory, World worldObj);
|
||||
void displayGui(IInteractionObject guiOwner, InventoryPlayer inventory, World world);
|
||||
void displayGuiHorse(EntityHorse horse, InventoryPlayer inventory, IInventory horseInventory);
|
||||
void displayGuiMerchant(String title, InventoryPlayer inventory, World worldObj);
|
||||
void displayGuiMerchant(String title, InventoryPlayer inventory, World world);
|
||||
void displayGuiSign(BlockPos pos, String[] text);
|
||||
void closeGui();
|
||||
}
|
|
@ -3,7 +3,5 @@ package common.network;
|
|||
import common.packet.HPacketHandshake;
|
||||
|
||||
public interface IHandshakeHandler {
|
||||
|
||||
void processHandshake(HPacketHandshake packetIn);
|
||||
|
||||
}
|
||||
void processHandshake(HPacketHandshake packet);
|
||||
}
|
||||
|
|
|
@ -5,11 +5,7 @@ import common.packet.LPacketPasswordResponse;
|
|||
import common.packet.LPacketStartEncrypt;
|
||||
|
||||
public interface ILoginHandler {
|
||||
|
||||
void processPasswordResponse(LPacketPasswordResponse packetIn);
|
||||
|
||||
void processPasswordResponse(LPacketPasswordResponse packet);
|
||||
void processEncryption(LPacketStartEncrypt packet);
|
||||
|
||||
void processLogin(LPacketLogin packet);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import common.inventory.Container;
|
|||
import common.inventory.IInventory;
|
||||
import common.item.ItemStack;
|
||||
import common.packet.CPacketAction;
|
||||
import common.packet.CPacketBook;
|
||||
import common.packet.CPacketBreak;
|
||||
import common.packet.CPacketCheat;
|
||||
import common.packet.CPacketClick;
|
||||
|
@ -63,115 +62,61 @@ public interface IPlayer {
|
|||
}
|
||||
|
||||
void onEntityDeath();
|
||||
|
||||
boolean isInEditor();
|
||||
|
||||
EntityNPC getPresentEntity();
|
||||
|
||||
String getUser();
|
||||
|
||||
int getLatency();
|
||||
|
||||
boolean isAdmin();
|
||||
|
||||
void addToPlayerScore(EntityLiving entity);
|
||||
|
||||
void displayTradeGui(EntityNPC npc);
|
||||
|
||||
void displayTradeGui(EntityNPC entity);
|
||||
void setPlayerHealthUpdated();
|
||||
|
||||
void removeEntity(Entity p_152339_1_);
|
||||
|
||||
void removeEntity(Entity entity);
|
||||
void sendPlayerAbilities();
|
||||
|
||||
void addFeed(String msg);
|
||||
|
||||
void addHotbar(String msg);
|
||||
|
||||
void addHotbar(String format, Object... args);
|
||||
|
||||
void sendThrowMessage(ItemStack stack);
|
||||
|
||||
void resetLastExperience();
|
||||
|
||||
void travelToDimension(int dimensionId, BlockPos pos, float yaw, float pitch, PortalType portal);
|
||||
|
||||
void travelToDimension(int dimension, BlockPos pos, float yaw, float pitch, PortalType portal);
|
||||
void teleport(double x, double y, double z, float yaw, float pitch, int dimension);
|
||||
|
||||
void onItemPickup(Entity entity, int amount);
|
||||
|
||||
void mountEntity(Entity entityIn);
|
||||
|
||||
void mountEntity(Entity entity);
|
||||
void openEditSign(TileEntitySign signTile);
|
||||
|
||||
void displayGui(IInteractionObject guiOwner);
|
||||
|
||||
void displayGUIChest(IInventory chestInventory);
|
||||
|
||||
void displayGUIHorse(EntityHorse horse, IInventory horseInventory);
|
||||
|
||||
void closeScreen();
|
||||
|
||||
void onItemUseFinish();
|
||||
|
||||
void onNewEffect(PotionEffect id);
|
||||
|
||||
void onChangedEffect(PotionEffect id, boolean added);
|
||||
|
||||
void onFinishedEffect(PotionEffect effect);
|
||||
|
||||
void setPositionAndUpdate(double x, double y, double z);
|
||||
|
||||
void onCriticalHit(Entity entityHit);
|
||||
|
||||
void onEnchantmentCritical(Entity entityHit);
|
||||
|
||||
void onCriticalHit(Entity entity);
|
||||
void onEnchantmentCritical(Entity entity);
|
||||
void updateEffectMeta();
|
||||
|
||||
void playSound(SoundEvent name, float volume);
|
||||
|
||||
void sendContainerToPlayer(Container container);
|
||||
|
||||
void updateEntity();
|
||||
|
||||
void setSelection(boolean primary, BlockPos pos);
|
||||
|
||||
void setSelectMode();
|
||||
|
||||
void sendPacket(Packet packet);
|
||||
|
||||
void setPlayerLocation(double x, double y, double z, float yaw, float pitch);
|
||||
|
||||
void processKeepAlive(CPacketKeepAlive packetIn);
|
||||
|
||||
void processMessage(CPacketMessage packetIn);
|
||||
|
||||
void processComplete(CPacketComplete packetIn);
|
||||
|
||||
void processPlayer(CPacketPlayer packetIn);
|
||||
|
||||
void processBreak(CPacketBreak packetIn);
|
||||
|
||||
void processPlace(CPacketPlace packetIn);
|
||||
|
||||
void processAction(CPacketAction packetIn);
|
||||
|
||||
void processInput(CPacketInput packetIn);
|
||||
|
||||
void processClick(CPacketClick packetIn);
|
||||
|
||||
void processCheat(CPacketCheat packetIn);
|
||||
|
||||
void processSign(CPacketSign packetIn);
|
||||
|
||||
void processSkin(CPacketSkin packetIn);
|
||||
|
||||
void processBook(CPacketBook packetIn);
|
||||
|
||||
void processForm(CPacketForm packet);
|
||||
|
||||
List<ChunkPos> getLoadedChunkList();
|
||||
double getManagedX();
|
||||
double getManagedZ();
|
||||
void setManagedPos(double x, double z);
|
||||
}
|
||||
|
||||
void processKeepAlive(CPacketKeepAlive packet);
|
||||
void processMessage(CPacketMessage packet);
|
||||
void processComplete(CPacketComplete packet);
|
||||
void processPlayer(CPacketPlayer packet);
|
||||
void processBreak(CPacketBreak packet);
|
||||
void processPlace(CPacketPlace packet);
|
||||
void processAction(CPacketAction packet);
|
||||
void processInput(CPacketInput packet);
|
||||
void processClick(CPacketClick packet);
|
||||
void processCheat(CPacketCheat packet);
|
||||
void processSign(CPacketSign packet);
|
||||
void processSkin(CPacketSkin packet);
|
||||
void processForm(CPacketForm packet);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,7 @@ package common.network;
|
|||
|
||||
import common.future.ListenableFuture;
|
||||
|
||||
public interface IThreadListener
|
||||
{
|
||||
public interface IThreadListener {
|
||||
ListenableFuture<Object> schedule(Runnable run);
|
||||
boolean isMainThread();
|
||||
default void log(String prefixed, String line) {
|
||||
|
|
|
@ -27,34 +27,32 @@ public class NetConnection extends SimpleChannelInboundHandler<Packet>
|
|||
{
|
||||
private static final Pattern IP_REPLACER = Pattern.compile("([0-9]*)\\.([0-9]*)\\.[0-9]*\\.[0-9]*");
|
||||
public static final AttributeKey<PacketRegistry> ATTR_STATE = AttributeKey.<PacketRegistry>valueOf("protocol");
|
||||
private final Queue<NetConnection.InboundHandlerTuplePacketListener> outboundPacketsQueue = new ConcurrentLinkedQueue<InboundHandlerTuplePacketListener>();
|
||||
private final ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock();
|
||||
|
||||
private final Queue<NetConnection.InboundHandlerTuplePacketListener> queue = new ConcurrentLinkedQueue<InboundHandlerTuplePacketListener>();
|
||||
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
|
||||
private Channel channel;
|
||||
private SocketAddress socketAddress;
|
||||
private NetHandler packetListener;
|
||||
private String terminationReason;
|
||||
private SocketAddress address;
|
||||
private NetHandler handler;
|
||||
private String exitReason;
|
||||
private boolean disconnected;
|
||||
|
||||
public void channelActive(ChannelHandlerContext p_channelActive_1_) throws Exception
|
||||
public void channelActive(ChannelHandlerContext context) throws Exception
|
||||
{
|
||||
super.channelActive(p_channelActive_1_);
|
||||
this.channel = p_channelActive_1_.channel();
|
||||
this.socketAddress = this.channel.remoteAddress();
|
||||
super.channelActive(context);
|
||||
this.channel = context.channel();
|
||||
this.address = this.channel.remoteAddress();
|
||||
|
||||
try
|
||||
{
|
||||
this.setConnectionState(PacketRegistry.HANDSHAKE);
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
catch (Throwable t)
|
||||
{
|
||||
Log.JNI.error(throwable, "Fehler beim Aufbauen der Verbindung für Handshake");
|
||||
Log.JNI.error(t, "Fehler beim Aufbauen der Verbindung für Handshake");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new connection state and registers which packets this channel may send and receive
|
||||
*/
|
||||
public void setConnectionState(PacketRegistry newState)
|
||||
{
|
||||
this.channel.attr(ATTR_STATE).set(newState);
|
||||
|
@ -62,36 +60,36 @@ public class NetConnection extends SimpleChannelInboundHandler<Packet>
|
|||
// Log.debug("Automatisches Lesen eingeschaltet");
|
||||
}
|
||||
|
||||
public void channelInactive(ChannelHandlerContext p_channelInactive_1_) throws Exception
|
||||
public void channelInactive(ChannelHandlerContext context) throws Exception
|
||||
{
|
||||
this.closeChannel("Ende der Datenübertragung");
|
||||
}
|
||||
|
||||
public void exceptionCaught(ChannelHandlerContext p_exceptionCaught_1_, Throwable p_exceptionCaught_2_) throws Exception
|
||||
public void exceptionCaught(ChannelHandlerContext context, Throwable throwable) throws Exception
|
||||
{
|
||||
String comp;
|
||||
|
||||
if (p_exceptionCaught_2_ instanceof TimeoutException)
|
||||
if (throwable instanceof TimeoutException)
|
||||
{
|
||||
comp = "Zeitüberschreitung";
|
||||
}
|
||||
else
|
||||
{
|
||||
comp = "Interner Fehler: " + p_exceptionCaught_2_;
|
||||
if(!(p_exceptionCaught_2_ instanceof ClosedChannelException))
|
||||
Log.SYSTEM.error(p_exceptionCaught_2_, "Fehler in der Verbindung mit %s", this.getCutAddress());
|
||||
comp = "Interner Fehler: " + throwable;
|
||||
if(!(throwable instanceof ClosedChannelException))
|
||||
Log.SYSTEM.error(throwable, "Fehler in der Verbindung mit %s", this.getCutAddress());
|
||||
}
|
||||
|
||||
this.closeChannel(comp);
|
||||
}
|
||||
|
||||
protected void channelRead0(ChannelHandlerContext p_channelRead0_1_, Packet p_channelRead0_2_) throws Exception
|
||||
protected void channelRead0(ChannelHandlerContext context, Packet packet) throws Exception
|
||||
{
|
||||
if (this.channel.isOpen())
|
||||
{
|
||||
try
|
||||
{
|
||||
p_channelRead0_2_.processPacket(this.packetListener);
|
||||
packet.processPacket(this.handler);
|
||||
}
|
||||
catch (ThreadQuickExitException e)
|
||||
{
|
||||
|
@ -100,17 +98,13 @@ public class NetConnection extends SimpleChannelInboundHandler<Packet>
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the NetHandler for this NetworkManager, no checks are made if this handler is suitable for the particular
|
||||
* connection state (protocol)
|
||||
*/
|
||||
public void setNetHandler(NetHandler handler)
|
||||
{
|
||||
if (handler == null) {
|
||||
throw new NullPointerException("Handler ist Null");
|
||||
}
|
||||
// Log.debug("Setze Handler von " + this + " auf " + handler);
|
||||
this.packetListener = handler;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public void sendPacket(Packet packetIn)
|
||||
|
@ -122,15 +116,15 @@ public class NetConnection extends SimpleChannelInboundHandler<Packet>
|
|||
}
|
||||
else
|
||||
{
|
||||
this.readWriteLock.writeLock().lock();
|
||||
this.lock.writeLock().lock();
|
||||
|
||||
try
|
||||
{
|
||||
this.outboundPacketsQueue.add(new NetConnection.InboundHandlerTuplePacketListener(packetIn, null));
|
||||
this.queue.add(new NetConnection.InboundHandlerTuplePacketListener(packetIn, null));
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.readWriteLock.writeLock().unlock();
|
||||
this.lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,29 +138,25 @@ public class NetConnection extends SimpleChannelInboundHandler<Packet>
|
|||
}
|
||||
else
|
||||
{
|
||||
this.readWriteLock.writeLock().lock();
|
||||
this.lock.writeLock().lock();
|
||||
|
||||
try
|
||||
{
|
||||
this.outboundPacketsQueue.add(new NetConnection.InboundHandlerTuplePacketListener(packetIn, listener));
|
||||
this.queue.add(new NetConnection.InboundHandlerTuplePacketListener(packetIn, listener));
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.readWriteLock.writeLock().unlock();
|
||||
this.lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Will commit the packet to the channel. If the current thread 'owns' the channel it will write and flush the
|
||||
* packet, otherwise it will add a task for the channel eventloop thread to do that.
|
||||
*/
|
||||
private void dispatchPacket(final Packet inPacket, final GenericFutureListener <? extends Future <? super Void >> [] futureListeners)
|
||||
{
|
||||
final PacketRegistry enumconnectionstate = PacketRegistry.getType(inPacket);
|
||||
final PacketRegistry enumconnectionstate1 = (PacketRegistry)this.channel.attr(ATTR_STATE).get();
|
||||
final PacketRegistry state = PacketRegistry.getType(inPacket);
|
||||
final PacketRegistry current = this.channel.attr(ATTR_STATE).get();
|
||||
|
||||
if (enumconnectionstate1 != enumconnectionstate)
|
||||
if (current != state)
|
||||
{
|
||||
// Log.debug("Automatisches Lesen ausgeschaltet");
|
||||
this.channel.config().setAutoRead(false);
|
||||
|
@ -174,9 +164,9 @@ public class NetConnection extends SimpleChannelInboundHandler<Packet>
|
|||
|
||||
if (this.channel.eventLoop().inEventLoop())
|
||||
{
|
||||
if (enumconnectionstate != enumconnectionstate1)
|
||||
if (state != current)
|
||||
{
|
||||
this.setConnectionState(enumconnectionstate);
|
||||
this.setConnectionState(state);
|
||||
}
|
||||
|
||||
ChannelFuture channelfuture = this.channel.writeAndFlush(inPacket);
|
||||
|
@ -194,9 +184,9 @@ public class NetConnection extends SimpleChannelInboundHandler<Packet>
|
|||
{
|
||||
public void run()
|
||||
{
|
||||
if (enumconnectionstate != enumconnectionstate1)
|
||||
if (state != current)
|
||||
{
|
||||
NetConnection.this.setConnectionState(enumconnectionstate);
|
||||
NetConnection.this.setConnectionState(state);
|
||||
}
|
||||
|
||||
ChannelFuture channelfuture1 = NetConnection.this.channel.writeAndFlush(inPacket);
|
||||
|
@ -212,68 +202,46 @@ public class NetConnection extends SimpleChannelInboundHandler<Packet>
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Will iterate through the outboundPacketQueue and dispatch all Packets
|
||||
*/
|
||||
private void flushOutboundQueue()
|
||||
{
|
||||
if (this.channel != null && this.channel.isOpen())
|
||||
{
|
||||
this.readWriteLock.readLock().lock();
|
||||
this.lock.readLock().lock();
|
||||
|
||||
try
|
||||
{
|
||||
while (!this.outboundPacketsQueue.isEmpty())
|
||||
while (!this.queue.isEmpty())
|
||||
{
|
||||
NetConnection.InboundHandlerTuplePacketListener networkmanager$inboundhandlertuplepacketlistener = (NetConnection.InboundHandlerTuplePacketListener)this.outboundPacketsQueue.poll();
|
||||
if(networkmanager$inboundhandlertuplepacketlistener != null) { // NPE Fix
|
||||
this.dispatchPacket(networkmanager$inboundhandlertuplepacketlistener.packet, networkmanager$inboundhandlertuplepacketlistener.futureListeners);
|
||||
}
|
||||
NetConnection.InboundHandlerTuplePacketListener entry = this.queue.poll();
|
||||
if(entry != null) // NPE Fix
|
||||
this.dispatchPacket(entry.packet, entry.listeners);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.readWriteLock.readLock().unlock();
|
||||
this.lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks timeouts and processes all packets received
|
||||
*/
|
||||
public void processReceivedPackets()
|
||||
{
|
||||
this.flushOutboundQueue();
|
||||
this.packetListener.update();
|
||||
// if (this.packetListener instanceof ITickable)
|
||||
// {
|
||||
// ((ITickable)this.packetListener).update();
|
||||
// }
|
||||
this.handler.update();
|
||||
if(this.channel != null)
|
||||
this.channel.flush();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Returns the socket address of the remote side. Server-only.
|
||||
// */
|
||||
// public SocketAddress getRemoteAddress()
|
||||
// {
|
||||
// return this.socketAddress;
|
||||
// }
|
||||
|
||||
public String getCutAddress() {
|
||||
return this.socketAddress == null ? "?.?.*.*" : IP_REPLACER.matcher(this.socketAddress.toString()).replaceAll("$1.$2.*.*");
|
||||
return this.address == null ? "?.?.*.*" : IP_REPLACER.matcher(this.address.toString()).replaceAll("$1.$2.*.*");
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the channel, the parameter can be used for an exit message (not certain how it gets sent)
|
||||
*/
|
||||
public void closeChannel(String message)
|
||||
{
|
||||
if (this.channel.isOpen())
|
||||
{
|
||||
this.channel.close().awaitUninterruptibly();
|
||||
this.terminationReason = message;
|
||||
this.exitReason = message;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,17 +255,6 @@ public class NetConnection extends SimpleChannelInboundHandler<Packet>
|
|||
return this.channel == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current handler for processing packets
|
||||
*/
|
||||
public NetHandler getNetHandler()
|
||||
{
|
||||
return this.packetListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches the channel to manual reading modus
|
||||
*/
|
||||
public void disableAutoRead()
|
||||
{
|
||||
this.channel.config().setAutoRead(false);
|
||||
|
@ -307,32 +264,32 @@ public class NetConnection extends SimpleChannelInboundHandler<Packet>
|
|||
{
|
||||
if (treshold >= 0)
|
||||
{
|
||||
if (this.channel.pipeline().get("decompress") instanceof NettyCompressionDecoder)
|
||||
if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder)
|
||||
{
|
||||
((NettyCompressionDecoder)this.channel.pipeline().get("decompress")).setCompressionTreshold(treshold);
|
||||
((CompressionDecoder)this.channel.pipeline().get("decompress")).setTreshold(treshold);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.channel.pipeline().addBefore("decoder", "decompress", new NettyCompressionDecoder(treshold));
|
||||
this.channel.pipeline().addBefore("decoder", "decompress", new CompressionDecoder(treshold));
|
||||
}
|
||||
|
||||
if (this.channel.pipeline().get("compress") instanceof NettyCompressionEncoder)
|
||||
if (this.channel.pipeline().get("compress") instanceof CompressionEncoder)
|
||||
{
|
||||
((NettyCompressionEncoder)this.channel.pipeline().get("compress")).setCompressionTreshold(treshold);
|
||||
((CompressionEncoder)this.channel.pipeline().get("compress")).setTreshold(treshold);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.channel.pipeline().addBefore("encoder", "compress", new NettyCompressionEncoder(treshold));
|
||||
this.channel.pipeline().addBefore("encoder", "compress", new CompressionEncoder(treshold));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.channel.pipeline().get("decompress") instanceof NettyCompressionDecoder)
|
||||
if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder)
|
||||
{
|
||||
this.channel.pipeline().remove("decompress");
|
||||
}
|
||||
|
||||
if (this.channel.pipeline().get("compress") instanceof NettyCompressionEncoder)
|
||||
if (this.channel.pipeline().get("compress") instanceof CompressionEncoder)
|
||||
{
|
||||
this.channel.pipeline().remove("compress");
|
||||
}
|
||||
|
@ -346,15 +303,8 @@ public class NetConnection extends SimpleChannelInboundHandler<Packet>
|
|||
if (!this.disconnected)
|
||||
{
|
||||
this.disconnected = true;
|
||||
|
||||
if (this.terminationReason != null)
|
||||
{
|
||||
this.getNetHandler().onDisconnect(this.terminationReason);
|
||||
}
|
||||
else if (this.getNetHandler() != null)
|
||||
{
|
||||
this.getNetHandler().onDisconnect("Verbindung getrennt");
|
||||
}
|
||||
if(this.handler != null)
|
||||
this.handler.onDisconnect(this.exitReason != null ? this.exitReason : "Verbindung getrennt");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -364,19 +314,19 @@ public class NetConnection extends SimpleChannelInboundHandler<Packet>
|
|||
}
|
||||
|
||||
public void startEncryption(SecretKey key) {
|
||||
this.channel.pipeline().addBefore("splitter", "decrypt", new NettyEncryptionDecoder(EncryptUtil.createCipher(Cipher.DECRYPT_MODE, key)));
|
||||
this.channel.pipeline().addBefore("prepender", "encrypt", new NettyEncryptionEncoder(EncryptUtil.createCipher(Cipher.ENCRYPT_MODE, key)));
|
||||
this.channel.pipeline().addBefore("splitter", "decrypt", new EncryptionDecoder(EncryptUtil.createCipher(Cipher.DECRYPT_MODE, key)));
|
||||
this.channel.pipeline().addBefore("prepender", "encrypt", new EncryptionEncoder(EncryptUtil.createCipher(Cipher.ENCRYPT_MODE, key)));
|
||||
}
|
||||
|
||||
static class InboundHandlerTuplePacketListener
|
||||
private static class InboundHandlerTuplePacketListener
|
||||
{
|
||||
private final Packet packet;
|
||||
private final GenericFutureListener <? extends Future <? super Void >> [] futureListeners;
|
||||
private final GenericFutureListener <? extends Future <? super Void >> [] listeners;
|
||||
|
||||
public InboundHandlerTuplePacketListener(Packet inPacket, GenericFutureListener <? extends Future <? super Void >> inFutureListener)
|
||||
public InboundHandlerTuplePacketListener(Packet packet, GenericFutureListener <? extends Future <? super Void >> listener)
|
||||
{
|
||||
this.packet = inPacket;
|
||||
this.futureListeners = inFutureListener == null ? null : new GenericFutureListener[] {inFutureListener};
|
||||
this.packet = packet;
|
||||
this.listeners = listener == null ? null : new GenericFutureListener[] {listener};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,7 @@ public abstract class NetHandler {
|
|||
public void update() {
|
||||
}
|
||||
|
||||
public static <T> void checkThread(final Packet<T> packet, final T handler, IThreadListener listener)
|
||||
throws ThreadQuickExitException {
|
||||
public static <T> void checkThread(final Packet<T> packet, final T handler, IThreadListener listener) throws ThreadQuickExitException {
|
||||
if(!listener.isMainThread()) {
|
||||
listener.schedule(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -31,11 +30,9 @@ public abstract class NetHandler {
|
|||
}
|
||||
}
|
||||
|
||||
public static <T> void checkThread(final Packet<T> packet, final T handler, IThreadListener listener, Object check)
|
||||
throws ThreadQuickExitException {
|
||||
if(check == null && listener.isMainThread()) {
|
||||
public static <T> void checkThread(final Packet<T> packet, final T handler, IThreadListener listener, Object check) throws ThreadQuickExitException {
|
||||
if(check == null && listener.isMainThread())
|
||||
throw EXIT;
|
||||
}
|
||||
checkThread(packet, handler, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
package common.network;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
|
||||
public class NettyCompressionDecoder extends ByteToMessageDecoder
|
||||
{
|
||||
private final Inflater inflater;
|
||||
private int treshold;
|
||||
|
||||
public NettyCompressionDecoder(int treshold)
|
||||
{
|
||||
this.treshold = treshold;
|
||||
this.inflater = new Inflater();
|
||||
}
|
||||
|
||||
protected void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List<Object> p_decode_3_) throws DataFormatException, Exception
|
||||
{
|
||||
if (p_decode_2_.readableBytes() != 0)
|
||||
{
|
||||
PacketBuffer packetbuffer = new PacketBuffer(p_decode_2_);
|
||||
int i = packetbuffer.readVarIntFromBuffer();
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
p_decode_3_.add(packetbuffer.readBytes(packetbuffer.readableBytes()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i < this.treshold)
|
||||
{
|
||||
throw new DecoderException("Badly compressed packet - size of " + i + " is below server threshold of " + this.treshold);
|
||||
}
|
||||
|
||||
if (i > 2097152)
|
||||
{
|
||||
throw new DecoderException("Badly compressed packet - size of " + i + " is larger than protocol maximum of " + 2097152);
|
||||
}
|
||||
|
||||
byte[] abyte = new byte[packetbuffer.readableBytes()];
|
||||
packetbuffer.readBytes(abyte);
|
||||
this.inflater.setInput(abyte);
|
||||
byte[] abyte1 = new byte[i];
|
||||
this.inflater.inflate(abyte1);
|
||||
p_decode_3_.add(Unpooled.wrappedBuffer(abyte1));
|
||||
this.inflater.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCompressionTreshold(int treshold)
|
||||
{
|
||||
this.treshold = treshold;
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
package common.network;
|
||||
|
||||
import java.util.zip.Deflater;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
|
||||
public class NettyCompressionEncoder extends MessageToByteEncoder<ByteBuf>
|
||||
{
|
||||
private final byte[] buffer = new byte[8192];
|
||||
private final Deflater deflater;
|
||||
private int treshold;
|
||||
|
||||
public NettyCompressionEncoder(int treshold)
|
||||
{
|
||||
this.treshold = treshold;
|
||||
this.deflater = new Deflater();
|
||||
}
|
||||
|
||||
protected void encode(ChannelHandlerContext p_encode_1_, ByteBuf p_encode_2_, ByteBuf p_encode_3_) throws Exception
|
||||
{
|
||||
int i = p_encode_2_.readableBytes();
|
||||
PacketBuffer packetbuffer = new PacketBuffer(p_encode_3_);
|
||||
|
||||
if (i < this.treshold)
|
||||
{
|
||||
packetbuffer.writeVarIntToBuffer(0);
|
||||
packetbuffer.writeBytes(p_encode_2_);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] abyte = new byte[i];
|
||||
p_encode_2_.readBytes(abyte);
|
||||
packetbuffer.writeVarIntToBuffer(abyte.length);
|
||||
this.deflater.setInput(abyte, 0, i);
|
||||
this.deflater.finish();
|
||||
|
||||
while (!this.deflater.finished())
|
||||
{
|
||||
int j = this.deflater.deflate(this.buffer);
|
||||
packetbuffer.writeBytes((byte[])this.buffer, 0, j);
|
||||
}
|
||||
|
||||
this.deflater.reset();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCompressionTreshold(int treshold)
|
||||
{
|
||||
this.treshold = treshold;
|
||||
}
|
||||
}
|
|
@ -2,8 +2,7 @@ package common.network;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface Packet<T>
|
||||
{
|
||||
public interface Packet<T> {
|
||||
void readPacketData(PacketBuffer buf) throws IOException;
|
||||
void writePacketData(PacketBuffer buf) throws IOException;
|
||||
void processPacket(T handler);
|
||||
|
|
|
@ -15,449 +15,250 @@ import io.netty.buffer.ByteBufOutputStream;
|
|||
import io.netty.handler.codec.DecoderException;
|
||||
import io.netty.handler.codec.EncoderException;
|
||||
|
||||
public class PacketBuffer
|
||||
{
|
||||
public class PacketBuffer {
|
||||
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
|
||||
private final ByteBuf buf;
|
||||
|
||||
public PacketBuffer(ByteBuf wrapped) {
|
||||
this.buf = wrapped;
|
||||
}
|
||||
|
||||
public static int getVarIntSize(int input) {
|
||||
for(int i = 1; i < 5; ++i) {
|
||||
if((input & -1 << i * 7) == 0)
|
||||
return i;
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
|
||||
public void writeByteArray(byte[] data) {
|
||||
this.writeVarInt(data.length);
|
||||
this.writeBytes(data);
|
||||
}
|
||||
|
||||
public byte[] readByteArray() {
|
||||
byte[] data = new byte[this.readVarInt()];
|
||||
this.readBytes(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
public void writeBlockPos(BlockPos pos) {
|
||||
this.writeInt(pos.getX());
|
||||
this.writeInt(pos.getY());
|
||||
this.writeInt(pos.getZ());
|
||||
}
|
||||
|
||||
public BlockPos readBlockPos() {
|
||||
return new BlockPos(this.readInt(), this.readInt(), this.readInt());
|
||||
}
|
||||
|
||||
public void writeEnumValue(Enum<?> value) {
|
||||
this.writeVarInt(value.ordinal());
|
||||
}
|
||||
|
||||
public <T extends Enum<T>> T readEnumValue(Class<T> clazz) {
|
||||
return (T)((Enum[])clazz.getEnumConstants())[this.readVarInt()];
|
||||
}
|
||||
|
||||
public void writeEnumOrNull(Enum<?> value) {
|
||||
this.writeVarInt(value == null ? -1 : value.ordinal());
|
||||
}
|
||||
|
||||
public <T extends Enum<T>> T readEnumOrNull(Class<T> clazz) {
|
||||
int n = this.readVarInt();
|
||||
return n < 0 ? null : (T)((Enum[])clazz.getEnumConstants())[n];
|
||||
}
|
||||
|
||||
public void writeVarInt(int value) {
|
||||
while((value & -128) != 0) {
|
||||
this.writeByte(value & 127 | 128);
|
||||
value >>>= 7;
|
||||
}
|
||||
this.writeByte(value);
|
||||
}
|
||||
|
||||
public int readVarInt() {
|
||||
int v = 0;
|
||||
int c = 0;
|
||||
while(true) {
|
||||
byte b = this.readByte();
|
||||
v |= (b & 127) << c++ * 7;
|
||||
if(c > 5)
|
||||
throw new RuntimeException("VarInt too big");
|
||||
if((b & 128) != 128)
|
||||
break;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
private final ByteBuf buf;
|
||||
public void writeTag(NBTTagCompound tag) {
|
||||
if(tag == null) {
|
||||
this.writeByte(0);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
NBTLoader.write(tag, new ByteBufOutputStream(this.buf));
|
||||
}
|
||||
catch(IOException e) {
|
||||
throw new EncoderException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound readTag() throws IOException {
|
||||
int i = this.buf.readerIndex();
|
||||
byte b = this.readByte();
|
||||
if(b == 0)
|
||||
return null;
|
||||
this.buf.readerIndex(i);
|
||||
return NBTLoader.read(new ByteBufInputStream(this.buf), new NBTSizeTracker(2097152L));
|
||||
}
|
||||
|
||||
public void writeItemStack(ItemStack stack) {
|
||||
if(stack == null) {
|
||||
this.writeShort(-1);
|
||||
return;
|
||||
}
|
||||
this.writeShort(ItemRegistry.getIdFromItem(stack.getItem()));
|
||||
this.writeVarInt(stack.stackSize);
|
||||
this.writeShort(stack.getMetadata());
|
||||
this.writeTag(stack.getTagCompound());
|
||||
}
|
||||
|
||||
public ItemStack readItemStack() throws IOException {
|
||||
int id = this.readShort();
|
||||
if(id < 0)
|
||||
return null;
|
||||
int amt = this.readVarInt();
|
||||
int meta = this.readShort();
|
||||
ItemStack stack = new ItemStack(ItemRegistry.getItemById(id), amt, meta);
|
||||
stack.setTagCompound(this.readTag());
|
||||
return stack;
|
||||
}
|
||||
|
||||
public void writeString(String str) {
|
||||
byte[] data = str.getBytes(UTF_8);
|
||||
if(data.length > 32767)
|
||||
throw new EncoderException("String too big (was " + str.length() + " bytes encoded, max " + 32767 + ")");
|
||||
this.writeVarInt(data.length);
|
||||
this.writeBytes(data);
|
||||
}
|
||||
|
||||
public String readString(int limit) {
|
||||
int len = this.readVarInt();
|
||||
if(len > limit * 4)
|
||||
throw new DecoderException("The received encoded string buffer length is longer than maximum allowed (" + len + " > " + limit * 4 + ")");
|
||||
else if(len < 0)
|
||||
throw new DecoderException("The received encoded string buffer length is less than zero! Weird string!");
|
||||
byte[] data = new byte[len];
|
||||
this.readBytes(data);
|
||||
String str = new String(data, UTF_8);
|
||||
if(str.length() > limit)
|
||||
throw new DecoderException("The received string length is longer than maximum allowed (" + len + " > " + limit + ")");
|
||||
return str;
|
||||
}
|
||||
|
||||
public void writeBoolean(boolean value) {
|
||||
this.buf.writeBoolean(value);
|
||||
}
|
||||
|
||||
public boolean readBoolean() {
|
||||
return this.buf.readBoolean();
|
||||
}
|
||||
|
||||
public void writeByte(int value) {
|
||||
this.buf.writeByte(value);
|
||||
}
|
||||
|
||||
public byte readByte() {
|
||||
return this.buf.readByte();
|
||||
}
|
||||
|
||||
public short readUnsignedByte() {
|
||||
return this.buf.readUnsignedByte();
|
||||
}
|
||||
|
||||
public void writeShort(int value) {
|
||||
this.buf.writeShort(value);
|
||||
}
|
||||
|
||||
public short readShort() {
|
||||
return this.buf.readShort();
|
||||
}
|
||||
|
||||
public int readUnsignedShort() {
|
||||
return this.buf.readUnsignedShort();
|
||||
}
|
||||
|
||||
public void writeInt(int value) {
|
||||
this.buf.writeInt(value);
|
||||
}
|
||||
|
||||
public int readInt() {
|
||||
return this.buf.readInt();
|
||||
}
|
||||
|
||||
public long readUnsignedInt() {
|
||||
return this.buf.readUnsignedInt();
|
||||
}
|
||||
|
||||
public void writeLong(long value) {
|
||||
this.buf.writeLong(value);
|
||||
}
|
||||
|
||||
public long readLong() {
|
||||
return this.buf.readLong();
|
||||
}
|
||||
|
||||
public void writeFloat(float value) {
|
||||
this.buf.writeFloat(value);
|
||||
}
|
||||
|
||||
public float readFloat() {
|
||||
return this.buf.readFloat();
|
||||
}
|
||||
|
||||
public void writeDouble(double value) {
|
||||
this.buf.writeDouble(value);
|
||||
}
|
||||
|
||||
public double readDouble() {
|
||||
return this.buf.readDouble();
|
||||
}
|
||||
|
||||
public ByteBuf readBytes(int size) {
|
||||
return this.buf.readBytes(size);
|
||||
}
|
||||
|
||||
public void writeBytes(byte[] data) {
|
||||
this.buf.writeBytes(data);
|
||||
}
|
||||
|
||||
public void readBytes(byte[] buffer) {
|
||||
this.buf.readBytes(buffer);
|
||||
}
|
||||
|
||||
public void writeBytes(byte[] data, int offset, int length) {
|
||||
this.buf.writeBytes(data, offset, length);
|
||||
}
|
||||
|
||||
public void writeBuffer(ByteBuf buf) {
|
||||
this.buf.writeBytes(buf);
|
||||
}
|
||||
|
||||
public void writeBuffer(ByteBuf buf, int offset, int length) {
|
||||
this.buf.writeBytes(buf, offset, length);
|
||||
}
|
||||
|
||||
public int readableBytes() {
|
||||
return this.buf.readableBytes();
|
||||
}
|
||||
|
||||
public void ensureWritable(int size) {
|
||||
this.buf.ensureWritable(size);
|
||||
}
|
||||
|
||||
public PacketBuffer(ByteBuf wrapped)
|
||||
{
|
||||
this.buf = wrapped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the number of bytes required to fit the supplied int (0-5) if it were to be read/written using
|
||||
* readVarIntFromBuffer or writeVarIntToBuffer
|
||||
*/
|
||||
public static int getVarIntSize(int input)
|
||||
{
|
||||
for (int i = 1; i < 5; ++i)
|
||||
{
|
||||
if ((input & -1 << i * 7) == 0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
||||
public void writeByteArray(byte[] array)
|
||||
{
|
||||
this.writeVarIntToBuffer(array.length);
|
||||
this.writeBytes(array);
|
||||
}
|
||||
|
||||
public byte[] readByteArray()
|
||||
{
|
||||
byte[] abyte = new byte[this.readVarIntFromBuffer()];
|
||||
this.readBytes(abyte);
|
||||
return abyte;
|
||||
}
|
||||
|
||||
public BlockPos readBlockPos()
|
||||
{
|
||||
return new BlockPos(this.readInt(), this.readInt(), this.readInt());
|
||||
}
|
||||
|
||||
public void writeBlockPos(BlockPos pos)
|
||||
{
|
||||
this.writeInt(pos.getX());
|
||||
this.writeInt(pos.getY());
|
||||
this.writeInt(pos.getZ());
|
||||
}
|
||||
|
||||
// public Text readChatComponent() throws IOException
|
||||
// {
|
||||
// return Text.toComponent(this.readNBTTagCompoundFromBuffer());
|
||||
// }
|
||||
//
|
||||
// public void writeChatComponent(Text component) throws IOException
|
||||
// {
|
||||
// this.writeNBTTagCompoundToBuffer(Text.toNbt(component));
|
||||
//// String s = ;
|
||||
//// if(s.length() > 32767) {
|
||||
//// s = component.getFormattedText();
|
||||
//// s = s.length() > 32720 ? s.substring(0, 32720) : s;
|
||||
//// s = TextSerializer.toNbt(new TextComponent(s + ChatFormat.GRAY + ChatFormat.ITALIC + " [...]"));
|
||||
//// }
|
||||
//// this.writeString(s);
|
||||
// }
|
||||
|
||||
public <T extends Enum<T>> T readEnumValue(Class<T> enumClass)
|
||||
{
|
||||
return (T)((Enum[])enumClass.getEnumConstants())[this.readVarIntFromBuffer()];
|
||||
}
|
||||
|
||||
public <T extends Enum<T>> T readEnumOrNull(Class<T> enumClass)
|
||||
{
|
||||
int n = this.readVarIntFromBuffer();
|
||||
return n < 0 ? null : (T)((Enum[])enumClass.getEnumConstants())[n];
|
||||
}
|
||||
|
||||
public void writeEnumValue(Enum<?> value)
|
||||
{
|
||||
this.writeVarIntToBuffer(value.ordinal());
|
||||
}
|
||||
|
||||
public void writeEnumOrNull(Enum<?> value)
|
||||
{
|
||||
this.writeVarIntToBuffer(value == null ? -1 : value.ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a compressed int from the buffer. To do so it maximally reads 5 byte-sized chunks whose most significant
|
||||
* bit dictates whether another byte should be read.
|
||||
*/
|
||||
public int readVarIntFromBuffer()
|
||||
{
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
byte b0 = this.readByte();
|
||||
i |= (b0 & 127) << j++ * 7;
|
||||
|
||||
if (j > 5)
|
||||
{
|
||||
throw new RuntimeException("VarInt too big");
|
||||
}
|
||||
|
||||
if ((b0 & 128) != 128)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
public long readVarLong()
|
||||
{
|
||||
long i = 0L;
|
||||
int j = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
byte b0 = this.readByte();
|
||||
i |= (long)(b0 & 127) << j++ * 7;
|
||||
|
||||
if (j > 10)
|
||||
{
|
||||
throw new RuntimeException("VarLong too big");
|
||||
}
|
||||
|
||||
if ((b0 & 128) != 128)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
// public void writeUuid(UUID uuid)
|
||||
// {
|
||||
// this.writeLong(uuid.getMostSignificantBits());
|
||||
// this.writeLong(uuid.getLeastSignificantBits());
|
||||
// }
|
||||
//
|
||||
// public UUID readUuid()
|
||||
// {
|
||||
// return new UUID(this.readLong(), this.readLong());
|
||||
// }
|
||||
|
||||
/**
|
||||
* Writes a compressed int to the buffer. The smallest number of bytes to fit the passed int will be written. Of
|
||||
* each such byte only 7 bits will be used to describe the actual value since its most significant bit dictates
|
||||
* whether the next byte is part of that same int. Micro-optimization for int values that are expected to have
|
||||
* values below 128.
|
||||
*/
|
||||
public void writeVarIntToBuffer(int input)
|
||||
{
|
||||
while ((input & -128) != 0)
|
||||
{
|
||||
this.writeByte(input & 127 | 128);
|
||||
input >>>= 7;
|
||||
}
|
||||
|
||||
this.writeByte(input);
|
||||
}
|
||||
|
||||
public void writeVarLong(long value)
|
||||
{
|
||||
while ((value & -128L) != 0L)
|
||||
{
|
||||
this.writeByte((int)(value & 127L) | 128);
|
||||
value >>>= 7;
|
||||
}
|
||||
|
||||
this.writeByte((int)value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a compressed NBTTagCompound to this buffer
|
||||
*/
|
||||
public void writeNBTTagCompoundToBuffer(NBTTagCompound nbt)
|
||||
{
|
||||
if (nbt == null)
|
||||
{
|
||||
this.writeByte(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
NBTLoader.write(nbt, new ByteBufOutputStream(this.buf));
|
||||
}
|
||||
catch (IOException ioexception)
|
||||
{
|
||||
throw new EncoderException(ioexception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a compressed NBTTagCompound from this buffer
|
||||
*/
|
||||
public NBTTagCompound readNBTTagCompoundFromBuffer() throws IOException
|
||||
{
|
||||
int i = this.buf.readerIndex();
|
||||
byte b0 = this.readByte();
|
||||
|
||||
if (b0 == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.buf.readerIndex(i);
|
||||
return NBTLoader.read(new ByteBufInputStream(this.buf), new NBTSizeTracker(2097152L));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the ItemStack's ID (short), then size (byte), then damage. (short)
|
||||
*/
|
||||
public void writeItemStackToBuffer(ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
this.writeShort(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.writeShort(ItemRegistry.getIdFromItem(stack.getItem()));
|
||||
this.writeVarIntToBuffer(stack.stackSize);
|
||||
this.writeShort(stack.getMetadata());
|
||||
NBTTagCompound nbttagcompound = null;
|
||||
|
||||
if (stack.getItem().isDamageable() || stack.getItem().getShareTag())
|
||||
{
|
||||
nbttagcompound = stack.getTagCompound();
|
||||
}
|
||||
|
||||
this.writeNBTTagCompoundToBuffer(nbttagcompound);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an ItemStack from this buffer
|
||||
*/
|
||||
public ItemStack readItemStackFromBuffer() throws IOException
|
||||
{
|
||||
ItemStack itemstack = null;
|
||||
int i = this.readShort();
|
||||
|
||||
if (i >= 0)
|
||||
{
|
||||
int j = this.readVarIntFromBuffer();
|
||||
int k = this.readShort();
|
||||
itemstack = new ItemStack(ItemRegistry.getItemById(i), j, k);
|
||||
itemstack.setTagCompound(this.readNBTTagCompoundFromBuffer());
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a string from this buffer. Expected parameter is maximum allowed string length. Will throw IOException if
|
||||
* string length exceeds this value!
|
||||
*/
|
||||
public String readStringFromBuffer(int maxLength)
|
||||
{
|
||||
int i = this.readVarIntFromBuffer();
|
||||
|
||||
if (i > maxLength * 4)
|
||||
{
|
||||
throw new DecoderException("The received encoded string buffer length is longer than maximum allowed (" + i + " > " + maxLength * 4 + ")");
|
||||
}
|
||||
else if (i < 0)
|
||||
{
|
||||
throw new DecoderException("The received encoded string buffer length is less than zero! Weird string!");
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] abyte = new byte[i];
|
||||
this.readBytes(abyte);
|
||||
String s = new String(abyte, UTF_8); // this.readBytes(i).array()
|
||||
|
||||
if (s.length() > maxLength)
|
||||
{
|
||||
throw new DecoderException("The received string length is longer than maximum allowed (" + i + " > " + maxLength + ")");
|
||||
}
|
||||
else
|
||||
{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PacketBuffer writeString(String string)
|
||||
{
|
||||
byte[] abyte = string.getBytes(UTF_8);
|
||||
|
||||
if (abyte.length > 32767)
|
||||
{
|
||||
throw new EncoderException("String too big (was " + string.length() + " bytes encoded, max " + 32767 + ")");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.writeVarIntToBuffer(abyte.length);
|
||||
this.writeBytes(abyte);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public int readableBytes()
|
||||
{
|
||||
return this.buf.readableBytes();
|
||||
}
|
||||
|
||||
public ByteBuf ensureWritable(int p_ensureWritable_1_)
|
||||
{
|
||||
return this.buf.ensureWritable(p_ensureWritable_1_);
|
||||
}
|
||||
|
||||
public boolean readBoolean()
|
||||
{
|
||||
return this.buf.readBoolean();
|
||||
}
|
||||
|
||||
public byte readByte()
|
||||
{
|
||||
return this.buf.readByte();
|
||||
}
|
||||
|
||||
public short readUnsignedByte()
|
||||
{
|
||||
return this.buf.readUnsignedByte();
|
||||
}
|
||||
|
||||
public short readShort()
|
||||
{
|
||||
return this.buf.readShort();
|
||||
}
|
||||
|
||||
public int readUnsignedShort()
|
||||
{
|
||||
return this.buf.readUnsignedShort();
|
||||
}
|
||||
|
||||
public int readInt()
|
||||
{
|
||||
return this.buf.readInt();
|
||||
}
|
||||
|
||||
public long readUnsignedInt()
|
||||
{
|
||||
return this.buf.readUnsignedInt();
|
||||
}
|
||||
|
||||
public long readLong()
|
||||
{
|
||||
return this.buf.readLong();
|
||||
}
|
||||
|
||||
public float readFloat()
|
||||
{
|
||||
return this.buf.readFloat();
|
||||
}
|
||||
|
||||
public double readDouble()
|
||||
{
|
||||
return this.buf.readDouble();
|
||||
}
|
||||
|
||||
public ByteBuf readBytes(int p_readBytes_1_)
|
||||
{
|
||||
return this.buf.readBytes(p_readBytes_1_);
|
||||
}
|
||||
|
||||
public ByteBuf readBytes(byte[] p_readBytes_1_)
|
||||
{
|
||||
return this.buf.readBytes(p_readBytes_1_);
|
||||
}
|
||||
|
||||
public ByteBuf writeBoolean(boolean p_writeBoolean_1_)
|
||||
{
|
||||
return this.buf.writeBoolean(p_writeBoolean_1_);
|
||||
}
|
||||
|
||||
public ByteBuf writeByte(int p_writeByte_1_)
|
||||
{
|
||||
return this.buf.writeByte(p_writeByte_1_);
|
||||
}
|
||||
|
||||
public ByteBuf writeShort(int p_writeShort_1_)
|
||||
{
|
||||
return this.buf.writeShort(p_writeShort_1_);
|
||||
}
|
||||
|
||||
public ByteBuf writeInt(int p_writeInt_1_)
|
||||
{
|
||||
return this.buf.writeInt(p_writeInt_1_);
|
||||
}
|
||||
|
||||
public ByteBuf writeLong(long p_writeLong_1_)
|
||||
{
|
||||
return this.buf.writeLong(p_writeLong_1_);
|
||||
}
|
||||
|
||||
public ByteBuf writeFloat(float p_writeFloat_1_)
|
||||
{
|
||||
return this.buf.writeFloat(p_writeFloat_1_);
|
||||
}
|
||||
|
||||
public ByteBuf writeDouble(double p_writeDouble_1_)
|
||||
{
|
||||
return this.buf.writeDouble(p_writeDouble_1_);
|
||||
}
|
||||
|
||||
public ByteBuf writeBytes(ByteBuf p_writeBytes_1_)
|
||||
{
|
||||
return this.buf.writeBytes(p_writeBytes_1_);
|
||||
}
|
||||
|
||||
public ByteBuf writeBytes(ByteBuf p_writeBytes_1_, int p_writeBytes_2_, int p_writeBytes_3_)
|
||||
{
|
||||
return this.buf.writeBytes(p_writeBytes_1_, p_writeBytes_2_, p_writeBytes_3_);
|
||||
}
|
||||
|
||||
public ByteBuf writeBytes(byte[] p_writeBytes_1_)
|
||||
{
|
||||
return this.buf.writeBytes(p_writeBytes_1_);
|
||||
}
|
||||
|
||||
public ByteBuf writeBytes(byte[] p_writeBytes_1_, int p_writeBytes_2_, int p_writeBytes_3_)
|
||||
{
|
||||
return this.buf.writeBytes(p_writeBytes_1_, p_writeBytes_2_, p_writeBytes_3_);
|
||||
}
|
||||
|
||||
public boolean release()
|
||||
{
|
||||
return this.buf.release();
|
||||
}
|
||||
public void release() {
|
||||
this.buf.release();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,45 +7,26 @@ import io.netty.buffer.ByteBuf;
|
|||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
|
||||
public class PacketDecoder extends ByteToMessageDecoder
|
||||
{
|
||||
private final boolean client;
|
||||
public class PacketDecoder extends ByteToMessageDecoder {
|
||||
private final boolean client;
|
||||
|
||||
public PacketDecoder(boolean client)
|
||||
{
|
||||
this.client = client;
|
||||
}
|
||||
public PacketDecoder(boolean client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
protected void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List<Object> p_decode_3_) throws IOException, InstantiationException, IllegalAccessException, Exception
|
||||
{
|
||||
if (p_decode_2_.readableBytes() != 0)
|
||||
{
|
||||
PacketBuffer packetbuffer = new PacketBuffer(p_decode_2_);
|
||||
int i = packetbuffer.readVarIntFromBuffer();
|
||||
Packet packet = ((PacketRegistry)p_decode_1_.channel().attr(NetConnection.ATTR_STATE).get()).getPacket(this.client, i);
|
||||
|
||||
if (packet == null)
|
||||
{
|
||||
throw new IOException("Ungültige Paket-ID " + i);
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.readPacketData(packetbuffer);
|
||||
|
||||
if (packetbuffer.readableBytes() > 0)
|
||||
{
|
||||
throw new IOException("Paket " + ((PacketRegistry)p_decode_1_.channel().attr(NetConnection.ATTR_STATE).get()).ordinal() + "/" + i + " (" + packet.getClass() + ") war größer als erwartet, " + packetbuffer.readableBytes() + " weitere Bytes wurden beim Lesen von Paket " + i + " gefunden");
|
||||
}
|
||||
else
|
||||
{
|
||||
p_decode_3_.add(packet);
|
||||
|
||||
// if (Log.isTraceEnabled())
|
||||
// {
|
||||
// Log.SYSTEM.info("EIN: [" + p_decode_1_.channel().attr(NetConnection.ATTR_STATE).get() + ":" + i + "] " + packet.getClass().getName());
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
protected void decode(ChannelHandlerContext context, ByteBuf buffer, List<Object> output) throws IOException, InstantiationException, IllegalAccessException, Exception {
|
||||
if(buffer.readableBytes() == 0)
|
||||
return;
|
||||
PacketBuffer pbuf = new PacketBuffer(buffer);
|
||||
int id = pbuf.readVarInt();
|
||||
Packet packet = context.channel().attr(NetConnection.ATTR_STATE).get().getPacket(this.client, id);
|
||||
if(packet == null)
|
||||
throw new IOException("Ungültige Paket-ID " + id);
|
||||
packet.readPacketData(pbuf);
|
||||
if(pbuf.readableBytes() > 0)
|
||||
throw new IOException("Paket " + ((PacketRegistry)context.channel().attr(NetConnection.ATTR_STATE).get()).ordinal() + "/" + id + " ("
|
||||
+ packet.getClass() + ") war größer als erwartet, " + pbuf.readableBytes() + " weitere Bytes wurden beim Lesen von Paket " + id + " gefunden");
|
||||
output.add(packet);
|
||||
// common.log.Log.SYSTEM.info("EIN: [" + context.channel().attr(NetConnection.ATTR_STATE).get() + ":" + id + "] " + packet.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,46 +2,29 @@ package common.network;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import common.log.Log;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
|
||||
public class PacketEncoder extends MessageToByteEncoder<Packet>
|
||||
{
|
||||
private final boolean client;
|
||||
public class PacketEncoder extends MessageToByteEncoder<Packet> {
|
||||
private final boolean client;
|
||||
|
||||
public PacketEncoder(boolean client)
|
||||
{
|
||||
this.client = client;
|
||||
}
|
||||
public PacketEncoder(boolean client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
protected void encode(ChannelHandlerContext p_encode_1_, Packet p_encode_2_, ByteBuf p_encode_3_) throws IOException, Exception
|
||||
{
|
||||
Integer integer = ((PacketRegistry)p_encode_1_.channel().attr(NetConnection.ATTR_STATE).get()).getId(this.client, p_encode_2_);
|
||||
|
||||
// if (Log.isTraceEnabled())
|
||||
// {
|
||||
// Log.SYSTEM.debug("AUS: [" + p_encode_1_.channel().attr(NetConnection.ATTR_STATE).get() + ":" + integer + "] " + p_encode_2_.getClass().getName());
|
||||
// }
|
||||
|
||||
if (integer == null)
|
||||
{
|
||||
throw new IOException("Kann nicht registriertes Paket nicht serialisieren");
|
||||
}
|
||||
else
|
||||
{
|
||||
PacketBuffer packetbuffer = new PacketBuffer(p_encode_3_);
|
||||
packetbuffer.writeVarIntToBuffer(integer.intValue());
|
||||
|
||||
try
|
||||
{
|
||||
p_encode_2_.writePacketData(packetbuffer);
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
Log.JNI.error(throwable, "Fehler beim Schreiben der Paketdaten");
|
||||
}
|
||||
}
|
||||
}
|
||||
protected void encode(ChannelHandlerContext context, Packet packet, ByteBuf output) throws IOException, Exception {
|
||||
Integer id = context.channel().attr(NetConnection.ATTR_STATE).get().getId(this.client, packet);
|
||||
if(id == null)
|
||||
throw new IOException("Kann nicht registriertes Paket nicht serialisieren");
|
||||
// common.log.Log.SYSTEM.debug("AUS: [" + context.channel().attr(NetConnection.ATTR_STATE).get() + ":" + id + "] " + packet.getClass().getName());
|
||||
PacketBuffer pbuf = new PacketBuffer(output);
|
||||
pbuf.writeVarInt(id);
|
||||
try {
|
||||
packet.writePacketData(pbuf);
|
||||
}
|
||||
catch(Throwable t) {
|
||||
throw new IOException("Fehler beim Schreiben der Paketdaten", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,23 +4,15 @@ import io.netty.buffer.ByteBuf;
|
|||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
|
||||
public class PacketPrepender extends MessageToByteEncoder<ByteBuf>
|
||||
{
|
||||
protected void encode(ChannelHandlerContext p_encode_1_, ByteBuf p_encode_2_, ByteBuf p_encode_3_) throws Exception
|
||||
{
|
||||
int i = p_encode_2_.readableBytes();
|
||||
int j = PacketBuffer.getVarIntSize(i);
|
||||
|
||||
if (j > 3)
|
||||
{
|
||||
throw new IllegalArgumentException("unable to fit " + i + " into " + 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
PacketBuffer packetbuffer = new PacketBuffer(p_encode_3_);
|
||||
packetbuffer.ensureWritable(j + i);
|
||||
packetbuffer.writeVarIntToBuffer(i);
|
||||
packetbuffer.writeBytes(p_encode_2_, p_encode_2_.readerIndex(), i);
|
||||
}
|
||||
}
|
||||
public class PacketPrepender extends MessageToByteEncoder<ByteBuf> {
|
||||
protected void encode(ChannelHandlerContext context, ByteBuf buffer, ByteBuf output) throws Exception {
|
||||
int len = buffer.readableBytes();
|
||||
int vs = PacketBuffer.getVarIntSize(len);
|
||||
if(vs > 3)
|
||||
throw new IllegalArgumentException("unable to fit " + len + " into " + 3);
|
||||
PacketBuffer pbuf = new PacketBuffer(output);
|
||||
pbuf.ensureWritable(vs + len);
|
||||
pbuf.writeVarInt(len);
|
||||
pbuf.writeBuffer(buffer, buffer.readerIndex(), len);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,10 @@ import java.util.Map;
|
|||
import common.collect.BiMap;
|
||||
import common.collect.HashBiMap;
|
||||
import common.collect.Maps;
|
||||
import common.packet.CPacketPlayerPosition;
|
||||
import common.packet.CPacketPlayerLook;
|
||||
import common.packet.CPacketPlayerPosLook;
|
||||
import common.packet.CPacketAction;
|
||||
import common.packet.CPacketBook;
|
||||
import common.packet.CPacketBreak;
|
||||
import common.packet.CPacketCheat;
|
||||
import common.packet.CPacketClick;
|
||||
|
@ -27,34 +29,37 @@ import common.packet.RPacketDisconnect;
|
|||
import common.packet.RPacketEnableCompression;
|
||||
import common.packet.RPacketLoginSuccess;
|
||||
import common.packet.RPacketRequestEncrypt;
|
||||
import common.packet.S14PacketEntity;
|
||||
import common.packet.S18PacketEntityTeleport;
|
||||
import common.packet.S19PacketEntityHeadLook;
|
||||
import common.packet.S1APacketEntityStatus;
|
||||
import common.packet.S1BPacketEntityAttach;
|
||||
import common.packet.S1CPacketEntityMetadata;
|
||||
import common.packet.S1DPacketEntityEffect;
|
||||
import common.packet.S1EPacketRemoveEntityEffect;
|
||||
import common.packet.S20PacketEntityProperties;
|
||||
import common.packet.S27PacketExplosion;
|
||||
import common.packet.S28PacketEffect;
|
||||
import common.packet.S29PacketSoundEffect;
|
||||
import common.packet.S2APacketParticles;
|
||||
import common.packet.S2BPacketChangeGameState;
|
||||
import common.packet.S2CPacketSpawnGlobalEntity;
|
||||
import common.packet.S2DPacketOpenWindow;
|
||||
import common.packet.S2EPacketCloseWindow;
|
||||
import common.packet.S2FPacketSetSlot;
|
||||
import common.packet.S30PacketWindowItems;
|
||||
import common.packet.S31PacketWindowProperty;
|
||||
import common.packet.S32PacketConfirmTransaction;
|
||||
import common.packet.S33PacketUpdateSign;
|
||||
import common.packet.S35PacketUpdateTileEntity;
|
||||
import common.packet.S36PacketSignEditorOpen;
|
||||
import common.packet.S38PacketPlayerListItem;
|
||||
import common.packet.S39PacketPlayerAbilities;
|
||||
import common.packet.S3APacketTabComplete;
|
||||
import common.packet.S43PacketUpdateEntityNBT;
|
||||
import common.packet.SPacketEntityRelMove;
|
||||
import common.packet.SPacketEntityLook;
|
||||
import common.packet.SPacketEntityLookMove;
|
||||
import common.packet.SPacketEntity;
|
||||
import common.packet.SPacketEntityTeleport;
|
||||
import common.packet.SPacketEntityHeadLook;
|
||||
import common.packet.SPacketEntityStatus;
|
||||
import common.packet.SPacketEntityAttach;
|
||||
import common.packet.SPacketEntityMetadata;
|
||||
import common.packet.SPacketEntityEffect;
|
||||
import common.packet.SPacketRemoveEntityEffect;
|
||||
import common.packet.SPacketEntityProperties;
|
||||
import common.packet.SPacketExplosion;
|
||||
import common.packet.SPacketEffect;
|
||||
import common.packet.SPacketSoundEffect;
|
||||
import common.packet.SPacketParticles;
|
||||
import common.packet.SPacketChangeGameState;
|
||||
import common.packet.SPacketSpawnGlobalEntity;
|
||||
import common.packet.SPacketOpenWindow;
|
||||
import common.packet.SPacketCloseWindow;
|
||||
import common.packet.SPacketSetSlot;
|
||||
import common.packet.SPacketWindowItems;
|
||||
import common.packet.SPacketWindowProperty;
|
||||
import common.packet.SPacketConfirmTransaction;
|
||||
import common.packet.SPacketUpdateSign;
|
||||
import common.packet.SPacketUpdateTileEntity;
|
||||
import common.packet.SPacketSignEditorOpen;
|
||||
import common.packet.SPacketPlayerListItem;
|
||||
import common.packet.SPacketPlayerAbilities;
|
||||
import common.packet.SPacketTabComplete;
|
||||
import common.packet.SPacketUpdateEntityNBT;
|
||||
import common.packet.SPacketAnimation;
|
||||
import common.packet.SPacketBiome;
|
||||
import common.packet.SPacketBlockAction;
|
||||
|
@ -92,144 +97,122 @@ import common.packet.SPacketWorld;
|
|||
|
||||
public enum PacketRegistry
|
||||
{
|
||||
HANDSHAKE
|
||||
{
|
||||
{
|
||||
this.client(HPacketHandshake.class);
|
||||
}
|
||||
},
|
||||
LOGIN
|
||||
{
|
||||
{
|
||||
this.server(RPacketDisconnect.class);
|
||||
this.server(RPacketRequestEncrypt.class);
|
||||
this.server(RPacketLoginSuccess.class);
|
||||
this.server(RPacketEnableCompression.class);
|
||||
this.client(LPacketLogin.class);
|
||||
this.client(LPacketStartEncrypt.class);
|
||||
this.client(LPacketPasswordResponse.class);
|
||||
}
|
||||
},
|
||||
PLAY
|
||||
{
|
||||
{
|
||||
this.server(SPacketKeepAlive.class);
|
||||
this.server(SPacketJoinGame.class);
|
||||
this.server(SPacketMessage.class);
|
||||
// this.server(SPacketMessage.class);
|
||||
this.server(SPacketTimeUpdate.class);
|
||||
this.server(SPacketEntityEquipment.class);
|
||||
this.server(SPacketUpdateHealth.class);
|
||||
this.server(SPacketRespawn.class);
|
||||
this.server(SPacketPlayerPosLook.class);
|
||||
this.server(SPacketHeldItemChange.class);
|
||||
this.server(SPacketAnimation.class);
|
||||
this.server(SPacketSpawnPlayer.class);
|
||||
this.server(SPacketCollectItem.class);
|
||||
this.server(SPacketSpawnObject.class);
|
||||
this.server(SPacketSpawnMob.class);
|
||||
// this.server(SPacketSpawnPainting.class);
|
||||
// this.server(SPacketSpawnExperienceOrb.class);
|
||||
this.server(SPacketEntityVelocity.class);
|
||||
this.server(SPacketDestroyEntities.class);
|
||||
this.server(S14PacketEntity.class);
|
||||
this.server(S14PacketEntity.S15PacketEntityRelMove.class);
|
||||
this.server(S14PacketEntity.S16PacketEntityLook.class);
|
||||
this.server(S14PacketEntity.S17PacketEntityLookMove.class);
|
||||
this.server(S18PacketEntityTeleport.class);
|
||||
this.server(S19PacketEntityHeadLook.class);
|
||||
this.server(S1APacketEntityStatus.class);
|
||||
this.server(S1BPacketEntityAttach.class);
|
||||
this.server(S1CPacketEntityMetadata.class);
|
||||
this.server(S1DPacketEntityEffect.class);
|
||||
this.server(S1EPacketRemoveEntityEffect.class);
|
||||
this.server(SPacketSetExperience.class);
|
||||
this.server(S20PacketEntityProperties.class);
|
||||
this.server(SPacketChunkData.class);
|
||||
this.server(SPacketMultiBlockChange.class);
|
||||
this.server(SPacketBlockChange.class);
|
||||
this.server(SPacketBlockAction.class);
|
||||
this.server(SPacketBlockBreakAnim.class);
|
||||
this.server(SPacketMapChunkBulk.class);
|
||||
this.server(S27PacketExplosion.class);
|
||||
this.server(S28PacketEffect.class);
|
||||
this.server(S29PacketSoundEffect.class);
|
||||
this.server(S2APacketParticles.class);
|
||||
this.server(S2BPacketChangeGameState.class);
|
||||
this.server(S2CPacketSpawnGlobalEntity.class);
|
||||
this.server(S2DPacketOpenWindow.class);
|
||||
this.server(S2EPacketCloseWindow.class);
|
||||
this.server(S2FPacketSetSlot.class);
|
||||
this.server(S30PacketWindowItems.class);
|
||||
this.server(S31PacketWindowProperty.class);
|
||||
this.server(S32PacketConfirmTransaction.class);
|
||||
this.server(S33PacketUpdateSign.class);
|
||||
// this.server(S34PacketMaps.class);
|
||||
this.server(S35PacketUpdateTileEntity.class);
|
||||
this.server(S36PacketSignEditorOpen.class);
|
||||
// this.server(S37PacketStatistics.class);
|
||||
this.server(S38PacketPlayerListItem.class);
|
||||
this.server(S39PacketPlayerAbilities.class);
|
||||
this.server(S3APacketTabComplete.class);
|
||||
// this.server(SPacketDisplay.class);
|
||||
this.server(SPacketSkin.class);
|
||||
this.server(SPacketDisconnect.class);
|
||||
this.server(SPacketWorld.class);
|
||||
// this.server(SPacketCapes.class);
|
||||
this.server(SPacketCamera.class);
|
||||
this.server(SPacketBiome.class);
|
||||
// this.server(S42PacketTitle.class);
|
||||
this.server(S43PacketUpdateEntityNBT.class);
|
||||
// this.server(SPacketBook.class);
|
||||
this.server(SPacketTrades.class);
|
||||
// this.server(SPacketNotify.class);
|
||||
this.server(SPacketDimensionName.class);
|
||||
this.server(SPacketCharacterList.class);
|
||||
this.server(SPacketServerTick.class);
|
||||
this.server(SPacketLoading.class);
|
||||
this.server(SPacketDisplayForm.class);
|
||||
|
||||
this.client(CPacketKeepAlive.class);
|
||||
this.client(CPacketMessage.class);
|
||||
this.client(CPacketAction.class);
|
||||
this.client(CPacketPlayer.class);
|
||||
this.client(CPacketPlayer.C04PacketPlayerPosition.class);
|
||||
this.client(CPacketPlayer.C05PacketPlayerLook.class);
|
||||
this.client(CPacketPlayer.C06PacketPlayerPosLook.class);
|
||||
this.client(CPacketBreak.class);
|
||||
this.client(CPacketPlace.class);
|
||||
this.client(CPacketInput.class);
|
||||
this.client(CPacketClick.class);
|
||||
this.client(CPacketCheat.class);
|
||||
this.client(CPacketComplete.class);
|
||||
this.client(CPacketSkin.class);
|
||||
this.client(CPacketSign.class);
|
||||
this.client(CPacketBook.class);
|
||||
this.client(CPacketForm.class);
|
||||
}
|
||||
};
|
||||
HANDSHAKE {{
|
||||
this.client(HPacketHandshake.class);
|
||||
}},
|
||||
LOGIN {{
|
||||
this.server(RPacketDisconnect.class);
|
||||
this.server(RPacketRequestEncrypt.class);
|
||||
this.server(RPacketLoginSuccess.class);
|
||||
this.server(RPacketEnableCompression.class);
|
||||
|
||||
this.client(LPacketLogin.class);
|
||||
this.client(LPacketStartEncrypt.class);
|
||||
this.client(LPacketPasswordResponse.class);
|
||||
}},
|
||||
PLAY {{
|
||||
this.server(SPacketKeepAlive.class);
|
||||
this.server(SPacketJoinGame.class);
|
||||
this.server(SPacketMessage.class);
|
||||
this.server(SPacketTimeUpdate.class);
|
||||
this.server(SPacketEntityEquipment.class);
|
||||
this.server(SPacketUpdateHealth.class);
|
||||
this.server(SPacketRespawn.class);
|
||||
this.server(SPacketPlayerPosLook.class);
|
||||
this.server(SPacketHeldItemChange.class);
|
||||
this.server(SPacketAnimation.class);
|
||||
this.server(SPacketSpawnPlayer.class);
|
||||
this.server(SPacketCollectItem.class);
|
||||
this.server(SPacketSpawnObject.class);
|
||||
this.server(SPacketSpawnMob.class);
|
||||
this.server(SPacketEntityVelocity.class);
|
||||
this.server(SPacketDestroyEntities.class);
|
||||
this.server(SPacketEntity.class);
|
||||
this.server(SPacketEntityRelMove.class);
|
||||
this.server(SPacketEntityLook.class);
|
||||
this.server(SPacketEntityLookMove.class);
|
||||
this.server(SPacketEntityTeleport.class);
|
||||
this.server(SPacketEntityHeadLook.class);
|
||||
this.server(SPacketEntityStatus.class);
|
||||
this.server(SPacketEntityAttach.class);
|
||||
this.server(SPacketEntityMetadata.class);
|
||||
this.server(SPacketEntityEffect.class);
|
||||
this.server(SPacketRemoveEntityEffect.class);
|
||||
this.server(SPacketSetExperience.class);
|
||||
this.server(SPacketEntityProperties.class);
|
||||
this.server(SPacketChunkData.class);
|
||||
this.server(SPacketMultiBlockChange.class);
|
||||
this.server(SPacketBlockChange.class);
|
||||
this.server(SPacketBlockAction.class);
|
||||
this.server(SPacketBlockBreakAnim.class);
|
||||
this.server(SPacketMapChunkBulk.class);
|
||||
this.server(SPacketExplosion.class);
|
||||
this.server(SPacketEffect.class);
|
||||
this.server(SPacketSoundEffect.class);
|
||||
this.server(SPacketParticles.class);
|
||||
this.server(SPacketChangeGameState.class);
|
||||
this.server(SPacketSpawnGlobalEntity.class);
|
||||
this.server(SPacketOpenWindow.class);
|
||||
this.server(SPacketCloseWindow.class);
|
||||
this.server(SPacketSetSlot.class);
|
||||
this.server(SPacketWindowItems.class);
|
||||
this.server(SPacketWindowProperty.class);
|
||||
this.server(SPacketConfirmTransaction.class);
|
||||
this.server(SPacketUpdateSign.class);
|
||||
this.server(SPacketUpdateTileEntity.class);
|
||||
this.server(SPacketSignEditorOpen.class);
|
||||
this.server(SPacketPlayerListItem.class);
|
||||
this.server(SPacketPlayerAbilities.class);
|
||||
this.server(SPacketTabComplete.class);
|
||||
this.server(SPacketSkin.class);
|
||||
this.server(SPacketDisconnect.class);
|
||||
this.server(SPacketWorld.class);
|
||||
this.server(SPacketCamera.class);
|
||||
this.server(SPacketBiome.class);
|
||||
this.server(SPacketUpdateEntityNBT.class);
|
||||
this.server(SPacketTrades.class);
|
||||
this.server(SPacketDimensionName.class);
|
||||
this.server(SPacketCharacterList.class);
|
||||
this.server(SPacketServerTick.class);
|
||||
this.server(SPacketLoading.class);
|
||||
this.server(SPacketDisplayForm.class);
|
||||
|
||||
this.client(CPacketKeepAlive.class);
|
||||
this.client(CPacketMessage.class);
|
||||
this.client(CPacketAction.class);
|
||||
this.client(CPacketPlayer.class);
|
||||
this.client(CPacketPlayerPosition.class);
|
||||
this.client(CPacketPlayerLook.class);
|
||||
this.client(CPacketPlayerPosLook.class);
|
||||
this.client(CPacketBreak.class);
|
||||
this.client(CPacketPlace.class);
|
||||
this.client(CPacketInput.class);
|
||||
this.client(CPacketClick.class);
|
||||
this.client(CPacketCheat.class);
|
||||
this.client(CPacketComplete.class);
|
||||
this.client(CPacketSkin.class);
|
||||
this.client(CPacketSign.class);
|
||||
this.client(CPacketForm.class);
|
||||
}};
|
||||
|
||||
private static final Map<Class<? extends Packet>, PacketRegistry> STATES = Maps.<Class<? extends Packet>, PacketRegistry>newHashMap();
|
||||
|
||||
private final BiMap<Integer, Class<? extends Packet>> server = HashBiMap.<Integer, Class<? extends Packet>>create();
|
||||
private final BiMap<Integer, Class<? extends Packet>> client = HashBiMap.<Integer, Class<? extends Packet>>create();
|
||||
|
||||
protected void server(Class <? extends Packet > clazz)
|
||||
{
|
||||
protected void server(Class <? extends Packet > clazz) {
|
||||
if(this.server.containsValue(clazz))
|
||||
throw new IllegalArgumentException("S-Paket " + clazz + " ist bereits bekannt unter ID " + this.server.inverse().get(clazz));
|
||||
this.server.put(Integer.valueOf(this.server.size()), clazz);
|
||||
}
|
||||
|
||||
protected void client(Class <? extends Packet > clazz)
|
||||
{
|
||||
protected void client(Class <? extends Packet > clazz) {
|
||||
if(this.client.containsValue(clazz))
|
||||
throw new IllegalArgumentException("C-Paket " + clazz + " ist bereits bekannt unter ID " + this.client.inverse().get(clazz));
|
||||
this.client.put(Integer.valueOf(this.client.size()), clazz);
|
||||
}
|
||||
|
||||
public Integer getId(boolean client, Packet packet)
|
||||
{
|
||||
public Integer getId(boolean client, Packet packet) {
|
||||
return (client ? this.client : this.server).inverse().get(packet.getClass());
|
||||
}
|
||||
|
||||
|
@ -238,19 +221,16 @@ public enum PacketRegistry
|
|||
return oclass == null ? null : oclass.newInstance();
|
||||
}
|
||||
|
||||
public static PacketRegistry getType(Packet packetIn)
|
||||
{
|
||||
return STATES.get(packetIn.getClass());
|
||||
public static PacketRegistry getType(Packet packet) {
|
||||
return STATES.get(packet.getClass());
|
||||
}
|
||||
|
||||
static {
|
||||
for(PacketRegistry reg : values()) {
|
||||
for(BiMap<Integer, Class<? extends Packet>> map : new BiMap[] {reg.server, reg.client}) {
|
||||
for(Class<? extends Packet> clazz : map.values()) {
|
||||
if(STATES.containsKey(clazz) && STATES.get(clazz) != reg) {
|
||||
throw new Error("Paket " + clazz + " ist bereits zu ID " + STATES.get(clazz)
|
||||
+ " zugewiesen - kann nicht auf " + reg + " neu zuweisen");
|
||||
}
|
||||
if(STATES.containsKey(clazz) && STATES.get(clazz) != reg)
|
||||
throw new Error("Paket " + clazz + " ist bereits zu ID " + STATES.get(clazz) + " zugewiesen - kann nicht auf " + reg + " neu zuweisen");
|
||||
try {
|
||||
clazz.newInstance();
|
||||
}
|
||||
|
|
|
@ -8,48 +8,32 @@ import io.netty.channel.ChannelHandlerContext;
|
|||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
import io.netty.handler.codec.CorruptedFrameException;
|
||||
|
||||
public class PacketSplitter extends ByteToMessageDecoder
|
||||
{
|
||||
protected void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List<Object> p_decode_3_) throws Exception
|
||||
{
|
||||
p_decode_2_.markReaderIndex();
|
||||
byte[] abyte = new byte[3];
|
||||
|
||||
for (int i = 0; i < abyte.length; ++i)
|
||||
{
|
||||
if (!p_decode_2_.isReadable())
|
||||
{
|
||||
p_decode_2_.resetReaderIndex();
|
||||
return;
|
||||
}
|
||||
|
||||
abyte[i] = p_decode_2_.readByte();
|
||||
|
||||
if (abyte[i] >= 0)
|
||||
{
|
||||
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.wrappedBuffer(abyte));
|
||||
|
||||
try
|
||||
{
|
||||
int j = packetbuffer.readVarIntFromBuffer();
|
||||
|
||||
if (p_decode_2_.readableBytes() >= j)
|
||||
{
|
||||
p_decode_3_.add(p_decode_2_.readBytes(j));
|
||||
return;
|
||||
}
|
||||
|
||||
p_decode_2_.resetReaderIndex();
|
||||
}
|
||||
finally
|
||||
{
|
||||
packetbuffer.release();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new CorruptedFrameException("length wider than 21-bit");
|
||||
}
|
||||
public class PacketSplitter extends ByteToMessageDecoder {
|
||||
protected void decode(ChannelHandlerContext context, ByteBuf buffer, List<Object> output) throws Exception {
|
||||
buffer.markReaderIndex();
|
||||
byte[] data = new byte[3];
|
||||
for(int z = 0; z < data.length; z++) {
|
||||
if(!buffer.isReadable()) {
|
||||
buffer.resetReaderIndex();
|
||||
return;
|
||||
}
|
||||
data[z] = buffer.readByte();
|
||||
if(data[z] < 0)
|
||||
continue;
|
||||
PacketBuffer pbuf = new PacketBuffer(Unpooled.wrappedBuffer(data));
|
||||
try {
|
||||
int len = pbuf.readVarInt();
|
||||
if(buffer.readableBytes() >= len) {
|
||||
output.add(buffer.readBytes(len));
|
||||
return;
|
||||
}
|
||||
buffer.resetReaderIndex();
|
||||
}
|
||||
finally {
|
||||
pbuf.release();
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new CorruptedFrameException("length wider than 21-bit");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ public abstract class APacketVarInt<T> implements Packet<T> {
|
|||
}
|
||||
|
||||
public final void readPacketData(PacketBuffer buf) throws IOException {
|
||||
this.value = buf.readVarIntFromBuffer();
|
||||
this.value = buf.readVarInt();
|
||||
}
|
||||
|
||||
public final void writePacketData(PacketBuffer buf) throws IOException {
|
||||
buf.writeVarIntToBuffer(this.value);
|
||||
buf.writeVarInt(this.value);
|
||||
}
|
||||
|
||||
public final int getValue() {
|
||||
|
|
|
@ -29,13 +29,13 @@ public class CPacketAction implements Packet<IPlayer>
|
|||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.action = buf.readEnumValue(Action.class);
|
||||
this.auxData = buf.readVarIntFromBuffer();
|
||||
this.auxData = buf.readVarInt();
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeEnumValue(this.action);
|
||||
buf.writeVarIntToBuffer(this.auxData);
|
||||
buf.writeVarInt(this.auxData);
|
||||
}
|
||||
|
||||
public void processPacket(IPlayer handler)
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
package common.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import common.network.IPlayer;
|
||||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class CPacketBook implements Packet<IPlayer>
|
||||
{
|
||||
private String[] pages;
|
||||
|
||||
public CPacketBook()
|
||||
{
|
||||
}
|
||||
|
||||
public CPacketBook(String[] pages)
|
||||
{
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
int pages = (int)buf.readByte();
|
||||
if(pages > 50) {
|
||||
this.pages = new String[0];
|
||||
return;
|
||||
}
|
||||
this.pages = new String[pages];
|
||||
for(int z = 0; z < pages; z++) {
|
||||
this.pages[z] = buf.readStringFromBuffer(1024);
|
||||
}
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeByte(this.pages.length);
|
||||
for(int z = 0; z < this.pages.length; z++) {
|
||||
buf.writeString(this.pages[z]);
|
||||
}
|
||||
}
|
||||
|
||||
public void processPacket(IPlayer handler)
|
||||
{
|
||||
handler.processBook(this);
|
||||
}
|
||||
|
||||
public String[] getPages()
|
||||
{
|
||||
return this.pages;
|
||||
}
|
||||
}
|
|
@ -30,13 +30,13 @@ public class CPacketCheat implements Packet<IPlayer>
|
|||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.stack = buf.readItemStackFromBuffer();
|
||||
this.stack = buf.readItemStack();
|
||||
this.slot = buf.readByte();
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeItemStackToBuffer(this.stack);
|
||||
buf.writeItemStack(this.stack);
|
||||
buf.writeByte(this.slot);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public class CPacketClick implements Packet<IPlayer>
|
|||
this.usedButton = buf.readByte();
|
||||
this.actionNumber = buf.readShort();
|
||||
this.mode = buf.readByte();
|
||||
this.clickedItem = buf.readItemStackFromBuffer();
|
||||
this.clickedItem = buf.readItemStack();
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
|
@ -63,7 +63,7 @@ public class CPacketClick implements Packet<IPlayer>
|
|||
buf.writeByte(this.usedButton);
|
||||
buf.writeShort(this.actionNumber);
|
||||
buf.writeByte(this.mode);
|
||||
buf.writeItemStackToBuffer(this.clickedItem);
|
||||
buf.writeItemStack(this.clickedItem);
|
||||
}
|
||||
|
||||
public int getWindowId()
|
||||
|
|
|
@ -26,8 +26,8 @@ public class CPacketComplete implements Packet<IPlayer>
|
|||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.message = buf.readStringFromBuffer(32767);
|
||||
this.entityId = buf.readVarIntFromBuffer();
|
||||
this.message = buf.readString(32767);
|
||||
this.entityId = buf.readVarInt();
|
||||
if(buf.readBoolean())
|
||||
this.position = buf.readBlockPos();
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class CPacketComplete implements Packet<IPlayer>
|
|||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeString(this.message.length() > 32767 ? this.message.substring(0, 32767) : this.message);
|
||||
buf.writeVarIntToBuffer(this.entityId);
|
||||
buf.writeVarInt(this.entityId);
|
||||
buf.writeBoolean(this.position != null);
|
||||
if(this.position != null)
|
||||
buf.writeBlockPos(this.position);
|
||||
|
|
|
@ -23,12 +23,12 @@ public class CPacketForm implements Packet<IPlayer>
|
|||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.id = buf.readVarIntFromBuffer();
|
||||
this.id = buf.readVarInt();
|
||||
if(!buf.readBoolean()) {
|
||||
this.data = null;
|
||||
return;
|
||||
}
|
||||
this.data = new Object[buf.readVarIntFromBuffer()];
|
||||
this.data = new Object[buf.readVarInt()];
|
||||
for(int z = 0; z < this.data.length; z++) {
|
||||
Object obj;
|
||||
switch(buf.readByte()) {
|
||||
|
@ -36,10 +36,10 @@ public class CPacketForm implements Packet<IPlayer>
|
|||
obj = buf.readBoolean();
|
||||
break;
|
||||
case 1:
|
||||
obj = buf.readVarIntFromBuffer();
|
||||
obj = buf.readVarInt();
|
||||
break;
|
||||
default:
|
||||
obj = buf.readStringFromBuffer(256);
|
||||
obj = buf.readString(256);
|
||||
break;
|
||||
}
|
||||
this.data[z] = obj;
|
||||
|
@ -48,11 +48,11 @@ public class CPacketForm implements Packet<IPlayer>
|
|||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.id);
|
||||
buf.writeVarInt(this.id);
|
||||
buf.writeBoolean(this.data != null);
|
||||
if(this.data == null)
|
||||
return;
|
||||
buf.writeVarIntToBuffer(this.data.length);
|
||||
buf.writeVarInt(this.data.length);
|
||||
for(int z = 0; z < this.data.length; z++) {
|
||||
Object obj = this.data[z];
|
||||
if(obj instanceof Boolean) {
|
||||
|
@ -61,7 +61,7 @@ public class CPacketForm implements Packet<IPlayer>
|
|||
}
|
||||
else if(obj instanceof Integer) {
|
||||
buf.writeByte(1);
|
||||
buf.writeVarIntToBuffer((Integer)obj);
|
||||
buf.writeVarInt((Integer)obj);
|
||||
}
|
||||
else {
|
||||
buf.writeByte(2);
|
||||
|
|
|
@ -24,7 +24,7 @@ public class CPacketMessage implements Packet<IPlayer>
|
|||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.type = buf.readEnumValue(Type.class);
|
||||
this.message = buf.readStringFromBuffer(this.type.length);
|
||||
this.message = buf.readString(this.type.length);
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
|
|
|
@ -42,7 +42,7 @@ public class CPacketPlace implements Packet<IPlayer>
|
|||
{
|
||||
this.position = buf.readBlockPos();
|
||||
this.placedBlockDirection = buf.readUnsignedByte();
|
||||
this.stack = buf.readItemStackFromBuffer();
|
||||
this.stack = buf.readItemStack();
|
||||
this.facingX = (float)buf.readUnsignedByte() / 16.0F;
|
||||
this.facingY = (float)buf.readUnsignedByte() / 16.0F;
|
||||
this.facingZ = (float)buf.readUnsignedByte() / 16.0F;
|
||||
|
@ -52,7 +52,7 @@ public class CPacketPlace implements Packet<IPlayer>
|
|||
{
|
||||
buf.writeBlockPos(this.position);
|
||||
buf.writeByte(this.placedBlockDirection);
|
||||
buf.writeItemStackToBuffer(this.stack);
|
||||
buf.writeItemStack(this.stack);
|
||||
buf.writeByte((int)(this.facingX * 16.0F));
|
||||
buf.writeByte((int)(this.facingY * 16.0F));
|
||||
buf.writeByte((int)(this.facingZ * 16.0F));
|
||||
|
|
|
@ -85,108 +85,4 @@ public class CPacketPlayer implements Packet<IPlayer>
|
|||
{
|
||||
this.moving = isMoving;
|
||||
}
|
||||
|
||||
public static class C04PacketPlayerPosition extends CPacketPlayer
|
||||
{
|
||||
public C04PacketPlayerPosition()
|
||||
{
|
||||
this.moving = true;
|
||||
}
|
||||
|
||||
public C04PacketPlayerPosition(double posX, double posY, double posZ, boolean isOnGround)
|
||||
{
|
||||
this.x = posX;
|
||||
this.y = posY;
|
||||
this.z = posZ;
|
||||
this.onGround = isOnGround;
|
||||
this.moving = true;
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.x = buf.readDouble();
|
||||
this.y = buf.readDouble();
|
||||
this.z = buf.readDouble();
|
||||
super.readPacketData(buf);
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeDouble(this.x);
|
||||
buf.writeDouble(this.y);
|
||||
buf.writeDouble(this.z);
|
||||
super.writePacketData(buf);
|
||||
}
|
||||
}
|
||||
|
||||
public static class C05PacketPlayerLook extends CPacketPlayer
|
||||
{
|
||||
public C05PacketPlayerLook()
|
||||
{
|
||||
this.rotating = true;
|
||||
}
|
||||
|
||||
public C05PacketPlayerLook(float playerYaw, float playerPitch, boolean isOnGround)
|
||||
{
|
||||
this.yaw = playerYaw;
|
||||
this.pitch = playerPitch;
|
||||
this.onGround = isOnGround;
|
||||
this.rotating = true;
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.yaw = buf.readFloat();
|
||||
this.pitch = buf.readFloat();
|
||||
super.readPacketData(buf);
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeFloat(this.yaw);
|
||||
buf.writeFloat(this.pitch);
|
||||
super.writePacketData(buf);
|
||||
}
|
||||
}
|
||||
|
||||
public static class C06PacketPlayerPosLook extends CPacketPlayer
|
||||
{
|
||||
public C06PacketPlayerPosLook()
|
||||
{
|
||||
this.moving = true;
|
||||
this.rotating = true;
|
||||
}
|
||||
|
||||
public C06PacketPlayerPosLook(double playerX, double playerY, double playerZ, float playerYaw, float playerPitch, boolean playerIsOnGround)
|
||||
{
|
||||
this.x = playerX;
|
||||
this.y = playerY;
|
||||
this.z = playerZ;
|
||||
this.yaw = playerYaw;
|
||||
this.pitch = playerPitch;
|
||||
this.onGround = playerIsOnGround;
|
||||
this.rotating = true;
|
||||
this.moving = true;
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.x = buf.readDouble();
|
||||
this.y = buf.readDouble();
|
||||
this.z = buf.readDouble();
|
||||
this.yaw = buf.readFloat();
|
||||
this.pitch = buf.readFloat();
|
||||
super.readPacketData(buf);
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeDouble(this.x);
|
||||
buf.writeDouble(this.y);
|
||||
buf.writeDouble(this.z);
|
||||
buf.writeFloat(this.yaw);
|
||||
buf.writeFloat(this.pitch);
|
||||
super.writePacketData(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
35
common/src/common/packet/CPacketPlayerLook.java
Normal file
35
common/src/common/packet/CPacketPlayerLook.java
Normal file
|
@ -0,0 +1,35 @@
|
|||
package common.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class CPacketPlayerLook extends CPacketPlayer
|
||||
{
|
||||
public CPacketPlayerLook()
|
||||
{
|
||||
this.rotating = true;
|
||||
}
|
||||
|
||||
public CPacketPlayerLook(float playerYaw, float playerPitch, boolean isOnGround)
|
||||
{
|
||||
this.yaw = playerYaw;
|
||||
this.pitch = playerPitch;
|
||||
this.onGround = isOnGround;
|
||||
this.rotating = true;
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.yaw = buf.readFloat();
|
||||
this.pitch = buf.readFloat();
|
||||
super.readPacketData(buf);
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeFloat(this.yaw);
|
||||
buf.writeFloat(this.pitch);
|
||||
super.writePacketData(buf);
|
||||
}
|
||||
}
|
46
common/src/common/packet/CPacketPlayerPosLook.java
Normal file
46
common/src/common/packet/CPacketPlayerPosLook.java
Normal file
|
@ -0,0 +1,46 @@
|
|||
package common.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class CPacketPlayerPosLook extends CPacketPlayer
|
||||
{
|
||||
public CPacketPlayerPosLook()
|
||||
{
|
||||
this.moving = true;
|
||||
this.rotating = true;
|
||||
}
|
||||
|
||||
public CPacketPlayerPosLook(double playerX, double playerY, double playerZ, float playerYaw, float playerPitch, boolean playerIsOnGround)
|
||||
{
|
||||
this.x = playerX;
|
||||
this.y = playerY;
|
||||
this.z = playerZ;
|
||||
this.yaw = playerYaw;
|
||||
this.pitch = playerPitch;
|
||||
this.onGround = playerIsOnGround;
|
||||
this.rotating = true;
|
||||
this.moving = true;
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.x = buf.readDouble();
|
||||
this.y = buf.readDouble();
|
||||
this.z = buf.readDouble();
|
||||
this.yaw = buf.readFloat();
|
||||
this.pitch = buf.readFloat();
|
||||
super.readPacketData(buf);
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeDouble(this.x);
|
||||
buf.writeDouble(this.y);
|
||||
buf.writeDouble(this.z);
|
||||
buf.writeFloat(this.yaw);
|
||||
buf.writeFloat(this.pitch);
|
||||
super.writePacketData(buf);
|
||||
}
|
||||
}
|
38
common/src/common/packet/CPacketPlayerPosition.java
Normal file
38
common/src/common/packet/CPacketPlayerPosition.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package common.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class CPacketPlayerPosition extends CPacketPlayer
|
||||
{
|
||||
public CPacketPlayerPosition()
|
||||
{
|
||||
this.moving = true;
|
||||
}
|
||||
|
||||
public CPacketPlayerPosition(double posX, double posY, double posZ, boolean isOnGround)
|
||||
{
|
||||
this.x = posX;
|
||||
this.y = posY;
|
||||
this.z = posZ;
|
||||
this.onGround = isOnGround;
|
||||
this.moving = true;
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.x = buf.readDouble();
|
||||
this.y = buf.readDouble();
|
||||
this.z = buf.readDouble();
|
||||
super.readPacketData(buf);
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeDouble(this.x);
|
||||
buf.writeDouble(this.y);
|
||||
buf.writeDouble(this.z);
|
||||
super.writePacketData(buf);
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ public class CPacketSign implements Packet<IPlayer>
|
|||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
this.lines[i] = buf.readStringFromBuffer(50);
|
||||
this.lines[i] = buf.readString(50);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public class CPacketSkin implements Packet<IPlayer> {
|
|||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
if(buf.readBoolean()) {
|
||||
this.texture = null;
|
||||
this.character = buf.readStringFromBuffer(64);
|
||||
this.character = buf.readString(64);
|
||||
}
|
||||
else {
|
||||
this.texture = buf.readByteArray();
|
||||
|
|
|
@ -17,7 +17,7 @@ public class HPacketHandshake implements Packet<IHandshakeHandler> {
|
|||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
this.protocol = buf.readVarIntFromBuffer();
|
||||
this.protocol = buf.readVarInt();
|
||||
int r = buf.readableBytes();
|
||||
if(r > 0) {
|
||||
this.protocol = 0;
|
||||
|
@ -27,7 +27,7 @@ public class HPacketHandshake implements Packet<IHandshakeHandler> {
|
|||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException {
|
||||
buf.writeVarIntToBuffer(this.protocol);
|
||||
buf.writeVarInt(this.protocol);
|
||||
}
|
||||
|
||||
public void processPacket(IHandshakeHandler handler) {
|
||||
|
|
|
@ -10,7 +10,7 @@ public class LPacketLogin implements Packet<ILoginHandler> {
|
|||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
buf.readStringFromBuffer(16);
|
||||
buf.readString(16);
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException {
|
||||
|
|
|
@ -29,9 +29,9 @@ public class LPacketPasswordResponse implements Packet<ILoginHandler>
|
|||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.user = buf.readStringFromBuffer(IPlayer.MAX_USER_LENGTH);
|
||||
this.access = buf.readStringFromBuffer(IPlayer.MAX_PASS_LENGTH);
|
||||
this.password = buf.readStringFromBuffer(IPlayer.MAX_PASS_LENGTH);
|
||||
this.user = buf.readString(IPlayer.MAX_USER_LENGTH);
|
||||
this.access = buf.readString(IPlayer.MAX_PASS_LENGTH);
|
||||
this.password = buf.readString(IPlayer.MAX_PASS_LENGTH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,7 @@ public class RPacketDisconnect implements Packet<IClientLoginHandler>
|
|||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.reason = buf.readStringFromBuffer(8192);
|
||||
this.reason = buf.readString(8192);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,208 +0,0 @@
|
|||
package common.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import common.entity.Entity;
|
||||
import common.network.IClientPlayer;
|
||||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
import common.world.World;
|
||||
|
||||
public class S14PacketEntity implements Packet<IClientPlayer>
|
||||
{
|
||||
protected int entityId;
|
||||
protected byte posX;
|
||||
protected byte posY;
|
||||
protected byte posZ;
|
||||
protected byte yaw;
|
||||
protected byte pitch;
|
||||
protected boolean onGround;
|
||||
protected boolean rotation;
|
||||
|
||||
public S14PacketEntity()
|
||||
{
|
||||
}
|
||||
|
||||
public S14PacketEntity(int entityIdIn)
|
||||
{
|
||||
this.entityId = entityIdIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readVarIntFromBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.entityId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(IClientPlayer handler)
|
||||
{
|
||||
handler.handleEntityMovement(this);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Entity_" + super.toString();
|
||||
}
|
||||
|
||||
public Entity getEntity(World worldIn)
|
||||
{
|
||||
return worldIn.getEntityByID(this.entityId);
|
||||
}
|
||||
|
||||
public byte getPosX()
|
||||
{
|
||||
return this.posX;
|
||||
}
|
||||
|
||||
public byte getPosY()
|
||||
{
|
||||
return this.posY;
|
||||
}
|
||||
|
||||
public byte getPosZ()
|
||||
{
|
||||
return this.posZ;
|
||||
}
|
||||
|
||||
public byte getYaw()
|
||||
{
|
||||
return this.yaw;
|
||||
}
|
||||
|
||||
public byte getPitch()
|
||||
{
|
||||
return this.pitch;
|
||||
}
|
||||
|
||||
public boolean hasRotations()
|
||||
{
|
||||
return this.rotation;
|
||||
}
|
||||
|
||||
public boolean getOnGround()
|
||||
{
|
||||
return this.onGround;
|
||||
}
|
||||
|
||||
public static class S15PacketEntityRelMove extends S14PacketEntity
|
||||
{
|
||||
public S15PacketEntityRelMove()
|
||||
{
|
||||
}
|
||||
|
||||
public S15PacketEntityRelMove(int entityIdIn, byte x, byte y, byte z, boolean onGroundIn)
|
||||
{
|
||||
super(entityIdIn);
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
this.posZ = z;
|
||||
this.onGround = onGroundIn;
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
super.readPacketData(buf);
|
||||
this.posX = buf.readByte();
|
||||
this.posY = buf.readByte();
|
||||
this.posZ = buf.readByte();
|
||||
this.onGround = buf.readBoolean();
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
super.writePacketData(buf);
|
||||
buf.writeByte(this.posX);
|
||||
buf.writeByte(this.posY);
|
||||
buf.writeByte(this.posZ);
|
||||
buf.writeBoolean(this.onGround);
|
||||
}
|
||||
}
|
||||
|
||||
public static class S16PacketEntityLook extends S14PacketEntity
|
||||
{
|
||||
public S16PacketEntityLook()
|
||||
{
|
||||
this.rotation = true;
|
||||
}
|
||||
|
||||
public S16PacketEntityLook(int entityIdIn, byte yawIn, byte pitchIn, boolean onGroundIn)
|
||||
{
|
||||
super(entityIdIn);
|
||||
this.yaw = yawIn;
|
||||
this.pitch = pitchIn;
|
||||
this.rotation = true;
|
||||
this.onGround = onGroundIn;
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
super.readPacketData(buf);
|
||||
this.yaw = buf.readByte();
|
||||
this.pitch = buf.readByte();
|
||||
this.onGround = buf.readBoolean();
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
super.writePacketData(buf);
|
||||
buf.writeByte(this.yaw);
|
||||
buf.writeByte(this.pitch);
|
||||
buf.writeBoolean(this.onGround);
|
||||
}
|
||||
}
|
||||
|
||||
public static class S17PacketEntityLookMove extends S14PacketEntity
|
||||
{
|
||||
public S17PacketEntityLookMove()
|
||||
{
|
||||
this.rotation = true;
|
||||
}
|
||||
|
||||
public S17PacketEntityLookMove(int p_i45973_1_, byte p_i45973_2_, byte p_i45973_3_, byte p_i45973_4_, byte p_i45973_5_, byte p_i45973_6_, boolean p_i45973_7_)
|
||||
{
|
||||
super(p_i45973_1_);
|
||||
this.posX = p_i45973_2_;
|
||||
this.posY = p_i45973_3_;
|
||||
this.posZ = p_i45973_4_;
|
||||
this.yaw = p_i45973_5_;
|
||||
this.pitch = p_i45973_6_;
|
||||
this.onGround = p_i45973_7_;
|
||||
this.rotation = true;
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
super.readPacketData(buf);
|
||||
this.posX = buf.readByte();
|
||||
this.posY = buf.readByte();
|
||||
this.posZ = buf.readByte();
|
||||
this.yaw = buf.readByte();
|
||||
this.pitch = buf.readByte();
|
||||
this.onGround = buf.readBoolean();
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
super.writePacketData(buf);
|
||||
buf.writeByte(this.posX);
|
||||
buf.writeByte(this.posY);
|
||||
buf.writeByte(this.posZ);
|
||||
buf.writeByte(this.yaw);
|
||||
buf.writeByte(this.pitch);
|
||||
buf.writeBoolean(this.onGround);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -33,14 +33,14 @@ public class SPacketAnimation implements Packet<IClientPlayer>
|
|||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readVarIntFromBuffer();
|
||||
this.entityId = buf.readVarInt();
|
||||
this.type = buf.readUnsignedByte();
|
||||
// this.par = buf.readVarIntFromBuffer();
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.entityId);
|
||||
buf.writeVarInt(this.entityId);
|
||||
buf.writeByte(this.type);
|
||||
// buf.writeVarIntToBuffer(this.par);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class SPacketBlockAction implements Packet<IClientPlayer>
|
|||
this.blockPosition = buf.readBlockPos();
|
||||
this.instrument = buf.readUnsignedByte();
|
||||
this.pitch = buf.readUnsignedByte();
|
||||
this.block = BlockRegistry.getBlockById(buf.readVarIntFromBuffer() & 4095);
|
||||
this.block = BlockRegistry.getBlockById(buf.readVarInt() & 4095);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,7 @@ public class SPacketBlockAction implements Packet<IClientPlayer>
|
|||
buf.writeBlockPos(this.blockPosition);
|
||||
buf.writeByte(this.instrument);
|
||||
buf.writeByte(this.pitch);
|
||||
buf.writeVarIntToBuffer(BlockRegistry.getIdFromBlock(this.block) & 4095);
|
||||
buf.writeVarInt(BlockRegistry.getIdFromBlock(this.block) & 4095);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,7 +29,7 @@ public class SPacketBlockBreakAnim implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.breakerId = buf.readVarIntFromBuffer();
|
||||
this.breakerId = buf.readVarInt();
|
||||
this.position = buf.readBlockPos();
|
||||
this.progress = buf.readUnsignedByte();
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class SPacketBlockBreakAnim implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.breakerId);
|
||||
buf.writeVarInt(this.breakerId);
|
||||
buf.writeBlockPos(this.position);
|
||||
buf.writeByte(this.progress);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class SPacketBlockChange implements Packet<IClientPlayer>
|
|||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.blockPosition = buf.readBlockPos();
|
||||
this.blockState = (State)BlockRegistry.STATEMAP.getByValue(buf.readVarIntFromBuffer());
|
||||
this.blockState = (State)BlockRegistry.STATEMAP.getByValue(buf.readVarInt());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,7 +40,7 @@ public class SPacketBlockChange implements Packet<IClientPlayer>
|
|||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeBlockPos(this.blockPosition);
|
||||
buf.writeVarIntToBuffer(BlockRegistry.STATEMAP.get(this.blockState));
|
||||
buf.writeVarInt(BlockRegistry.STATEMAP.get(this.blockState));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,12 +23,12 @@ public class SPacketCamera implements Packet<IClientPlayer>
|
|||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readVarIntFromBuffer();
|
||||
this.entityId = buf.readVarInt();
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.entityId);
|
||||
buf.writeVarInt(this.entityId);
|
||||
}
|
||||
|
||||
public void processPacket(IClientPlayer handler)
|
||||
|
|
|
@ -7,26 +7,26 @@ import common.network.Packet;
|
|||
import common.network.PacketBuffer;
|
||||
import common.util.ExtMath;
|
||||
|
||||
public class S2BPacketChangeGameState implements Packet<IClientPlayer>
|
||||
public class SPacketChangeGameState implements Packet<IClientPlayer>
|
||||
{
|
||||
private Action action;
|
||||
private int param;
|
||||
|
||||
public S2BPacketChangeGameState()
|
||||
public SPacketChangeGameState()
|
||||
{
|
||||
}
|
||||
|
||||
public S2BPacketChangeGameState(Action action)
|
||||
public SPacketChangeGameState(Action action)
|
||||
{
|
||||
this(action, 0);
|
||||
}
|
||||
|
||||
public S2BPacketChangeGameState(Action action, float param)
|
||||
public SPacketChangeGameState(Action action, float param)
|
||||
{
|
||||
this(action, (int)(param * 1000.0f));
|
||||
}
|
||||
|
||||
public S2BPacketChangeGameState(Action action, int param)
|
||||
public SPacketChangeGameState(Action action, int param)
|
||||
{
|
||||
this.action = action;
|
||||
this.param = param;
|
||||
|
@ -35,13 +35,13 @@ public class S2BPacketChangeGameState implements Packet<IClientPlayer>
|
|||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.action = buf.readEnumValue(Action.class);
|
||||
this.param = buf.readVarIntFromBuffer();
|
||||
this.param = buf.readVarInt();
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeEnumValue(this.action);
|
||||
buf.writeVarIntToBuffer(this.param);
|
||||
buf.writeVarInt(this.param);
|
||||
}
|
||||
|
||||
public void processPacket(IClientPlayer handler)
|
|
@ -40,31 +40,31 @@ public class SPacketCharacterList implements Packet<IClientPlayer> {
|
|||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
int n = buf.readVarIntFromBuffer();
|
||||
int n = buf.readVarInt();
|
||||
for(int z = 0; z < n; z++) {
|
||||
int id = buf.readVarIntFromBuffer();
|
||||
String name = buf.readStringFromBuffer(IPlayer.MAX_NICK_LENGTH);
|
||||
int id = buf.readVarInt();
|
||||
String name = buf.readString(IPlayer.MAX_NICK_LENGTH);
|
||||
if(name.isEmpty()) {
|
||||
this.players.put(id, null);
|
||||
continue;
|
||||
}
|
||||
String info = buf.readStringFromBuffer(IPlayer.MAX_INFO_LENGTH);
|
||||
String info = buf.readString(IPlayer.MAX_INFO_LENGTH);
|
||||
info = info.isEmpty() ? null : info;
|
||||
Alignment align = buf.readEnumValue(Alignment.class);
|
||||
String dim = buf.readStringFromBuffer(256);
|
||||
String dim = buf.readString(256);
|
||||
BlockPos pos = buf.readBlockPos();
|
||||
String type = buf.readStringFromBuffer(256);
|
||||
int level = buf.readVarIntFromBuffer();
|
||||
String type = buf.readString(256);
|
||||
int level = buf.readVarInt();
|
||||
this.players.put(id, new PlayerCharacter(name, info, align, dim, pos, type, level));
|
||||
}
|
||||
this.selected = buf.readVarIntFromBuffer();
|
||||
this.selected = buf.readVarInt();
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException {
|
||||
buf.writeVarIntToBuffer(this.players.size());
|
||||
buf.writeVarInt(this.players.size());
|
||||
for(Entry<Integer, PlayerCharacter> data : this.players.entrySet()) {
|
||||
PlayerCharacter chr = data.getValue();
|
||||
buf.writeVarIntToBuffer(data.getKey());
|
||||
buf.writeVarInt(data.getKey());
|
||||
if(chr == null) {
|
||||
buf.writeString("");
|
||||
continue;
|
||||
|
@ -75,9 +75,9 @@ public class SPacketCharacterList implements Packet<IClientPlayer> {
|
|||
buf.writeString(chr.dim);
|
||||
buf.writeBlockPos(chr.pos);
|
||||
buf.writeString(chr.type);
|
||||
buf.writeVarIntToBuffer(chr.level);
|
||||
buf.writeVarInt(chr.level);
|
||||
}
|
||||
buf.writeVarIntToBuffer(this.selected);
|
||||
buf.writeVarInt(this.selected);
|
||||
}
|
||||
|
||||
public void processPacket(IClientPlayer handler) {
|
||||
|
|
|
@ -34,9 +34,9 @@ public class SPacketChunkData implements Packet<IClientPlayer>
|
|||
this.biomes = buf.readBoolean();
|
||||
this.extractedData = new SPacketChunkData.Extracted();
|
||||
this.extractedData.data = buf.readByteArray();
|
||||
this.extractedData.extend = new int[buf.readVarIntFromBuffer()];
|
||||
this.extractedData.extend = new int[buf.readVarInt()];
|
||||
for(int z = 0; z < this.extractedData.extend.length; z++) {
|
||||
this.extractedData.extend[z] = buf.readVarIntFromBuffer();
|
||||
this.extractedData.extend[z] = buf.readVarInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,9 @@ public class SPacketChunkData implements Packet<IClientPlayer>
|
|||
buf.writeInt(this.chunkZ);
|
||||
buf.writeBoolean(this.biomes);
|
||||
buf.writeByteArray(this.extractedData.data);
|
||||
buf.writeVarIntToBuffer(this.extractedData.extend.length);
|
||||
buf.writeVarInt(this.extractedData.extend.length);
|
||||
for(int z = 0; z < this.extractedData.extend.length; z++) {
|
||||
buf.writeVarIntToBuffer(this.extractedData.extend[z]);
|
||||
buf.writeVarInt(this.extractedData.extend[z]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,15 +6,15 @@ import common.network.IClientPlayer;
|
|||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class S2EPacketCloseWindow implements Packet<IClientPlayer>
|
||||
public class SPacketCloseWindow implements Packet<IClientPlayer>
|
||||
{
|
||||
private int windowId;
|
||||
|
||||
public S2EPacketCloseWindow()
|
||||
public SPacketCloseWindow()
|
||||
{
|
||||
}
|
||||
|
||||
public S2EPacketCloseWindow(int windowIdIn)
|
||||
public SPacketCloseWindow(int windowIdIn)
|
||||
{
|
||||
this.windowId = windowIdIn;
|
||||
}
|
|
@ -26,8 +26,8 @@ public class SPacketCollectItem implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.collectedItemEntityId = buf.readVarIntFromBuffer();
|
||||
this.entityId = buf.readVarIntFromBuffer();
|
||||
this.collectedItemEntityId = buf.readVarInt();
|
||||
this.entityId = buf.readVarInt();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,8 +35,8 @@ public class SPacketCollectItem implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.collectedItemEntityId);
|
||||
buf.writeVarIntToBuffer(this.entityId);
|
||||
buf.writeVarInt(this.collectedItemEntityId);
|
||||
buf.writeVarInt(this.entityId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,17 +6,17 @@ import common.network.IClientPlayer;
|
|||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class S32PacketConfirmTransaction implements Packet<IClientPlayer>
|
||||
public class SPacketConfirmTransaction implements Packet<IClientPlayer>
|
||||
{
|
||||
private int windowId;
|
||||
private short actionNumber;
|
||||
private boolean matching;
|
||||
|
||||
public S32PacketConfirmTransaction()
|
||||
public SPacketConfirmTransaction()
|
||||
{
|
||||
}
|
||||
|
||||
public S32PacketConfirmTransaction(int windowIdIn, short actionNumberIn, boolean matching)
|
||||
public SPacketConfirmTransaction(int windowIdIn, short actionNumberIn, boolean matching)
|
||||
{
|
||||
this.windowId = windowIdIn;
|
||||
this.actionNumber = actionNumberIn;
|
|
@ -24,11 +24,11 @@ public class SPacketDestroyEntities implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityIDs = new int[buf.readVarIntFromBuffer()];
|
||||
this.entityIDs = new int[buf.readVarInt()];
|
||||
|
||||
for (int i = 0; i < this.entityIDs.length; ++i)
|
||||
{
|
||||
this.entityIDs[i] = buf.readVarIntFromBuffer();
|
||||
this.entityIDs[i] = buf.readVarInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,11 +37,11 @@ public class SPacketDestroyEntities implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.entityIDs.length);
|
||||
buf.writeVarInt(this.entityIDs.length);
|
||||
|
||||
for (int i = 0; i < this.entityIDs.length; ++i)
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.entityIDs[i]);
|
||||
buf.writeVarInt(this.entityIDs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ public class SPacketDimensionName implements Packet<IClientPlayer> {
|
|||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
this.fullName = buf.readStringFromBuffer(64);
|
||||
this.customName = buf.readStringFromBuffer(64);
|
||||
this.fullName = buf.readString(64);
|
||||
this.customName = buf.readString(64);
|
||||
this.customName = this.customName.isEmpty() ? null : this.customName;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public class SPacketDisconnect implements Packet<IClientPlayer> {
|
|||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
this.message = buf.readStringFromBuffer(2048);
|
||||
this.message = buf.readString(2048);
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException {
|
||||
|
|
|
@ -31,36 +31,36 @@ public class SPacketDisplayForm implements Packet<IClientPlayer>
|
|||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.id = buf.readVarIntFromBuffer();
|
||||
this.title = buf.readStringFromBuffer(256);
|
||||
this.data = new Triplet[buf.readVarIntFromBuffer()];
|
||||
this.id = buf.readVarInt();
|
||||
this.title = buf.readString(256);
|
||||
this.data = new Triplet[buf.readVarInt()];
|
||||
for(int z = 0; z < this.data.length; z++) {
|
||||
String name = buf.readStringFromBuffer(64);
|
||||
String name = buf.readString(64);
|
||||
Object obj;
|
||||
switch(buf.readByte()) {
|
||||
case 0:
|
||||
obj = buf.readBoolean();
|
||||
break;
|
||||
case 1:
|
||||
String[] strs = new String[buf.readVarIntFromBuffer()];
|
||||
String[] strs = new String[buf.readVarInt()];
|
||||
obj = strs;
|
||||
for(int n = 0; n < strs.length; n++) {
|
||||
strs[n] = buf.readStringFromBuffer(128);
|
||||
strs[n] = buf.readString(128);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
obj = buf.readStringFromBuffer(256);
|
||||
obj = buf.readString(256);
|
||||
break;
|
||||
}
|
||||
this.data[z] = new Triplet<String, Object, Integer>(name, obj, buf.readVarIntFromBuffer());
|
||||
this.data[z] = new Triplet<String, Object, Integer>(name, obj, buf.readVarInt());
|
||||
}
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.id);
|
||||
buf.writeVarInt(this.id);
|
||||
buf.writeString(this.title);
|
||||
buf.writeVarIntToBuffer(this.data.length);
|
||||
buf.writeVarInt(this.data.length);
|
||||
for(int z = 0; z < this.data.length; z++) {
|
||||
buf.writeString(this.data[z].first);
|
||||
Object obj = this.data[z].second;
|
||||
|
@ -71,7 +71,7 @@ public class SPacketDisplayForm implements Packet<IClientPlayer>
|
|||
else if(obj instanceof String[]) {
|
||||
buf.writeByte(1);
|
||||
String[] strs = (String[])obj;
|
||||
buf.writeVarIntToBuffer(strs.length);
|
||||
buf.writeVarInt(strs.length);
|
||||
for(int n = 0; n < strs.length; n++) {
|
||||
buf.writeString(strs[n]);
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public class SPacketDisplayForm implements Packet<IClientPlayer>
|
|||
buf.writeByte(2);
|
||||
buf.writeString((String)obj);
|
||||
}
|
||||
buf.writeVarIntToBuffer(this.data[z].third);
|
||||
buf.writeVarInt(this.data[z].third);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,15 +7,15 @@ import common.network.Packet;
|
|||
import common.network.PacketBuffer;
|
||||
import common.util.BlockPos;
|
||||
|
||||
public class S28PacketEffect implements Packet<IClientPlayer> {
|
||||
public class SPacketEffect implements Packet<IClientPlayer> {
|
||||
private int soundType;
|
||||
private BlockPos soundPos;
|
||||
private int soundData;
|
||||
|
||||
public S28PacketEffect() {
|
||||
public SPacketEffect() {
|
||||
}
|
||||
|
||||
public S28PacketEffect(int soundTypeIn, BlockPos soundPosIn, int soundDataIn) {
|
||||
public SPacketEffect(int soundTypeIn, BlockPos soundPosIn, int soundDataIn) {
|
||||
this.soundType = soundTypeIn;
|
||||
this.soundPos = soundPosIn;
|
||||
this.soundData = soundDataIn;
|
99
common/src/common/packet/SPacketEntity.java
Executable file
99
common/src/common/packet/SPacketEntity.java
Executable file
|
@ -0,0 +1,99 @@
|
|||
package common.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import common.entity.Entity;
|
||||
import common.network.IClientPlayer;
|
||||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
import common.world.World;
|
||||
|
||||
public class SPacketEntity implements Packet<IClientPlayer>
|
||||
{
|
||||
protected int entityId;
|
||||
protected byte posX;
|
||||
protected byte posY;
|
||||
protected byte posZ;
|
||||
protected byte yaw;
|
||||
protected byte pitch;
|
||||
protected boolean onGround;
|
||||
protected boolean rotation;
|
||||
|
||||
public SPacketEntity()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketEntity(int entityIdIn)
|
||||
{
|
||||
this.entityId = entityIdIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the raw packet data from the data stream.
|
||||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readVarInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the raw packet data to the data stream.
|
||||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarInt(this.entityId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes this Packet on to the NetHandler for processing.
|
||||
*/
|
||||
public void processPacket(IClientPlayer handler)
|
||||
{
|
||||
handler.handleEntityMovement(this);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Entity_" + super.toString();
|
||||
}
|
||||
|
||||
public Entity getEntity(World worldIn)
|
||||
{
|
||||
return worldIn.getEntityByID(this.entityId);
|
||||
}
|
||||
|
||||
public byte getPosX()
|
||||
{
|
||||
return this.posX;
|
||||
}
|
||||
|
||||
public byte getPosY()
|
||||
{
|
||||
return this.posY;
|
||||
}
|
||||
|
||||
public byte getPosZ()
|
||||
{
|
||||
return this.posZ;
|
||||
}
|
||||
|
||||
public byte getYaw()
|
||||
{
|
||||
return this.yaw;
|
||||
}
|
||||
|
||||
public byte getPitch()
|
||||
{
|
||||
return this.pitch;
|
||||
}
|
||||
|
||||
public boolean hasRotations()
|
||||
{
|
||||
return this.rotation;
|
||||
}
|
||||
|
||||
public boolean getOnGround()
|
||||
{
|
||||
return this.onGround;
|
||||
}
|
||||
}
|
|
@ -7,17 +7,17 @@ import common.network.IClientPlayer;
|
|||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class S1BPacketEntityAttach implements Packet<IClientPlayer>
|
||||
public class SPacketEntityAttach implements Packet<IClientPlayer>
|
||||
{
|
||||
private int leash;
|
||||
private int entityId;
|
||||
private int vehicleEntityId;
|
||||
|
||||
public S1BPacketEntityAttach()
|
||||
public SPacketEntityAttach()
|
||||
{
|
||||
}
|
||||
|
||||
public S1BPacketEntityAttach(int leashIn, Entity entityIn, Entity vehicle)
|
||||
public SPacketEntityAttach(int leashIn, Entity entityIn, Entity vehicle)
|
||||
{
|
||||
this.leash = leashIn;
|
||||
this.entityId = entityIn.getId();
|
|
@ -8,7 +8,7 @@ import common.network.PacketBuffer;
|
|||
import common.potion.Potion;
|
||||
import common.potion.PotionEffect;
|
||||
|
||||
public class S1DPacketEntityEffect implements Packet<IClientPlayer>
|
||||
public class SPacketEntityEffect implements Packet<IClientPlayer>
|
||||
{
|
||||
private int entityId;
|
||||
private Potion effectId;
|
||||
|
@ -17,11 +17,11 @@ public class S1DPacketEntityEffect implements Packet<IClientPlayer>
|
|||
private int remaining;
|
||||
private boolean particles;
|
||||
|
||||
public S1DPacketEntityEffect()
|
||||
public SPacketEntityEffect()
|
||||
{
|
||||
}
|
||||
|
||||
public S1DPacketEntityEffect(int entityIdIn, PotionEffect effect)
|
||||
public SPacketEntityEffect(int entityIdIn, PotionEffect effect)
|
||||
{
|
||||
this.entityId = entityIdIn;
|
||||
this.effectId = effect.getPotion();
|
||||
|
@ -45,11 +45,11 @@ public class S1DPacketEntityEffect implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readVarIntFromBuffer();
|
||||
this.entityId = buf.readVarInt();
|
||||
this.effectId = buf.readEnumValue(Potion.class);
|
||||
this.amplifier = buf.readVarIntFromBuffer();
|
||||
this.duration = buf.readVarIntFromBuffer();
|
||||
this.remaining = buf.readVarIntFromBuffer();
|
||||
this.amplifier = buf.readVarInt();
|
||||
this.duration = buf.readVarInt();
|
||||
this.remaining = buf.readVarInt();
|
||||
this.particles = buf.readBoolean();
|
||||
}
|
||||
|
||||
|
@ -58,11 +58,11 @@ public class S1DPacketEntityEffect implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.entityId);
|
||||
buf.writeVarInt(this.entityId);
|
||||
buf.writeEnumValue(this.effectId);
|
||||
buf.writeVarIntToBuffer(this.amplifier);
|
||||
buf.writeVarIntToBuffer(this.duration);
|
||||
buf.writeVarIntToBuffer(this.remaining);
|
||||
buf.writeVarInt(this.amplifier);
|
||||
buf.writeVarInt(this.duration);
|
||||
buf.writeVarInt(this.remaining);
|
||||
buf.writeBoolean(this.particles);
|
||||
}
|
||||
|
|
@ -29,9 +29,9 @@ public class SPacketEntityEquipment implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityID = buf.readVarIntFromBuffer();
|
||||
this.entityID = buf.readVarInt();
|
||||
this.equipmentSlot = buf.readShort();
|
||||
this.itemStack = buf.readItemStackFromBuffer();
|
||||
this.itemStack = buf.readItemStack();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,9 @@ public class SPacketEntityEquipment implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.entityID);
|
||||
buf.writeVarInt(this.entityID);
|
||||
buf.writeShort(this.equipmentSlot);
|
||||
buf.writeItemStackToBuffer(this.itemStack);
|
||||
buf.writeItemStack(this.itemStack);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,16 +8,16 @@ import common.network.Packet;
|
|||
import common.network.PacketBuffer;
|
||||
import common.world.World;
|
||||
|
||||
public class S19PacketEntityHeadLook implements Packet<IClientPlayer>
|
||||
public class SPacketEntityHeadLook implements Packet<IClientPlayer>
|
||||
{
|
||||
private int entityId;
|
||||
private byte yaw;
|
||||
|
||||
public S19PacketEntityHeadLook()
|
||||
public SPacketEntityHeadLook()
|
||||
{
|
||||
}
|
||||
|
||||
public S19PacketEntityHeadLook(Entity entityIn, byte p_i45214_2_)
|
||||
public SPacketEntityHeadLook(Entity entityIn, byte p_i45214_2_)
|
||||
{
|
||||
this.entityId = entityIn.getId();
|
||||
this.yaw = p_i45214_2_;
|
||||
|
@ -28,7 +28,7 @@ public class S19PacketEntityHeadLook implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readVarIntFromBuffer();
|
||||
this.entityId = buf.readVarInt();
|
||||
this.yaw = buf.readByte();
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class S19PacketEntityHeadLook implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.entityId);
|
||||
buf.writeVarInt(this.entityId);
|
||||
buf.writeByte(this.yaw);
|
||||
}
|
||||
|
38
common/src/common/packet/SPacketEntityLook.java
Normal file
38
common/src/common/packet/SPacketEntityLook.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package common.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class SPacketEntityLook extends SPacketEntity
|
||||
{
|
||||
public SPacketEntityLook()
|
||||
{
|
||||
this.rotation = true;
|
||||
}
|
||||
|
||||
public SPacketEntityLook(int entityIdIn, byte yawIn, byte pitchIn, boolean onGroundIn)
|
||||
{
|
||||
super(entityIdIn);
|
||||
this.yaw = yawIn;
|
||||
this.pitch = pitchIn;
|
||||
this.rotation = true;
|
||||
this.onGround = onGroundIn;
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
super.readPacketData(buf);
|
||||
this.yaw = buf.readByte();
|
||||
this.pitch = buf.readByte();
|
||||
this.onGround = buf.readBoolean();
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
super.writePacketData(buf);
|
||||
buf.writeByte(this.yaw);
|
||||
buf.writeByte(this.pitch);
|
||||
buf.writeBoolean(this.onGround);
|
||||
}
|
||||
}
|
47
common/src/common/packet/SPacketEntityLookMove.java
Normal file
47
common/src/common/packet/SPacketEntityLookMove.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
package common.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class SPacketEntityLookMove extends SPacketEntity
|
||||
{
|
||||
public SPacketEntityLookMove()
|
||||
{
|
||||
this.rotation = true;
|
||||
}
|
||||
|
||||
public SPacketEntityLookMove(int p_i45973_1_, byte p_i45973_2_, byte p_i45973_3_, byte p_i45973_4_, byte p_i45973_5_, byte p_i45973_6_, boolean p_i45973_7_)
|
||||
{
|
||||
super(p_i45973_1_);
|
||||
this.posX = p_i45973_2_;
|
||||
this.posY = p_i45973_3_;
|
||||
this.posZ = p_i45973_4_;
|
||||
this.yaw = p_i45973_5_;
|
||||
this.pitch = p_i45973_6_;
|
||||
this.onGround = p_i45973_7_;
|
||||
this.rotation = true;
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
super.readPacketData(buf);
|
||||
this.posX = buf.readByte();
|
||||
this.posY = buf.readByte();
|
||||
this.posZ = buf.readByte();
|
||||
this.yaw = buf.readByte();
|
||||
this.pitch = buf.readByte();
|
||||
this.onGround = buf.readBoolean();
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
super.writePacketData(buf);
|
||||
buf.writeByte(this.posX);
|
||||
buf.writeByte(this.posY);
|
||||
buf.writeByte(this.posZ);
|
||||
buf.writeByte(this.yaw);
|
||||
buf.writeByte(this.pitch);
|
||||
buf.writeBoolean(this.onGround);
|
||||
}
|
||||
}
|
|
@ -8,16 +8,16 @@ import common.network.IClientPlayer;
|
|||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class S1CPacketEntityMetadata implements Packet<IClientPlayer>
|
||||
public class SPacketEntityMetadata implements Packet<IClientPlayer>
|
||||
{
|
||||
private int entityId;
|
||||
private List<DataWatcher.WatchableObject> field_149378_b;
|
||||
|
||||
public S1CPacketEntityMetadata()
|
||||
public SPacketEntityMetadata()
|
||||
{
|
||||
}
|
||||
|
||||
public S1CPacketEntityMetadata(int entityIdIn, DataWatcher p_i45217_2_, boolean p_i45217_3_)
|
||||
public SPacketEntityMetadata(int entityIdIn, DataWatcher p_i45217_2_, boolean p_i45217_3_)
|
||||
{
|
||||
this.entityId = entityIdIn;
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class S1CPacketEntityMetadata implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readVarIntFromBuffer();
|
||||
this.entityId = buf.readVarInt();
|
||||
this.field_149378_b = DataWatcher.readWatchedListFromPacketBuffer(buf);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class S1CPacketEntityMetadata implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.entityId);
|
||||
buf.writeVarInt(this.entityId);
|
||||
DataWatcher.writeWatchedListToPacketBuffer(this.field_149378_b, buf);
|
||||
}
|
||||
|
|
@ -11,22 +11,22 @@ import common.network.IClientPlayer;
|
|||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class S20PacketEntityProperties implements Packet<IClientPlayer>
|
||||
public class SPacketEntityProperties implements Packet<IClientPlayer>
|
||||
{
|
||||
private int entityId;
|
||||
private final List<S20PacketEntityProperties.Snapshot> field_149444_b = Lists.<S20PacketEntityProperties.Snapshot>newArrayList();
|
||||
private final List<SPacketEntityProperties.Snapshot> field_149444_b = Lists.<SPacketEntityProperties.Snapshot>newArrayList();
|
||||
|
||||
public S20PacketEntityProperties()
|
||||
public SPacketEntityProperties()
|
||||
{
|
||||
}
|
||||
|
||||
public S20PacketEntityProperties(int entityIdIn, Collection<AttributeInstance> p_i45236_2_)
|
||||
public SPacketEntityProperties(int entityIdIn, Collection<AttributeInstance> p_i45236_2_)
|
||||
{
|
||||
this.entityId = entityIdIn;
|
||||
|
||||
for (AttributeInstance iattributeinstance : p_i45236_2_)
|
||||
{
|
||||
this.field_149444_b.add(new S20PacketEntityProperties.Snapshot(iattributeinstance.getAttribute().getUnlocalizedName(), iattributeinstance.getBaseValue(), iattributeinstance.getModifiers()));
|
||||
this.field_149444_b.add(new SPacketEntityProperties.Snapshot(iattributeinstance.getAttribute().getUnlocalizedName(), iattributeinstance.getBaseValue(), iattributeinstance.getModifiers()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,15 +35,15 @@ public class S20PacketEntityProperties implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readVarIntFromBuffer();
|
||||
this.entityId = buf.readVarInt();
|
||||
int i = buf.readInt();
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
String s = buf.readStringFromBuffer(64);
|
||||
String s = buf.readString(64);
|
||||
double d0 = buf.readDouble();
|
||||
List<AttributeModifier> list = Lists.<AttributeModifier>newArrayList();
|
||||
int k = buf.readVarIntFromBuffer();
|
||||
int k = buf.readVarInt();
|
||||
|
||||
for (int l = 0; l < k; ++l)
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ public class S20PacketEntityProperties implements Packet<IClientPlayer>
|
|||
list.add(new AttributeModifier(id, "Unknown synced attribute modifier", buf.readDouble(), buf.readBoolean()));
|
||||
}
|
||||
|
||||
this.field_149444_b.add(new S20PacketEntityProperties.Snapshot(s, d0, list));
|
||||
this.field_149444_b.add(new SPacketEntityProperties.Snapshot(s, d0, list));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,14 +60,14 @@ public class S20PacketEntityProperties implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.entityId);
|
||||
buf.writeVarInt(this.entityId);
|
||||
buf.writeInt(this.field_149444_b.size());
|
||||
|
||||
for (S20PacketEntityProperties.Snapshot s20packetentityproperties$snapshot : this.field_149444_b)
|
||||
for (SPacketEntityProperties.Snapshot s20packetentityproperties$snapshot : this.field_149444_b)
|
||||
{
|
||||
buf.writeString(s20packetentityproperties$snapshot.func_151409_a());
|
||||
buf.writeDouble(s20packetentityproperties$snapshot.func_151410_b());
|
||||
buf.writeVarIntToBuffer(s20packetentityproperties$snapshot.func_151408_c().size());
|
||||
buf.writeVarInt(s20packetentityproperties$snapshot.func_151408_c().size());
|
||||
|
||||
for (AttributeModifier attributemodifier : s20packetentityproperties$snapshot.func_151408_c())
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ public class S20PacketEntityProperties implements Packet<IClientPlayer>
|
|||
return this.entityId;
|
||||
}
|
||||
|
||||
public List<S20PacketEntityProperties.Snapshot> func_149441_d()
|
||||
public List<SPacketEntityProperties.Snapshot> func_149441_d()
|
||||
{
|
||||
return this.field_149444_b;
|
||||
}
|
39
common/src/common/packet/SPacketEntityRelMove.java
Normal file
39
common/src/common/packet/SPacketEntityRelMove.java
Normal file
|
@ -0,0 +1,39 @@
|
|||
package common.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class SPacketEntityRelMove extends SPacketEntity
|
||||
{
|
||||
public SPacketEntityRelMove()
|
||||
{
|
||||
}
|
||||
|
||||
public SPacketEntityRelMove(int entityIdIn, byte x, byte y, byte z, boolean onGroundIn)
|
||||
{
|
||||
super(entityIdIn);
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
this.posZ = z;
|
||||
this.onGround = onGroundIn;
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
super.readPacketData(buf);
|
||||
this.posX = buf.readByte();
|
||||
this.posY = buf.readByte();
|
||||
this.posZ = buf.readByte();
|
||||
this.onGround = buf.readBoolean();
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
super.writePacketData(buf);
|
||||
buf.writeByte(this.posX);
|
||||
buf.writeByte(this.posY);
|
||||
buf.writeByte(this.posZ);
|
||||
buf.writeBoolean(this.onGround);
|
||||
}
|
||||
}
|
|
@ -8,16 +8,16 @@ import common.network.Packet;
|
|||
import common.network.PacketBuffer;
|
||||
import common.world.World;
|
||||
|
||||
public class S1APacketEntityStatus implements Packet<IClientPlayer>
|
||||
public class SPacketEntityStatus implements Packet<IClientPlayer>
|
||||
{
|
||||
private int entityId;
|
||||
private byte logicOpcode;
|
||||
|
||||
public S1APacketEntityStatus()
|
||||
public SPacketEntityStatus()
|
||||
{
|
||||
}
|
||||
|
||||
public S1APacketEntityStatus(Entity entityIn, byte opCodeIn)
|
||||
public SPacketEntityStatus(Entity entityIn, byte opCodeIn)
|
||||
{
|
||||
this.entityId = entityIn.getId();
|
||||
this.logicOpcode = opCodeIn;
|
|
@ -8,7 +8,7 @@ import common.network.Packet;
|
|||
import common.network.PacketBuffer;
|
||||
import common.util.ExtMath;
|
||||
|
||||
public class S18PacketEntityTeleport implements Packet<IClientPlayer>
|
||||
public class SPacketEntityTeleport implements Packet<IClientPlayer>
|
||||
{
|
||||
private int entityId;
|
||||
private int posX;
|
||||
|
@ -18,11 +18,11 @@ public class S18PacketEntityTeleport implements Packet<IClientPlayer>
|
|||
private byte pitch;
|
||||
private boolean onGround;
|
||||
|
||||
public S18PacketEntityTeleport()
|
||||
public SPacketEntityTeleport()
|
||||
{
|
||||
}
|
||||
|
||||
public S18PacketEntityTeleport(Entity entityIn)
|
||||
public SPacketEntityTeleport(Entity entityIn)
|
||||
{
|
||||
this.entityId = entityIn.getId();
|
||||
this.posX = ExtMath.floord(entityIn.posX * 32.0D);
|
||||
|
@ -33,7 +33,7 @@ public class S18PacketEntityTeleport implements Packet<IClientPlayer>
|
|||
this.onGround = entityIn.onGround;
|
||||
}
|
||||
|
||||
public S18PacketEntityTeleport(int entityIdIn, int posXIn, int posYIn, int posZIn, byte yawIn, byte pitchIn, boolean onGroundIn)
|
||||
public SPacketEntityTeleport(int entityIdIn, int posXIn, int posYIn, int posZIn, byte yawIn, byte pitchIn, boolean onGroundIn)
|
||||
{
|
||||
this.entityId = entityIdIn;
|
||||
this.posX = posXIn;
|
||||
|
@ -49,7 +49,7 @@ public class S18PacketEntityTeleport implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readVarIntFromBuffer();
|
||||
this.entityId = buf.readVarInt();
|
||||
this.posX = buf.readInt();
|
||||
this.posY = buf.readInt();
|
||||
this.posZ = buf.readInt();
|
||||
|
@ -63,7 +63,7 @@ public class S18PacketEntityTeleport implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.entityId);
|
||||
buf.writeVarInt(this.entityId);
|
||||
buf.writeInt(this.posX);
|
||||
buf.writeInt(this.posY);
|
||||
buf.writeInt(this.posZ);
|
|
@ -68,7 +68,7 @@ public class SPacketEntityVelocity implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityID = buf.readVarIntFromBuffer();
|
||||
this.entityID = buf.readVarInt();
|
||||
this.motionX = buf.readShort();
|
||||
this.motionY = buf.readShort();
|
||||
this.motionZ = buf.readShort();
|
||||
|
@ -79,7 +79,7 @@ public class SPacketEntityVelocity implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.entityID);
|
||||
buf.writeVarInt(this.entityID);
|
||||
buf.writeShort(this.motionX);
|
||||
buf.writeShort(this.motionY);
|
||||
buf.writeShort(this.motionZ);
|
||||
|
|
|
@ -11,7 +11,7 @@ import common.network.PacketBuffer;
|
|||
import common.util.BlockPos;
|
||||
import common.util.Vec3;
|
||||
|
||||
public class S27PacketExplosion implements Packet<IClientPlayer>
|
||||
public class SPacketExplosion implements Packet<IClientPlayer>
|
||||
{
|
||||
private double posX;
|
||||
private double posY;
|
||||
|
@ -23,11 +23,11 @@ public class S27PacketExplosion implements Packet<IClientPlayer>
|
|||
private float field_149159_h;
|
||||
private boolean altSound;
|
||||
|
||||
public S27PacketExplosion()
|
||||
public SPacketExplosion()
|
||||
{
|
||||
}
|
||||
|
||||
public S27PacketExplosion(double p_i45193_1_, double y, double z, float strengthIn, List<BlockPos> affectedBlocksIn, Vec3 p_i45193_9_, boolean altSound)
|
||||
public SPacketExplosion(double p_i45193_1_, double y, double z, float strengthIn, List<BlockPos> affectedBlocksIn, Vec3 p_i45193_9_, boolean altSound)
|
||||
{
|
||||
this.posX = p_i45193_1_;
|
||||
this.posY = y;
|
|
@ -26,14 +26,14 @@ public class SPacketJoinGame implements Packet<IClientPlayer> {
|
|||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
this.entityId = buf.readInt();
|
||||
this.dimension = buf.readNBTTagCompoundFromBuffer();
|
||||
this.dimension = buf.readTag();
|
||||
this.type = buf.readUnsignedShort();
|
||||
this.editor = buf.readBoolean();
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException {
|
||||
buf.writeInt(this.entityId);
|
||||
buf.writeNBTTagCompoundToBuffer(this.dimension);
|
||||
buf.writeTag(this.dimension);
|
||||
buf.writeShort(this.type & 65535);
|
||||
buf.writeBoolean(this.editor);
|
||||
}
|
||||
|
|
|
@ -29,10 +29,10 @@ public class SPacketLoading implements Packet<IClientPlayer> {
|
|||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
this.message = buf.readStringFromBuffer(128);
|
||||
this.message = buf.readString(128);
|
||||
this.message = this.message != null && this.message.isEmpty() ? null : this.message;
|
||||
if(this.message == null) {
|
||||
this.task = buf.readStringFromBuffer(128);
|
||||
this.task = buf.readString(128);
|
||||
this.task = this.task != null && this.task.isEmpty() ? null : this.task;
|
||||
this.total = buf.readInt();
|
||||
this.progress = buf.readInt();
|
||||
|
|
|
@ -30,7 +30,7 @@ public class SPacketMapChunkBulk implements Packet<IClientPlayer>
|
|||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.sky = buf.readBoolean();
|
||||
int i = buf.readVarIntFromBuffer();
|
||||
int i = buf.readVarInt();
|
||||
this.xPositions = new int[i];
|
||||
this.zPositions = new int[i];
|
||||
this.chunksData = new SPacketChunkData.Extracted[i];
|
||||
|
@ -40,9 +40,9 @@ public class SPacketMapChunkBulk implements Packet<IClientPlayer>
|
|||
this.xPositions[j] = buf.readInt();
|
||||
this.zPositions[j] = buf.readInt();
|
||||
this.chunksData[j] = new SPacketChunkData.Extracted();
|
||||
this.chunksData[j].extend = new int[buf.readVarIntFromBuffer()];
|
||||
this.chunksData[j].extend = new int[buf.readVarInt()];
|
||||
for(int z = 0; z < this.chunksData[j].extend.length; z++) {
|
||||
this.chunksData[j].extend[z] = buf.readVarIntFromBuffer();
|
||||
this.chunksData[j].extend[z] = buf.readVarInt();
|
||||
}
|
||||
this.chunksData[j].data = new byte[SPacketChunkData.getSize(this.chunksData[j].extend.length, this.sky, true)];
|
||||
}
|
||||
|
@ -59,15 +59,15 @@ public class SPacketMapChunkBulk implements Packet<IClientPlayer>
|
|||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeBoolean(this.sky);
|
||||
buf.writeVarIntToBuffer(this.chunksData.length);
|
||||
buf.writeVarInt(this.chunksData.length);
|
||||
|
||||
for (int i = 0; i < this.xPositions.length; ++i)
|
||||
{
|
||||
buf.writeInt(this.xPositions[i]);
|
||||
buf.writeInt(this.zPositions[i]);
|
||||
buf.writeVarIntToBuffer(this.chunksData[i].extend.length);
|
||||
buf.writeVarInt(this.chunksData[i].extend.length);
|
||||
for(int z = 0; z < this.chunksData[i].extend.length; z++) {
|
||||
buf.writeVarIntToBuffer(this.chunksData[i].extend[z]);
|
||||
buf.writeVarInt(this.chunksData[i].extend[z]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public class SPacketMessage implements Packet<IClientPlayer> {
|
|||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
this.message = buf.readStringFromBuffer(32767);
|
||||
this.message = buf.readString(32767);
|
||||
this.type = buf.readEnumValue(Type.class);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,11 +35,11 @@ public class SPacketMultiBlockChange implements Packet<IClientPlayer>
|
|||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.chunkPosCoord = new ChunkPos(buf.readInt(), buf.readInt());
|
||||
this.changedBlocks = new SPacketMultiBlockChange.BlockUpdateData[buf.readVarIntFromBuffer()];
|
||||
this.changedBlocks = new SPacketMultiBlockChange.BlockUpdateData[buf.readVarInt()];
|
||||
|
||||
for (int i = 0; i < this.changedBlocks.length; ++i)
|
||||
{
|
||||
this.changedBlocks[i] = new SPacketMultiBlockChange.BlockUpdateData(buf.readLong(), (State)BlockRegistry.STATEMAP.getByValue(buf.readVarIntFromBuffer()));
|
||||
this.changedBlocks[i] = new SPacketMultiBlockChange.BlockUpdateData(buf.readLong(), (State)BlockRegistry.STATEMAP.getByValue(buf.readVarInt()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,12 +50,12 @@ public class SPacketMultiBlockChange implements Packet<IClientPlayer>
|
|||
{
|
||||
buf.writeInt(this.chunkPosCoord.x);
|
||||
buf.writeInt(this.chunkPosCoord.z);
|
||||
buf.writeVarIntToBuffer(this.changedBlocks.length);
|
||||
buf.writeVarInt(this.changedBlocks.length);
|
||||
|
||||
for (SPacketMultiBlockChange.BlockUpdateData s22packetmultiblockchange$blockupdatedata : this.changedBlocks)
|
||||
{
|
||||
buf.writeLong(s22packetmultiblockchange$blockupdatedata.getRawPos());
|
||||
buf.writeVarIntToBuffer(BlockRegistry.STATEMAP.get(s22packetmultiblockchange$blockupdatedata.getBlockState()));
|
||||
buf.writeVarInt(BlockRegistry.STATEMAP.get(s22packetmultiblockchange$blockupdatedata.getBlockState()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import common.network.Packet;
|
|||
import common.network.PacketBuffer;
|
||||
import common.util.BlockPos;
|
||||
|
||||
public class S2DPacketOpenWindow implements Packet<IClientPlayer>
|
||||
public class SPacketOpenWindow implements Packet<IClientPlayer>
|
||||
{
|
||||
private int windowId;
|
||||
private String inventoryType;
|
||||
|
@ -16,16 +16,16 @@ public class S2DPacketOpenWindow implements Packet<IClientPlayer>
|
|||
private int entityId;
|
||||
private BlockPos tilePos;
|
||||
|
||||
public S2DPacketOpenWindow()
|
||||
public SPacketOpenWindow()
|
||||
{
|
||||
}
|
||||
|
||||
public S2DPacketOpenWindow(int incomingWindowId, String incomingWindowTitle, String windowTitleIn)
|
||||
public SPacketOpenWindow(int incomingWindowId, String incomingWindowTitle, String windowTitleIn)
|
||||
{
|
||||
this(incomingWindowId, incomingWindowTitle, windowTitleIn, 0);
|
||||
}
|
||||
|
||||
public S2DPacketOpenWindow(int windowIdIn, String guiId, String windowTitleIn, int slotCountIn)
|
||||
public SPacketOpenWindow(int windowIdIn, String guiId, String windowTitleIn, int slotCountIn)
|
||||
{
|
||||
this.windowId = windowIdIn;
|
||||
this.inventoryType = guiId;
|
||||
|
@ -33,13 +33,13 @@ public class S2DPacketOpenWindow implements Packet<IClientPlayer>
|
|||
this.slotCount = slotCountIn;
|
||||
}
|
||||
|
||||
public S2DPacketOpenWindow(int windowIdIn, String guiId, String windowTitleIn, int slotCountIn, int incomingEntityId)
|
||||
public SPacketOpenWindow(int windowIdIn, String guiId, String windowTitleIn, int slotCountIn, int incomingEntityId)
|
||||
{
|
||||
this(windowIdIn, guiId, windowTitleIn, slotCountIn);
|
||||
this.entityId = incomingEntityId;
|
||||
}
|
||||
|
||||
public S2DPacketOpenWindow(int windowIdIn, String guiId, String windowTitleIn, int slotCountIn, BlockPos incomingTilePos)
|
||||
public SPacketOpenWindow(int windowIdIn, String guiId, String windowTitleIn, int slotCountIn, BlockPos incomingTilePos)
|
||||
{
|
||||
this(windowIdIn, guiId, windowTitleIn, slotCountIn);
|
||||
this.tilePos = incomingTilePos;
|
||||
|
@ -59,8 +59,8 @@ public class S2DPacketOpenWindow implements Packet<IClientPlayer>
|
|||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.windowId = buf.readUnsignedByte();
|
||||
this.inventoryType = buf.readStringFromBuffer(32);
|
||||
this.windowTitle = buf.readStringFromBuffer(256);
|
||||
this.inventoryType = buf.readString(32);
|
||||
this.windowTitle = buf.readString(256);
|
||||
this.slotCount = buf.readUnsignedByte();
|
||||
|
||||
if (this.inventoryType.equals("EntityHorse"))
|
|
@ -7,7 +7,7 @@ import common.network.IClientPlayer;
|
|||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class S2APacketParticles implements Packet<IClientPlayer>
|
||||
public class SPacketParticles implements Packet<IClientPlayer>
|
||||
{
|
||||
private ParticleType particleType;
|
||||
private float xCoord;
|
||||
|
@ -25,11 +25,11 @@ public class S2APacketParticles implements Packet<IClientPlayer>
|
|||
*/
|
||||
private int[] particleArguments;
|
||||
|
||||
public S2APacketParticles()
|
||||
public SPacketParticles()
|
||||
{
|
||||
}
|
||||
|
||||
public S2APacketParticles(ParticleType particleTypeIn, boolean longDistanceIn, float x, float y, float z, float xOffsetIn, float yOffset, float zOffset, float particleSpeedIn, int particleCountIn, int[] particleArgumentsIn)
|
||||
public SPacketParticles(ParticleType particleTypeIn, boolean longDistanceIn, float x, float y, float z, float xOffsetIn, float yOffset, float zOffset, float particleSpeedIn, int particleCountIn, int[] particleArgumentsIn)
|
||||
{
|
||||
this.particleType = particleTypeIn;
|
||||
this.longDistance = longDistanceIn;
|
||||
|
@ -70,7 +70,7 @@ public class S2APacketParticles implements Packet<IClientPlayer>
|
|||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
this.particleArguments[j] = buf.readVarIntFromBuffer();
|
||||
this.particleArguments[j] = buf.readVarInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class S2APacketParticles implements Packet<IClientPlayer>
|
|||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.particleArguments[j]);
|
||||
buf.writeVarInt(this.particleArguments[j]);
|
||||
}
|
||||
}
|
||||
|
|
@ -7,14 +7,14 @@ import common.network.IClientPlayer;
|
|||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class S39PacketPlayerAbilities implements Packet<IClientPlayer> {
|
||||
public class SPacketPlayerAbilities implements Packet<IClientPlayer> {
|
||||
private boolean flying;
|
||||
private boolean noClip;
|
||||
|
||||
public S39PacketPlayerAbilities() {
|
||||
public SPacketPlayerAbilities() {
|
||||
}
|
||||
|
||||
public S39PacketPlayerAbilities(EntityNPC capabilities) {
|
||||
public SPacketPlayerAbilities(EntityNPC capabilities) {
|
||||
this.flying = capabilities.flying;
|
||||
this.noClip = capabilities.noclip;
|
||||
}
|
|
@ -11,36 +11,36 @@ import common.network.IPlayer;
|
|||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class S38PacketPlayerListItem implements Packet<IClientPlayer> {
|
||||
public class SPacketPlayerListItem implements Packet<IClientPlayer> {
|
||||
private final Map<String, Integer> players = Maps.newHashMap();
|
||||
|
||||
public S38PacketPlayerListItem() {
|
||||
public SPacketPlayerListItem() {
|
||||
}
|
||||
|
||||
public S38PacketPlayerListItem(boolean remove, IPlayer... conns) {
|
||||
public SPacketPlayerListItem(boolean remove, IPlayer... conns) {
|
||||
for(IPlayer conn : conns) {
|
||||
this.players.put(conn.getUser(), remove ? -1 : conn.getLatency());
|
||||
}
|
||||
}
|
||||
|
||||
public S38PacketPlayerListItem(Iterable<IPlayer> conns) {
|
||||
public SPacketPlayerListItem(Iterable<IPlayer> conns) {
|
||||
for(IPlayer conn : conns) {
|
||||
this.players.put(((IPlayer)conn).getUser(), ((IPlayer)conn).getLatency());
|
||||
}
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
int n = buf.readVarIntFromBuffer();
|
||||
int n = buf.readVarInt();
|
||||
for(int z = 0; z < n; z++) {
|
||||
this.players.put(buf.readStringFromBuffer(16), buf.readVarIntFromBuffer());
|
||||
this.players.put(buf.readString(16), buf.readVarInt());
|
||||
}
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException {
|
||||
buf.writeVarIntToBuffer(this.players.size());
|
||||
buf.writeVarInt(this.players.size());
|
||||
for(Entry<String, Integer> data : this.players.entrySet()) {
|
||||
buf.writeString(data.getKey());
|
||||
buf.writeVarIntToBuffer(data.getValue());
|
||||
buf.writeVarInt(data.getValue());
|
||||
}
|
||||
}
|
||||
|
|
@ -8,16 +8,16 @@ import common.network.PacketBuffer;
|
|||
import common.potion.Potion;
|
||||
import common.potion.PotionEffect;
|
||||
|
||||
public class S1EPacketRemoveEntityEffect implements Packet<IClientPlayer>
|
||||
public class SPacketRemoveEntityEffect implements Packet<IClientPlayer>
|
||||
{
|
||||
private int entityId;
|
||||
private Potion effectId;
|
||||
|
||||
public S1EPacketRemoveEntityEffect()
|
||||
public SPacketRemoveEntityEffect()
|
||||
{
|
||||
}
|
||||
|
||||
public S1EPacketRemoveEntityEffect(int entityIdIn, PotionEffect effect)
|
||||
public SPacketRemoveEntityEffect(int entityIdIn, PotionEffect effect)
|
||||
{
|
||||
this.entityId = entityIdIn;
|
||||
this.effectId = effect.getPotion();
|
||||
|
@ -28,7 +28,7 @@ public class S1EPacketRemoveEntityEffect implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readVarIntFromBuffer();
|
||||
this.entityId = buf.readVarInt();
|
||||
this.effectId = buf.readEnumValue(Potion.class);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class S1EPacketRemoveEntityEffect implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.entityId);
|
||||
buf.writeVarInt(this.entityId);
|
||||
buf.writeEnumValue(this.effectId);
|
||||
}
|
||||
|
|
@ -32,14 +32,14 @@ public class SPacketRespawn implements Packet<IClientPlayer>
|
|||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.dimension = buf.readNBTTagCompoundFromBuffer();
|
||||
this.dimension = buf.readTag();
|
||||
this.type = buf.readUnsignedShort();
|
||||
this.editor = buf.readBoolean();
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeNBTTagCompoundToBuffer(this.dimension);
|
||||
buf.writeTag(this.dimension);
|
||||
buf.writeShort(this.type & 65535);
|
||||
buf.writeBoolean(this.editor);
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ public class SPacketSetExperience implements Packet<IClientPlayer>
|
|||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.progress = buf.readFloat();
|
||||
this.level = buf.readVarIntFromBuffer();
|
||||
this.totalExperience = buf.readVarIntFromBuffer();
|
||||
this.level = buf.readVarInt();
|
||||
this.totalExperience = buf.readVarInt();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,8 +39,8 @@ public class SPacketSetExperience implements Packet<IClientPlayer>
|
|||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeFloat(this.progress);
|
||||
buf.writeVarIntToBuffer(this.level);
|
||||
buf.writeVarIntToBuffer(this.totalExperience);
|
||||
buf.writeVarInt(this.level);
|
||||
buf.writeVarInt(this.totalExperience);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,17 +7,17 @@ import common.network.IClientPlayer;
|
|||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class S2FPacketSetSlot implements Packet<IClientPlayer>
|
||||
public class SPacketSetSlot implements Packet<IClientPlayer>
|
||||
{
|
||||
private int windowId;
|
||||
private int slot;
|
||||
private ItemStack item;
|
||||
|
||||
public S2FPacketSetSlot()
|
||||
public SPacketSetSlot()
|
||||
{
|
||||
}
|
||||
|
||||
public S2FPacketSetSlot(int windowIdIn, int slotIn, ItemStack itemIn)
|
||||
public SPacketSetSlot(int windowIdIn, int slotIn, ItemStack itemIn)
|
||||
{
|
||||
this.windowId = windowIdIn;
|
||||
this.slot = slotIn;
|
||||
|
@ -39,7 +39,7 @@ public class S2FPacketSetSlot implements Packet<IClientPlayer>
|
|||
{
|
||||
this.windowId = buf.readByte();
|
||||
this.slot = buf.readShort();
|
||||
this.item = buf.readItemStackFromBuffer();
|
||||
this.item = buf.readItemStack();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,7 @@ public class S2FPacketSetSlot implements Packet<IClientPlayer>
|
|||
{
|
||||
buf.writeByte(this.windowId);
|
||||
buf.writeShort(this.slot);
|
||||
buf.writeItemStackToBuffer(this.item);
|
||||
buf.writeItemStack(this.item);
|
||||
}
|
||||
|
||||
public int getWindowId()
|
|
@ -7,15 +7,15 @@ import common.network.Packet;
|
|||
import common.network.PacketBuffer;
|
||||
import common.util.BlockPos;
|
||||
|
||||
public class S36PacketSignEditorOpen implements Packet<IClientPlayer>
|
||||
public class SPacketSignEditorOpen implements Packet<IClientPlayer>
|
||||
{
|
||||
private BlockPos signPosition;
|
||||
|
||||
public S36PacketSignEditorOpen()
|
||||
public SPacketSignEditorOpen()
|
||||
{
|
||||
}
|
||||
|
||||
public S36PacketSignEditorOpen(BlockPos signPositionIn)
|
||||
public SPacketSignEditorOpen(BlockPos signPositionIn)
|
||||
{
|
||||
this.signPosition = signPositionIn;
|
||||
}
|
|
@ -40,7 +40,7 @@ public class SPacketSkin implements Packet<IClientPlayer>
|
|||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.id = buf.readVarIntFromBuffer();
|
||||
this.id = buf.readVarInt();
|
||||
// this.model = buf.readEnumValue(ModelType.class);
|
||||
this.texture = buf.readByteArray();
|
||||
if(this.texture.length == 0) {
|
||||
|
@ -53,7 +53,7 @@ public class SPacketSkin implements Packet<IClientPlayer>
|
|||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.id);
|
||||
buf.writeVarInt(this.id);
|
||||
// buf.writeEnumValue(this.model);
|
||||
buf.writeByteArray(this.texture == null ? new byte[0] : this.texture);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import common.network.IClientPlayer;
|
|||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class S29PacketSoundEffect implements Packet<IClientPlayer>
|
||||
public class SPacketSoundEffect implements Packet<IClientPlayer>
|
||||
{
|
||||
private SoundEvent sound;
|
||||
private int posX;
|
||||
|
@ -15,12 +15,12 @@ public class S29PacketSoundEffect implements Packet<IClientPlayer>
|
|||
private int posZ;
|
||||
private float soundVolume;
|
||||
|
||||
public S29PacketSoundEffect()
|
||||
public SPacketSoundEffect()
|
||||
{
|
||||
this.sound = null;
|
||||
}
|
||||
|
||||
public S29PacketSoundEffect(SoundEvent sound, double soundX, double soundY, double soundZ, float volume)
|
||||
public SPacketSoundEffect(SoundEvent sound, double soundX, double soundY, double soundZ, float volume)
|
||||
{
|
||||
this.sound = sound;
|
||||
if(this.sound == null) {
|
|
@ -8,7 +8,7 @@ import common.network.Packet;
|
|||
import common.network.PacketBuffer;
|
||||
import common.util.ExtMath;
|
||||
|
||||
public class S2CPacketSpawnGlobalEntity implements Packet<IClientPlayer>
|
||||
public class SPacketSpawnGlobalEntity implements Packet<IClientPlayer>
|
||||
{
|
||||
private int entityId;
|
||||
private int x;
|
||||
|
@ -17,11 +17,11 @@ public class S2CPacketSpawnGlobalEntity implements Packet<IClientPlayer>
|
|||
private int type;
|
||||
private int data;
|
||||
|
||||
public S2CPacketSpawnGlobalEntity()
|
||||
public SPacketSpawnGlobalEntity()
|
||||
{
|
||||
}
|
||||
|
||||
public S2CPacketSpawnGlobalEntity(Entity entityIn, int type, int data)
|
||||
public SPacketSpawnGlobalEntity(Entity entityIn, int type, int data)
|
||||
{
|
||||
this.entityId = entityIn.getId();
|
||||
this.x = ExtMath.floord(entityIn.posX * 32.0D);
|
||||
|
@ -36,12 +36,12 @@ public class S2CPacketSpawnGlobalEntity implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readVarIntFromBuffer();
|
||||
this.entityId = buf.readVarInt();
|
||||
this.type = buf.readByte();
|
||||
this.x = buf.readInt();
|
||||
this.y = buf.readInt();
|
||||
this.z = buf.readInt();
|
||||
this.data = buf.readVarIntFromBuffer();
|
||||
this.data = buf.readVarInt();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,12 +49,12 @@ public class S2CPacketSpawnGlobalEntity implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.entityId);
|
||||
buf.writeVarInt(this.entityId);
|
||||
buf.writeByte(this.type);
|
||||
buf.writeInt(this.x);
|
||||
buf.writeInt(this.y);
|
||||
buf.writeInt(this.z);
|
||||
buf.writeVarIntToBuffer(this.data);
|
||||
buf.writeVarInt(this.data);
|
||||
}
|
||||
|
||||
/**
|
|
@ -84,7 +84,7 @@ public class SPacketSpawnMob implements Packet<IClientPlayer>
|
|||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readVarIntFromBuffer();
|
||||
this.entityId = buf.readVarInt();
|
||||
this.type = buf.readUnsignedShort();
|
||||
this.x = buf.readInt();
|
||||
this.y = buf.readInt();
|
||||
|
@ -100,7 +100,7 @@ public class SPacketSpawnMob implements Packet<IClientPlayer>
|
|||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.entityId);
|
||||
buf.writeVarInt(this.entityId);
|
||||
buf.writeShort(this.type & 65535);
|
||||
buf.writeInt(this.x);
|
||||
buf.writeInt(this.y);
|
||||
|
|
|
@ -106,7 +106,7 @@ public class SPacketSpawnObject implements Packet<IClientPlayer>
|
|||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readVarIntFromBuffer();
|
||||
this.entityId = buf.readVarInt();
|
||||
this.type = buf.readUnsignedShort();
|
||||
this.x = buf.readInt();
|
||||
this.y = buf.readInt();
|
||||
|
@ -123,7 +123,7 @@ public class SPacketSpawnObject implements Packet<IClientPlayer>
|
|||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.entityId);
|
||||
buf.writeVarInt(this.entityId);
|
||||
buf.writeShort(this.type & 65535);
|
||||
buf.writeInt(this.x);
|
||||
buf.writeInt(this.y);
|
||||
|
|
|
@ -52,7 +52,7 @@ public class SPacketSpawnPlayer implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.entityId = buf.readVarIntFromBuffer();
|
||||
this.entityId = buf.readVarInt();
|
||||
this.type = buf.readUnsignedShort();
|
||||
this.x = buf.readInt();
|
||||
this.y = buf.readInt();
|
||||
|
@ -75,7 +75,7 @@ public class SPacketSpawnPlayer implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.entityId);
|
||||
buf.writeVarInt(this.entityId);
|
||||
buf.writeShort(this.type & 65535);
|
||||
buf.writeInt(this.x);
|
||||
buf.writeInt(this.y);
|
||||
|
|
|
@ -6,15 +6,15 @@ import common.network.IClientPlayer;
|
|||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class S3APacketTabComplete implements Packet<IClientPlayer>
|
||||
public class SPacketTabComplete implements Packet<IClientPlayer>
|
||||
{
|
||||
private String[] matches;
|
||||
|
||||
public S3APacketTabComplete()
|
||||
public SPacketTabComplete()
|
||||
{
|
||||
}
|
||||
|
||||
public S3APacketTabComplete(String[] matchesIn)
|
||||
public SPacketTabComplete(String[] matchesIn)
|
||||
{
|
||||
this.matches = matchesIn;
|
||||
}
|
||||
|
@ -24,11 +24,11 @@ public class S3APacketTabComplete implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.matches = new String[buf.readVarIntFromBuffer()];
|
||||
this.matches = new String[buf.readVarInt()];
|
||||
|
||||
for (int i = 0; i < this.matches.length; ++i)
|
||||
{
|
||||
this.matches[i] = buf.readStringFromBuffer(32767);
|
||||
this.matches[i] = buf.readString(32767);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class S3APacketTabComplete implements Packet<IClientPlayer>
|
|||
*/
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeVarIntToBuffer(this.matches.length);
|
||||
buf.writeVarInt(this.matches.length);
|
||||
|
||||
for (String s : this.matches)
|
||||
{
|
|
@ -20,7 +20,7 @@ public class SPacketTimeUpdate implements Packet<IClientPlayer> {
|
|||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
this.worldTime = buf.readLong();
|
||||
this.serverInfo = buf.readStringFromBuffer(512);
|
||||
this.serverInfo = buf.readString(512);
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue